2018-06-01

2018-06-01 Friday - Groovy Warning: Java (9, 10) Illegal Reflective Access

After upgrading to Java 10, I ran into this annoying Groovy warning:

WARNING: An illegal reflective access operation has occurredWARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/D:/apps/groovy/groovy-2.4.10/lib/groovy-2.4.10.jar) to method java.lang.Object.finalize()WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClassWARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operationsWARNING: All illegal access operations will be denied in a future releaseCaught: java.io.FileNotFoundException: C:\Users\Kelvin\-V (C:\Users\Kelvin\-V)java.io.FileNotFoundException: C:\Users\Kelvin\-V (C:\Users\Kelvin\-V)        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

"An illegal reflective access operation has occurred"
  • https://issues.apache.org/jira/browse/GROOVY-8339
  • Per Paul King:
    • "That warning is to be expected on all currently released versions of Groovy under JDK9. The operation we are doing is perfectly legal under JDK8 and earlier and represents correctly working code. It just doesn't conform to the new rules imposed by the Java 9 module system. It won't affect program use under JDK9."
    • "In unreleased versions of Groovy, we have a temporary workaround to avoid the warnings involving setting an environment property flag but this doesn't apply to using Groovy in an embedded mode like from Gradle. You could adopt the same approach it uses (involves --add-opens and --add-modules) but it would involve some hackery on your part."
    • "There are other nasty hacks to get around the warning but I" don't recommend them"
    • "Groovy continues to work fine with JDK10 despite the annoying warnings."



Background Reading:

No comments:

Copyright

© 2001-2021 International Technology Ventures, Inc., All Rights Reserved.