Integrated: 8327683: Crash with primitive type pattern and generic expression in instanceof
Aggelos Biboudis
abimpoudis at openjdk.org
Thu Mar 21 08:05:25 UTC 2024
On Fri, 8 Mar 2024 11:14:21 GMT, Aggelos Biboudis <abimpoudis at openjdk.org> wrote:
> 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`.
This pull request has now been integrated.
Changeset: a5a2eca1
Author: Aggelos Biboudis <abimpoudis at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/a5a2eca155bf5d9a1f01d0f3f21bd19dd0a7bd4d
Stats: 241 lines in 5 files changed: 204 ins; 15 del; 22 mod
8327683: Crash with primitive type pattern and generic expression in instanceof
Reviewed-by: vromero
-------------
PR: https://git.openjdk.org/jdk/pull/18168
More information about the compiler-dev
mailing list