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

Invalid reference generated in InnerClasses attribute for nested interface

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.4.15
    • 2.4.16, 2.5.1
    • class generator
    • None

    Description

      Compiling a class with a nested interface results in a reference to a non-existent inner class "X$Y$1" in the InnerClasses attribute of the resultant class file. Nested classes and inner classes do not exhibit this problem, only nested interfaces.

      Sample class that demonstrates the problem:

      class X {
          interface Y {}
      }
      

      Examining the resultant class file:

      $ javap -v -cp . X.class
      ...
      SourceFile: "X.groovy"
      InnerClasses:
           public #139= #138 of #2; //Y=class X$Y of class X
           static #142= #141 of #2; //1=class X$Y$1 of class X
      

      There is a reference to "X$Y$1" which does not exist. This breaks some tools, for example JUnit 5 test discovery.

       

      It looks to me like this is related to https://issues.apache.org/jira/browse/GROOVY-5082, being the same bug just manifesting for nested interfaces.

      Attachments

        Issue Links

          Activity

            People

              jwagenleitner John Wagenleitner
              tabbott Tony Abbott
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: