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

`VerifyError` when annotating with both @InheritConstructors and @NullCheck and calling the resulting c'tor

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.1
    • 3.0.2
    • None
    • None

    Description

      Given a class annotated with both `@InheritConstructors` and
      `@NullCheck` (note the order!), a `java.lang.VerifyError` happens, when
      the c'tor is called.

      E.g.

      class Base {
      	Long id
      	Base(Long id) { this.id = id }
      }
      
      @groovy.transform.InheritConstructors // <1>
      @groovy.transform.NullCheck           // <2>
      class Sub extends Base {}
      
      new Sub(null)
      

      Results in:

      Caught: java.lang.VerifyError: Bad operand type when invoking <init>
      Exception Details:
        Location:
          Sub.<init>(Ljava/lang/Long;)V @38: invokespecial
        Reason:
          Invalid type: 'Sub' (current frame, stack[0])
        Current Frame:
          bci: @38
          flags: { }
          locals: { 'Sub', 'java/lang/Long', '[Lorg/codehaus/groovy/runtime/callsite/CallSite;' }
          stack: { 'Sub', 'java/lang/Long' }
        Bytecode:
          0x0000000: b800 104d 2ab7 0013 2b01 b800 1999 0014
          0x0000010: 2c12 1a32 121c 121e b900 2403 00c0 0026
          0x0000020: bf2a 2bc0 0028 b700 2ab1               
        Stackmap Table:
          full_frame(@33,{Object[#2],Object[#40],Object[#48]},{})
      
      java.lang.VerifyError: Bad operand type when invoking <init>
      Exception Details:
        Location:
          Sub.<init>(Ljava/lang/Long;)V @38: invokespecial
        Reason:
          Invalid type: 'Sub' (current frame, stack[0])
        Current Frame:
          bci: @38
          flags: { }
          locals: { 'Sub', 'java/lang/Long', '[Lorg/codehaus/groovy/runtime/callsite/CallSite;' }
          stack: { 'Sub', 'java/lang/Long' }
        Bytecode:
          0x0000000: b800 104d 2ab7 0013 2b01 b800 1999 0014
          0x0000010: 2c12 1a32 121c 121e b900 2403 00c0 0026
          0x0000020: bf2a 2bc0 0028 b700 2ab1               
        Stackmap Table:
          full_frame(@33,{Object[#2],Object[#40],Object[#48]},{})
      
      	at nullcheckinherhitctor.run(nullcheckinherhitctor.groovy:10)
      

      Please note: switching `<1>` and `<2>` does not show this error, but
      the `null` does not throw either.

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              ridcully Christoph Frick
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: