JDK-8016334 : Hide the lambda proxy frame
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2013-06-11
  • Updated: 2015-01-28
  • Resolved: 2015-01-28
Related Reports
Duplicate :  
Description
Currently when you print a stacktrace that show a call inside a lambda,
users can see the the frame corresponding to the method of the generated 
proxy.

By example:
java.lang.Throwable
     StackTraceTest.lambda$0(StackTraceTest.java:6)
     StackTraceTest$$Lambda$1.run(Unknown Source)     <---   ugly, isn't it
     StackTraceTest.main(StackTraceTest.java:8)

I think this line should not be visible to user, it doesn't provide 
useful information,
just make the stack trace longer than it should.

A method can be marked hidden in a stack trace by using the annotation 
LambdaFom.Hidden.

With ASM, one just have to add the following line:

mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);

Submitted on behalf of R��mi Forax.




Comments
Maybe invert the problem: maybe suppress frames for ACC_SYNTHETIC methods, EXCEPT those marked with some "non-hidden" option?
28-01-2015

Release team: This is an enhancement so it doesn't need to go through the deferral process.
12-10-2013

SQE is OK with JDK 8 deferral.
10-10-2013

Yes, ACC_SYNTHETIC is too coarse. I would suggest taking the route outlined above in this repot (the Ljava/lang/invoke/LambdaForm$Hidden; annotation).
10-10-2013

Both the proxy frame and the desugared method frame (lambda$0 in above) are synthetic. But we probably only want to suppress the proxy frame. So perhaps ACC_SYNTHETIC is too coarse a criteria?
10-10-2013

Would be better to take a more general approach, where by default *all* synthetic methods were suppressed from stack traces.
27-09-2013