[ https://issues.apache.org/jira/browse/GROOVY-8339?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16817017#comment-16817017 ]
Daniel Sun edited comment on GROOVY-8339 at 4/13/19 6:36 PM: ------------------------------------------------------------- h3. *Current Status* >From now on, the proposed PR( [https://github.com/apache/groovy/pull/905] ) >can fix most of unnecessary illegal access warnings, here is the build result >of Apache Groovy project: [https://travis-ci.org/apache/groovy/jobs/519678165] h3. *Reasons and solutions* As you can see, there are still illegal access warnings in the build result because of the following reasons I've found: ① The code truely accesses members illegally(account for the vast majority of the warnings in the build result), e.g. [https://github.com/apache/groovy/blob/master/src/test/groovy/PrimitiveTypesTest.groovy#L88] {code:java} // groovy code BigInteger big = new BigInteger(Long.MAX_VALUE) // the constructor is private {code} *Solution:* we have to fix them by change our code to avoid illegal access ② Sub-class derives the public members from package-private class, but invoke the members on the sub class instances, e.g. [https://github.com/apache/groovy/blob/master/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/Groovysh.groovy#L532] {code:java} // groovy code // the declaring class of method `setLength` is `AbstractStringBuilder`(i.e. the base class of `StringBuilder`) // but `AbstractStringBuilder` is package-private buff.setLength(0) // buff is a `StringBuilder` instance {code} *Solution:* Groovy should be smarter to be able to choose the derived method, e.g. {{StringBuilder::setLength}} h3. *Help wanted* As for ①, hi Groovy community, let's add {{--illegal-access=debug}} to JVM option and find the cause of illegal access, then fix them together. As for ②, I wish [~blackdrag] could give us some hints to make progress faster ;) was (Author: daniel_sun): h3. *Current Status* >From now on, the proposed PR( [https://github.com/apache/groovy/pull/905] ) >can fix most of unnecessary illegal access warnings, here is the build result >of Apache Groovy project: [https://travis-ci.org/apache/groovy/jobs/519678165] h3. *Reasons and solutions* As you can see, there are still illegal access warnings in the build result because of the following reasons I've found: ① The code truely accesses members illegally(account for the vast majority of the warnings in the build result), e.g. https://github.com/apache/groovy/blob/master/src/test/groovy/PrimitiveTypesTest.groovy#L88 {code:java} // groovy code BigInteger big = new BigInteger(Long.MAX_VALUE) // the constructor is private {code} *Solution:* we have to fix them by change our code to avoid illegal access ② Sub-class derives the public members from package-private class, but invoke the members on the sub class instances, e.g. https://github.com/apache/groovy/blob/master/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/Groovysh.groovy#L532 {code:java} // groovy code // the declaring class of method `setLength` is `AbstractStringBuilder`(i.e. the base class of `StringBuilder`) // but `AbstractStringBuilder` is package-private buff.setLength(0) // buff is a `StringBuilder` instance {code} *Solution:* Groovy should be smarter to be able to choose the derived method, e.g. {{StringBuilder::setLength}} h3. *Help wanted* As for ①, let's add {{--illegal-access=debug}} to JVM option and find the cause of illegal access, then fix them together. As for ②, I wish [~blackdrag] could give us some hints to make progress faster ;) > Fix warning "An illegal reflective access operation has occurred" > ----------------------------------------------------------------- > > Key: GROOVY-8339 > URL: https://issues.apache.org/jira/browse/GROOVY-8339 > Project: Groovy > Issue Type: Improvement > Components: groovy-jdk > Affects Versions: 2.4.11, 2.4.15 > Environment: >gradle --version > Gradle 4.2 > Build time: 2017-09-20 14:48:23 UTC > Revision: 5ba503cc17748671c83ce35d7da1cffd6e24dfbd > Groovy: 2.4.11 > Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015 > JVM: 9 (Oracle Corporation 9+181) > OS: Windows 10 10.0 amd64 > Reporter: Benjamin Roedell > Priority: Major > Labels: security > Time Spent: 10m > Remaining Estimate: 0h > > I'm running JDK-9 on Windows 10 with Gradle 4.2. > My global gradle.properties file contains the following line: > org.gradle.java.home=C:/Program Files/Java/jdk-9 > When I request the gradle version (gradle --version) I get the following > warning: > {code:none} > WARNING: An illegal reflective access operation has occurred > WARNING: Illegal reflective access by > org.codehaus.groovy.reflection.CachedClass > (file:/C:/Program%20Files/gradle-4.2/lib/groovy-all-2.4.11.jar) to method > java.lang.Object.finalize() > WARNING: Please consider reporting this to the maintainers of > org.codehaus.groovy.reflection.CachedClass > WARNING: Use --illegal-access=warn to enable warnings of further illegal > reflective access operations > WARNING: All illegal access operations will be denied in a future release > {code} > This warning displayed regardless of whether I'm using a regular command > prompt or an elevated rights (Administrator) command prompt. > Here's the full command and output: > {code:none} > gradle --version > WARNING: An illegal reflective access operation has occurred > WARNING: Illegal reflective access by > org.codehaus.groovy.reflection.CachedClass > (file:/C:/Program%20Files/gradle-4.2/lib/groovy-all-2.4.11.jar) to method > java.lang.Object.finalize() > WARNING: Please consider reporting this to the maintainers of > org.codehaus.groovy.reflection.CachedClass > WARNING: Use --illegal-access=warn to enable warnings of further illegal > reflective access operations > WARNING: All illegal access operations will be denied in a future release > ------------------------------------------------------------ > Gradle 4.2 > ------------------------------------------------------------ > Build time: 2017-09-20 14:48:23 UTC > Revision: 5ba503cc17748671c83ce35d7da1cffd6e24dfbd > Groovy: 2.4.11 > Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015 > JVM: 9 (Oracle Corporation 9+181) > OS: Windows 10 10.0 amd64 > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)