< prev index next >

src/java.base/share/classes/java/util/Map.java

Print this page
rev 48077 : 8193128: Reduce number of implementation classes returned by List/Set/Map.of()
Reviewed-by: smarks

*** 1285,1295 **** * @return an empty {@code Map} * * @since 9 */ static <K, V> Map<K, V> of() { ! return ImmutableCollections.Map0.instance(); } /** * Returns an unmodifiable map containing a single mapping. * See <a href="#unmodifiable">Unmodifiable Maps</a> for details. --- 1285,1295 ---- * @return an empty {@code Map} * * @since 9 */ static <K, V> Map<K, V> of() { ! return ImmutableCollections.emptyMap(); } /** * Returns an unmodifiable map containing a single mapping. * See <a href="#unmodifiable">Unmodifiable Maps</a> for details.
*** 1602,1612 **** */ @SafeVarargs @SuppressWarnings("varargs") static <K, V> Map<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) { if (entries.length == 0) { // implicit null check of entries array ! return ImmutableCollections.Map0.instance(); } else if (entries.length == 1) { // implicit null check of the array slot return new ImmutableCollections.Map1<>(entries[0].getKey(), entries[0].getValue()); } else { --- 1602,1612 ---- */ @SafeVarargs @SuppressWarnings("varargs") static <K, V> Map<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) { if (entries.length == 0) { // implicit null check of entries array ! return ImmutableCollections.emptyMap(); } else if (entries.length == 1) { // implicit null check of the array slot return new ImmutableCollections.Map1<>(entries[0].getKey(), entries[0].getValue()); } else {
< prev index next >