Skip to content

Commit 12f93eb

Browse files
author
Roger Riggs
committed
8253962: Add @valuebased to unmodifable Collection implementation classes
Reviewed-by: mchung
1 parent c6385a2 commit 12f93eb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ private ImmutableCollections() { }
137137

138138
static UnsupportedOperationException uoe() { return new UnsupportedOperationException(); }
139139

140+
@jdk.internal.ValueBased
140141
static abstract class AbstractImmutableCollection<E> extends AbstractCollection<E> {
141142
// all mutating methods throw UnsupportedOperationException
142143
@Override public boolean add(E e) { throw uoe(); }
@@ -160,6 +161,7 @@ static <E> List<E> listCopy(Collection<? extends E> coll) {
160161
}
161162
}
162163

164+
@jdk.internal.ValueBased
163165
static abstract class AbstractImmutableList<E> extends AbstractImmutableCollection<E>
164166
implements List<E>, RandomAccess {
165167

@@ -444,6 +446,7 @@ public <T> T[] toArray(T[] a) {
444446
}
445447
}
446448

449+
@jdk.internal.ValueBased
447450
static final class List12<E> extends AbstractImmutableList<E>
448451
implements Serializable {
449452

@@ -526,6 +529,7 @@ public <T> T[] toArray(T[] a) {
526529
}
527530
}
528531

532+
@jdk.internal.ValueBased
529533
static final class ListN<E> extends AbstractImmutableList<E>
530534
implements Serializable {
531535

@@ -607,6 +611,7 @@ public <T> T[] toArray(T[] a) {
607611

608612
// ---------- Set Implementations ----------
609613

614+
@jdk.internal.ValueBased
610615
static abstract class AbstractImmutableSet<E> extends AbstractImmutableCollection<E>
611616
implements Set<E> {
612617

@@ -634,6 +639,7 @@ public boolean equals(Object o) {
634639
public abstract int hashCode();
635640
}
636641

642+
@jdk.internal.ValueBased
637643
static final class Set12<E> extends AbstractImmutableSet<E>
638644
implements Serializable {
639645

@@ -759,6 +765,7 @@ public <T> T[] toArray(T[] a) {
759765
* least one null is always present.
760766
* @param <E> the element type
761767
*/
768+
@jdk.internal.ValueBased
762769
static final class SetN<E> extends AbstractImmutableSet<E>
763770
implements Serializable {
764771

@@ -925,6 +932,7 @@ public <T> T[] toArray(T[] a) {
925932

926933
// ---------- Map Implementations ----------
927934

935+
@jdk.internal.ValueBased
928936
abstract static class AbstractImmutableMap<K,V> extends AbstractMap<K,V> implements Serializable {
929937
@Override public void clear() { throw uoe(); }
930938
@Override public V compute(K key, BiFunction<? super K,? super V,? extends V> rf) { throw uoe(); }
@@ -955,6 +963,7 @@ public V getOrDefault(Object key, V defaultValue) {
955963
}
956964
}
957965

966+
@jdk.internal.ValueBased
958967
static final class Map1<K,V> extends AbstractImmutableMap<K,V> {
959968
@Stable
960969
private final K k0;
@@ -1021,6 +1030,7 @@ public int hashCode() {
10211030
* @param <K> the key type
10221031
* @param <V> the value type
10231032
*/
1033+
@jdk.internal.ValueBased
10241034
static final class MapN<K,V> extends AbstractImmutableMap<K,V> {
10251035

10261036
@Stable

0 commit comments

Comments
 (0)