Null out levels that will never be referenced again.
Null entries are candidates to be the next current level.
546548
private static void garbageCollectUnusedLevels() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "garbageCollectUnusedLevels");

        final int numLevels = _syncLevels.size();
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "Levels: " + numLevels);

        // No need to do anything if we only have one level
        if (numLevels < 2) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(tc, "garbageCollectUnusedLevels", "Doing nothing");
            return;
        }

        final int[] counts = new int[numLevels];

        // Check through all transactions to see which levels are still in use
        final TransactionImpl[] txns = LocalTIDTable.getAllTransactions();

        // Record the levels with transactions referring to them

        // Record the levels with transactions referring to them
        for (int i = txns.length; --i >= 0;) {
            // TransactionImpl has a dependency on CORBA which we definitely don't want
            // Skip this step to avoid a classcastexception
            // TODO can we work around the dependency?
            int level = 0;
            // final int level = ((com.ibm.ws.tx.jta.TransactionImpl) txns[i]).getExtJTASyncLevel();
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "Not generating any counts for garbageCollectUnusedLevels()");
            }

            if (level >= 0 && level < numLevels) {
                counts[level]++;
            }
        }

        // Now null out the levels with no references
        for (int i = counts.length; --i >= 0;) {
            // We never want to null out the current level
            if (i != _syncLevel) {
                if (counts[i] == 0) {
                    _syncLevels.set(i, null);
                }
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "garbageCollectUnusedLevels", _syncLevels.size());
    }
485459
public static void nullCoalesce(CodeBuilder builder, Label nullExit) {
    builder.dup();
    Label nonNull = new Label();
    builder.ifNonNull(nonNull);
    // See http://mail.ow2.org/wws/arc/asm/2016-02/msg00001.html for a discussion of this pattern
    // but even though the value at the top of the stack here is null, its type isn't.  So we need
    // to pop and push.  This is the idiomatic pattern.
    builder.pop();
    builder.pushNull();
    builder.goTo(nullExit);
    builder.mark(nonNull);
  }
886456
@NullSafe
  @SuppressWarnings("all")
  public static boolean areAllNull(Object... values) {

    for (Object value : nullSafeArray(values)) {
      if (value != null) {
        return false;
      }
    }

    return true;
  }
404300
@Nullable
    String next() {
        if( lastIdx >= selector.length() ) {
            return null;
        }
        LOOP: do {
            if( ++idx == selector.length() ) {
                break LOOP;
            }
            switch( selector.charAt( idx ) ) {
                case '.':
                case '#':
                case ':':
                case '[':
                    break LOOP;
            }
        } while( true );
        String str = selector.substring( lastIdx, idx ).trim();
        lastIdx = idx;
        return str;
    }
252734
public <T> void cleanNullReferencesAll() {
		for (Map<Object, Reference<Object>> objectMap : classMaps.values()) {
			cleanMap(objectMap);
		}
	}
919841
public void cleanUpNullReferences() {
        final Iterator<Map.Entry<Object, Object>> iterator = cache.entrySet().iterator();
        while (iterator.hasNext()) {
            final Map.Entry<Object, Object> entry = iterator.next();
            Object entryVal = entry.getValue();
            if (entryVal != null && ((SoftReference) entryVal).get() == null) cache.remove(entry.getKey(), entryVal);
        }
    }
252623
private static boolean containsNonNull(Object... items) {
        for (Object item : items) {
            if (item != null) {
                return true;
            }
        }
        return false;
    }
162668
@Override
    public void clear() {
        root = new PatriciaNode<>(null, null, -1);
        root.setLeft(root);
        entries = 0;
    }
1134117
private V getForNullKey() {
	for (Entry<K, V> e = table[0]; e != null; e = e.next) {
	    if (e.key == null) return e.value;
	}
	return null;
    }
1248698
void clear() {
        // A VoltDB extension to diagnose ArrayOutOfBounds.
        if (linkTable != null) {
            voltDBclearCapacity = linkTable.length;
        }
        ++voltDBclearCount;
        voltDBlastClearEvent = voltDBhistoryDepth;
        // End of VoltDB extension

        int   to       = linkTable.length;
        int[] intArray = linkTable;

        while (--to >= 0) {
            intArray[to] = 0;
        }

        resetTables();
    }
315560
private void nullPrintln(PrintStream out, String line)
    {
        if (out != null)
        {
            out.println(line);
        }
    }
237764
private final void clearUnreferencedEntries()
    {
        for (WeakEntry entry = (WeakEntry) queue.poll(); entry != null; entry = (WeakEntry) queue.poll()) {
            WeakEntry removedEntry = (WeakEntry) super.remove(entry.key);
            // The entry for this key may have been replaced with another one after it was dereferenced.
            // Make sure we removed the correct entry.
            if (removedEntry != entry) {
                super.put(entry.key, removedEntry);
            }
        } // for...
    }
404104
static void checkNoneNull(Iterable<?> objects) {
    if (!(objects instanceof ImmutableCollection)) {
      for (Object o : objects) {
        checkNotNull(o);
      }
    }
  }
543254
public String next() {
        if (entry == null) return null;
        entry = entry.next;
        return entry.element;
    }
1058208
@Nullable V removeWithWriter(Object key) {
    @SuppressWarnings("unchecked")
    K castKey = (K) key;
    @SuppressWarnings({"unchecked", "rawtypes"})
    Node<K, V>[] node = new Node[1];
    @SuppressWarnings("unchecked")
    V[] oldValue = (V[]) new Object[1];
    RemovalCause[] cause = new RemovalCause[1];

    data.computeIfPresent(nodeFactory.newLookupKey(key), (k, n) -> {
      synchronized (n) {
        oldValue[0] = n.getValue();
        if (oldValue[0] == null) {
          cause[0] = RemovalCause.COLLECTED;
        } else if (hasExpired(n, expirationTicker().read())) {
          cause[0] = RemovalCause.EXPIRED;
        } else {
          cause[0] = RemovalCause.EXPLICIT;
        }
        writer.delete(castKey, oldValue[0], cause[0]);
        n.retire();
      }
      node[0] = n;
      return null;
    });

    if (cause[0] != null) {
      afterWrite(new RemovalTask(node[0]));
      if (hasRemovalListener()) {
        notifyRemoval(castKey, oldValue[0], cause[0]);
      }
    }
    return (cause[0] == RemovalCause.EXPLICIT) ? oldValue[0] : null;
  }
1030213
private void emptyQueue() {
        if (queue == null) {
            return;
        }
        int startSize = cacheMap.size();
        while (true) {
            @SuppressWarnings("unchecked")
            CacheEntry<K,V> entry = (CacheEntry<K,V>)queue.poll();
            if (entry == null) {
                break;
            }
            K key = entry.getKey();
            if (key == null) {
                // key is null, entry has already been removed
                continue;
            }
            CacheEntry<K,V> currentEntry = cacheMap.remove(key);
            // check if the entry in the map corresponds to the expired
            // entry. If not, readd the entry
            if ((currentEntry != null) && (entry != currentEntry)) {
                cacheMap.put(key, currentEntry);
            }
        }
        if (DEBUG) {
            int endSize = cacheMap.size();
            if (startSize != endSize) {
                System.out.println("*** Expunged " + (startSize - endSize)
                        + " entries, " + endSize + " entries left");
            }
        }
    }
1086846
public static boolean atLeastOneNotNull(final Object... o1s) {
        if (o1s != null && o1s.length > 0) {
            for (final Object o1 : o1s) {
                if (o1 != null) {
                    return true;
                }
            }
        }
        return false;
    }