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

VerifyError if superclass has static and non-static overloads

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.0-alpha-1, 3.0.5, 2.5.14
    • 2.5.15, 3.0.8, 4.0.0-alpha-3
    • None
    • None
    • Java version AdoptOpenJDK (build 25.262-b10, mixed mode)
      Gradle version 6.6.1
      Groovy version 3.0.5

    Description

      java.lang.VerifyError instantiating a concrete class if superclass has static and non-static overloading methods.

      superclass:

      package bar
      import groovy.transform.CompileStatic
      @CompileStatic
      abstract class SuperProblem {
          static void fun(Integer i) {}
          protected void fun(String s) {}
      }
      

      concrete class:

      package foo
      import bar.SuperProblem
      import groovy.transform.CompileStatic
      @CompileStatic
      class Problem extends SuperProblem {
          protected void doit() {
              fun('')
          }
      }
      

      harness:

      package app
      import foo.Problem
      import groovy.transform.CompileStatic
      @CompileStatic
      class Test {
          static void main(String[] args) {
              Problem problem = new Problem()
              println('SHOULD NOT SEE THIS BECAUSE IT MEANS Class Problem HAS NO PROBLEM!!!')
          }
      }
      

       
      Observations:

      1. No compilation error.
      2. Superclass must be in a different package.
      3. Groovy 2.5.13 has no such issue.

      I have included the test project,

      ./gradlew run
      

      produces this error:

      % ./gradlew run
      
      > Task :run FAILED
      Exception in thread "main" java.lang.VerifyError: Bad access to protected data in invokevirtual
      Exception Details:
        Location:
          foo/Problem.doit()V @12: invokevirtual
        Reason:
          Type 'bar/SuperProblem' (current frame, stack[0]) is not assignable to 'foo/Problem'
        Current Frame:
          bci: @12
          flags: { }
          locals: { 'foo/Problem' }
          stack: { 'bar/SuperProblem', 'java/lang/String' }
        Bytecode:
          0x0000000: 1202 1204 b800 17c0 0004 1219 b600 1d01
          0x0000010: 57b1
      
              at app.Test.main(Test.groovy:13)
      

       

       

      Attachments

        1. g3ve.tar.gz
          56 kB
          Chiang Seng Chang

        Activity

          People

            emilles Eric Milles
            chacs Chiang Seng Chang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: