[jdk18] RFR: 8278930: javac tries to compile a file twice via PackageElement.getEnclosedElements
Jan Lahoda
jlahoda at openjdk.java.net
Thu Jan 6 13:57:54 UTC 2022
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.
-------------
Commit messages:
- 8278930: javac tries to compile a file twice via PackageElement.getEnclosedElements
Changes: https://git.openjdk.java.net/jdk18/pull/85/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk18&pr=85&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8278930
Stats: 176 lines in 2 files changed: 174 ins; 0 del; 2 mod
Patch: https://git.openjdk.java.net/jdk18/pull/85.diff
Fetch: git fetch https://git.openjdk.java.net/jdk18 pull/85/head:pull/85
PR: https://git.openjdk.java.net/jdk18/pull/85
More information about the compiler-dev
mailing list