<i18n dev> RFR: 8311188: Simplify and modernize equals and hashCode in java.text

Chen Liang liach at openjdk.org
Mon Jul 3 23:52:52 UTC 2023


On Mon, 3 Jul 2023 11:12:32 GMT, Pavel Rappo <prappo at openjdk.org> wrote:

> Please review this PR to use modern APIs and language features to simplify `equals` and `hashCode` in the java.text area.
> 
> * Some changes to `equals` and `hashCode` are refactoring rather than modernization. Such changes can be as trivial as rearranging, adding, or commenting checks.
> 
> * java.text area contains more classes whose `equals` and `hashCode` could be simplified; for example: sun.text.CompactByteArray or java.text.DigitList. However, I found no evidence of `equals` and `hashCode` in those classes being used in source or tests. Since writing new tests in this case seems unreasonable, I **excluded** those classes from this PR.

src/java.base/share/classes/java/text/AttributedString.java line 661:

> 659: 
> 660:     // returns whether the two objects are either both null or equal
> 661:     private static boolean valuesMatch(Object value1, Object value2) {

Can this be simply inlined, that its occurrences are replaced by Objects.equals?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14752#discussion_r1250888931


More information about the i18n-dev mailing list