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 2020/07/02 20:49:00 UTC

[jira] [Commented] (GROOVY-9596) Cannot access protected field of Java superclass with --illegal-access=deny

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

Eric Milles commented on GROOVY-9596:
-------------------------------------

With indy compilation, "this.in" in MyFilterReader is resolved by: https://github.com/apache/groovy/blob/GROOVY_3_0_4/src/main/java/org/codehaus/groovy/vmplugin/v8/Selector.java#L328

It is returning a property-missing MetaProperty (the last return statement).  

> Cannot access protected field of Java superclass with --illegal-access=deny
> ---------------------------------------------------------------------------
>
>                 Key: GROOVY-9596
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9596
>             Project: Groovy
>          Issue Type: Bug
>          Components: bytecode
>    Affects Versions: 3.0.4, 2.5.12
>         Environment: JDK 14
> Groovy 2.5.12 or 3.0.4
>            Reporter: Kevin Rushforth
>            Assignee: Eric Milles
>            Priority: Major
>         Attachments: Main.groovy, Main2.groovy, MyAWTEvent.groovy, MyFilterReader.groovy
>
>
> When using the Java option {{--illegal-access=deny}}, a Groovy subclass that extends a Java superclass in the Java runtime (e.g., a class in the {{java.base}} module) cannot access a protected field in the parent class using {{this.fieldName}}.
> To reproduce this bug, use JDK 14 (or later) and run the following using either Groovy 2.5.12 or 3.0.4:
> {{$ groovyc Main.groovy MyFilterReader.groovy}}
>  {{$ _JAVA_OPTIONS="--illegal-access=deny" groovy Main}}
> It works correctly without {{--illegal-access=deny}}. You can add {{-Dsun.reflect.debugModuleAccessChecks=access}} to get more detailed information about the illegal access exceptions that are being swallowed by Groovy.
> {{$ _JAVA_OPTIONS="--illegal-access=deny -Dsun.reflect.debugModuleAccessChecks=access" groovy Main}}
> WORKAROUND: change the following line in the Groovy subclass:
> line = ((BufferedReader)this.in).readLine();
> to:
> line = ((BufferedReader)super.in).readLine();



--
This message was sent by Atlassian Jira
(v8.3.4#803005)