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

java.lang.VerifyError: Bad <init> method call from inside of a branch

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.9
    • 2.5.8, 3.0.0-rc-1
    • Compiler
    • None

    Description

      given this base class

      abstract class AnimalBuilder {
      
          def animal;
      
          AnimalBuilder(def animal) {
              this.animal = animal
          }
      
      }
      

      This subclass works as expected

      class CatBuilder extends AnimalBuilder {
      
          CatBuilder() {
              super(new Cat());
          }
      
      }
      

      but this

      class CatBuilder2 extends AnimalBuilder {
      
          CatBuilder2() {
              super(createCat());
          }
      
          private Cat createCat() {
              new Cat()
          }
      
      }
      

      Will result an

      java.lang.VerifyError: Bad <init> method call from inside of a branch
      Exception Details:
        Location:
          org/example/builder/CatBuilder2.<init>()V @25: invokespecial
        Reason:
          Error exists in the bytecode
      

      The full example can be seen here https://github.com/szantopeter/groovy-compile-failure2

      Attachments

        Activity

          People

            emilles Eric Milles
            szantopeter Peter Szanto
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: