You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (JIRA)" <ji...@apache.org> on 2019/06/12 17:35:00 UTC

[jira] [Commented] (GROOVY-9173) IllegalAccessError for class extending Java class that provides protected getProperty/setProperty

    [ https://issues.apache.org/jira/browse/GROOVY-9173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16862303#comment-16862303 ] 

Eric Milles commented on GROOVY-9173:
-------------------------------------

Also, in a joint compilation situation where the Groovyc Ant task was used, we got errors for the Java stub created for the Groovy class because getProperty and setProperty are final in the base class.  The stub generation must have added public implementations of the GroovyObject methods.

> IllegalAccessError for class extending Java class that provides protected getProperty/setProperty
> -------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-9173
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9173
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.7
>            Reporter: Eric Milles
>            Priority: Major
>         Attachments: property-methods.zip
>
>
> Consider the following:
> PropertyBased.java
> {code:java}
> public class PropertyBased {
>   protected final Object getProperty(String name) {
>     return null;
>   }
>   protected final void setProperty(String name, Object value) {
>   }
> }
> {code}
> Whatever.groovy
> {code:groovy}
> @groovy.transform.CompileStatic
> class Whatever extends PropertyBased {
>   def getSomething() {
>     'some thing'
>   }
> }
> {code}
> 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}})



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)