[BUG] java.util.Properties.entrySet() does not override java.lang.Object methods since Java 9
Roger Riggs
Roger.Riggs at oracle.com
Mon May 25 02:33:54 UTC 2020
Hi Rob,
Thanks for the report, an issues has been created:
https://bugs.openjdk.java.net/browse/JDK-8245694
Regards, Roger
On 5/23/20 3:13 PM, Rob Spoor wrote:
> Hi,
>
> I was working on upgrading a library of mine from Java 8 to 11, and I
> noticed my unit tests started failing. Some investigation showed that
> in Java 9, java.util.Properties was rewritten to no longer rely on the
> fact that it extends Hashtable. One of the changes was to use a
> private static class called EntrySet. However, while this class
> implements most methods from java.util.Set, it's actually missing two:
> equals and hashCode. As a result it does not adhere to the general
> contract of java.util.Set. It's also missing a toString
> implementation, thereby inheriting its String representation from
> java.lang.Object. I've checked the source code up to Java 14, and even
> the Mercurial repository, and this issue still exists.
>
> I think this could be solved as simply as by having this private
> EntrySet class extend AbstractSet, or otherwise delegate its methods
> to its entrySet field. The latter is probably preferred, as it matches
> the implementation of the same methods of the java.util.Properties
> class itself.
>
> Rob
More information about the core-libs-dev
mailing list