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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.7
    • 3.0.0-rc-2
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: