Strings in Switch
Mark Thornton
mthornton at optrak.co.uk
Tue Dec 8 06:52:22 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?
>
>
>
Add a note in the JavaDoc to the effect that string switches depend on
the hashcode algorithm not changing. Anyone changing the algorithm in
spite of such a not could expect serious grief (shot at dawn)!
Mark Thornton
More information about the coin-dev
mailing list