On Wed, 19 Jul 2023 17:15:34 GMT, Martin Buchholz <mar...@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

Reply via email to