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

IllegalAccessError for class extending Java class that provides protected getProperty/setProperty

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.7
    • Fix Version/s: 3.0.0-rc-2
    • Component/s: None
    • Labels:
      None

      Description

      Consider the following:
      PropertyBased.java

      public class PropertyBased {
        protected final Object getProperty(String name) {
          return null;
        }
        protected final void setProperty(String name, Object value) {
        }
      }
      

      Whatever.groovy

      @groovy.transform.CompileStatic
      class Whatever extends PropertyBased {
        def getSomething() {
          'some thing'
        }
      }
      

      No compiler errors are produced for Whatever having protected "implementations" of GroovyObject methods. In this case, our legacy Java base class has getProperty for non-Groovy reasons. However, when accessing Whatever from dynamic Groovy code, IllegalAccessError is thrown. See the attached (run gradlew test)

        Attachments

        1. property-methods.zip
          55 kB
          Eric Milles

          Activity

            People

            • Assignee:
              emilles Eric Milles
              Reporter:
              emilles Eric Milles
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: