diff --git a/android/guava/src/com/google/common/collect/MapMakerInternalMap.java b/android/guava/src/com/google/common/collect/MapMakerInternalMap.java index 815fdb4d79db..e80ec27a5dac 100644 --- a/android/guava/src/com/google/common/collect/MapMakerInternalMap.java +++ b/android/guava/src/com/google/common/collect/MapMakerInternalMap.java @@ -488,6 +488,7 @@ private StrongKeyWeakValueEntry(K key, int hash) { } @Override + @CheckForNull public final V getValue() { return valueReference.get(); } @@ -1157,6 +1158,7 @@ Segment createSegment(int initialCapacity) { * Gets the value from an entry. Returns {@code null} if the entry is invalid, partially-collected * or computing. */ + @CheckForNull V getLiveValue(E entry) { if (entry.getKey() == null) { return null; @@ -1265,6 +1267,7 @@ void setValue(E entry, V value) { } /** Returns a copy of the given {@code entry}. */ + @CheckForNull E copyEntry(E original, E newNext) { return this.map.entryHelper.copy(self(), original, newNext); } @@ -1352,6 +1355,7 @@ boolean removeTableEntryForTesting(InternalEntry entry) { } /** Unsafely removes the given entry from the given chain in this segment's hash table. */ + @CheckForNull E removeFromChainForTesting(InternalEntry first, InternalEntry entry) { return removeFromChain(castForTesting(first), castForTesting(entry)); } @@ -1410,6 +1414,7 @@ void clearReferenceQueue(ReferenceQueue referenceQueue) { } /** Returns first entry of bin for given hash. */ + @CheckForNull E getFirst(int hash) { // read this volatile field only once AtomicReferenceArray table = this.table; @@ -1418,6 +1423,7 @@ E getFirst(int hash) { // Specialized implementations of map methods + @CheckForNull E getEntry(Object key, int hash) { if (count != 0) { // read-volatile for (E e = getFirst(hash); e != null; e = e.getNext()) { @@ -1440,10 +1446,12 @@ E getEntry(Object key, int hash) { return null; } + @CheckForNull E getLiveEntry(Object key, int hash) { return getEntry(key, hash); } + @CheckForNull V get(Object key, int hash) { try { E e = getLiveEntry(key, hash); @@ -1503,6 +1511,7 @@ boolean containsValue(Object value) { } } + @CheckForNull V put(K key, int hash, V value, boolean onlyIfAbsent) { lock(); try { @@ -1676,6 +1685,7 @@ boolean replace(K key, int hash, V oldValue, V newValue) { } } + @CheckForNull V replace(K key, int hash, V newValue) { lock(); try { @@ -1717,6 +1727,7 @@ V replace(K key, int hash, V newValue) { } } + @CheckForNull @CanIgnoreReturnValue V remove(Object key, int hash) { lock(); @@ -1831,6 +1842,7 @@ void clear() { * @return the new first entry for the table */ @GuardedBy("this") + @CheckForNull E removeFromChain(E first, E entry) { int newCount = count; E newFirst = entry.getNext(); @@ -2043,7 +2055,9 @@ StrongKeyStrongValueSegment self() { @SuppressWarnings("unchecked") @Override - public StrongKeyStrongValueEntry castForTesting(InternalEntry entry) { + @CheckForNull + public StrongKeyStrongValueEntry castForTesting( + @CheckForNull InternalEntry entry) { return (StrongKeyStrongValueEntry) entry; } } @@ -2072,7 +2086,9 @@ ReferenceQueue getValueReferenceQueueForTesting() { @SuppressWarnings("unchecked") @Override - public StrongKeyWeakValueEntry castForTesting(InternalEntry entry) { + @CheckForNull + public StrongKeyWeakValueEntry castForTesting( + @CheckForNull InternalEntry entry) { return (StrongKeyWeakValueEntry) entry; } @@ -2202,7 +2218,8 @@ ReferenceQueue getValueReferenceQueueForTesting() { @SuppressWarnings("unchecked") @Override - public WeakKeyWeakValueEntry castForTesting(InternalEntry entry) { + @CheckForNull + public WeakKeyWeakValueEntry castForTesting(@CheckForNull InternalEntry entry) { return (WeakKeyWeakValueEntry) entry; } @@ -2372,6 +2389,7 @@ public V get(@CheckForNull Object key) { * Returns the internal entry for the specified key. The entry may be computing or partially * collected. Does not impact recency ordering. */ + @CheckForNull E getEntry(@CheckForNull Object key) { if (key == null) { return null; diff --git a/guava/src/com/google/common/collect/MapMakerInternalMap.java b/guava/src/com/google/common/collect/MapMakerInternalMap.java index 815fdb4d79db..e80ec27a5dac 100644 --- a/guava/src/com/google/common/collect/MapMakerInternalMap.java +++ b/guava/src/com/google/common/collect/MapMakerInternalMap.java @@ -488,6 +488,7 @@ private StrongKeyWeakValueEntry(K key, int hash) { } @Override + @CheckForNull public final V getValue() { return valueReference.get(); } @@ -1157,6 +1158,7 @@ Segment createSegment(int initialCapacity) { * Gets the value from an entry. Returns {@code null} if the entry is invalid, partially-collected * or computing. */ + @CheckForNull V getLiveValue(E entry) { if (entry.getKey() == null) { return null; @@ -1265,6 +1267,7 @@ void setValue(E entry, V value) { } /** Returns a copy of the given {@code entry}. */ + @CheckForNull E copyEntry(E original, E newNext) { return this.map.entryHelper.copy(self(), original, newNext); } @@ -1352,6 +1355,7 @@ boolean removeTableEntryForTesting(InternalEntry entry) { } /** Unsafely removes the given entry from the given chain in this segment's hash table. */ + @CheckForNull E removeFromChainForTesting(InternalEntry first, InternalEntry entry) { return removeFromChain(castForTesting(first), castForTesting(entry)); } @@ -1410,6 +1414,7 @@ void clearReferenceQueue(ReferenceQueue referenceQueue) { } /** Returns first entry of bin for given hash. */ + @CheckForNull E getFirst(int hash) { // read this volatile field only once AtomicReferenceArray table = this.table; @@ -1418,6 +1423,7 @@ E getFirst(int hash) { // Specialized implementations of map methods + @CheckForNull E getEntry(Object key, int hash) { if (count != 0) { // read-volatile for (E e = getFirst(hash); e != null; e = e.getNext()) { @@ -1440,10 +1446,12 @@ E getEntry(Object key, int hash) { return null; } + @CheckForNull E getLiveEntry(Object key, int hash) { return getEntry(key, hash); } + @CheckForNull V get(Object key, int hash) { try { E e = getLiveEntry(key, hash); @@ -1503,6 +1511,7 @@ boolean containsValue(Object value) { } } + @CheckForNull V put(K key, int hash, V value, boolean onlyIfAbsent) { lock(); try { @@ -1676,6 +1685,7 @@ boolean replace(K key, int hash, V oldValue, V newValue) { } } + @CheckForNull V replace(K key, int hash, V newValue) { lock(); try { @@ -1717,6 +1727,7 @@ V replace(K key, int hash, V newValue) { } } + @CheckForNull @CanIgnoreReturnValue V remove(Object key, int hash) { lock(); @@ -1831,6 +1842,7 @@ void clear() { * @return the new first entry for the table */ @GuardedBy("this") + @CheckForNull E removeFromChain(E first, E entry) { int newCount = count; E newFirst = entry.getNext(); @@ -2043,7 +2055,9 @@ StrongKeyStrongValueSegment self() { @SuppressWarnings("unchecked") @Override - public StrongKeyStrongValueEntry castForTesting(InternalEntry entry) { + @CheckForNull + public StrongKeyStrongValueEntry castForTesting( + @CheckForNull InternalEntry entry) { return (StrongKeyStrongValueEntry) entry; } } @@ -2072,7 +2086,9 @@ ReferenceQueue getValueReferenceQueueForTesting() { @SuppressWarnings("unchecked") @Override - public StrongKeyWeakValueEntry castForTesting(InternalEntry entry) { + @CheckForNull + public StrongKeyWeakValueEntry castForTesting( + @CheckForNull InternalEntry entry) { return (StrongKeyWeakValueEntry) entry; } @@ -2202,7 +2218,8 @@ ReferenceQueue getValueReferenceQueueForTesting() { @SuppressWarnings("unchecked") @Override - public WeakKeyWeakValueEntry castForTesting(InternalEntry entry) { + @CheckForNull + public WeakKeyWeakValueEntry castForTesting(@CheckForNull InternalEntry entry) { return (WeakKeyWeakValueEntry) entry; } @@ -2372,6 +2389,7 @@ public V get(@CheckForNull Object key) { * Returns the internal entry for the specified key. The entry may be computing or partially * collected. Does not impact recency ordering. */ + @CheckForNull E getEntry(@CheckForNull Object key) { if (key == null) { return null;