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

Private setter method in class that is extended by another class cannot be found.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.7
    • 3.0.8, 2.5.16
    • None
    • None
    • groovy 3.0.7
      javac 13.0.2
      Windows/10

    Description

      If you have a class that is extended by another class and there is a private setter in the class that is extended, that setter cannot be found at runtime. Example script attached. At runtime, the following exception trace is shown:

      groovy.lang.MissingPropertyException: No such property: $priv for class: com.my_example.ExtendedBugClass
      Possible solutions: $pub
      
      at com.my_example.BugClass.test(StaticSetterBug.groovy:27)
      
      at com.my_example.ExtendedBugClass.run(StaticSetterBug.groovy:37)
      
      at com.my_example.ExtendedBugClass$run.call(Unknown Source)
      
      at com.my_example.StaticSetterBug.run(StaticSetterBug.groovy:42)
      
      at jdk.internal.reflect.GeneratedMethodAccessor305.invoke(Unknown Source)
      
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      
      

       Note: Problem occurs regardless of whether classes are dynamic or static compiled. The '$' in the names has no effect, a letter in its place has same problem. The extending class does not have this problem. A stand alone class also does not have this problem. If the setter is public or protected, the problem goes away. Private getters do not display the problem.

      Attachments

        1. StaticSetterBug.groovy
          0.7 kB
          Eric Holley
        2. StaticSetterBug.groovy
          0.8 kB
          Eric Holley

        Activity

          People

            emilles Eric Milles
            holley256 Eric Holley
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: