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

java.lang.VerifyError when calling this() with static final field from a super class

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.x, 2.5.2
    • Fix Version/s: 3.0.0-alpha-4, 2.5.3
    • Component/s: Compiler
    • Labels:
      None

      Description

      If a constructor attempts to call this(X), where X is a static final field defined in a super class a java.lang.VerifyError is thrown at runtime . This only occurs if X is not qualified with the super class name.

      Parent.java
      class Parent { 
      	static final String DEFAULT = 'default' 
      }
      
      Child.java
      class Child extends Parent {
      	String value
      	Child() { this(DEFAULT) }  // <-- here
      	Child(String value) { this.value = value }
      }
      
      java.lang.VerifyError
       Caught: java.lang.VerifyError: Bad type on operand stack
       Exception Details:
       Location:
       Child.<init>()V @10: invokeinterface
       Reason:
       Type uninitializedThis (current frame, stack[2]) is not assignable to 'java/lang/Object'
       Current Frame:
       bci: @10
       flags: \{ flagThisUninit }
       locals: \{ uninitializedThis, '[Lorg/codehaus/groovy/runtime/callsite/CallSite;' }
       stack: \{ uninitializedThis, 'org/codehaus/groovy/runtime/callsite/CallSite', uninitializedThis }
       Bytecode:
       0x0000000: b800 114c 2a2b 1212 322a b900 1802 00b8
       0x0000010: 001e c000 20b7 0023 b1 
      

      Workaround

      Simply ensure that references to static final fields from the super class are qualified with the super class name.

      Child.java
      class Child extends Parent {
      	String value
      	Child() { this(Parent.DEFAULT) }  // ok
      	Child(String value) { this.value = value }
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                daniel_sun Daniel Sun
                Reporter:
                ksuderman Keith Suderman
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: