On Sat, 20 Apr 2024 07:39:53 GMT, Chen Liang <li...@openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 685:
>> 
>>> 683:     record TypePairs(Class<?> from, Class<?> to) {
>>> 684: 
>>> 685:         private static final Map<TypePairs, String> typePairToName = 
>>> initialize();
>> 
>> If `TypePairs.typePairToName` is never modified after initialisation, then 
>> it should probably be made immutable:
>> Suggestion:
>> 
>>         private static final Map<TypePairs, String> typePairToName = 
>> Map.copyOf(initialize());
>
> If you really think about it, the `initialize` method itself is somewhat 
> problematic, as it's initializing with byte/short/char on the left, all of 
> which are already converted to int in the of() factory. This should be done 
> in a separate issue.

Yes, the "redirected" mappings can simply be removed in the current 
implementation. 

Using `Map.copyOf` should be ok to nail down the read-only intent.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18865#discussion_r1574385797

Reply via email to