Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.7.10
    • Fix Version/s: None
    • Component/s: Compiler
    • Labels:
      None
    • Environment:
      wnidows xp
      java version "1.6.0_22"
      Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
      Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)
    • Number of attachments :
      0

      Description

      Following code prints 1 or 2 from time to time I start it. Tried at http://groovyconsole.appspot.com. This code generates error there:

      java.lang.NoSuchFieldError: __$stMC
      	at I1( or I2!!!!!!!!!!!!!!!!!!!!).<clinit>(Script1.groovy)
      	at Script1.run(Script1.groovy:9)
      

      but error differs from time to time too.

      interface I1{
         int VALUE = 1
      }
      interface I2{
         int VALUE = 2
      }
      class C implements I1, I2{
      }
      println(new C().VALUE)
      

        Issue Links

          Activity

          blackdrag blackdrag made changes -
          Field Original Value New Value
          Link This issue is related to GROOVY-4756 [ GROOVY-4756 ]
          Hide
          blackdrag blackdrag added a comment -

          I splitted out the __$stMC problem for 1.8, which is realted to the performance improvements I implemented and therefore should be treated with more priority as this non-critical bug. As ofr the bug here I guess the best route would be to actually disallow it by the compiler. Only that in Java, the compiler does allow this construct. Only when you request VALUE, it will be marked as error. The only way for gRoovy would be to check in the implementing part and then throw an error here. But still, what if the interfaces and C are defined in Java. We would have to flag the println part from the Java perspective. If we don't then we would still get these strange differing outputs. On the other hand, people could simply add an VALUE field per MOP, then it would not be an error. We could maybe, when creating the meta class for C recognize that there are two fields of name VALUE and then make the usage of the field throw an erro that shows the ambigouty. I guess that would be the route that would work reliable and produces similar results to Java

          Show
          blackdrag blackdrag added a comment - I splitted out the __$stMC problem for 1.8, which is realted to the performance improvements I implemented and therefore should be treated with more priority as this non-critical bug. As ofr the bug here I guess the best route would be to actually disallow it by the compiler. Only that in Java, the compiler does allow this construct. Only when you request VALUE, it will be marked as error. The only way for gRoovy would be to check in the implementing part and then throw an error here. But still, what if the interfaces and C are defined in Java. We would have to flag the println part from the Java perspective. If we don't then we would still get these strange differing outputs. On the other hand, people could simply add an VALUE field per MOP, then it would not be an error. We could maybe, when creating the meta class for C recognize that there are two fields of name VALUE and then make the usage of the field throw an erro that shows the ambigouty. I guess that would be the route that would work reliable and produces similar results to Java
          Hide
          Paul King added a comment -

          code tags

          Show
          Paul King added a comment - code tags
          Paul King made changes -
          Description Following code prints 1 or 2 from time to time I start it. Tried at http://groovyconsole.appspot.com. This code generates error there:
          java.lang.NoSuchFieldError: __$stMC
          at I1( or I2!!!!!!!!!!!!!!!!!!!!).<clinit>(Script1.groovy)
          at Script1.run(Script1.groovy:9)
          but error differs from time to time too.


          interface I1{
             int VALUE = 1
          }
          interface I2{
             int VALUE = 2
          }
          class C implements I1, I2{
          }
          println(new C().VALUE)
          Following code prints 1 or 2 from time to time I start it. Tried at http://groovyconsole.appspot.com. This code generates error there:
          {noformat}
          java.lang.NoSuchFieldError: __$stMC
          at I1( or I2!!!!!!!!!!!!!!!!!!!!).<clinit>(Script1.groovy)
          at Script1.run(Script1.groovy:9)
          {noformat}
          but error differs from time to time too.

          {code}
          interface I1{
             int VALUE = 1
          }
          interface I2{
             int VALUE = 2
          }
          class C implements I1, I2{
          }
          println(new C().VALUE)
          {code}
          blackdrag blackdrag made changes -
          Component/s Compiler [ 13529 ]
          Hide
          Pascal Schumacher added a comment -

          As of groovy 2.3 the code always prints '2'. Does this mean this should be closed?

          Show
          Pascal Schumacher added a comment - As of groovy 2.3 the code always prints '2'. Does this mean this should be closed?

            People

            • Assignee:
              Unassigned
              Reporter:
              Gunchin Aleksey
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: