Is Java String.hashcode() completely independent of Locale? In other words, if someone fiddles with the default Locale, are we 100% sure this is not going to impact the hash code?
We know that such fiddling impacts toUpperCase() and toLowerCase().
The Locale does not affect the hashCode of the String (directly). It is solely based on the chars stored in the String. The hashCode is generated by
but the problem is how the String is generated. If it is, for example, the result of toUpperCase, which depends on Locale, obviously the resulting String is dependent on Locale and so is the hashCode.