Review Request: JDK-8157464: StackWalker.getCallerClass() is not
Mandy Chung
mandy.chung at oracle.com
Tue Sep 13 22:23:54 UTC 2016
Hi Coleen,
Thanks for the review.
> On Sep 13, 2016, at 2:32 PM, Coleen Phillimore <coleen.phillimore at oracle.com> wrote:
>
>
>
> On 9/13/16 2:54 PM, Daniel Fuchs wrote:
>> Hi Mandy,
>>
>> This looks good to me.
>> But I wonder about these 5 lines - isn't this introducing a change
>> of behavior if the caller is an anonymous class?
>>
>> 149 InstanceKlass* ik = method->method_holder();
>> 150 if (ik->is_anonymous()) {
>> 151 // use the host class as the caller class
>> 152 ik = ik->host_klass();
>> 153 }
>>
>> What is the reason for returning the host class instead?
>
> Somehow I think you want to see all the lambda classes in the stack trace, or skip them but the host class might be confusing because it's something like java/lang/invoke/LambdaForm a lot of the time. At least you'd get java.lang.invoke.LambdaForm$BMH/1170794006 which has a little more information.
>
StackWalker::walk wants to see all lambda classes in the stack trrace (if SHOW_HIDDEN_FRAMES is set). StackWalker::getCallerClass does not since it wants to find the true caller. I have revised the patch to skip the hidden frames instead:
http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8157464/webrev.02/
> http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8157464/webrev.01/hotspot/src/share/vm/prims/stackwalk.cpp.udiff.html
>
> + THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(),
>
> I think you need ResourceMark rm(THREAD); above this line.
>
Fixed. Thanks for catching it.
> I can't review the test because I'm not sure what it's doing. Does it create a module just for the test?
>
It creates a module called “csm” where CallerSensitiveTest class is in and then invoke CallerSensitiveTest with and without security manager. This test can run in an unnamed module but I chose it as an example to build a module.
This test invokes StackWalker::getCallerClass via static reference, reflection, MethodHandle, lambda. Also verify that StackWalker::getCallerClass can't be called from @CallerSensitive method.
Mandy
More information about the hotspot-runtime-dev
mailing list