RFR: 8272042: java.util.ImmutableCollections$Map1 and MapN should not be @ValueBased [v2]

Jens Li duke at openjdk.java.net
Sun Nov 21 11:21:13 UTC 2021


On Fri, 19 Nov 2021 20:47:40 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> The `jdk.internal.ValueBased` annotation was incorrectly applied to subclasses of java.util.AbstractMap.
>> [ValueBased](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/doc-files/ValueBased.html) requires that supertypes have no instance fields; AbstractMap has instance fields keySet and values.
>> 
>> Remove the internal @ValueBased annotation for subclasses of AbstractMap including:
>> AbstractImmutableMap, Map1, and MapN.
>
> Roger Riggs has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Added comment explaining why immutable Maps are not 'ValueBased'

Should this change also update the Javadoc on `java.util.Map` and remove the statement that the return values of `Map#of` are value-based?

See the [documentation on `Map`](https://github.com/openjdk/jdk/blob/42fce0394b80df0c9f46f826f624d3714274c5bf/src/java.base/share/classes/java/util/Map.java).

The documentation on `Map` refers to the [documentation for value-based classes](https://github.com/openjdk/jdk/blob/42fce0394b80df0c9f46f826f624d3714274c5bf/src/java.base/share/classes/java/lang/doc-files/ValueBased.html).

Or maybe the documentation on `Map` should say that `Map#of` _might_ return value-based objects? In that case the implementation have the possibility to change in the future.

-------------

PR: https://git.openjdk.java.net/jdk/pull/6480


More information about the core-libs-dev mailing list