Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0.4, 2.5.12
-
None
-
JDK 14
Groovy 2.5.12 or 3.0.4
Description
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();
Attachments
Attachments
Issue Links
- is related to
-
GROOVY-9144 Fix warning "An illegal reflective access operation has occurred"
- Closed
- relates to
-
GROOVY-10070 Groovy classes (for Groovy < 4) cannot access protected methods from base classes under Java 16
- Closed