groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From C├ędric Champeau <cchamp...@apache.org>
Subject trySetAccessible for Java 9
Date Wed, 05 Jul 2017 16:28:57 GMT
Hi folks,

We've made some good progress on making Gradle compatible with Java 9 as a
runtime. However, since the latest release, builds easily get bloated with
warnings like this:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by
org.codehaus.groovy.reflection.CachedClass
(file:/home/cchampeau/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy-all/2.4.11/444a64af79c540aad257e49d95050e7c189f1309/groovy-all-2.4.11.jar)
to method java.lang.Object.finalize()

Which is, I think, related to calls to AccessibleObject#setAccessible
in org.codehaus.groovy.reflection.CachedClass#makeAccessible.

However, this class precisely _tries_ to set accessible members of a class,
but doesn't necessarily _have to_. That is, precisely the semantics of the
new `trySetAccessible` method in AccessibleObject on JDK 9, so I would
suggest we use it.

However, as you may understand, things are never so easy: for binary and
runtime compatibility, we need to be able to use this method only if JDK 9
is available, so it either requires using reflection, or method handles if
we are using Java 8.

It would be nice to have this in the next 2.x release of Groovy, so that we
can get rid of those nasty error messages, but then it also means no
MethodHandle, so no fast call of that `trySetAccessible` method. We cannot
use the `Java7` or `Java8` approach either, without actually _building_ on
JDK 9, which would be a problem itself.

Any suggestion?

Mime
View raw message