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/~sla/8025636/webrev.01/>

Thanks,
/Staffan


> On 3 feb 2015, at 10:15, Staffan Larsen <staffan.lar...@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/~sla/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
> 

Reply via email to