[jdk18] RFR: 8278930: javac tries to compile a file twice via PackageElement.getEnclosedElements
Vicente Romero
vromero at openjdk.java.net
Thu Jan 6 18:05:15 UTC 2022
On Thu, 6 Jan 2022 13:48:40 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> When using the Elements API, it may happen that an inner class is being completed before its enclosing class. The code is generally prepared for that, and will complete the enclosing class before filling in the content of the inner class.
>
> An issue happens if the enclosing class is completed from source. Then, since [JDK-8224922](https://bugs.openjdk.java.net/browse/JDK-8224922), the innerclass' `ClassSymbol.classfile` will be set to the source file as well, and then javac will try to fill the innerclass from the source code again, leading to duplicate class error. (Before JDK-8224922, the innerclass was, as far as I can tell, completed from the classfile, which didn't lead to this specific problem, but is unlikely to be completely correct either.)
>
> The proposal in this fix is to detect the situation where the nested class was already filled after the enclosing class has been completed, and skip further processing.
looks sensible
-------------
Marked as reviewed by vromero (Reviewer).
PR: https://git.openjdk.java.net/jdk18/pull/85
More information about the compiler-dev
mailing list