RFR(m): 8177290 add copy factory methods for unmodifiable List, Set, Map
John Rose
john.r.rose at oracle.com
Sat Nov 18 05:43:01 UTC 2017
Late to the party, but these lines rub me the wrong way:
@return the new {@code List}
@return the new {@code Set}
@return the new {@code Map}
The word "new" is a loaded term, which usually means
(or can be easily mistaken to mean) that a new object
identity is guaranteed. Thus, "new" shouldn't be used
to specify the behavior of value-based classes.
Given that that the underlying objects are of VBCs,
and that we are encouraging programmers to rely on
the efficiency of chained copies, it should say something
like this instead:
@return a {@code List} containing the same elements as the given collection
@return a {@code Set} containing the same elements as the given collection
@return a {@code Map} containing the same mappings as the given map
(Or even s/return a/return an unmodifiable/.)
— John
More information about the core-libs-dev
mailing list