[jdk18] Integrated: 8278930: javac tries to compile a file twice via PackageElement.getEnclosedElements
Jan Lahoda
jlahoda at openjdk.java.net
Mon Jan 10 09:34:43 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.
This pull request has now been integrated.
Changeset: 8f969a13
Author: Jan Lahoda <jlahoda at openjdk.org>
URL: https://git.openjdk.java.net/jdk18/commit/8f969a1362343df8592046a838436f41894ee471
Stats: 158 lines in 2 files changed: 155 ins; 0 del; 3 mod
8278930: javac tries to compile a file twice via PackageElement.getEnclosedElements
Reviewed-by: vromero
-------------
PR: https://git.openjdk.java.net/jdk18/pull/85
More information about the compiler-dev
mailing list