< prev index next >

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

Print this page

        

*** 1284,1296 **** * @param <V> the {@code Map}'s value type * @return an empty {@code Map} * * @since 9 */ - @SuppressWarnings("unchecked") static <K, V> Map<K, V> of() { ! return (Map<K,V>) ImmutableCollections.MapN.EMPTY_MAP; } /** * Returns an unmodifiable map containing a single mapping. * See <a href="#unmodifiable">Unmodifiable Maps</a> for details. --- 1284,1295 ---- * @param <V> the {@code Map}'s value type * @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.
*** 1603,1615 **** */ @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 ! @SuppressWarnings("unchecked") ! var map = (Map<K,V>) ImmutableCollections.MapN.EMPTY_MAP; ! return map; } 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 >