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

nested classes on interfaces are not static

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 2.4.7
    • Fix Version/s: None
    • Component/s: class generator
    • Labels:
      None

      Description

      According to the JLS, "A member type declaration in an interface is implicitly static and public", and there does not seem to be any reason for Groovy to support non-static nested classes on interfaces. However, classes not explicitly marked static do not have the static flag set. This appears to be a simple bug in the class generator, as the generated constructor does not attempt to store an outer reference or otherwise behave as an inner class. It does, however, break reflective code (Jackson) that gets very confused when looking for an eligible constructor.

      interface Example {
        class Response {
          int code
        }
      }
      

      Expected result: Example$Response has the static modifier flag set.
      Actual result: It does not.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                chrylis Christopher Smith
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: