sun.reflect.Reflection.getCallerClass(int) is going to be removed... how to replace?
Jochen Theodorou
blackdrag at gmx.org
Tue Jul 2 05:56:52 PDT 2013
Hi all,
"""The Oracle JDK internal method sun.reflect.Reflection.
getCallerClass(int) is planned to be disabled in Oracle JDK 7u40. It is
considered for removal in a later 7 update release.
As you may be aware, the Oracle JDK internal
sun.reflect.Reflection.getCallerClass(int) method has been removed from
JDK 8. [1]
The method is also planned [2] to be disabled in the 7u40 release. A
call to the method would then trigger an UnsupportedOperationException."""
That means the method will be fully away for jdk8 and is going away in
7u40, but can still be enabled by a command line switch. There is a
@CallSensitve annotation which allows calling Reflection.getCallerClass().
But this is causing some problems for us actually. Even if
Reflection.getCallerClass() is ignoring all frames added by reflection
(what about those added by invokedynamic/lambda?), it is not enough for
us, since we will have also runtime generated classes appearing in there.
A simple example is a Groovy program calling
ResourceBundle#getBundle(String). While in non-indy mode the first
access from that call site may be done by reflection and then work,
subsequent calls would be done with runtime generated classes and then
it can stop working very fast. Another one is Groovy grapes, which add
libraries to the classpath at runtime, and it depends on being able to
get the caller class loader for that. The usual depths here are 3-4, and
that means 3-4 frames, that are not our callsite caching or indy, or
reflection.
With the runtime generated classes in the way I am not sure we can
resolve the issue without really major changes, or we simply say that
Groovy 2.x and earlier may not properly work on post jdk 7u40... unless
you use indy, where I would still need confirmation there are no frames
in the way from that then.
I imagine other languages will have similar problems here and there...
or not?
bye Jochen
--
Jochen "blackdrag" Theodorou - Groovy Project Tech Lead
blog: http://blackdragsview.blogspot.com/
german groovy discussion newsgroup: de.comp.lang.misc
For Groovy programming sources visit http://groovy-lang.org
More information about the mlvm-dev
mailing list