Review Request: JDK-8157464: StackWalker.getCallerClass() should not filter out non-invoker frames

Mandy Chung mandy.chung at
Wed Jul 13 11:01:16 UTC 2016


StackWalker::getCallerClass() is specified to return the invoker of the MethodHandle and java.lang.reflect.Method for the method calling StackWalker::getCallerClass().

StackWalker::getCallerClass() is not used by any @CallerSensitive method.  Instead one intended usage of StackWalker::getCallerClass() is to be called by library code acting as an agent that calls @CallerSensitive method on behalf of the true caller and typically it will call an appropriate method with the appropriate parameter (e.g. ResourceBundle.getBundle(String, ClassLoader).

MethodHandle for @CS method behaves as if the caller is the lookup class.  The actual caller class may not be the lookup class which is left as implementation details.  This patch adjusts the stack walker to return the same caller as jdk.internal.reflect.Reflection::getCallerClass.


More information about the core-libs-dev mailing list