You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by Cédric Champeau <ce...@gmail.com> on 2018/10/12 15:07:02 UTC

Can we get rid of illegal reflective access operation warnings?

Hi,

It's long overdue, but the status quo is not really nice. Running Groovy on
Java 9+ gives warnings like this:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by
org.codehaus.groovy.vmplugin.v7.Java7$1
(file:/tmp/groovy-2.5.3/target/groovy-2.5.3/lib/groovy-2.5.3.jar) to
constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of
org.codehaus.groovy.vmplugin.v7.Java7$1

Or

WARNING: Illegal reflective access by
org.codehaus.groovy.reflection.CachedClass
(file:/home/tcagent1/agent/work/668602365d1521fc/subprojects/ivy/build/integ%20test/lib/groovy-all-2.4.12.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

I know it's hard to get rid of those, but we have to do something.
Unfortunately I don't have the expertise here...

Re: Can we get rid of illegal reflective access operation warnings?

Posted by Simon Sadedin <ss...@gmail.com>.
> Hi,
>
> It's long overdue, but the status quo is not really nice. Running Groovy
> on Java 9+ gives warnings like this:
>
> WARNING: An illegal reflective access operation has occurred
> WARNING: Illegal reflective access by
> org.codehaus.groovy.vmplugin.v7.Java7$1
> (file:/tmp/groovy-2.5.3/target/groovy-2.5.3/lib/groovy-2.5.3.jar) to
> constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
> WARNING: Please consider reporting this to the maintainers of
> org.codehaus.groovy.vmplugin.v7.Java7$1
>

I am curious if the approach utilising sun.misc.Unsafe discussed in this
stack overflow thread has been considered?

https://stackoverflow.com/questions/46454995/how-to-hide-warning-illegal-reflective-access-in-java-9-without-jvm-argument

It's definitely a hack and may not work on all JVMs or in the future.
Nonetheless, I still consider it superior to having these warnings emitted,
and it fairly cleanly just turns off logging of these messages. The main
downside is it turns them off globally so non-groovy related warnings and
maybe other messages of interest from the same logger would also not be
emitted.

Cheers,

Simon