Strings in Switch
Jonathan Gibbons
Jonathan.Gibbons at Sun.COM
Tue Dec 8 08:47:55 PST 2009
Paul Benedict wrote:
> Joe,
>
>
>> Such discrepancies and changes were long ago in a Java platform far, far
>> away. It is vanishingly unlikely that String.hashCode will change again
>> in the SE platform because the "behavioral compatibility" impact would
>> be too large; see
>>
>
> I agree the change may be unlikely, but why bet your compiler on it?
> Since you are encoding the result of the hash **in the class file**, I
> think it is necessary to ensure it *never* changes. Do remedies exist?
>
> Paul
>
>
If hell were to freeze over, and String.hashCode were to change in JDK
n, n >=8, then javac could emit different code for Strings in switch,
depending on the value of -target.
-- Jon
More information about the coin-dev
mailing list