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

MissingPropertyException when accessing a static inner class member from a sub class

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.7
    • Fix Version/s: 2.4.8
    • Component/s: class generator
    • Labels:
      None

      Description

      Run the following code in groovy to get the error.

      class Base {
          static class Inner {
              static final String CONST = "Hello World";
          }
      }
      
      class Derived extends Base {
          // empty for this example
      }
      
      println Derived.Inner.CONST
      

      Error:

      Caught: groovy.lang.MissingPropertyException: No such property: Inner for class: Derived
      groovy.lang.MissingPropertyException: No such property: Inner for class: Derived
      

      This code can be easily converted to Java and in Java everything works as it should.

      GROOVY-7762 seems to be a related issue.

      I've verified the issue is on this line...

      println Derived.Inner.CONST

      ...because I tried writing the two classes in Java and still have the same issue.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                paulk Paul King
                Reporter:
                cott@redstonecontentsolutions.com Caleb Ott
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: