RFR: 8255757: Javac emits duplicate pool entries on array::clone
Vicente Romero
vromero at openjdk.java.net
Wed Dec 30 22:51:57 UTC 2020
On Wed, 30 Dec 2020 17:55:48 GMT, Guoxiong Li <github.com+13688759+lgxbslgx at openjdk.org> wrote:
> Hi all,
>
> Currently, javac would emit duplicate pool entries when compiling array::clone.
> This patch fixes it by using a cached field `Map<Type, Symbol> qualifiedSymbolCache;` and adds a corresponding test case.
>
> Thank you for taking the time to review.
>
> Best Regards.
Changes requested by vromero (Reviewer).
src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java line 244:
> 242: // array clone can be qualified by the array type in later targets
> 243: if (qualifiedSymbolCache == null) {
> 244: qualifiedSymbolCache = new HashMap<>();
given that the map is initialized in the constructor I assume that this line should never be executed right? also I think that you can clear the map in the `finally` block of method `Gen::genClass`
test/langtools/tools/javac/classfiles/T8255757/T8255757.java line 77:
> 75: .outdir(curPath)
> 76: .run()
> 77: .writeAll();
nit: I think that invoking the `writeAll` method is not necessary as the output is discarded, so it can be removed from the chain
-------------
PR: https://git.openjdk.java.net/jdk/pull/1912
More information about the compiler-dev
mailing list