/*
 * HPPC
 *
 * Copyright (C) 2010-2020 Carrot Search s.c.
 * All rights reserved.
 *
 * Refer to the full license file "LICENSE.txt":
 * https://github.com/carrotsearch/hppc/blob/master/LICENSE.txt
 */
package com.carrotsearch.hppc;

import com.carrotsearch.randomizedtesting.RandomizedTest;
import com.carrotsearch.randomizedtesting.annotations.Repeat;
import org.assertj.core.api.Assertions;
import org.junit.Test;

public class ObjectIdentityHashSetTest extends RandomizedTest {
  /* */
  @Repeat(iterations = 500)
  @Test
  public void testHashKeyUsesSystemIdentity() {
    int expectedElements = 200;
    ObjectIdentityHashSet<Integer> foo = new ObjectIdentityHashSet<>(expectedElements);
    for (int i = 0; i < expectedElements; i++) {
      @SuppressWarnings("deprecation")
      Integer v2 = new Integer(44);
      foo.add(v2);
    }

    // Assert that values didn't "cluster" into one contiguous block.
    // This ensures each object above had a different target bucket.
    int firstValue = 0;
    if (foo.keys[0] != null) {
      int i = firstValue;
      do {
        firstValue = i;
        i = (i - 1) & foo.mask;
      } while (foo.keys[i] != null);
    } else {
      while (foo.keys[firstValue] == null) {
        firstValue++;
      }
    }

    int blockSize = 0;
    while (foo.keys[firstValue] != null) {
      firstValue = (firstValue + 1) & foo.mask;
      blockSize++;
    }

    Assertions.assertThat(blockSize).isNotEqualTo(expectedElements);
  }
}

@@ -349,16 +349,89 @@
 Repeat;%0A
+import com.carrotsearch.randomizedtesting.annotations.SuppressForbidden;%0A
 import o
@@ -594,16 +594,72 @@
   @Test%0A
+  @SuppressForbidden(%22Legitimate use of new Integer()%22)%0A
   public

Add forbidden APIs check suppression.