8035284: Remove redundant null initialization
Reviewed-by: lancea, martin, chegar, shade
--- a/jdk/src/share/classes/java/util/AbstractMap.java Fri Apr 11 13:12:11 2014 -0700
+++ b/jdk/src/share/classes/java/util/AbstractMap.java Fri Apr 11 14:07:25 2014 -0700
@@ -305,8 +305,8 @@
* appropriate view the first time this view is requested. The views are
* stateless, so there's no reason to create more than one of each.
*/
- transient volatile Set<K> keySet = null;
- transient volatile Collection<V> values = null;
+ transient volatile Set<K> keySet;
+ transient volatile Collection<V> values;
/**
* {@inheritDoc}
--- a/jdk/src/share/classes/java/util/Collections.java Fri Apr 11 13:12:11 2014 -0700
+++ b/jdk/src/share/classes/java/util/Collections.java Fri Apr 11 14:07:25 2014 -0700
@@ -1466,9 +1466,9 @@
throw new UnsupportedOperationException();
}
- private transient Set<K> keySet = null;
- private transient Set<Map.Entry<K,V>> entrySet = null;
- private transient Collection<V> values = null;
+ private transient Set<K> keySet;
+ private transient Set<Map.Entry<K,V>> entrySet;
+ private transient Collection<V> values;
public Set<K> keySet() {
if (keySet==null)
@@ -2597,9 +2597,9 @@
synchronized (mutex) {m.clear();}
}
- private transient Set<K> keySet = null;
- private transient Set<Map.Entry<K,V>> entrySet = null;
- private transient Collection<V> values = null;
+ private transient Set<K> keySet;
+ private transient Set<Map.Entry<K,V>> entrySet;
+ private transient Collection<V> values;
public Set<K> keySet() {
synchronized (mutex) {
@@ -3082,7 +3082,7 @@
return c.add(e);
}
- private E[] zeroLengthElementArray = null; // Lazily initialized
+ private E[] zeroLengthElementArray; // Lazily initialized
private E[] zeroLengthElementArray() {
return zeroLengthElementArray != null ? zeroLengthElementArray :
@@ -3643,7 +3643,7 @@
m.put(e.getKey(), e.getValue());
}
- private transient Set<Map.Entry<K,V>> entrySet = null;
+ private transient Set<Map.Entry<K,V>> entrySet;
public Set<Map.Entry<K,V>> entrySet() {
if (entrySet==null)
@@ -4877,9 +4877,9 @@
public boolean containsValue(Object value) {return eq(value, v);}
public V get(Object key) {return (eq(key, k) ? v : null);}
- private transient Set<K> keySet = null;
- private transient Set<Map.Entry<K,V>> entrySet = null;
- private transient Collection<V> values = null;
+ private transient Set<K> keySet;
+ private transient Set<Map.Entry<K,V>> entrySet;
+ private transient Collection<V> values;
public Set<K> keySet() {
if (keySet==null)
--- a/jdk/src/share/classes/java/util/EnumMap.java Fri Apr 11 13:12:11 2014 -0700
+++ b/jdk/src/share/classes/java/util/EnumMap.java Fri Apr 11 14:07:25 2014 -0700
@@ -367,7 +367,7 @@
* view the first time this view is requested. The view is stateless,
* so there's no reason to create more than one.
*/
- private transient Set<Map.Entry<K,V>> entrySet = null;
+ private transient Set<Map.Entry<K,V>> entrySet;
/**
* Returns a {@link Set} view of the keys contained in this map.
@@ -562,7 +562,7 @@
}
private class EntryIterator extends EnumMapIterator<Map.Entry<K,V>> {
- private Entry lastReturnedEntry = null;
+ private Entry lastReturnedEntry;
public Map.Entry<K,V> next() {
if (!hasNext())
--- a/jdk/src/share/classes/java/util/Hashtable.java Fri Apr 11 13:12:11 2014 -0700
+++ b/jdk/src/share/classes/java/util/Hashtable.java Fri Apr 11 14:07:25 2014 -0700
@@ -617,9 +617,9 @@
* appropriate view the first time this view is requested. The views are
* stateless, so there's no reason to create more than one of each.
*/
- private transient volatile Set<K> keySet = null;
- private transient volatile Set<Map.Entry<K,V>> entrySet = null;
- private transient volatile Collection<V> values = null;
+ private transient volatile Set<K> keySet;
+ private transient volatile Set<Map.Entry<K,V>> entrySet;
+ private transient volatile Collection<V> values;
/**
* Returns a {@link Set} view of the keys contained in this map.
@@ -1300,8 +1300,8 @@
private class Enumerator<T> implements Enumeration<T>, Iterator<T> {
Entry<?,?>[] table = Hashtable.this.table;
int index = table.length;
- Entry<?,?> entry = null;
- Entry<?,?> lastReturned = null;
+ Entry<?,?> entry;
+ Entry<?,?> lastReturned;
int type;
/**
--- a/jdk/src/share/classes/java/util/IdentityHashMap.java Fri Apr 11 13:12:11 2014 -0700
+++ b/jdk/src/share/classes/java/util/IdentityHashMap.java Fri Apr 11 14:07:25 2014 -0700
@@ -842,7 +842,7 @@
private class EntryIterator
extends IdentityHashMapIterator<Map.Entry<K,V>>
{
- private Entry lastReturnedEntry = null;
+ private Entry lastReturnedEntry;
public Map.Entry<K,V> next() {
lastReturnedEntry = new Entry(nextIndex());
@@ -928,7 +928,7 @@
* view the first time this view is requested. The view is stateless,
* so there's no reason to create more than one.
*/
- private transient Set<Map.Entry<K,V>> entrySet = null;
+ private transient Set<Map.Entry<K,V>> entrySet;
/**
* Returns an identity-based set view of the keys contained in this map.
--- a/jdk/src/share/classes/java/util/LinkedList.java Fri Apr 11 13:12:11 2014 -0700
+++ b/jdk/src/share/classes/java/util/LinkedList.java Fri Apr 11 14:07:25 2014 -0700
@@ -869,7 +869,7 @@
}
private class ListItr implements ListIterator<E> {
- private Node<E> lastReturned = null;
+ private Node<E> lastReturned;
private Node<E> next;
private int nextIndex;
private int expectedModCount = modCount;
--- a/jdk/src/share/classes/java/util/TreeMap.java Fri Apr 11 13:12:11 2014 -0700
+++ b/jdk/src/share/classes/java/util/TreeMap.java Fri Apr 11 14:07:25 2014 -0700
@@ -120,7 +120,7 @@
*/
private final Comparator<? super K> comparator;
- private transient Entry<K,V> root = null;
+ private transient Entry<K,V> root;
/**
* The number of entries in the tree
@@ -781,9 +781,9 @@
* the first time this view is requested. Views are stateless, so
* there's no reason to create more than one.
*/
- private transient EntrySet entrySet = null;
- private transient KeySet<K> navigableKeySet = null;
- private transient NavigableMap<K,V> descendingMap = null;
+ private transient EntrySet entrySet;
+ private transient KeySet<K> navigableKeySet;
+ private transient NavigableMap<K,V> descendingMap;
/**
* Returns a {@link Set} view of the keys contained in this map.
@@ -1583,9 +1583,9 @@
}
// Views
- transient NavigableMap<K,V> descendingMapView = null;
- transient EntrySetView entrySetView = null;
- transient KeySet<K> navigableKeySetView = null;
+ transient NavigableMap<K,V> descendingMapView;
+ transient EntrySetView entrySetView;
+ transient KeySet<K> navigableKeySetView;
public final NavigableSet<K> navigableKeySet() {
KeySet<K> nksv = navigableKeySetView;
@@ -2046,8 +2046,8 @@
static final class Entry<K,V> implements Map.Entry<K,V> {
K key;
V value;
- Entry<K,V> left = null;
- Entry<K,V> right = null;
+ Entry<K,V> left;
+ Entry<K,V> right;
Entry<K,V> parent;
boolean color = BLACK;
--- a/jdk/src/share/classes/java/util/WeakHashMap.java Fri Apr 11 13:12:11 2014 -0700
+++ b/jdk/src/share/classes/java/util/WeakHashMap.java Fri Apr 11 14:07:25 2014 -0700
@@ -759,21 +759,21 @@
private abstract class HashIterator<T> implements Iterator<T> {
private int index;
- private Entry<K,V> entry = null;
- private Entry<K,V> lastReturned = null;
+ private Entry<K,V> entry;
+ private Entry<K,V> lastReturned;
private int expectedModCount = modCount;
/**
* Strong reference needed to avoid disappearance of key
* between hasNext and next
*/
- private Object nextKey = null;
+ private Object nextKey;
/**
* Strong reference needed to avoid disappearance of key
* between nextEntry() and any use of the entry
*/
- private Object currentKey = null;
+ private Object currentKey;
HashIterator() {
index = isEmpty() ? 0 : table.length;
@@ -848,7 +848,7 @@
// Views
- private transient Set<Map.Entry<K,V>> entrySet = null;
+ private transient Set<Map.Entry<K,V>> entrySet;
/**
* Returns a {@link Set} view of the keys contained in this map.