Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8253962: Add @ValueBased to unmodifable Collection implementation classes #267

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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