RFR: 8327683: Crash with primitive type pattern and generic expression in instanceof [v3]
Aggelos Biboudis
abimpoudis at openjdk.org
Tue Mar 19 08:42:34 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 three additional commits since the last revision:
- Merge branch 'master' into fix-#8327683
- 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/d57b0456..e53bec1d
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=18168&range=02
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=18168&range=01-02
Stats: 302490 lines in 632 files changed: 11358 ins; 8478 del; 282654 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