RFR: 8312019: Simplify and modernize java.util.BitSet.equals
Pavel Rappo
prappo at openjdk.org
Wed Jul 19 17:37:50 UTC 2023
On Wed, 19 Jul 2023 17:15:34 GMT, Martin Buchholz <martin at openjdk.org> wrote:
> > > BitSet#equals
> >
> >
> > Did you mean BitSet#hashCode?
>
> No. BitSet#equals uses the private fields and methods of its argument, which OO purists would never allow. If the other is a subclass with a different private representation, this code would fail. (Don't fix it!)
I see.
While both `hashCode` and `equals` use private fields, `equals` also calls the `checkInvariants` private method on `this` and the other set. I reckon, it makes `equals` quantitatively worse than `hashCode`, rather than qualitatively.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14868#issuecomment-1642486252
More information about the core-libs-dev
mailing list