Skip to content
Permalink
Browse files
8253962: Add @valuebased to unmodifable Collection implementation cla…
…sses

Reviewed-by: mchung
  • Loading branch information
Roger Riggs committed Nov 19, 2020
1 parent c6385a2 commit 12f93ebf88ada7fe762a3d715f72a4be1d61ef0e
Showing 1 changed file with 10 additions and 0 deletions.
@@ -137,6 +137,7 @@ private ImmutableCollections() { }

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

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

@jdk.internal.ValueBased
static abstract class AbstractImmutableList<E> extends AbstractImmutableCollection<E>
implements List<E>, RandomAccess {

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

@jdk.internal.ValueBased
static final class List12<E> extends AbstractImmutableList<E>
implements Serializable {

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

@jdk.internal.ValueBased
static final class ListN<E> extends AbstractImmutableList<E>
implements Serializable {

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

// ---------- Set Implementations ----------

@jdk.internal.ValueBased
static abstract class AbstractImmutableSet<E> extends AbstractImmutableCollection<E>
implements Set<E> {

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

@jdk.internal.ValueBased
static final class Set12<E> extends AbstractImmutableSet<E>
implements Serializable {

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

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

// ---------- Map Implementations ----------

@jdk.internal.ValueBased
abstract static class AbstractImmutableMap<K,V> extends AbstractMap<K,V> implements Serializable {
@Override public void clear() { throw uoe(); }
@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) {
}
}

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

@Stable

0 comments on commit 12f93eb

Please sign in to comment.