RFR: JDK-8025636 Hide lambda proxy frames in stacktraces

Staffan Larsen staffan.larsen at oracle.com
Mon Feb 16 14:25:13 UTC 2015


Good point!

new webrev: http://cr.openjdk.java.net/~sla/8025636/webrev.02/ <http://cr.openjdk.java.net/~sla/8025636/webrev.02/>

Thanks,
/Staffan

> On 16 feb 2015, at 12:40, Remi Forax <forax at univ-mlv.fr> wrote:
> 
> Hi Staffan,
> ASM MethodVisitor API requires to call visitAnnotation before calling visitCode so
> I think you shoud call visitAnnotation before calling new ForwardingMethodGenerator(mv).generate().
> 
> cheers,
> Rémi
> 
> On 02/16/2015 08:47 AM, Staffan Larsen wrote:
>> Brian pointed out to me that this change missed to add the annotation to bridge methods. Here is an updated version that takes those into account. I also needed to update the test to verify that bridge methods were correctly annotated - it got a little bit more complex since I had to force bridges being used.
>> 
>> new webrev: http://cr.openjdk.java.net/~sla/8025636/webrev.01/ <http://cr.openjdk.java.net/%7Esla/8025636/webrev.01/>
>> 
>> Thanks,
>> /Staffan
>> 
>> 
>>> On 3 feb 2015, at 10:15, Staffan Larsen <staffan.larsen at oracle.com <mailto:staffan.larsen at oracle.com>> wrote:
>>> 
>>> Hi,
>>> 
>>> Please review this patch for hiding the lambda proxy frame in stack traces:
>>> 
>>> bug: https://bugs.openjdk.java.net/browse/JDK-8025636 <https://bugs.openjdk.java.net/browse/JDK-8025636>
>>> webrev: http://cr.openjdk.java.net/~sla/8025636/webrev.00/ <http://cr.openjdk.java.net/%7Esla/8025636/webrev.00/>
>>> 
>>> This is a straightforward addition of the LambdaForm$Hidden annotation to the generated methods. What is surprising is that this works even if LambdaForm$Hidden is a package-private class in java.lang.invoke and thus not accessible from most of the generated classes. There is some discussion of and answers to this in the bug, but essentially this works because the annotation class is never resolved and the code in Hotspot that looks for the annotation amounts to nothing more than string comparisons.
>>> 
>>> Hidden stack frames can be shown by running with “-XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames”.
>>> 
>>> For an example of what this patch does, consider this code:
>>> 
>>>        Runnable r = () -> { throw new RuntimeException(); };
>>>        r.run();
>>> 
>>> Previously, this would output:
>>> 
>>>     java.lang.RuntimeException
>>>  at pkg.Foo.lambda$main$0(Foo.java:5)
>>>  at pkg.Foo$$Lambda$1/2001112025.run(<Unknown>:1000000)
>>>  at pkg.Foo.main(Foo.java:15)
>>> 
>>> With the patch it looks like this:
>>> 
>>>     java.lang.RuntimeException
>>>  at pkg.Foo.lambda$main$0(Foo.java:5)
>>>  at pkg.Foo.main(Foo.java:15)
>>> 
>>> 
>>> Thanks,
>>> /Staffan
>>> 
>> 
> 




More information about the core-libs-dev mailing list