8267110: Update java.util to use instanceof pattern variable
Reviewed-by: lancea, naoto
This commit is contained in:
parent
0a03fc84b3
commit
a52c4ede2f
@ -476,9 +476,8 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
|
|||||||
if (o == this)
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!(o instanceof Map))
|
if (!(o instanceof Map<?, ?> m))
|
||||||
return false;
|
return false;
|
||||||
Map<?,?> m = (Map<?,?>) o;
|
|
||||||
if (m.size() != size())
|
if (m.size() != size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -688,10 +687,9 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
|
|||||||
* @see #hashCode
|
* @see #hashCode
|
||||||
*/
|
*/
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
return o instanceof Map.Entry<?, ?> e
|
||||||
return false;
|
&& eq(key, e.getKey())
|
||||||
Map.Entry<?,?> e = (Map.Entry<?,?>)o;
|
&& eq(value, e.getValue());
|
||||||
return eq(key, e.getKey()) && eq(value, e.getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -822,10 +820,9 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
|
|||||||
* @see #hashCode
|
* @see #hashCode
|
||||||
*/
|
*/
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
return o instanceof Map.Entry<?, ?> e
|
||||||
return false;
|
&& eq(key, e.getKey())
|
||||||
Map.Entry<?,?> e = (Map.Entry<?,?>)o;
|
&& eq(value, e.getValue());
|
||||||
return eq(key, e.getKey()) && eq(value, e.getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1066,13 +1066,11 @@ public class BitSet implements Cloneable, java.io.Serializable {
|
|||||||
* @see #size()
|
* @see #size()
|
||||||
*/
|
*/
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (!(obj instanceof BitSet))
|
if (!(obj instanceof BitSet set))
|
||||||
return false;
|
return false;
|
||||||
if (this == obj)
|
if (this == obj)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
BitSet set = (BitSet) obj;
|
|
||||||
|
|
||||||
checkInvariants();
|
checkInvariants();
|
||||||
set.checkInvariants();
|
set.checkInvariants();
|
||||||
|
|
||||||
|
@ -1775,12 +1775,9 @@ public class Collections {
|
|||||||
if (o == this)
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!(o instanceof Set))
|
return o instanceof Set<?> s
|
||||||
return false;
|
&& s.size() == c.size()
|
||||||
Set<?> s = (Set<?>) o;
|
&& containsAll(s); // Invokes safe containsAll() above
|
||||||
if (s.size() != c.size())
|
|
||||||
return false;
|
|
||||||
return containsAll(s); // Invokes safe containsAll() above
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1805,11 +1802,9 @@ public class Collections {
|
|||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o)
|
if (this == o)
|
||||||
return true;
|
return true;
|
||||||
if (!(o instanceof Map.Entry))
|
return o instanceof Map.Entry<?, ?> t
|
||||||
return false;
|
&& eq(e.getKey(), t.getKey())
|
||||||
Map.Entry<?,?> t = (Map.Entry<?,?>)o;
|
&& eq(e.getValue(), t.getValue());
|
||||||
return eq(e.getKey(), t.getKey()) &&
|
|
||||||
eq(e.getValue(), t.getValue());
|
|
||||||
}
|
}
|
||||||
public String toString() {return e.toString();}
|
public String toString() {return e.toString();}
|
||||||
}
|
}
|
||||||
@ -3933,11 +3928,8 @@ public class Collections {
|
|||||||
* setValue method.
|
* setValue method.
|
||||||
*/
|
*/
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
return o instanceof Map.Entry<?, ?> e
|
||||||
return false;
|
&& s.contains((e instanceof CheckedEntry) ? e : checkedEntry(e, valueType));
|
||||||
Map.Entry<?,?> e = (Map.Entry<?,?>) o;
|
|
||||||
return s.contains(
|
|
||||||
(e instanceof CheckedEntry) ? e : checkedEntry(e, valueType));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3981,11 +3973,9 @@ public class Collections {
|
|||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o == this)
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
if (!(o instanceof Set))
|
return o instanceof Set<?> that
|
||||||
return false;
|
&& that.size() == s.size()
|
||||||
Set<?> that = (Set<?>) o;
|
&& containsAll(that); // Invokes safe containsAll() above
|
||||||
return that.size() == s.size()
|
|
||||||
&& containsAll(that); // Invokes safe containsAll() above
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static <K,V,T> CheckedEntry<K,V,T> checkedEntry(Map.Entry<K,V> e,
|
static <K,V,T> CheckedEntry<K,V,T> checkedEntry(Map.Entry<K,V> e,
|
||||||
@ -5251,8 +5241,7 @@ public class Collections {
|
|||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o == this)
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
if (o instanceof CopiesList) {
|
if (o instanceof CopiesList<?> other) {
|
||||||
CopiesList<?> other = (CopiesList<?>) o;
|
|
||||||
return n == other.n && (n == 0 || eq(element, other.element));
|
return n == other.n && (n == 0 || eq(element, other.element));
|
||||||
}
|
}
|
||||||
if (!(o instanceof List))
|
if (!(o instanceof List))
|
||||||
|
@ -328,8 +328,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
|||||||
* one or more keys in the specified map are null
|
* one or more keys in the specified map are null
|
||||||
*/
|
*/
|
||||||
public void putAll(Map<? extends K, ? extends V> m) {
|
public void putAll(Map<? extends K, ? extends V> m) {
|
||||||
if (m instanceof EnumMap) {
|
if (m instanceof EnumMap<?, ?> em) {
|
||||||
EnumMap<?, ?> em = (EnumMap<?, ?>)m;
|
|
||||||
if (em.keyType != keyType) {
|
if (em.keyType != keyType) {
|
||||||
if (em.isEmpty())
|
if (em.isEmpty())
|
||||||
return;
|
return;
|
||||||
@ -473,16 +472,12 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
return o instanceof Map.Entry<?, ?> entry
|
||||||
return false;
|
&& containsMapping(entry.getKey(), entry.getValue());
|
||||||
Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
|
|
||||||
return containsMapping(entry.getKey(), entry.getValue());
|
|
||||||
}
|
}
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
return o instanceof Map.Entry<?, ?> entry
|
||||||
return false;
|
&& removeMapping(entry.getKey(), entry.getValue());
|
||||||
Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
|
|
||||||
return removeMapping(entry.getKey(), entry.getValue());
|
|
||||||
}
|
}
|
||||||
public int size() {
|
public int size() {
|
||||||
return size;
|
return size;
|
||||||
@ -606,10 +601,9 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
|||||||
if (index < 0)
|
if (index < 0)
|
||||||
return o == this;
|
return o == this;
|
||||||
|
|
||||||
if (!(o instanceof Map.Entry))
|
if (!(o instanceof Map.Entry<?, ?> e))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Map.Entry<?,?> e = (Map.Entry<?,?>)o;
|
|
||||||
V ourValue = unmaskNull(vals[index]);
|
V ourValue = unmaskNull(vals[index]);
|
||||||
Object hisValue = e.getValue();
|
Object hisValue = e.getValue();
|
||||||
return (e.getKey() == keyUniverse[index] &&
|
return (e.getKey() == keyUniverse[index] &&
|
||||||
@ -655,10 +649,9 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
|||||||
return true;
|
return true;
|
||||||
if (o instanceof EnumMap)
|
if (o instanceof EnumMap)
|
||||||
return equals((EnumMap<?,?>)o);
|
return equals((EnumMap<?,?>)o);
|
||||||
if (!(o instanceof Map))
|
if (!(o instanceof Map<?, ?> m))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Map<?,?> m = (Map<?,?>)o;
|
|
||||||
if (size != m.size())
|
if (size != m.size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -307,13 +307,10 @@ public class HashMap<K,V> extends AbstractMap<K,V>
|
|||||||
public final boolean equals(Object o) {
|
public final boolean equals(Object o) {
|
||||||
if (o == this)
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
if (o instanceof Map.Entry) {
|
|
||||||
Map.Entry<?,?> e = (Map.Entry<?,?>)o;
|
return o instanceof Map.Entry<?, ?> e
|
||||||
if (Objects.equals(key, e.getKey()) &&
|
&& Objects.equals(key, e.getKey())
|
||||||
Objects.equals(value, e.getValue()))
|
&& Objects.equals(value, e.getValue());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1100,16 +1097,14 @@ public class HashMap<K,V> extends AbstractMap<K,V>
|
|||||||
return new EntryIterator();
|
return new EntryIterator();
|
||||||
}
|
}
|
||||||
public final boolean contains(Object o) {
|
public final boolean contains(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
if (!(o instanceof Map.Entry<?, ?> e))
|
||||||
return false;
|
return false;
|
||||||
Map.Entry<?,?> e = (Map.Entry<?,?>) o;
|
|
||||||
Object key = e.getKey();
|
Object key = e.getKey();
|
||||||
Node<K,V> candidate = getNode(key);
|
Node<K,V> candidate = getNode(key);
|
||||||
return candidate != null && candidate.equals(e);
|
return candidate != null && candidate.equals(e);
|
||||||
}
|
}
|
||||||
public final boolean remove(Object o) {
|
public final boolean remove(Object o) {
|
||||||
if (o instanceof Map.Entry) {
|
if (o instanceof Map.Entry<?, ?> e) {
|
||||||
Map.Entry<?,?> e = (Map.Entry<?,?>) o;
|
|
||||||
Object key = e.getKey();
|
Object key = e.getKey();
|
||||||
Object value = e.getValue();
|
Object value = e.getValue();
|
||||||
return removeNode(hash(key), key, value, true, true) != null;
|
return removeNode(hash(key), key, value, true, true) != null;
|
||||||
|
@ -714,9 +714,8 @@ public class Hashtable<K,V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
if (!(o instanceof Map.Entry<?, ?> entry))
|
||||||
return false;
|
return false;
|
||||||
Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
|
|
||||||
Object key = entry.getKey();
|
Object key = entry.getKey();
|
||||||
Entry<?,?>[] tab = table;
|
Entry<?,?>[] tab = table;
|
||||||
int hash = key.hashCode();
|
int hash = key.hashCode();
|
||||||
@ -729,9 +728,8 @@ public class Hashtable<K,V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
if (!(o instanceof Map.Entry<?, ?> entry))
|
||||||
return false;
|
return false;
|
||||||
Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
|
|
||||||
Object key = entry.getKey();
|
Object key = entry.getKey();
|
||||||
Entry<?,?>[] tab = table;
|
Entry<?,?>[] tab = table;
|
||||||
int hash = key.hashCode();
|
int hash = key.hashCode();
|
||||||
@ -816,9 +814,8 @@ public class Hashtable<K,V>
|
|||||||
if (o == this)
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!(o instanceof Map))
|
if (!(o instanceof Map<?, ?> t))
|
||||||
return false;
|
return false;
|
||||||
Map<?,?> t = (Map<?,?>) o;
|
|
||||||
if (t.size() != size())
|
if (t.size() != size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1393,9 +1390,8 @@ public class Hashtable<K,V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
if (!(o instanceof Map.Entry<?, ?> e))
|
||||||
return false;
|
return false;
|
||||||
Map.Entry<?,?> e = (Map.Entry<?,?>)o;
|
|
||||||
|
|
||||||
return (key==null ? e.getKey()==null : key.equals(e.getKey())) &&
|
return (key==null ? e.getKey()==null : key.equals(e.getKey())) &&
|
||||||
(value==null ? e.getValue()==null : value.equals(e.getValue()));
|
(value==null ? e.getValue()==null : value.equals(e.getValue()));
|
||||||
|
@ -642,8 +642,7 @@ public class IdentityHashMap<K,V>
|
|||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o == this) {
|
if (o == this) {
|
||||||
return true;
|
return true;
|
||||||
} else if (o instanceof IdentityHashMap) {
|
} else if (o instanceof IdentityHashMap<?, ?> m) {
|
||||||
IdentityHashMap<?,?> m = (IdentityHashMap<?,?>) o;
|
|
||||||
if (m.size() != size)
|
if (m.size() != size)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -654,8 +653,7 @@ public class IdentityHashMap<K,V>
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (o instanceof Map) {
|
} else if (o instanceof Map<?, ?> m) {
|
||||||
Map<?,?> m = (Map<?,?>)o;
|
|
||||||
return entrySet().equals(m.entrySet());
|
return entrySet().equals(m.entrySet());
|
||||||
} else {
|
} else {
|
||||||
return false; // o is not a Map
|
return false; // o is not a Map
|
||||||
@ -888,11 +886,9 @@ public class IdentityHashMap<K,V>
|
|||||||
if (index < 0)
|
if (index < 0)
|
||||||
return super.equals(o);
|
return super.equals(o);
|
||||||
|
|
||||||
if (!(o instanceof Map.Entry))
|
return o instanceof Map.Entry<?, ?> e
|
||||||
return false;
|
&& e.getKey() == unmaskNull(traversalTable[index])
|
||||||
Map.Entry<?,?> e = (Map.Entry<?,?>)o;
|
&& e.getValue() == traversalTable[index+1];
|
||||||
return (e.getKey() == unmaskNull(traversalTable[index]) &&
|
|
||||||
e.getValue() == traversalTable[index+1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
@ -1189,16 +1185,12 @@ public class IdentityHashMap<K,V>
|
|||||||
return new EntryIterator();
|
return new EntryIterator();
|
||||||
}
|
}
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
return o instanceof Entry<?, ?> entry
|
||||||
return false;
|
&& containsMapping(entry.getKey(), entry.getValue());
|
||||||
Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
|
|
||||||
return containsMapping(entry.getKey(), entry.getValue());
|
|
||||||
}
|
}
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
return o instanceof Entry<?, ?> entry
|
||||||
return false;
|
&& removeMapping(entry.getKey(), entry.getValue());
|
||||||
Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
|
|
||||||
return removeMapping(entry.getKey(), entry.getValue());
|
|
||||||
}
|
}
|
||||||
public int size() {
|
public int size() {
|
||||||
return size;
|
return size;
|
||||||
|
@ -248,10 +248,9 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||||||
* @throws NullPointerException if the specified collection is null
|
* @throws NullPointerException if the specified collection is null
|
||||||
*/
|
*/
|
||||||
public boolean containsAll(Collection<?> c) {
|
public boolean containsAll(Collection<?> c) {
|
||||||
if (!(c instanceof JumboEnumSet))
|
if (!(c instanceof JumboEnumSet<?> es))
|
||||||
return super.containsAll(c);
|
return super.containsAll(c);
|
||||||
|
|
||||||
JumboEnumSet<?> es = (JumboEnumSet<?>)c;
|
|
||||||
if (es.elementType != elementType)
|
if (es.elementType != elementType)
|
||||||
return es.isEmpty();
|
return es.isEmpty();
|
||||||
|
|
||||||
@ -270,10 +269,9 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||||||
* its elements are null
|
* its elements are null
|
||||||
*/
|
*/
|
||||||
public boolean addAll(Collection<? extends E> c) {
|
public boolean addAll(Collection<? extends E> c) {
|
||||||
if (!(c instanceof JumboEnumSet))
|
if (!(c instanceof JumboEnumSet<?> es))
|
||||||
return super.addAll(c);
|
return super.addAll(c);
|
||||||
|
|
||||||
JumboEnumSet<?> es = (JumboEnumSet<?>)c;
|
|
||||||
if (es.elementType != elementType) {
|
if (es.elementType != elementType) {
|
||||||
if (es.isEmpty())
|
if (es.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
@ -296,10 +294,9 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||||||
* @throws NullPointerException if the specified collection is null
|
* @throws NullPointerException if the specified collection is null
|
||||||
*/
|
*/
|
||||||
public boolean removeAll(Collection<?> c) {
|
public boolean removeAll(Collection<?> c) {
|
||||||
if (!(c instanceof JumboEnumSet))
|
if (!(c instanceof JumboEnumSet<?> es))
|
||||||
return super.removeAll(c);
|
return super.removeAll(c);
|
||||||
|
|
||||||
JumboEnumSet<?> es = (JumboEnumSet<?>)c;
|
|
||||||
if (es.elementType != elementType)
|
if (es.elementType != elementType)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -317,10 +314,9 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||||||
* @throws NullPointerException if the specified collection is null
|
* @throws NullPointerException if the specified collection is null
|
||||||
*/
|
*/
|
||||||
public boolean retainAll(Collection<?> c) {
|
public boolean retainAll(Collection<?> c) {
|
||||||
if (!(c instanceof JumboEnumSet))
|
if (!(c instanceof JumboEnumSet<?> es))
|
||||||
return super.retainAll(c);
|
return super.retainAll(c);
|
||||||
|
|
||||||
JumboEnumSet<?> es = (JumboEnumSet<?>)c;
|
|
||||||
if (es.elementType != elementType) {
|
if (es.elementType != elementType) {
|
||||||
boolean changed = (size != 0);
|
boolean changed = (size != 0);
|
||||||
clear();
|
clear();
|
||||||
@ -350,10 +346,9 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||||||
* @return {@code true} if the specified object is equal to this set
|
* @return {@code true} if the specified object is equal to this set
|
||||||
*/
|
*/
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!(o instanceof JumboEnumSet))
|
if (!(o instanceof JumboEnumSet<?> es))
|
||||||
return super.equals(o);
|
return super.equals(o);
|
||||||
|
|
||||||
JumboEnumSet<?> es = (JumboEnumSet<?>)o;
|
|
||||||
if (es.elementType != elementType)
|
if (es.elementType != elementType)
|
||||||
return size == 0 && es.size == 0;
|
return size == 0 && es.size == 0;
|
||||||
|
|
||||||
|
@ -101,10 +101,9 @@ final class KeyValueHolder<K,V> implements Map.Entry<K,V> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
return o instanceof Map.Entry<?, ?> e
|
||||||
return false;
|
&& key.equals(e.getKey())
|
||||||
Map.Entry<?,?> e = (Map.Entry<?,?>)o;
|
&& value.equals(e.getValue());
|
||||||
return key.equals(e.getKey()) && value.equals(e.getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -681,16 +681,14 @@ public class LinkedHashMap<K,V>
|
|||||||
return new LinkedEntryIterator();
|
return new LinkedEntryIterator();
|
||||||
}
|
}
|
||||||
public final boolean contains(Object o) {
|
public final boolean contains(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
if (!(o instanceof Map.Entry<?, ?> e))
|
||||||
return false;
|
return false;
|
||||||
Map.Entry<?,?> e = (Map.Entry<?,?>) o;
|
|
||||||
Object key = e.getKey();
|
Object key = e.getKey();
|
||||||
Node<K,V> candidate = getNode(key);
|
Node<K,V> candidate = getNode(key);
|
||||||
return candidate != null && candidate.equals(e);
|
return candidate != null && candidate.equals(e);
|
||||||
}
|
}
|
||||||
public final boolean remove(Object o) {
|
public final boolean remove(Object o) {
|
||||||
if (o instanceof Map.Entry) {
|
if (o instanceof Map.Entry<?, ?> e) {
|
||||||
Map.Entry<?,?> e = (Map.Entry<?,?>) o;
|
|
||||||
Object key = e.getKey();
|
Object key = e.getKey();
|
||||||
Object value = e.getValue();
|
Object value = e.getValue();
|
||||||
return removeNode(hash(key), key, value, true, true) != null;
|
return removeNode(hash(key), key, value, true, true) != null;
|
||||||
|
@ -885,10 +885,9 @@ public final class Locale implements Cloneable, Serializable {
|
|||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof LocaleKey)) {
|
if (!(obj instanceof LocaleKey other)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LocaleKey other = (LocaleKey)obj;
|
|
||||||
if (hash != other.hash || !base.equals(other.base)) {
|
if (hash != other.hash || !base.equals(other.base)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -3341,12 +3340,9 @@ public final class Locale implements Cloneable, Serializable {
|
|||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof LanguageRange)) {
|
return obj instanceof LanguageRange other
|
||||||
return false;
|
&& range.equals(other.range)
|
||||||
}
|
&& weight == other.weight;
|
||||||
LanguageRange other = (LanguageRange)obj;
|
|
||||||
return range.equals(other.range)
|
|
||||||
&& weight == other.weight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -423,12 +423,8 @@ public final class Optional<T> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(obj instanceof Optional)) {
|
return obj instanceof Optional<?> other
|
||||||
return false;
|
&& Objects.equals(value, other.value);
|
||||||
}
|
|
||||||
|
|
||||||
Optional<?> other = (Optional<?>) obj;
|
|
||||||
return Objects.equals(value, other.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -295,14 +295,10 @@ public final class OptionalDouble {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(obj instanceof OptionalDouble)) {
|
return obj instanceof OptionalDouble other
|
||||||
return false;
|
&& (isPresent && other.isPresent
|
||||||
}
|
? Double.compare(value, other.value) == 0
|
||||||
|
: isPresent == other.isPresent);
|
||||||
OptionalDouble other = (OptionalDouble) obj;
|
|
||||||
return (isPresent && other.isPresent)
|
|
||||||
? Double.compare(value, other.value) == 0
|
|
||||||
: isPresent == other.isPresent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -293,14 +293,10 @@ public final class OptionalInt {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(obj instanceof OptionalInt)) {
|
return obj instanceof OptionalInt other
|
||||||
return false;
|
&& (isPresent && other.isPresent
|
||||||
}
|
|
||||||
|
|
||||||
OptionalInt other = (OptionalInt) obj;
|
|
||||||
return (isPresent && other.isPresent)
|
|
||||||
? value == other.value
|
? value == other.value
|
||||||
: isPresent == other.isPresent;
|
: isPresent == other.isPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -293,14 +293,10 @@ public final class OptionalLong {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(obj instanceof OptionalLong)) {
|
return obj instanceof OptionalLong other
|
||||||
return false;
|
&& (isPresent && other.isPresent
|
||||||
}
|
|
||||||
|
|
||||||
OptionalLong other = (OptionalLong) obj;
|
|
||||||
return (isPresent && other.isPresent)
|
|
||||||
? value == other.value
|
? value == other.value
|
||||||
: isPresent == other.isPresent;
|
: isPresent == other.isPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,15 +187,11 @@ public final class PropertyPermission extends BasicPermission {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean implies(Permission p) {
|
public boolean implies(Permission p) {
|
||||||
if (!(p instanceof PropertyPermission))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
PropertyPermission that = (PropertyPermission) p;
|
|
||||||
|
|
||||||
// we get the effective mask. i.e., the "and" of this and that.
|
// we get the effective mask. i.e., the "and" of this and that.
|
||||||
// They must be equal to that.mask for implies to return true.
|
// They must be equal to that.mask for implies to return true.
|
||||||
|
return p instanceof PropertyPermission that
|
||||||
return ((this.mask & that.mask) == that.mask) && super.implies(that);
|
&& ((this.mask & that.mask) == that.mask)
|
||||||
|
&& super.implies(that);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -211,13 +207,9 @@ public final class PropertyPermission extends BasicPermission {
|
|||||||
if (obj == this)
|
if (obj == this)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (! (obj instanceof PropertyPermission))
|
return obj instanceof PropertyPermission that
|
||||||
return false;
|
&& this.mask == that.mask
|
||||||
|
&& this.getName().equals(that.getName());
|
||||||
PropertyPermission that = (PropertyPermission) obj;
|
|
||||||
|
|
||||||
return (this.mask == that.mask) &&
|
|
||||||
(this.getName().equals(that.getName()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -471,14 +463,13 @@ final class PropertyPermissionCollection extends PermissionCollection
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void add(Permission permission) {
|
public void add(Permission permission) {
|
||||||
if (! (permission instanceof PropertyPermission))
|
if (! (permission instanceof PropertyPermission pp))
|
||||||
throw new IllegalArgumentException("invalid permission: "+
|
throw new IllegalArgumentException("invalid permission: "+
|
||||||
permission);
|
permission);
|
||||||
if (isReadOnly())
|
if (isReadOnly())
|
||||||
throw new SecurityException(
|
throw new SecurityException(
|
||||||
"attempt to add a Permission to a readonly PermissionCollection");
|
"attempt to add a Permission to a readonly PermissionCollection");
|
||||||
|
|
||||||
PropertyPermission pp = (PropertyPermission) permission;
|
|
||||||
String propName = pp.getName();
|
String propName = pp.getName();
|
||||||
|
|
||||||
// Add permission to map if it is absent, or replace with new
|
// Add permission to map if it is absent, or replace with new
|
||||||
@ -523,10 +514,9 @@ final class PropertyPermissionCollection extends PermissionCollection
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean implies(Permission permission) {
|
public boolean implies(Permission permission) {
|
||||||
if (! (permission instanceof PropertyPermission))
|
if (! (permission instanceof PropertyPermission pp))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
PropertyPermission pp = (PropertyPermission) permission;
|
|
||||||
PropertyPermission x;
|
PropertyPermission x;
|
||||||
|
|
||||||
int desired = pp.getMask();
|
int desired = pp.getMask();
|
||||||
|
@ -196,10 +196,9 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||||||
* @throws NullPointerException if the specified collection is null
|
* @throws NullPointerException if the specified collection is null
|
||||||
*/
|
*/
|
||||||
public boolean containsAll(Collection<?> c) {
|
public boolean containsAll(Collection<?> c) {
|
||||||
if (!(c instanceof RegularEnumSet))
|
if (!(c instanceof RegularEnumSet<?> es))
|
||||||
return super.containsAll(c);
|
return super.containsAll(c);
|
||||||
|
|
||||||
RegularEnumSet<?> es = (RegularEnumSet<?>)c;
|
|
||||||
if (es.elementType != elementType)
|
if (es.elementType != elementType)
|
||||||
return es.isEmpty();
|
return es.isEmpty();
|
||||||
|
|
||||||
@ -215,10 +214,9 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||||||
* of its elements are null
|
* of its elements are null
|
||||||
*/
|
*/
|
||||||
public boolean addAll(Collection<? extends E> c) {
|
public boolean addAll(Collection<? extends E> c) {
|
||||||
if (!(c instanceof RegularEnumSet))
|
if (!(c instanceof RegularEnumSet<?> es))
|
||||||
return super.addAll(c);
|
return super.addAll(c);
|
||||||
|
|
||||||
RegularEnumSet<?> es = (RegularEnumSet<?>)c;
|
|
||||||
if (es.elementType != elementType) {
|
if (es.elementType != elementType) {
|
||||||
if (es.isEmpty())
|
if (es.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
@ -241,10 +239,9 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||||||
* @throws NullPointerException if the specified collection is null
|
* @throws NullPointerException if the specified collection is null
|
||||||
*/
|
*/
|
||||||
public boolean removeAll(Collection<?> c) {
|
public boolean removeAll(Collection<?> c) {
|
||||||
if (!(c instanceof RegularEnumSet))
|
if (!(c instanceof RegularEnumSet<?> es))
|
||||||
return super.removeAll(c);
|
return super.removeAll(c);
|
||||||
|
|
||||||
RegularEnumSet<?> es = (RegularEnumSet<?>)c;
|
|
||||||
if (es.elementType != elementType)
|
if (es.elementType != elementType)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -262,10 +259,9 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||||||
* @throws NullPointerException if the specified collection is null
|
* @throws NullPointerException if the specified collection is null
|
||||||
*/
|
*/
|
||||||
public boolean retainAll(Collection<?> c) {
|
public boolean retainAll(Collection<?> c) {
|
||||||
if (!(c instanceof RegularEnumSet))
|
if (!(c instanceof RegularEnumSet<?> es))
|
||||||
return super.retainAll(c);
|
return super.retainAll(c);
|
||||||
|
|
||||||
RegularEnumSet<?> es = (RegularEnumSet<?>)c;
|
|
||||||
if (es.elementType != elementType) {
|
if (es.elementType != elementType) {
|
||||||
boolean changed = (elements != 0);
|
boolean changed = (elements != 0);
|
||||||
elements = 0;
|
elements = 0;
|
||||||
@ -294,10 +290,9 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||||||
* @return {@code true} if the specified object is equal to this set
|
* @return {@code true} if the specified object is equal to this set
|
||||||
*/
|
*/
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!(o instanceof RegularEnumSet))
|
if (!(o instanceof RegularEnumSet<?> es))
|
||||||
return super.equals(o);
|
return super.equals(o);
|
||||||
|
|
||||||
RegularEnumSet<?> es = (RegularEnumSet<?>)o;
|
|
||||||
if (es.elementType != elementType)
|
if (es.elementType != elementType)
|
||||||
return elements == 0 && es.elements == 0;
|
return elements == 0 && es.elements == 0;
|
||||||
return es.elements == elements;
|
return es.elements == elements;
|
||||||
|
@ -2664,9 +2664,8 @@ public final class Scanner implements Iterator<String>, Closeable {
|
|||||||
*/
|
*/
|
||||||
public BigInteger nextBigInteger(int radix) {
|
public BigInteger nextBigInteger(int radix) {
|
||||||
// Check cached result
|
// Check cached result
|
||||||
if ((typeCache != null) && (typeCache instanceof BigInteger)
|
if ((typeCache != null) && (typeCache instanceof BigInteger val)
|
||||||
&& this.radix == radix) {
|
&& this.radix == radix) {
|
||||||
BigInteger val = (BigInteger)typeCache;
|
|
||||||
useTypeCache();
|
useTypeCache();
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@ -2730,8 +2729,7 @@ public final class Scanner implements Iterator<String>, Closeable {
|
|||||||
*/
|
*/
|
||||||
public BigDecimal nextBigDecimal() {
|
public BigDecimal nextBigDecimal() {
|
||||||
// Check cached result
|
// Check cached result
|
||||||
if ((typeCache != null) && (typeCache instanceof BigDecimal)) {
|
if ((typeCache != null) && (typeCache instanceof BigDecimal val)) {
|
||||||
BigDecimal val = (BigDecimal)typeCache;
|
|
||||||
useTypeCache();
|
useTypeCache();
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -818,11 +818,8 @@ public final class ServiceLoader<S>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object ob) {
|
public boolean equals(Object ob) {
|
||||||
if (!(ob instanceof ProviderImpl))
|
return ob instanceof @SuppressWarnings("unchecked")ProviderImpl<?> that
|
||||||
return false;
|
&& this.service == that.service
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
ProviderImpl<?> that = (ProviderImpl<?>)ob;
|
|
||||||
return this.service == that.service
|
|
||||||
&& this.type == that.type
|
&& this.type == that.type
|
||||||
&& Objects.equals(this.acc, that.acc);
|
&& Objects.equals(this.acc, that.acc);
|
||||||
}
|
}
|
||||||
|
@ -878,19 +878,14 @@ public class SimpleTimeZone extends TimeZone {
|
|||||||
* @return True if the given {@code obj} is the same as this
|
* @return True if the given {@code obj} is the same as this
|
||||||
* {@code SimpleTimeZone} object; false otherwise.
|
* {@code SimpleTimeZone} object; false otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj) {
|
||||||
{
|
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof SimpleTimeZone)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleTimeZone that = (SimpleTimeZone) obj;
|
return obj instanceof SimpleTimeZone that
|
||||||
|
&& getID().equals(that.getID())
|
||||||
return getID().equals(that.getID()) &&
|
&& hasSameRules(that);
|
||||||
hasSameRules(that);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -904,28 +899,26 @@ public class SimpleTimeZone extends TimeZone {
|
|||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(other instanceof SimpleTimeZone)) {
|
return other instanceof SimpleTimeZone that
|
||||||
return false;
|
&& rawOffset == that.rawOffset
|
||||||
}
|
&& useDaylight == that.useDaylight
|
||||||
SimpleTimeZone that = (SimpleTimeZone) other;
|
&& (!useDaylight ||
|
||||||
return rawOffset == that.rawOffset &&
|
// Only check rules if using DST
|
||||||
useDaylight == that.useDaylight &&
|
(dstSavings == that.dstSavings
|
||||||
(!useDaylight
|
&& startMode == that.startMode
|
||||||
// Only check rules if using DST
|
&& startMonth == that.startMonth
|
||||||
|| (dstSavings == that.dstSavings &&
|
&& startDay == that.startDay
|
||||||
startMode == that.startMode &&
|
&& startDayOfWeek == that.startDayOfWeek
|
||||||
startMonth == that.startMonth &&
|
&& startTime == that.startTime
|
||||||
startDay == that.startDay &&
|
&& startTimeMode == that.startTimeMode
|
||||||
startDayOfWeek == that.startDayOfWeek &&
|
&& endMode == that.endMode
|
||||||
startTime == that.startTime &&
|
&& endMonth == that.endMonth
|
||||||
startTimeMode == that.startTimeMode &&
|
&& endDay == that.endDay
|
||||||
endMode == that.endMode &&
|
&& endDayOfWeek == that.endDayOfWeek
|
||||||
endMonth == that.endMonth &&
|
&& endTime == that.endTime
|
||||||
endDay == that.endDay &&
|
&& endTimeMode == that.endTimeMode
|
||||||
endDayOfWeek == that.endDayOfWeek &&
|
&& startYear == that.startYear)
|
||||||
endTime == that.endTime &&
|
);
|
||||||
endTimeMode == that.endTimeMode &&
|
|
||||||
startYear == that.startYear));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1341,18 +1341,16 @@ public class TreeMap<K,V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
if (!(o instanceof Map.Entry<?, ?> entry))
|
||||||
return false;
|
return false;
|
||||||
Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
|
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
Entry<K,V> p = getEntry(entry.getKey());
|
Entry<K,V> p = getEntry(entry.getKey());
|
||||||
return p != null && valEquals(p.getValue(), value);
|
return p != null && valEquals(p.getValue(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
if (!(o instanceof Map.Entry<?, ?> entry))
|
||||||
return false;
|
return false;
|
||||||
Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
|
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
Entry<K,V> p = getEntry(entry.getKey());
|
Entry<K,V> p = getEntry(entry.getKey());
|
||||||
if (p != null && valEquals(p.getValue(), value)) {
|
if (p != null && valEquals(p.getValue(), value)) {
|
||||||
@ -1963,9 +1961,8 @@ public class TreeMap<K,V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
if (!(o instanceof Entry<?, ?> entry))
|
||||||
return false;
|
return false;
|
||||||
Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
|
|
||||||
Object key = entry.getKey();
|
Object key = entry.getKey();
|
||||||
if (!inRange(key))
|
if (!inRange(key))
|
||||||
return false;
|
return false;
|
||||||
@ -1975,9 +1972,8 @@ public class TreeMap<K,V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
if (!(o instanceof Entry<?, ?> entry))
|
||||||
return false;
|
return false;
|
||||||
Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
|
|
||||||
Object key = entry.getKey();
|
Object key = entry.getKey();
|
||||||
if (!inRange(key))
|
if (!inRange(key))
|
||||||
return false;
|
return false;
|
||||||
@ -2425,11 +2421,9 @@ public class TreeMap<K,V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
return o instanceof Map.Entry<?, ?> e
|
||||||
return false;
|
&& valEquals(key,e.getKey())
|
||||||
Map.Entry<?,?> e = (Map.Entry<?,?>)o;
|
&& valEquals(value,e.getValue());
|
||||||
|
|
||||||
return valEquals(key,e.getKey()) && valEquals(value,e.getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -299,9 +299,8 @@ public class TreeSet<E> extends AbstractSet<E>
|
|||||||
// Use linear-time version if applicable
|
// Use linear-time version if applicable
|
||||||
if (m.size()==0 && c.size() > 0 &&
|
if (m.size()==0 && c.size() > 0 &&
|
||||||
c instanceof SortedSet &&
|
c instanceof SortedSet &&
|
||||||
m instanceof TreeMap) {
|
m instanceof TreeMap<E, Object> map) {
|
||||||
SortedSet<? extends E> set = (SortedSet<? extends E>) c;
|
SortedSet<? extends E> set = (SortedSet<? extends E>) c;
|
||||||
TreeMap<E,Object> map = (TreeMap<E, Object>) m;
|
|
||||||
if (Objects.equals(set.comparator(), map.comparator())) {
|
if (Objects.equals(set.comparator(), map.comparator())) {
|
||||||
map.addAllForTreeSet(set, PRESENT);
|
map.addAllForTreeSet(set, PRESENT);
|
||||||
return true;
|
return true;
|
||||||
|
@ -619,10 +619,9 @@ public class WeakHashMap<K,V>
|
|||||||
|
|
||||||
/** Special version of remove needed by Entry set */
|
/** Special version of remove needed by Entry set */
|
||||||
boolean removeMapping(Object o) {
|
boolean removeMapping(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
if (!(o instanceof Map.Entry<?, ?> entry))
|
||||||
return false;
|
return false;
|
||||||
Entry<K,V>[] tab = getTable();
|
Entry<K,V>[] tab = getTable();
|
||||||
Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
|
|
||||||
Object k = maskNull(entry.getKey());
|
Object k = maskNull(entry.getKey());
|
||||||
int h = hash(k);
|
int h = hash(k);
|
||||||
int i = indexFor(h, tab.length);
|
int i = indexFor(h, tab.length);
|
||||||
@ -737,9 +736,8 @@ public class WeakHashMap<K,V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
if (!(o instanceof Map.Entry<?, ?> e))
|
||||||
return false;
|
return false;
|
||||||
Map.Entry<?,?> e = (Map.Entry<?,?>)o;
|
|
||||||
K k1 = getKey();
|
K k1 = getKey();
|
||||||
Object k2 = e.getKey();
|
Object k2 = e.getKey();
|
||||||
if (k1 == k2 || (k1 != null && k1.equals(k2))) {
|
if (k1 == k2 || (k1 != null && k1.equals(k2))) {
|
||||||
@ -977,11 +975,9 @@ public class WeakHashMap<K,V>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
if (!(o instanceof Map.Entry))
|
return o instanceof Map.Entry<?, ?> e
|
||||||
return false;
|
&& getEntry(e.getKey()) != null
|
||||||
Map.Entry<?,?> e = (Map.Entry<?,?>)o;
|
&& getEntry(e.getKey()).equals(e);
|
||||||
Entry<K,V> candidate = getEntry(e.getKey());
|
|
||||||
return candidate != null && candidate.equals(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
|
@ -514,12 +514,8 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||||||
if (this == o) {
|
if (this == o) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (o instanceof Name) {
|
return o instanceof Name other
|
||||||
Name other = (Name)o;
|
&& other.name.equalsIgnoreCase(name);
|
||||||
return other.name.equalsIgnoreCase(name);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -551,10 +551,9 @@ class JarVerifier {
|
|||||||
* Match CodeSource to a CodeSigner[] in the signer cache.
|
* Match CodeSource to a CodeSigner[] in the signer cache.
|
||||||
*/
|
*/
|
||||||
private CodeSigner[] findMatchingSigners(CodeSource cs) {
|
private CodeSigner[] findMatchingSigners(CodeSource cs) {
|
||||||
if (cs instanceof VerifierCodeSource) {
|
if (cs instanceof VerifierCodeSource vcs) {
|
||||||
VerifierCodeSource vcs = (VerifierCodeSource) cs;
|
|
||||||
if (vcs.isSameDomain(csdomain)) {
|
if (vcs.isSameDomain(csdomain)) {
|
||||||
return ((VerifierCodeSource) cs).getPrivateSigners();
|
return vcs.getPrivateSigners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,8 +616,7 @@ class JarVerifier {
|
|||||||
if (obj == this) {
|
if (obj == this) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj instanceof VerifierCodeSource) {
|
if (obj instanceof VerifierCodeSource that) {
|
||||||
VerifierCodeSource that = (VerifierCodeSource) obj;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Only compare against other per-signer singletons constructed
|
* Only compare against other per-signer singletons constructed
|
||||||
|
@ -379,13 +379,9 @@ public class Manifest implements Cloneable {
|
|||||||
* the same main Attributes and entries
|
* the same main Attributes and entries
|
||||||
*/
|
*/
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o instanceof Manifest) {
|
return o instanceof Manifest m
|
||||||
Manifest m = (Manifest)o;
|
&& attr.equals(m.getMainAttributes())
|
||||||
return attr.equals(m.getMainAttributes()) &&
|
&& entries.equals(m.getEntries());
|
||||||
entries.equals(m.getEntries());
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3083,8 +3083,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||||||
if (saveTCNCount < topClosureNodes.size())
|
if (saveTCNCount < topClosureNodes.size())
|
||||||
topClosureNodes.subList(saveTCNCount, topClosureNodes.size()).clear();
|
topClosureNodes.subList(saveTCNCount, topClosureNodes.size()).clear();
|
||||||
|
|
||||||
if (node instanceof Ques) {
|
if (node instanceof Ques ques) {
|
||||||
Ques ques = (Ques) node;
|
|
||||||
if (ques.type == Qtype.POSSESSIVE) {
|
if (ques.type == Qtype.POSSESSIVE) {
|
||||||
root = node;
|
root = node;
|
||||||
return node;
|
return node;
|
||||||
@ -3098,8 +3097,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||||||
}
|
}
|
||||||
root = tail;
|
root = tail;
|
||||||
return head;
|
return head;
|
||||||
} else if (node instanceof Curly) {
|
} else if (node instanceof Curly curly) {
|
||||||
Curly curly = (Curly) node;
|
|
||||||
if (curly.type == Qtype.POSSESSIVE) {
|
if (curly.type == Qtype.POSSESSIVE) {
|
||||||
root = node;
|
root = node;
|
||||||
return node;
|
return node;
|
||||||
|
@ -131,21 +131,18 @@ class PrintPattern {
|
|||||||
node = loop;
|
node = loop;
|
||||||
} else if (node instanceof Pattern.Loop) {
|
} else if (node instanceof Pattern.Loop) {
|
||||||
return; // stop here, body.next -> loop
|
return; // stop here, body.next -> loop
|
||||||
} else if (node instanceof Pattern.Curly) {
|
} else if (node instanceof Pattern.Curly c) {
|
||||||
Pattern.Curly c = (Pattern.Curly)node;
|
|
||||||
str = "Curly " + c.type + " " + toStringRange(c.cmin, c.cmax);
|
str = "Curly " + c.type + " " + toStringRange(c.cmin, c.cmax);
|
||||||
print(node, str, depth);
|
print(node, str, depth);
|
||||||
walk(c.atom, depth);
|
walk(c.atom, depth);
|
||||||
print("/Curly", depth);
|
print("/Curly", depth);
|
||||||
} else if (node instanceof Pattern.GroupCurly) {
|
} else if (node instanceof Pattern.GroupCurly gc) {
|
||||||
Pattern.GroupCurly gc = (Pattern.GroupCurly)node;
|
|
||||||
str = "GroupCurly " + gc.groupIndex / 2 +
|
str = "GroupCurly " + gc.groupIndex / 2 +
|
||||||
", " + gc.type + " " + toStringRange(gc.cmin, gc.cmax);
|
", " + gc.type + " " + toStringRange(gc.cmin, gc.cmax);
|
||||||
print(node, str, depth);
|
print(node, str, depth);
|
||||||
walk(gc.atom, depth);
|
walk(gc.atom, depth);
|
||||||
print("/GroupCurly", depth);
|
print("/GroupCurly", depth);
|
||||||
} else if (node instanceof Pattern.GroupHead) {
|
} else if (node instanceof Pattern.GroupHead head) {
|
||||||
Pattern.GroupHead head = (Pattern.GroupHead)node;
|
|
||||||
Pattern.GroupTail tail = head.tail;
|
Pattern.GroupTail tail = head.tail;
|
||||||
print(head, "Group.head " + (tail.groupIndex / 2), depth);
|
print(head, "Group.head " + (tail.groupIndex / 2), depth);
|
||||||
walk(head.next, depth);
|
walk(head.next, depth);
|
||||||
@ -157,8 +154,7 @@ class PrintPattern {
|
|||||||
print(node, "Ques " + ((Pattern.Ques)node).type, depth);
|
print(node, "Ques " + ((Pattern.Ques)node).type, depth);
|
||||||
walk(((Pattern.Ques)node).atom, depth);
|
walk(((Pattern.Ques)node).atom, depth);
|
||||||
print("/Ques", depth);
|
print("/Ques", depth);
|
||||||
} else if (node instanceof Pattern.Branch) {
|
} else if (node instanceof Pattern.Branch b) {
|
||||||
Pattern.Branch b = (Pattern.Branch)node;
|
|
||||||
print(b, name, depth);
|
print(b, name, depth);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -186,8 +182,7 @@ class PrintPattern {
|
|||||||
str = name + " \"" +
|
str = name + " \"" +
|
||||||
toStringCPS(((Pattern.SliceNode)node).buffer) + "\"";
|
toStringCPS(((Pattern.SliceNode)node).buffer) + "\"";
|
||||||
print(node, str, depth);
|
print(node, str, depth);
|
||||||
} else if (node instanceof Pattern.CharPropertyGreedy) {
|
} else if (node instanceof Pattern.CharPropertyGreedy gcp) {
|
||||||
Pattern.CharPropertyGreedy gcp = (Pattern.CharPropertyGreedy)node;
|
|
||||||
String pstr = pmap.get(gcp.predicate);
|
String pstr = pmap.get(gcp.predicate);
|
||||||
if (pstr == null)
|
if (pstr == null)
|
||||||
pstr = gcp.predicate.toString();
|
pstr = gcp.predicate.toString();
|
||||||
|
@ -1218,8 +1218,7 @@ public class ZipFile implements ZipConstants, Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof Key) {
|
if (obj instanceof Key key) {
|
||||||
Key key = (Key)obj;
|
|
||||||
if (key.utf8 != utf8) {
|
if (key.utf8 != utf8) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user