RFR: 8354323: Safeguard SwitchBootstraps.typeSwitch when used outside the compiler [v3]

Aggelos Biboudis abimpoudis at openjdk.org
Tue May 13 09:58:52 UTC 2025


On Mon, 12 May 2025 09:15:56 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Simplify unconditional exactness in both Types and SwitchBootstraps
>
> src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 786:
> 
>> 784:                      (selectorType.equals(char.class)  && (selectorWrapper.isStrictSubRangeOf(targetWrapper)))  ||
>> 785:                      (selectorType.equals(int.class)   && (targetType.equals(double.class) || targetType.equals(long.class))) ||
>> 786:                      (selectorType.equals(float.class) && (selectorWrapper.isStrictSubRangeOf(targetWrapper)))))) return true;
> 
> Is `double` the only allowed target for `float` ? If so, perhaps we could simplify like for other selector types.
> Or, alternatively, I wonder if it wouldn't be simpler to _always_ check for strict subrange on the wrappers, but then ban the conversions that are not exact (e.g. int -> float), as those are few?

Thanks @mcimadamore. I gave it a shot, despite the fact that it touches the mirrored code in Types because it is a good recommendation. But please take a look again since it is a very central part: https://github.com/openjdk/jdk/pull/25090/commits/a7c4e398f2a163083853a2a6e58a97d6a06d592f

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25090#discussion_r2086413064


More information about the core-libs-dev mailing list