RFR: JDK-8217393 Re: Clarification in Attributes equal

Philipp Kunz philipp.kunz at paratix.ch
Sun Jan 27 13:40:03 UTC 2019


The class comment to Attributes says> > This map and its views have a
predictable iteration order, namely the> order that keys were inserted
into the map, as with {@link LinkedHashMap}.>
Considering above statement, are two Attributes equal if they contain
the same mappings in a different iteration order? I'm afraid I'd guess
not.Attributes inherits from Map and therefore two Attributes are equal
according to Map's definition of equals regardless of their iteration
order. Same for AbstractMap.I'm now wondering if it was an improvement
if the equals' comment in Attributes was extended clarifying this minor
ambiguity by explicitly excluding iteration order from comparison?
Besides that, the new version looks good to me. Thanks and
regards,Philipp

On Sun, 2019-01-27 at 07:39 +0000, Alan Bateman wrote:
> On 25/01/2019 19:44, Lance Andersen wrote:
> > Thank you Joe.
> > 
> > So the change is (see bolded change):
> > 
> > $ hg diff
> > diff -r 6130409b923e
> > src/java.base/share/classes/java/util/jar/Attributes.java
> > --- a/src/java.base/share/classes/java/util/jar/Attributes.java	
> > Thu Jan 24 10:57:31 2019 -0800
> > +++ b/src/java.base/share/classes/java/util/jar/Attributes.java	
> > Fri Jan 25 14:44:12 2019 -0500
> > @@ -265,9 +265,10 @@
> >       }
> >   
> >       /**
> > -     * Compares the specified Attributes object with this Map for
> > equality.
> > -     * Returns true if the given object is also an instance of
> > Attributes
> > -     * and the two Attributes objects represent the same mappings.
> > +     * Compares the specified object to the underlying
> > +     * {@linkplain map map} for equality.
> > +     * Returns true if the given object is also a Map
> > +     * and the two maps represent the same mappings.
> > 
> 
> This wording looks okay (I see the other mails about fixing the
> javadoc 
> link).
> 
> -Alan


More information about the core-libs-dev mailing list