RFR: JDK-8025636 Hide lambda proxy frames in stacktraces
joel.franck at oracle.com
Tue Feb 3 19:56:40 UTC 2015
> On 03 Feb 2015, at 10:15, Staffan Larsen <staffan.larsen at oracle.com> wrote:
> Please review this patch for hiding the lambda proxy frame in stack traces:
> bug: https://bugs.openjdk.java.net/browse/JDK-8025636
> webrev: 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.
Parsing of the annotation by core reflection can of course happen but should be fine. AnnotationParser calls into the generics machinery to get a Class instance for the annotation type, this shouldn’t be a problem since Class.forName() doesn’t care about package visibility when handing out Class instances to the best of my understanding. Also the parsing machinery is in the null loader so it will be able to find the type. The Proxy for the annotation also shouldn’t care about the package visibility since there is only one interface being proxied (again to the best of my knowledge). If someone were to access members of the parsed annotation things might start to break, but there are none.
Looks good to me, but you should probably get at reviewer that knows the invoke code better.
More information about the compiler-dev