Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10197

java.lang.VerifyError using property inside enum's constant

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.8
    • 3.0.9, 2.5.16
    • None
    • None

    Description

      I'm facing with this strange error after script compiles successfully but fails to load using groovy 3.0.8:

      java.lang.VerifyError: Bad type on operand stack
      Exception Details:
        Location:
          E$1.<init>(Ljava/lang/String;ILjava/util/LinkedHashMap;)V @50: invokevirtual
        Reason:
          Type 'E$1' (current frame, stack[0]) is not assignable to 'groovy/lang/Closure'
        Current Frame:
          bci: @50
          flags: { }
          locals: { 'E$1', 'java/lang/String', integer, 'java/util/LinkedHashMap', integer }
          stack: { 'E$1' }
        Bytecode:
          0000000: 2a2b 1c2d 01b7 0012 0436 0415 042a 5fb5
          0000010: 0014 1504 572d c700 0704 a700 0403 9900
          0000020: 13bb 0016 5912 18b7 001b c000 1dbf 0000
          0000030: bf2a b600 23c0 0004 c000 2512 26b6 002a
          0000040: 9900 1a2d 1226 b900 3002 003a 0519 05b8
          0000050: 0036 2a5f b500 1419 0557 2a2d b800 3c01
          0000060: 57b1                                   
        Stackmap Table:
          full_frame(@29,{Object[#2],Object[#69],Integer,Object[#37],Integer},{})
          same_locals_1_stack_item_frame(@30,Integer)
          full_frame(@46,{},{Object[#29]})
          full_frame(@49,{Object[#2],Object[#69],Integer,Object[#37],Integer},{})
          same_frame(@90)
          same_frame(@97)	at E.<clinit>(ideaGroovyConsole.groovy)
      	at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
      	at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1155)
      	at java.base/jdk.internal.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:42)
      	at java.base/jdk.internal.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:186)
      	at java.base/java.lang.reflect.Field.acquireFieldAccessor(Field.java:1126)
      	at java.base/java.lang.reflect.Field.getFieldAccessor(Field.java:1107)
      	at java.base/java.lang.reflect.Field.get(Field.java:419)
      	at org.codehaus.groovy.reflection.CachedField.getProperty(CachedField.java:68)
      	at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1900)
      	at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:3874)
      	at org.codehaus.groovy.runtime.callsite.ClassMetaClassGetPropertySite.getProperty(ClassMetaClassGetPropertySite.java:50)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:329)
      	at ideaGroovyConsole.run(ideaGroovyConsole.groovy:110) 

      Here is the reproducing script:

      @CompileStatic
      enum E {
          E1{
      //        int value = 1
              int getValue() { 1 }
          }
      
          int getValue() { -1 }
      }
      

      If you use an overriding method, all is working fine. But replacing method with local field causes an error above. I think it is @CompileStatic-specific error, because without this annotation both versions are loaded successfully.

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              ikuznetsov Ivan Kuznetsov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: