RFR: JDK-8223443: Calling Trees.getScope early changes names of local/anonymous classes
Jan Lahoda
jan.lahoda at oracle.com
Thu May 9 15:39:06 UTC 2019
Hi,
In the Trees API, there is the (com.sun.source.util.)Trees.getScope
method. It works by cloning the body of the enclosing method and
attributing the clone, capturing the appropriate Env.
There are a few issues with this method:
1. if getScope is called on an unattributed (but already entered) AST,
while attributing the copy of the enclosing method, (some of) the names
of the local/anonymous classes are assigned to the copy, and then not
reused when actually attributing the real AST and generating classfiles.
So calling getScope "early" may lead to generating different classfiles
with different names for the local/anonymous classes. This can be fixed
by un-entering the classes (which is already done in DeferredAttr).
2. the binary names of the TypeElements for local/anonymous classes in
the returned Scope do not match those from the real AST. This can be
fixed by assigning the correct flat/binary names to the returned
ClassSymbols.
3. if there are (compile-time) errors in the enclosing method, these may
be reported during this attribution for getScope. This can be fixed by
ignoring errors reported from the attribution for getScope.
The proposed fix for these is here:
http://cr.openjdk.java.net/~jlahoda/8223443/webrev.00/
JBS: https://bugs.openjdk.java.net/browse/JDK-8223443
How does this look?
Thanks,
Jan
More information about the compiler-dev
mailing list