Strings in Switch
Reinier Zwitserloot
reinier at zwitserloot.com
Tue Dec 8 08:23:29 PST 2009
A note in String's javadoc works for me. It doesn't neccessary have to
mention strings in switch. All it really needs to mention is that the
algorithm cannot, ever, change, period.
--Reinier Zwitserloot
On Tue, Dec 8, 2009 at 3:52 PM, Mark Thornton <mthornton at optrak.co.uk>wrote:
> 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