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

inner class inheritance with outer class inheritance can't find constructor

    XMLWordPrintableJSON

Details

    Description

      Instantiation fails at runtime if I have an inner class extending an inner class defined in the outer class's parent I get a NoSuchMethodError on instantiation. In other words, C2 extends C1 and C2.B extends C1.A yields C1$A: method <init>()V not found in C2.B's constructor. A repeatable test case is below:

      class FailingInnerClassInheritance {
      	
      	public static void main(String[] args) {
      		new C2()
      	}
      	
      }
      
      class C1 {
      	class A {}
      }
      
      class C2 extends C1 {
      	{ new B() }
      	class B extends C1.A {}
      }
      

      The analogous example works in Java. It fails in Groovy even if we construct B later (after C2 construction) and try to supply various explicit constructors.

      Attachments

        Activity

          People

            melix Cédric Champeau
            alex.heneveld Alex Heneveld
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: