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

undefined default constructor of outer class causes runtime exception

    XMLWordPrintableJSON

Details

    Description

      I have the following program

      class Test {
        Test(String x) {}
        class Foo extends Test {}
      
        public static void main(String[] args) {
          Test x = new Test("");
          Test.Foo y = x.new Foo();
        }
      } 

      Actual behavior

      The code compiles, but there's a runtime error

      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
          at Test$Foo.<init>(test.groovy)
          at Test.main(test.groovy:8) 

      Expected behavior

      The code should have been rejected.

      Attachments

        Activity

          People

            emilles Eric Milles
            theosot Thodoris Sotiropoulos
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: