Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v5]

2023-07-18 Thread Lance Andersen
On Mon, 17 Jul 2023 23:33:37 GMT, Pavel Rappo 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

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v5]

2023-07-18 Thread Roger Riggs
On Mon, 17 Jul 2023 23:33:37 GMT, Pavel Rappo 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

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v5]

2023-07-17 Thread Pavel Rappo
On Wed, 12 Jul 2023 22:26:14 GMT, John R Rose wrote: > Yes, it would be, because `rp` has a statically observable type, > `BigInteger`. And that observation will flow across the call to the helper > method. After all, my mental model is incorrect; sigh. I read your write-up as though once we

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v5]

2023-07-17 Thread Pavel Rappo
> 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.

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v4]

2023-07-12 Thread John R Rose
On Fri, 7 Jul 2023 00:39:20 GMT, Pavel Rappo wrote: >> Thanks @rose00 for the writeup and @pavelrappo for asking pertinent followup >> questions. >> >> For me the issue here is that there is a bunch of lore about avoiding >> `Objects::equals` and it's embodied in comments like this: >> >>> NB

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v4]

2023-07-06 Thread Pavel Rappo
On Thu, 6 Jul 2023 23:38:01 GMT, Stuart Marks wrote: > For me the issue here is that there is a bunch of lore about avoiding > `Objects::equals` and it's embodied in comments like this: > > > NB: Do not replace with Object.equals until JDK-8015417 is resolved. > > These comments are almost exa

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v4]

2023-07-06 Thread Stuart Marks
On Tue, 4 Jul 2023 22:03:58 GMT, John R Rose wrote: >>> Hmm, I think that issue refers to code that have explicit non-Object >>> parameter types (like `X::equals(Object)boolean` in the issue's sample). >>> This method already have both arguments as `Object`, so I don't think >>> there's any ty

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v4]

2023-07-06 Thread Pavel Rappo
On Thu, 6 Jul 2023 14:46:59 GMT, Pavel Rappo wrote: >> I'd suggest replacing the calls to `valuesMatch` with `Objects.equals` and >> remove the `valuesMatch` method as unnecessary. > >> I'd suggest replacing the calls to `valuesMatch` with `Objects.equals` and >> remove the `valuesMatch` method

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v4]

2023-07-06 Thread Pavel Rappo
On Wed, 5 Jul 2023 15:33:13 GMT, Roger Riggs wrote: > I'd suggest replacing the calls to `valuesMatch` with `Objects.equals` and > remove the `valuesMatch` method as unnecessary. I'll do something about them soon, Roger. But first I need to understand JDK-8015417 better, as it also affects oth

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v4]

2023-07-06 Thread Pavel Rappo
> 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.

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v4]

2023-07-06 Thread Pavel Rappo
On Wed, 5 Jul 2023 17:44:52 GMT, Roger Riggs wrote: >> You are right, I have no stats. Performance-wise, it's already better than >> what was there before. Before, there was no short-circuit check. But I can >> go either way; I don't have a strong opinion. >> >> Reusing superclass' equals is n

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v3]

2023-07-05 Thread Pavel Rappo
On Wed, 5 Jul 2023 17:39:49 GMT, Roger Riggs wrote: >> Do you mean we could use `obj instanceof DecimalFormat other` in front of >> that 30-line `&&` expression, or that we could collapse the list to exactly >> what you wrote? >> >> Separately, `super.equals` already performs the class check;

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v3]

2023-07-05 Thread Roger Riggs
On Wed, 5 Jul 2023 16:39:58 GMT, Pavel Rappo wrote: >> src/java.base/share/classes/java/text/CompactNumberFormat.java line 2364: >> >>> 2362: return true; >>> 2363: } >>> 2364: >> >> Moving this before the `super.equals` call performance-wise would favor the >> equals cas

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v3]

2023-07-05 Thread Roger Riggs
On Wed, 5 Jul 2023 16:27:38 GMT, Pavel Rappo wrote: >> src/java.base/share/classes/java/text/DecimalFormat.java line 2930: >> >>> 2928: DecimalFormat other = (DecimalFormat) obj; >>> 2929: return ((posPrefixPattern == other.posPrefixPattern && >>> 2930: positiveP

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v3]

2023-07-05 Thread Pavel Rappo
> 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.

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v2]

2023-07-05 Thread Pavel Rappo
On Wed, 5 Jul 2023 15:46:56 GMT, Roger Riggs wrote: >> Pavel Rappo has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Adhere to surrounding code style > > src/java.base/share/classes/java/text/CompactNumberFormat.java line 2364: > >> 2362:

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v2]

2023-07-05 Thread Pavel Rappo
On Wed, 5 Jul 2023 15:47:56 GMT, Roger Riggs wrote: >> Pavel Rappo has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Adhere to surrounding code style > > src/java.base/share/classes/java/text/DecimalFormat.java line 2926: > >> 2924:

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text [v2]

2023-07-05 Thread Pavel Rappo
> 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.

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text

2023-07-05 Thread Roger Riggs
On Mon, 3 Jul 2023 11:12:32 GMT, Pavel Rappo 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 tr

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text

2023-07-05 Thread Roger Riggs
On Tue, 4 Jul 2023 22:03:58 GMT, John R Rose wrote: >>> Hmm, I think that issue refers to code that have explicit non-Object >>> parameter types (like `X::equals(Object)boolean` in the issue's sample). >>> This method already have both arguments as `Object`, so I don't think >>> there's any ty

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text

2023-07-04 Thread John R Rose
On Tue, 4 Jul 2023 01:01:22 GMT, Pavel Rappo wrote: >> Hmm, I think that issue refers to code that have explicit non-Object >> parameter types (like `X::equals(Object)boolean` in the issue's sample). >> This method already have both arguments as `Object`, so I don't think >> there's any type-s

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text

2023-07-03 Thread Pavel Rappo
On Tue, 4 Jul 2023 00:40:14 GMT, Chen Liang wrote: > Hmm, I think that issue refers to code that have explicit non-Object > parameter types (like `X::equals(Object)boolean` in the issue's sample). This > method already have both arguments as `Object`, so I don't think there's any > type-specif

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text

2023-07-03 Thread Chen Liang
On Tue, 4 Jul 2023 00:22:02 GMT, Pavel Rappo wrote: >> 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) {

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text

2023-07-03 Thread Pavel Rappo
On Mon, 3 Jul 2023 13:22:27 GMT, Chen Liang 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 a

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text

2023-07-03 Thread Chen Liang
On Mon, 3 Jul 2023 11:12:32 GMT, Pavel Rappo 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 tr

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text

2023-07-03 Thread Naoto Sato
On Mon, 3 Jul 2023 11:12:32 GMT, Pavel Rappo 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 tr

Re: RFR: 8311188: Simplify and modernize equals and hashCode in java.text

2023-07-03 Thread Lance Andersen
On Mon, 3 Jul 2023 11:12:32 GMT, Pavel Rappo 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 tr