We recently found public boolean equals(Object) in com.ibm.icu.ULocale may
return true even the input argument is java.lang.String.
boolean b = new ULocale("en").equals("en");
returns true. Obviously, it was intentionally implemented like this way,
but such implementation violates the contract of equals() method - because
given object A and B, A.equals(B) and B.equals(A) must return the same
result. Such implementation may lead unexpected results when ULocale and
String instances are mixed in a collection. Such behavior was probably
implemented for convenience, but doing the right thing would be also
pretty trivial - for example, locale.getName().equals("xx") would suffice
I think this behavior was introduced by a mistake and it should be fixed.
I'm proposing to make this change (ULocale#equals(Object) no longer
returns true for String argument) for ICU4J 51.
I'm circulating this message to icu-design and icu-support because this
might be a breaking change in ICU4J consumer code. If you have any
objections, please reply to this message by the end of this week