if (buckets[slot] == bucket)
WeakBucket prev = null; WeakBucket next = buckets[slot]; while (next != bucket) { if (next == null) throw new InternalError("WeakHashMap in incosistent state"); prev = next; next = prev.next; } if (prev == null)
  void internalRemove(WeakBucket bucket)  {    int slot = bucket.slot;    if (slot == -1)      // This bucket was already removed.      return;    // Mark the bucket as removed.  This is necessary, since the    // bucket may be enqueued later by the garbage collection, and    // internalRemove will be called a second time.    bucket.slot = -1;    if (buckets[slot] == bucket)      buckets[slot] = bucket.next;    else      {        WeakBucket prev = buckets[slot];        /* This may throw a NullPointerException.  It shouldn't but if         * a race condition occurred (two threads removing the same         * bucket at the same time) it may happen.  <br>         * But with race condition many much worse things may happen         * anyway.         */        while (prev.next != bucket)          prev = prev.next;        prev.next = bucket.next;      }    size--;  }