Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.10
    • Fix Version/s: 2.3.0
    • 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)

      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

          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Closed Closed
          1366d 1h 12m 1 Pascal Schumacher 28/Dec/14 08:07
          Mark Thomas made changes -
          Workflow jira [ 12971164 ] Default workflow, editable Closed status [ 12978957 ]
          Mark Thomas made changes -
          Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
          Mark Thomas made changes -
          Workflow jira [ 12733683 ] Default workflow, editable Closed status [ 12745450 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
          Pascal Schumacher made changes -
          Resolution Fixed [ 1 ]
          Fix Version/s 2.3.0 [ 20375 ]
          Status Open [ 1 ] Closed [ 6 ]
          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?
          Jochen Theodorou made changes -
          Component/s Compiler [ 13529 ]
          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}
          Hide
          Paul King added a comment -

          code tags

          Show
          Paul King added a comment - code tags
          Hide
          Jochen Theodorou 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
          Jochen Theodorou 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
          Jochen Theodorou made changes -
          Field Original Value New Value
          Link This issue is related to GROOVY-4756 [ GROOVY-4756 ]
          Gunchin Aleksey created issue -

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development