# HG changeset patch
# User mli
# Date 1543390483 -28800
# Node ID 70adb0f573a78c939783326dcac9d061a1ae30ce
# Parent c76cfae195c8f05da723de1ec323452a06028af3
8211975: move testlibrary/jdk/testlibrary/OptimalCapacity.java to top-level library
Reviewed-by: igerasim
diff -r c76cfae195c8 -r 70adb0f573a7 test/jdk/java/lang/Character/UnicodeBlock/OptimalMapSize.java
--- a/test/jdk/java/lang/Character/UnicodeBlock/OptimalMapSize.java Wed Nov 28 10:21:07 2018 +0530
+++ b/test/jdk/java/lang/Character/UnicodeBlock/OptimalMapSize.java Wed Nov 28 15:34:43 2018 +0800
@@ -25,14 +25,14 @@
* @test
* @bug 8080535 8191410
* @summary Expected size of Character.UnicodeBlock.map is not optimal
- * @library /lib/testlibrary
+ * @library /test/lib
* @modules java.base/java.lang:open
* java.base/java.util:open
- * @build jdk.testlibrary.OptimalCapacity
+ * @build jdk.test.lib.util.OptimalCapacity
* @run main OptimalMapSize
*/
-import jdk.testlibrary.OptimalCapacity;
+import jdk.test.lib.util.OptimalCapacity;
// What will be the number of the Unicode blocks in the future.
//
diff -r c76cfae195c8 -r 70adb0f573a7 test/jdk/java/lang/Enum/ConstantDirectoryOptimalCapacity.java
--- a/test/jdk/java/lang/Enum/ConstantDirectoryOptimalCapacity.java Wed Nov 28 10:21:07 2018 +0530
+++ b/test/jdk/java/lang/Enum/ConstantDirectoryOptimalCapacity.java Wed Nov 28 15:34:43 2018 +0800
@@ -25,14 +25,14 @@
* @test
* @bug 8200696
* @summary Initial capacity of Class.enumConstantDirectory is not optimal
- * @library /lib/testlibrary
+ * @library /test/lib
* @modules java.base/java.lang:open
* java.base/java.util:open
- * @build jdk.testlibrary.OptimalCapacity
+ * @build jdk.test.lib.util.OptimalCapacity
* @run main ConstantDirectoryOptimalCapacity
*/
-import jdk.testlibrary.OptimalCapacity;
+import jdk.test.lib.util.OptimalCapacity;
public class ConstantDirectoryOptimalCapacity {
diff -r c76cfae195c8 -r 70adb0f573a7 test/jdk/java/lang/invoke/VarHandle/AccessMode/OptimalMapSize.java
--- a/test/jdk/java/lang/invoke/VarHandle/AccessMode/OptimalMapSize.java Wed Nov 28 10:21:07 2018 +0530
+++ b/test/jdk/java/lang/invoke/VarHandle/AccessMode/OptimalMapSize.java Wed Nov 28 15:34:43 2018 +0800
@@ -25,15 +25,15 @@
* @test
* @bug 8200788
* @summary Optimal initial capacity of AccessMode.methodNameToAccessMode
- * @library /lib/testlibrary
+ * @library /test/lib
* @modules java.base/java.lang.invoke:open
* java.base/java.util:open
- * @build jdk.testlibrary.OptimalCapacity
+ * @build jdk.test.lib.util.OptimalCapacity
* @run main OptimalMapSize
*/
import java.lang.invoke.VarHandle.AccessMode;
-import jdk.testlibrary.OptimalCapacity;
+import jdk.test.lib.util.OptimalCapacity;
public class OptimalMapSize {
public static void main(String[] args) throws Throwable {
diff -r c76cfae195c8 -r 70adb0f573a7 test/jdk/lib/testlibrary/jdk/testlibrary/OptimalCapacity.java
--- a/test/jdk/lib/testlibrary/jdk/testlibrary/OptimalCapacity.java Wed Nov 28 10:21:07 2018 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,240 +0,0 @@
-/*
- * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.IdentityHashMap;
-
-/**
- * Utility functions to check that the static storages are pre-sized
- * optimally.
- */
-public final class OptimalCapacity {
-
- private OptimalCapacity() {}
-
- /**
- * Checks adequacy of the initial capacity of a static field
- * of type {@code ArrayList}.
- *
- * Having
- *
- * class XClass {
- * static ArrayList theList = new ArrayList(N);
- * }
- *
- */
- public static void ofArrayList(Class> clazz, String fieldName,
- int initialCapacity)
- {
- try {
- Field field = clazz.getDeclaredField(fieldName);
- field.setAccessible(true);
- Object obj = field.get(null);
- if (!ArrayList.class.equals(obj.getClass())) {
- throw new RuntimeException("'" + field +
- "' expected to be of type ArrayList");
- }
- ArrayList> list = (ArrayList>)obj;
-
- // For ArrayList the optimal capacity is its final size
- if (list.size() != initialCapacity) {
- throw new RuntimeException("Size of '" + field +
- "' is " + list.size() +
- ", but expected to be " + initialCapacity);
- }
- if (internalArraySize(list) != initialCapacity) {
- throw new RuntimeException("Capacity of '" + field +
- "' is " + internalArraySize(list) +
- ", but expected to be " + initialCapacity);
- }
- } catch (ReflectiveOperationException roe) {
- throw new RuntimeException(roe);
- }
- }
-
- /**
- * Checks adequacy of the initial capacity of a static field
- * of type {@code HashMap}.
- *
- * Having
- *
- * class XClass {
- * static HashMap theMap = new HashMap(N);
- * }
- *
- */
- public static void ofHashMap(Class> clazz, String fieldName,
- int initialCapacity)
- {
- ofHashMap(clazz, null, fieldName, initialCapacity);
- }
-
- /**
- * Checks adequacy of the initial capacity of a non-static field
- * of type {@code HashMap}.
- *
- * Having
- *
- */
- public static void ofHashMap(Class> clazz, Object instance,
- String fieldName, int initialCapacity)
- {
- try {
- Field field = clazz.getDeclaredField(fieldName);
- field.setAccessible(true);
- Object obj = field.get(instance);
- if (!HashMap.class.equals(obj.getClass())) {
- throw new RuntimeException(field +
- " expected to be of type HashMap");
- }
- HashMap,?> map = (HashMap,?>)obj;
-
- // Check that the map allocates only necessary amount of space
- HashMap