test_class.file: tools/galaxyLibrary/project/GalaxyLib/src/test/java/com/ahli/util/StringInternerTest.java
test_class.identifier: StringInternerTest
test_case.body: @Test
  	public void testWeakRefStringInterner() {
  		final double value = Math.random();
  		final String text = "HELLO WORLD! ";
  		String firstToBeInterned = text + value;
  		
  		// first intern
  		String firstInterned = StringInterner.intern(firstToBeInterned);
  		assertSame(firstInterned, firstToBeInterned, "first interned received different reference");
  		
  		// second intern
  		final String secondToBeInterned = text + value;
  		assertNotSame(firstToBeInterned, secondToBeInterned,
  				"first and second interned are same reference - VM is breaking this test with optimizations");
  		String secondInterned = StringInterner.intern(secondToBeInterned);
  		
  		assertEquals(secondInterned, firstInterned, "second interned changed value during interning - first vs second");
  		assertEquals(secondInterned, secondToBeInterned,
  				"second interned changed value during interning - second input vs output");
  		assertNotSame(secondInterned, secondToBeInterned, "second interned delivered same reference back");
  		assertSame(firstInterned, secondInterned, "first interned received different reference");
  		
  		// test garbage collection
  		final var referenceQueue = new ReferenceQueue<String>();
  		final var weakRef = new WeakReference<>(firstInterned, referenceQueue);
  		firstToBeInterned = null;
  		firstInterned = null;
  		secondInterned = null;
  		
  		int i = 0;
  		final int maxAttempts = 3;
  		while (referenceQueue.poll() == null && i < maxAttempts) {
  			++i;
  			System.gc();
  			System.runFinalization();
  		}
  		// fails on J9 JDK
  		assertTrue(i < maxAttempts, "GC did not remove the WeakReference within " + maxAttempts + " attempts");
  	}
test_case.class_method_signature: StringInternerTest.testWeakRefStringInterner()
test_case.full_signature: @Test public void testWeakRefStringInterner()
test_case.identifier: testWeakRefStringInterner
test_case.invocations: random intern assertSame assertNotSame intern assertEquals assertEquals assertNotSame assertSame poll gc runFinalization assertTrue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testWeakRefStringInterner()
focal_class.declarator: map = new ConcurrentWeakWeakHashMap<>(8, 0.9F, 1)
focal_class.modifier: private static final
focal_class.original_string: private static final ConcurrentWeakWeakHashMap<String> map = new ConcurrentWeakWeakHashMap<>(8, 0.9F, 1);
focal_class.type: ConcurrentWeakWeakHashMap<String>
focal_class.var_name: map
focal_class.file: tools/galaxyLibrary/project/GalaxyLib/src/main/java/com/ahli/util/StringInterner.java
focal_class.identifier: StringInterner
focal_class.class_method_signature: StringInterner.StringInterner()
focal_class.full_signature: private  StringInterner()
focal_class.identifier: StringInterner
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.signature:  StringInterner()
focal_class.class_method_signature: StringInterner.intern(final String s)
focal_class.full_signature: public static String intern(final String s)
focal_class.identifier: intern
focal_class.modifiers: public static
focal_class.parameters: (final String s)
focal_class.return: String
focal_class.signature: String intern(final String s)
focal_class.class_method_signature: StringInterner.clear()
focal_class.full_signature: public static void clear()
focal_class.identifier: clear
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void clear()
focal_class.class_method_signature: StringInterner.cleanUpGarbage()
focal_class.full_signature: public static void cleanUpGarbage()
focal_class.identifier: cleanUpGarbage
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void cleanUpGarbage()
focal_class.class_method_signature: StringInterner.size()
focal_class.full_signature: public static int size()
focal_class.identifier: size
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int size()
focal_method.body: public static String intern(final String s) {
  		final String exists = map.putIfAbsent(s, s);
  		return (exists == null) ? s : exists;
  	}
focal_method.class_method_signature: StringInterner.intern(final String s)
focal_method.full_signature: public static String intern(final String s)
focal_method.identifier: intern
focal_method.invocations: putIfAbsent
focal_method.modifiers: public static
focal_method.parameters: (final String s)
focal_method.return: String
focal_method.signature: String intern(final String s)