[jdk18] RFR: 8278930: javac tries to compile a file twice via PackageElement.getEnclosedElements [v2]
Jan Lahoda
jlahoda at openjdk.java.net
Fri Jan 7 12:41:07 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.
Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision:
Test cleanup.
-------------
Changes:
- all: https://git.openjdk.java.net/jdk18/pull/85/files
- new: https://git.openjdk.java.net/jdk18/pull/85/files/c3473de4..6bef38f5
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk18&pr=85&range=01
- incr: https://webrevs.openjdk.java.net/?repo=jdk18&pr=85&range=00-01
Stats: 41 lines in 1 file changed: 7 ins; 26 del; 8 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