Question on JDK-8215470: Bad EnclosingMethod attribute
merkel05 at gmail.com
Fri Jan 4 12:08:20 UTC 2019
Recently I was working on the following bug:
It is mainly about anonymous classes that miss
type variable information if declared inside lambda expression.
It leads to a bug in the javac compiler
emits `EnclosingMethod` attribute that points to the synthetic
method for anonymous classes if declared inside lambda.
I was experimenting with it a bit and want to know compiler-dev's
opinion on what would be the best way to fix it.
So my goal in the end is to have `EnclosingMethod` for anonymous
classes, as well as for class declarations inside lambda expressions,
to have `EnclosingMethod` attribute pointing to the nearest lexically
enclosing method (not the synthetic method!)
I see a couple of options to probably achieve the goal:
1) Skip the lambdas when assigning the owner (e.g. use `owner(true)`)
that approach requires additional changes in other compiler
parts. I cannot say for sure how big the changes could be.
2) When compiler writes a classfile, identify the `EnclosingMethod`
attribute that point to synthetic method and repoint it to a lexically
Does anybody have any suggestions? Should I at all try either of
options above? Is there any better way to do it? Please let me know.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the compiler-dev