RFR: 8327683: Crash with primitive type pattern and generic expression in instanceof [v3]
Vicente Romero
vromero at openjdk.org
Wed Mar 20 17:10:23 UTC 2024
On Tue, 19 Mar 2024 08:42:34 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`.
>
> 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
looks sensible
-------------
Marked as reviewed by vromero (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/18168#pullrequestreview-1949546303
More information about the compiler-dev
mailing list