RFR: 8327683: Crash with primitive type pattern and generic expression in instanceof [v2]
Aggelos Biboudis
abimpoudis at openjdk.org
Sun Mar 10 15:58:19 UTC 2024
> When compiling the following code, javac results in `java.lang.AssertionError: T.intValue`:
>
>
> public static <T extends Integer> boolean wideningReferenceConversionUnboxing(T i) {
> return i instanceof int ii;
> }
>
>
> The translated code after `Lower`, results in a generated assignment `(int)i.intValue()`. The reason for this bug is that the variable `i` required to have the erased type, set. This PR addresses this issue in `TransPatterns`:
>
>
> public static boolean wideningReferenceConversionUnboxing(Integer i) {
> return (let int ii in
> (let /*synthetic*/ final T tmp4500$ = i in tmp4500$ != null && (let /*synthetic*/ final T tmp4500$ = i in tmp4500$ != null)) &&
> (let ii = (int)i.intValue(); in true));
> }
>
>
> We also observe a duplicated check in the generated code: `(let /*synthetic*/ final T tmp4500$ = i in tmp4500$ != null`. This PR also tidies up the relevant code transformation in `Lower`.
Aggelos Biboudis has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
- Merge branch 'master' into fix-#8327683
- 8327683: Crash with primitive type pattern and generic expression in instanceof
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/18168/files
- new: https://git.openjdk.org/jdk/pull/18168/files/aaf20903..d57b0456
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=18168&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=18168&range=00-01
Stats: 7955 lines in 150 files changed: 3776 ins; 3694 del; 485 mod
Patch: https://git.openjdk.org/jdk/pull/18168.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/18168/head:pull/18168
PR: https://git.openjdk.org/jdk/pull/18168
More information about the compiler-dev
mailing list