-ras.hotswap=<stress_level>
- enable JVMTI hotswap of
+ * the currently running test classes. Here are the possible HotSwap stress
+ * levels:
+ * 0 - HotSwap off
+ * 2 - HotSwap tested class in every JVMTI method entry event of running test
+ * (default mode)
+ * 20 - HotSwap tested class in every JVMTI method entry event of every class
+ * 3 - HotSwap tested class in every JVMTI single step event of running test
+ * 4 - HotSwap tested class in every JVMTI exception event of running test
+ * 40 - HotSwap tested class in every JVMTI exception event of every class
+ */
+public class RASagent {
+ static final int HOTSWAP_OFF = 0;
+ static final int HOTSWAP_EVERY_METHOD_ENTRY = 2;
+ static final int HOTSWAP_EVERY_METHOD_ENTRY_FOR_EVERY_CLASS = 20;
+ static final int HOTSWAP_EVERY_SINGLE_STEP = 3;
+ static final int HOTSWAP_EVERY_EXCEPTION = 4;
+ static final int HOTSWAP_EVERY_EXCEPTION_FOR_EVERY_CLASS = 40;
+
+ // path to the directory with class files of the invoked test
+ static String clfBasePath = null;
+
+ private static boolean verbose = false;
+
+ private static PrintStream out;
+
+ native static int setHotSwapMode(boolean vrb, int stress_lev,
+ String shortName);
+
+ public static void main(String argv[]) {
+ System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
+ }
+
+ public static int run(String argv[], PrintStream out) {
+ return new RASagent().runThis(argv, out);
+ }
+
+ private int runThis(String argv[], PrintStream out) {
+ int skipArgs = 1; // number of arguments which must be skipped
+ // for the invoked test
+ boolean invokeRun = false; // invoke the method "main" by default
+ int hotSwapMode = HOTSWAP_EVERY_METHOD_ENTRY; // HotSwap default stress level
+ int res;
+ String hotSwapModeName = "HOTSWAP_EVERY_METHOD_ENTRY";
+
+ RASagent.out = out;
+
+ if (argv.length != 0) {
+ // parse arguments for the RASagent and then skip them
+ while(argv[skipArgs-1].startsWith("-ras.")) {
+ if (argv[skipArgs-1].equals("-ras.verbose")) {
+ verbose = true;
+ } else if (argv[skipArgs-1].equals("-ras.help")) {
+ printHelp();
+ return Consts.TEST_FAILED;
+ } else if (argv[skipArgs-1].equals("-ras.invoke_run")) {
+ invokeRun = true;
+ } else if (argv[skipArgs-1].startsWith("-ras.hotswap=")) {
+ try {
+ hotSwapMode = Integer.parseInt(
+ argv[skipArgs-1].substring(argv[skipArgs-1].lastIndexOf("=")+1));
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ out.println("\nERROR: RASagent: specified HotSwap mode \""
+ + hotSwapMode + "\" is not an integer");
+ printHelp();
+ return Consts.TEST_FAILED;
+ }
+ switch(hotSwapMode) {
+ case HOTSWAP_EVERY_METHOD_ENTRY:
+ hotSwapModeName = "HOTSWAP_EVERY_METHOD_ENTRY";
+ break;
+ case HOTSWAP_EVERY_METHOD_ENTRY_FOR_EVERY_CLASS:
+ hotSwapModeName = "HOTSWAP_EVERY_METHOD_ENTRY_FOR_EVERY_CLASS";
+ break;
+ case HOTSWAP_EVERY_SINGLE_STEP:
+ hotSwapModeName = "HOTSWAP_EVERY_SINGLE_STEP";
+ break;
+ case HOTSWAP_EVERY_EXCEPTION:
+ hotSwapModeName = "HOTSWAP_EVERY_EXCEPTION";
+ break;
+ case HOTSWAP_EVERY_EXCEPTION_FOR_EVERY_CLASS:
+ hotSwapModeName = "HOTSWAP_EVERY_EXCEPTION_FOR_EVERY_CLASS";
+ break;
+ default:
+ out.println("\nERROR: RASagent: specified HotSwap mode \""
+ + hotSwapMode + "\" is unrecognized");
+ printHelp();
+ return Consts.TEST_FAILED;
+ }
+ }
+ skipArgs++;
+ }
+
+ String shortTestName = getTestNameAndPath(argv[skipArgs-1]);
+
+ display("\n#### RASagent: setting hotswap mode \""
+ + hotSwapModeName + "\" for class \""
+ + shortTestName + "\" ...");
+ if ((res = setHotSwapMode(verbose, hotSwapMode, shortTestName)) != 0) {
+ out.println("\nERROR: RASagent: unable to set HotSwap stress level for \""
+ + shortTestName + "\", exiting");
+ return Consts.TEST_FAILED;
+ }
+ display("\n#### RASagent: ... setting hotswap mode done");
+
+ try {
+ Class testCls = Class.forName(argv[skipArgs-1]);
+ display("\n#### RASagent: main class \""
+ + testCls.toString() + "\" loaded");
+
+ // copy arguments for the invoked test
+ String args[] = new String[argv.length-skipArgs];
+ System.arraycopy(argv, skipArgs, args, 0, args.length);
+
+ // invoke the test
+ if (invokeRun)
+ return invokeRunMethod(testCls, args);
+ else
+ return invokeMainMethod(testCls, args);
+ } catch(ClassNotFoundException e) {
+ // just pass: the invoked test is already a RAS specific one
+ out.println("\nWARNING: the test was not really run due to the following error:"
+ + "\n\tunable to get the Class object for \""
+ + argv[skipArgs-1] + "\"\n\tcaught: " + e);
+ return Consts.TEST_PASSED;
+ }
+
+ } else {
+ out.println("\nERROR: RASagent: required test name is absent in parameters list");
+ return Consts.TEST_FAILED;
+ }
+ }
+
+ /**
+ * Verify that test's class file exists with a path given as a parameter
+ * and, if so, store that path in the static field "clfBasePath".
+ */
+ private boolean pathValid(String pathToCheck, String testName) {
+ String fullPath = pathToCheck + File.separator
+ + testName.replace('.', File.separatorChar) + ".class";
+ File classFile = null;
+
+ display("\n#### RASagent: verifying class path\n\t"
+ + pathToCheck + " ...");
+ try {
+ classFile = new File(fullPath);
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ out.println("\nERROR: RASagent: verification of class file "
+ + fullPath + " failed: caught " + e);
+ System.exit(Consts.JCK_STATUS_BASE + Consts.TEST_FAILED);
+ }
+
+ if (classFile.exists()) {
+ clfBasePath = pathToCheck;
+ display("\tthe class file exists:\n\t\t"
+ + fullPath + "\n\tclass file base directory found:\n"
+ + "\t\t" + clfBasePath
+ + "\n#### RASagent: ... class path verification done\n");
+ return true;
+ }
+ else {
+ display("\tno class file at location :\n\t\t"
+ + fullPath
+ + "\n#### RASagent: ... class path verification done\n");
+ return false;
+ }
+ }
+
+ /**
+ * Get short name of an invoked test (i.e. without package name) and
+ * store path to the directory with the test's class files.
+ */
+ private String getTestNameAndPath(String testName) {
+ String shortTestName = testName;
+ String packageName = "";
+
+ // if '.' occurs, it means that current test is inside a package
+ if (testName.lastIndexOf(".") != -1) {
+ shortTestName = testName.substring(testName.lastIndexOf(".")+1);
+ packageName = testName.substring(0, testName.lastIndexOf("."));
+ }
+
+ StringTokenizer clPathes = new StringTokenizer(
+ System.getProperty("java.class.path"), File.pathSeparator);
+
+ while(clPathes.hasMoreTokens()) {
+ String clPath = clPathes.nextToken();
+
+ // trying to load a class file defining the current test from
+ // this entry of "java.class.path": the class file may locate
+ // at the test's work directory or if it's already compiled,
+ // at any directory in classpath
+ if (pathValid(clPath, testName))
+ return shortTestName;
+ }
+
+ // directory with the test's class files was not found.
+ // Actually, it means that the invoked test has own Java
+ // options such as, for example, "-verify"
+ out.println("\nWARNING: the test was not really run due to the following reason:"
+ + "\n\tthe invoked test has the own Java option: "
+ + testName);
+ System.exit(Consts.JCK_STATUS_BASE + Consts.TEST_PASSED);
+
+ return null; // fake return for too smart javac
+ }
+
+ /**
+ * Invoke the method main(String[]) of the test.
+ */
+ private int invokeMainMethod(Class testCls, String args[]) {
+ Class[] methType = { String[].class };
+ Object[] methArgs = { args };
+
+ return invokeMethod(testCls, "main", methType, methArgs);
+ }
+
+ /**
+ * Invoke the method run(String[], PrintStream) of the test.
+ */
+ private int invokeRunMethod(Class testCls, String args[]) {
+ Class[] methType = { String[].class, PrintStream.class };
+ Object[] methArgs = { args, out };
+
+ return invokeMethod(testCls, "run", methType, methArgs);
+ }
+
+ /**
+ * Low level invocation of the test.
+ */
+ private int invokeMethod(Class> testCls, String methodName,
+ Class methType[], Object methArgs[]) {
+
+ try {
+ Method testMeth = testCls.getMethod(methodName, methType);
+ display("\n#### RASagent: invoking method \""
+ + testMeth.toString() + "\" ...");
+
+ Object result = testMeth.invoke(null, methArgs);
+
+ display("\n#### RASagent: ... invocation of \""
+ + testMeth.toString() + "\" done");
+ if (result instanceof Integer) {
+ Integer retCode = (Integer) result;
+ return retCode.intValue();
+ }
+ } catch(NoSuchMethodException e) {
+ e.printStackTrace();
+ out.println("\nFAILURE: RASagent: unable to get method \""
+ + methodName + "\" in class "
+ + testCls + "\n\tcaught " + e);
+ return Consts.TEST_FAILED;
+ } catch(Exception e) {
+ e.printStackTrace();
+ out.println("\nFAILURE: RASagent: caught during invokation of the test class "
+ + testCls + " " + e);
+ return Consts.TEST_FAILED;
+ }
+
+ return -1;
+ }
+
+ /**
+ * Load class bytes for HotSwap.
+ */
+ static byte[] loadFromClassFile(String signature) {
+ String testPath = clfBasePath + File.separator + signature.substring(
+ 1, signature.length()-1).replace('/', File.separatorChar) + ".class";
+ File classFile = null;
+
+ display("\n#### RASagent: looking for class file\n\t"
+ + testPath + " ...");
+
+ try {
+ classFile = new File(testPath);
+ } catch (NullPointerException e) {
+ out.println("\nFAILURE: RASagent: path name to the redefining class file is null");
+ }
+
+ display("\n#### RASagent: loading " + classFile.length()
+ + " bytes from class file "+ testPath + " ...");
+ byte[] buf = new byte[(int) classFile.length()];
+ try {
+ InputStream in = new FileInputStream(classFile);
+ in.read(buf);
+ in.close();
+ } catch(FileNotFoundException e) {
+ e.printStackTrace();
+ out.println("\nFAILURE: RASagent: loadFromClassFile: file " +
+ classFile.getName() + " not found");
+ System.exit(Consts.JCK_STATUS_BASE + Consts.TEST_FAILED);
+ } catch (Exception e) {
+ e.printStackTrace();
+ out.println("\nFAILURE: RASagent: unable to load bytes from the file:\n");
+ out.println("\t" + testPath + ": caught " + e);
+ System.exit(Consts.JCK_STATUS_BASE + Consts.TEST_FAILED);
+ }
+
+ display("\n#### RASagent: ... " + classFile.length() + " bytes loaded");
+
+ return buf;
+ }
+
+ /**
+ * This method is used in verbose mode. It prints paramter string only
+ * in case of verbose mode.
+ */
+ private static void display(String msg) {
+ if (verbose)
+ out.println(msg);
+ }
+
+ /**
+ * This method prints out RASagent usage message.
+ */
+ private static void printHelp() {
+ out.println("\nRASagent usage: RASagent [option, ...] test" +
+ "\n\t-ras.help print this message and exit" +
+ "\n\t-ras.verbose verbose mode (off by default)" +
+ "\n\t-ras.hotswap=mode enable HotSwap of the running test classes" +
+ "\n\t\twhere mode is:" +
+ "\n\t\t\t" + HOTSWAP_EVERY_METHOD_ENTRY
+ + " - hotswap tested class in its every method entry event" +
+ "\n\t\t\t" + HOTSWAP_EVERY_METHOD_ENTRY_FOR_EVERY_CLASS
+ + " - hotswap tested class in every method entry event for every class" +
+ "\n\t\t\t" + HOTSWAP_EVERY_SINGLE_STEP
+ + " - hotswap tested class in its every single step event" +
+ "\n\t\t\t" + HOTSWAP_EVERY_EXCEPTION
+ + " - hotswap tested class in its every exception event" +
+ "\n\t\t\t" + HOTSWAP_EVERY_EXCEPTION_FOR_EVERY_CLASS
+ + " - hotswap tested class in every exception event for every class\n" +
+ "\n\t-ras.invoke_run invoke the method run() of the test" +
+ "\n\t\tinstead of main() by default");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/README b/test/hotspot/jtreg/vmTestbase/nsk/share/README
new file mode 100644
index 00000000000..9da486350bd
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/README
@@ -0,0 +1,128 @@
+Copyright (c) 2003, 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.
+
+---------------------------------------------------------------------------------
+
+This directory contains source files of NSK tests framework
+shared between all NSK tests.
+
+Files located directly in this directory provide general support
+for all tests.
+
+Files in the subdirectories provide specific support for tests of
+particular subsuites.
+
+---------------------------------------------------------------------------------
+
+Short description of files:
+
+ common exceptions:
+ Failure,java, TestBug.java, Oddity.java
+ common constants:
+ Consts.java
+ parsing command line arguments:
+ ArgumentPareser.java
+ output of errors and messages:
+ Log.java
+ process running:
+ LocalProcess.java, IORedirector.java
+ class loading/unloading:
+ DummyClassLoader.java, ZipClassLoader.java,
+ CustomClassLoader.java, ClassUnloder.java
+ objects finalization:
+ Finalizable.java, FinalizableObject.java, Finalizer.java
+ threads synchronization:
+ Wicket.java
+ text processing:
+ Grep.java, Paragrep.java
+ timeouts handling:
+ Harakiri.java, TimeoutHandler.java
+ tree structures support:
+ Denotation.java, TreeNodesDenotation.java
+ RAS mode support:
+ RASagent.java, JVMTIagent.c
+ JVMDI tests support:
+ JVMDITools.h, JVMDITools.c
+
+Short description of subdirectories:
+
+ Alien - support for accessing external tests (JCK)
+ native - support for native part of NSK tests
+ jni - support for JNI tests and accessing JNI API
+ jvmti - support for JVMTI tests and accessing JVMTI API
+ jpda - support for two-VMs JPDA tests
+ jdwp - support for JDWP tests and accessing JDWP API
+ jdi - support for JDI tests and accesing JDI API
+ jdb - support for JDB tests and accessing JDB tool
+ monitoring - support for monitoring tests and accessing Java Monitoring&Management API
+ sysdict - support for System Dictionary tests
+ gc - support for GC tests
+ regression - support for regression tests for known bugs
+ split_verifier - support for Split Verifier tests
+
+For more detailed description see README files in subdirectories.
+
+---------------------------------------------------------------------------------
+
+Naming conventions
+
+Classes:
+
+ All shared classes are groupped into packages to prevent
+ name collision.
+
+ All classes exported directly from this directory are
+ of package:
+
+ nsk.share
+
+ All classes exported from subdirectories are of particular
+ subpackage, e.g.:
+
+ nsk.share.jpda
+ nsk.share.jdwp
+ nsk.share.jdi
+ nsk.share.jdb
+ nsk.share.monitoring
+ nsk.share.sysdict
+
+Native functions and macroses:
+
+ Most native functions have special prefix to prevent linking collisions.
+ Most macroses also have special prefix and are wrote in upper register.
+
+ Here is typical naming scheme used for native functions and macroses:
+
+ share/native
+ functions: nsk_*
+ macroses: NSK_*
+
+ share/jni
+ functions: nsk_jni_*
+ macroses: NSK_JNI_*
+
+ share/jvmti
+ functions: nsk_jvmti_*
+ macroses: NSK_JVMTI_*
+
+ However, some native functions and macroses do not follow this scheme,
+ in order to preserve compatibility with old tests.
+
+---------------------------------------------------------------------------------
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/ReferringObject.java b/test/hotspot/jtreg/vmTestbase/nsk/share/ReferringObject.java
new file mode 100644
index 00000000000..1dd4bb9ffc1
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/ReferringObject.java
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2006, 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 nsk.share;
+
+import java.lang.ref.PhantomReference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
+
+/*
+ * This class create/delete reference with given type.
+ *
+ * Supported reference types are:
+ * - strong
+ * - soft
+ * - weak
+ * - phantom
+ * - jni local
+ * - jni global
+ * - jni weak
+ */
+public class ReferringObject
+{
+ static
+ {
+ System.loadLibrary("JNIreferences");
+ }
+
+ public final static int maxJNIGlobalReferences = 1000;
+ public final static int maxJNIWeakReferences = 1000;
+
+ private Object reference;
+
+ private String referenceType;
+
+ //used for storing jni global and jni weak references
+ private int referenceIndex;
+
+ public ReferringObject(Object object, String referenceType)
+ {
+ this.referenceType = referenceType;
+
+ if(referenceType.equals(ObjectInstancesManager.STRONG_REFERENCE))
+ {
+ createStrongReference(object);
+ }
+ else
+ if(referenceType.equals(ObjectInstancesManager.SOFT_REFERENCE))
+ {
+ createSoftReference(object);
+ }
+ else
+ if(referenceType.equals(ObjectInstancesManager.WEAK_REFERENCE))
+ {
+ createWeakReference(object);
+ }
+ else
+ if(referenceType.equals(ObjectInstancesManager.PHANTOM_REFERENCE))
+ {
+ createPhantomReference(object);
+ }
+ else
+ if(referenceType.equals(ObjectInstancesManager.JNI_GLOBAL_REFERENCE))
+ {
+ createJNIGlobalReference(object);
+ }
+ else
+ if(referenceType.equals(ObjectInstancesManager.JNI_LOCAL_REFERENCE))
+ {
+ createJNILocalReference(object);
+ }
+ else
+ if(referenceType.equals(ObjectInstancesManager.JNI_WEAK_REFERENCE))
+ {
+ createJNIWeakReference(object);
+ }
+ else
+ throw new IllegalArgumentException("Invalid reference type: " + referenceType);
+ }
+
+ public void delete()
+ {
+ if(referenceType == null)
+ {
+ throw new TestBug("Reference type is null");
+ }
+
+ if(referenceType.equals(ObjectInstancesManager.SOFT_REFERENCE))
+ {
+ if(reference == null)
+ {
+ throw new TestBug("Reference is null for SoftReference");
+ }
+
+ if(((SoftReference)reference).get() == null)
+ {
+ // throw new TestBug("Test execution error: SoftReference was collected");
+ }
+ }
+ else
+ if(referenceType.equals(ObjectInstancesManager.WEAK_REFERENCE))
+ {
+ if(reference == null)
+ {
+ throw new TestBug("Reference is null for WeakReference");
+ }
+
+ if(((WeakReference)reference).get() == null)
+ {
+ // throw new TestBug("Test execution error: WeakReference was collected");
+ }
+ }
+ else
+ if(referenceType.equals(ObjectInstancesManager.PHANTOM_REFERENCE))
+ {
+ if(reference == null)
+ {
+ throw new TestBug("Reference is null for PhantomReference");
+ }
+ }
+ else
+ if(referenceType.equals(ObjectInstancesManager.JNI_GLOBAL_REFERENCE))
+ {
+ deleteJNIGlobalReferenceNative(referenceIndex);
+ }
+ else
+ if(referenceType.equals(ObjectInstancesManager.JNI_LOCAL_REFERENCE))
+ {
+ deleteJNILocalReference();
+ }
+ else
+ if(referenceType.equals(ObjectInstancesManager.JNI_WEAK_REFERENCE))
+ {
+ try {
+ deleteJNIWeakReferenceNative(referenceIndex);
+ } catch (Throwable t)
+ {
+
+ }
+ }
+
+ reference = null;
+ }
+
+ private void createStrongReference(Object object)
+ {
+ reference = object;
+ }
+
+ private void createSoftReference(Object object)
+ {
+ reference = new SoftReference(object);
+ }
+
+ private void createWeakReference(Object object)
+ {
+ reference = new WeakReference(object);
+ }
+
+ private void createPhantomReference(Object object)
+ {
+ reference = new PhantomReference(object, new ReferenceQueue());
+ }
+
+ private void createJNIGlobalReference(Object object)
+ {
+ referenceIndex = createJNIGlobalReferenceNative(object, maxJNIGlobalReferences);
+
+ if(referenceIndex < 0)
+ {
+ throw new TestBug("Error on creation of JNI_Global reference, Possible number of JNI_Global references exceeded max available value!");
+ }
+ }
+
+ /*
+ * Since jni local reference valid only for duration of native method call, to create jni local reference
+ * special thread is created which enter in native method, create jni local reference and wait
+ */
+ private void createJNILocalReference(Object object)
+ {
+ this.reference = object;
+
+ jniLocalReferenceThread = new JNILocalReferenceThread();
+ jniLocalReferenceThread.start();
+
+ // wait till JNI local reference will be created
+ jniLocalReferenceThread.createWhicket.waitFor();
+
+ reference = null;
+ }
+
+ private void deleteJNILocalReference()
+ {
+ // notify JNI method that JNI local reference is not needed any more and could be released
+ jniLocalReferenceThread.deleteWhicket.unlock();
+
+ try
+ {
+ jniLocalReferenceThread.join(1000 * 60 * 2);
+
+ if(jniLocalReferenceThread.isAlive())
+ {
+ throw new TestBug("JNI_Local_Reference thread can't finish execution");
+ }
+ }
+ catch(InterruptedException e)
+ {
+ throw new TestBug("deleteJNILocalReference was interrupted");
+ }
+ }
+
+ private void createJNIWeakReference(Object object)
+ {
+ referenceIndex = createJNIWeakReferenceNative(object, maxJNIWeakReferences);
+
+ if(referenceIndex < 0)
+ {
+ throw new TestBug("Error on creation of JNI_Weak reference. Possible number of JNI_Weak references exceeded max available value!");
+ }
+ }
+
+ class JNILocalReferenceThread
+ extends Thread
+ {
+ Wicket createWhicket = new Wicket();
+ Wicket deleteWhicket = new Wicket();
+
+ public void run()
+ {
+ createJNILocalReferenceNative(reference, createWhicket, deleteWhicket);
+ }
+ }
+
+ private JNILocalReferenceThread jniLocalReferenceThread;
+
+ private native int createJNIGlobalReferenceNative(Object object, int maxJNIGlobalReferences);
+
+ private native void deleteJNIGlobalReferenceNative(int index);
+
+ private native void createJNILocalReferenceNative(Object object, Wicket createWhicket, Wicket deleteWhicket);
+
+ private native int createJNIWeakReferenceNative(Object object, int maxJNIWeakReferences);
+
+ private native void deleteJNIWeakReferenceNative(int index);
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/ReferringObjectSet.java b/test/hotspot/jtreg/vmTestbase/nsk/share/ReferringObjectSet.java
new file mode 100644
index 00000000000..a4c778b44c2
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/ReferringObjectSet.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2006, 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 nsk.share;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+/*
+ * Class create a number of referrers to given object
+ */
+public class ReferringObjectSet
+{
+ private Collection referringObjects;
+ private String referenceType;
+
+ public ReferringObjectSet(Object object, int referringCount, String referenceType)
+ {
+ this.referenceType = referenceType;
+ referringObjects = new ArrayList(referringCount);
+
+ for(int i = 0; i < referringCount; i++)
+ referringObjects.add(new ReferringObject(object, referenceType));
+ }
+
+ public void delete(int count)
+ {
+ if((count < 0) || (count > referringObjects.size()))
+ {
+ throw new TestBug("Invalid 'count' value: " + count + ", size=" + referringObjects.size());
+ }
+
+ Iterator iterator = referringObjects.iterator();
+
+ for(int i = 0; i < count; i++)
+ {
+ ReferringObject referringObject = iterator.next();
+ referringObject.delete();
+
+ iterator.remove();
+ }
+ }
+
+ public void deleteAll()
+ {
+ delete(referringObjects.size());
+ }
+
+ public String getReferenceType() {
+ return referenceType;
+ }
+
+ public int getReferrerCount()
+ {
+ return referringObjects.size();
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/StringGoldChecker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/StringGoldChecker.java
new file mode 100644
index 00000000000..50f3bbf095e
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/StringGoldChecker.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2008, 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 nsk.share;
+
+public class StringGoldChecker extends AbstractGoldChecker {
+
+ private final String goldenString;
+
+ public StringGoldChecker(String goldenString) {
+ this.goldenString = goldenString;
+ }
+
+ @Override
+ protected String getGoldenString() {
+ return goldenString;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/TestBug.java b/test/hotspot/jtreg/vmTestbase/nsk/share/TestBug.java
new file mode 100644
index 00000000000..fa97f8b85bd
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/TestBug.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2001, 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 nsk.share;
+
+/**
+ * Thrown when it becomes obvious that the test algorithm
+ * works incorrectly (for example - tries to write to debugee's
+ * stdin after it is already redirected, or something of the
+ * kind).
+ */
+public class TestBug extends Failure {
+ /** Explain particular failure. */
+ public TestBug(String message) {
+ super(message);
+ }
+
+ /** Enwrap another throwable. */
+ public TestBug(Throwable throwable) {
+ super(throwable);
+ }
+
+ public TestBug(String message, Throwable throwable) {
+ super(message, throwable);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/TestFailure.java b/test/hotspot/jtreg/vmTestbase/nsk/share/TestFailure.java
new file mode 100644
index 00000000000..001a0a53869
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/TestFailure.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share;
+
+public class TestFailure extends RuntimeException {
+ public TestFailure() {
+ super();
+ }
+
+ public TestFailure(String message) {
+ super(message);
+ }
+
+ public TestFailure(String message, Throwable e) {
+ super(message, e);
+ }
+
+ public TestFailure(Throwable e) {
+ super(e);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/TestJNIError.java b/test/hotspot/jtreg/vmTestbase/nsk/share/TestJNIError.java
new file mode 100644
index 00000000000..6867c60a423
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/TestJNIError.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2006, 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 nsk.share;
+
+public class TestJNIError
+ extends Error
+{
+ public TestJNIError(String message)
+ {
+ super(message);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/TimeoutHandler.java b/test/hotspot/jtreg/vmTestbase/nsk/share/TimeoutHandler.java
new file mode 100644
index 00000000000..7a79c672d98
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/TimeoutHandler.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2001, 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 nsk.share;
+
+import java.io.*;
+
+/**
+ * This class can be used to set timeout for test execution.
+ */
+public class TimeoutHandler {
+
+ /**
+ * Test execution timeout in minutes.
+ */
+ private int waitTime;
+
+ /**
+ * Make new TimeoutHandler
object for timeout value
+ * specified in command line arguments.
+ */
+ public TimeoutHandler(ArgumentParser argumentHandler) {
+ this.waitTime = argumentHandler.getWaitTime();
+ }
+
+ /**
+ * Perform test execution in separate thread and wait for
+ * thread finishes or timeout exceeds.
+ */
+ public void runTest(Thread testThread) {
+ long millisec = waitTime * 60 * 1000;
+ testThread.start();
+ try {
+ testThread.join(millisec);
+ } catch (InterruptedException ex) {
+ throw new Failure(ex);
+ }
+ }
+
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/TreeNodesDenotation.java b/test/hotspot/jtreg/vmTestbase/nsk/share/TreeNodesDenotation.java
new file mode 100644
index 00000000000..95d59c9dcc5
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/TreeNodesDenotation.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2002, 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 nsk.share;
+
+import java.util.*;
+
+/**
+ * This denotation provides naming and indexing for nodes
+ * of a binary, or ternary, or n -ary tree.
+ *
+ * Here, n would be the length of a symbols
+ * string used as an alphabeth for nodes naming. For a
+ * binary tree, n=2 , and an aplhabeth could be
+ * the "LR" string. This implies the following
+ * naming for tree nodes:
+ *
+ * (empty)
+ * / \
+ * L R
+ * / \ / \
+ * LL LR RL RR
+ * / \ / \ / \ / \
+ *
+ *
+ * Anyway, the tree root node is named with the empty
+ * string "" and is indexed with 2-zeroes array
+ * {0,0} .
+ *
+ *
Index for a tree node is 2-elements int[]
+ * array. The 1st element is the node's level in a tree.
+ * The 2nd element is the item's number among all nodes of
+ * that level; provided that node items are enumerated from
+ * 0 to n level -1 .
+ * Given a level, lexicographic order is assumed for the
+ * nodes of the same level.
+ *
+ *
For example: given the above sample tree, the node
+ * "L" has the index {1,0} , while the
+ * node "RL" has the index {2,2} .
+ *
+ *
In general case, ordering of characters used for nodes
+ * naming is implied by the given alphabeth. This may differ
+ * from the ``natural'' ordering. For example, if alphabeth
+ * is "ZYX...CBA" , then ordering for nodes would be
+ * opposite to ``natural''.
+ */
+public class TreeNodesDenotation extends Denotation {
+ /**
+ * Symbols to denote tree nodes.
+ *
+ * @see #TreeNodeDenotation(String)
+ */
+ private String alphabeth;
+
+ /**
+ * Standard denotation for a binary tree; alphabeth
+ * is "LR" .
+ *
+ * @see #TreeNodesDenotation(String)
+ */
+ public TreeNodesDenotation() {
+ this("LR");
+ }
+
+ /**
+ * Denotation for nodes of a tree.
+ *
+ *
Each tree node is marked with a string of symbols
+ * from the given alphabeth . A string length
+ * equals to the node's level. The root node is always
+ * denoted with the empty string.
+ *
+ *
For example, an alphabeth for a binary
+ * tree could be "LR" , or "01" , or
+ * any 2-symbols string. However, "lL" or
+ * "rR" would be illegal because of collision
+ * between upper- and lower- case letters.
+ *
+ *
In general case, it is illegal for alphabeth
+ * to contain two or several copies of the same symbol.
+ * This constructor deems lower- and upper-case variants
+ * of the same letter are the same symbol.
+ *
+ * @throws IllegalArgumentException If the alphabeth
+ * looks illegal.
+ */
+ public TreeNodesDenotation(String alphabeth) {
+ if (alphabeth.length() == 0)
+ throw new IllegalArgumentException("empty alphabeth");
+ // Check for lower- to upper- case collision:
+ this.alphabeth = alphabeth.toUpperCase();
+ int length = this.alphabeth.length();
+ Set pool = new HashSet(); // still empty
+ for (int i=0; iname is legal, and return the
+ * numeric index for the tree node denoted by the given
+ * name .
+ *
+ * @throws IllegalArgumentException If the name
+ * is illegal.
+ */
+ public int[] indexFor(String name) {
+ int level = name.length();
+ int factor = alphabeth.length();
+ long item = 0;
+ for (int i=0; i Integer.MAX_VALUE)
+ throw new IllegalArgumentException("too long name: " + name);
+ };
+ int[] index = new int [] { level, (int)item };
+ return index;
+ }
+
+ /**
+ * Check if the index[] is legal, and return
+ * a symbolic name for the tree node denoted by the
+ * given index[] .
+ *
+ * @throws IllegalArgumentException If the index[]
+ * is illegal.
+ */
+ public String nameFor(int[] index) {
+ if (index.length != 2)
+ throw new IllegalArgumentException(
+ "index dimention: " + index.length);
+ StringBuffer name = new StringBuffer(); // still empty
+ int level = index[0];
+ int item = index[1];
+ if (level < 0 || item < 0)
+ throw new IllegalArgumentException(
+ "negative index: " + level + ", " + item);
+ int factor = alphabeth.length();
+ for (int i=0; iWicket instances are intended to be used generally in the following
+ * scenarios:
+ *
+ * One thread starts one or more child threads and waits until the
+ * child threads to be started.
+ *
+ * One thread starts one or more child threads and waits until at least
+ * one of the child threads to be started.
+ *
+ * One or more child threads wait until a main thread lets them
+ * to finish.
+ *
+ * Disable the current thread for thread scheduling purposes, for up to
+ * the specified waiting time.
+ */
+
+public class Wicket {
+
+ /** Number of closed locks, can be greater or equal to zero */
+ private int count;
+
+ /** Number of waiters **/
+ private int waiters = 0;
+
+ /** Enable debug output */
+ private PrintStream debugOutput = null;
+
+ /** Wicket's string identifier */
+ private String name = "";
+
+ /**
+ * Construct a Wicket with only one closed lock.
+ */
+ public Wicket() {
+ this(1);
+ }
+
+ /**
+ * Construct a Wicket with the given number of closed locks.
+ *
+ * @param _name Wicket's identifier
+ * @param _count the initial number of closed locks
+ * @param _debugOutput whether to print debug info or not
+ * @throws IllegalArgumentException if count is less than 1
+ */
+ public Wicket(String _name, int _count, PrintStream _debugOutput) {
+ this(_count);
+ name = _name;
+ debugOutput = _debugOutput;
+ }
+
+ /**
+ * Construct a Wicket with the given number of closed locks.
+ *
+ * @param count the initial number of closed locks
+ * @throws IllegalArgumentException if count is less than 1
+ */
+ public Wicket(int count) {
+ if (count < 1)
+ throw new IllegalArgumentException(
+ "count is less than one: " + count);
+ this.count = count;
+ }
+
+ /**
+ * Wait for all locks of this Wicket to be open.
+ *
+ * If all locks are already open then returns immediately.
+ *
+ *
If at least one lock is still closed then the current thread becomes
+ * disabled for thread scheduling purposes and lies dormant until all
+ * the locks will be open by some other threads. One lock can be open
+ * by invoking the unlock method for this Wicket.
+ *
+ *
Please note, that the method would ignore Thread.interrupt() requests.
+ */
+ public synchronized void waitFor() {
+ ++waiters;
+ if (debugOutput != null) {
+ debugOutput.printf("Wicket %s: waitFor()\n", name);
+ }
+
+ while (count > 0) {
+ try {
+ wait();
+ } catch (InterruptedException e) {}
+ }
+ --waiters;
+ }
+
+ /**
+ * Wait for all locks of this Wicket to be open within the given
+ * period of time.
+ *
+ *
If all locks are already open then returns immediately with zero.
+ *
+ *
If the time is equal to zero, the method will not
+ * wait and returns a number of closed locks,
+ * if all locks are open, the return value is zero.
+ *
+ *
If at least one lock is still closed then the current thread becomes
+ * disabled for thread scheduling purposes and lies dormant until
+ * of the two things happens:
+ *
+ *
Some other threads invoke the unlock method for this Wicket
+ * to open all the closed locks; or
+ *
+ * The specified waiting time elapses.
+ *
+ * If all locks are open then the return value is 0.
+ *
+ *
If the specified waiting time elapses and some locks are still closed
+ * then the return value is equal to number of closed locks.
+ *
+ *
Please note, that the method would ignore Thread.interrupt() requests.
+ *
+ * @param timeout the maximum time to wait in milliseconds
+ * @return the number of closed locks
+ * @throws IllegalArgumentException if timeout is less than 0
+ */
+ public synchronized int waitFor(long timeout) {
+ if (debugOutput != null) {
+ debugOutput.printf("Wicket %s: waitFor(%d)\n", name, timeout);
+ }
+
+ if (timeout < 0)
+ throw new IllegalArgumentException(
+ "timeout value is negative: " + timeout);
+ ++waiters;
+ long waitTime = timeout;
+ long startTime = System.currentTimeMillis();
+ while (count > 0 && waitTime > 0) {
+ try {
+ wait(waitTime);
+ } catch (InterruptedException e) {}
+ waitTime = timeout - (System.currentTimeMillis() - startTime);
+ }
+ --waiters;
+ return (count);
+ }
+
+ /**
+ * Unlock one closed lock.
+ *
+ *
Open a lock, reducing the number of closed locks by one.
+ *
+ *
If last closed lock is opened then all of the threads waiting
+ * by invoking the waitFor method for this Wicket will be released
+ * and re-enabled for thread scheduling purposes.
+ *
+ * @throws IllegalStateException if there is no one closed lock
+ */
+ public synchronized void unlock() {
+ if (debugOutput != null) {
+ debugOutput.printf("Wicket %s: unlock()\n", name);
+ }
+
+ if (count == 0)
+ throw new IllegalStateException("locks are already open");
+
+ --count;
+ if (count == 0) {
+ notifyAll();
+ }
+ }
+
+ /**
+ * Unlock all closed locks.
+ *
+ *
Open all closed locks, setting the number of closed locks to zero.
+ *
+ *
If any threads are waiting by invoking the waitFor method for
+ * this Wicket then they will be released and re-enabled for thread
+ * scheduling purposes.
+ */
+ public synchronized void unlockAll() {
+ if (debugOutput != null) {
+ debugOutput.printf("Wicket %s: unlockAll()\n", name);
+ }
+
+ count = 0;
+ notifyAll();
+ }
+
+ /**
+ * Return current number of waiters - threads that are currently
+ * waiting using one of waitFor methods.
+ *
+ * @return number of waiters
+ */
+ public synchronized int getWaiters() {
+ if (debugOutput != null) {
+ debugOutput.printf("Wicket %s: getWaiters()\n", name);
+ }
+ return waiters;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AODRunnerArgParser.java b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AODRunnerArgParser.java
new file mode 100644
index 00000000000..e6a961dc08d
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AODRunnerArgParser.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2008, 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 nsk.share.aod;
+
+import nsk.share.*;
+import java.util.*;
+
+public class AODRunnerArgParser extends ArgumentParser {
+
+ public static final String jarAgentParam = "ja";
+
+ public static final String nativeAgentParam = "na";
+
+ public static final String targetAppParam = "target";
+
+ public static final String javaOptsParam = "javaOpts";
+
+ public static final String testedJdkParam = "jdk";
+
+ private static List supportedOptions;
+
+ static {
+ supportedOptions = new ArrayList();
+ supportedOptions.add(jarAgentParam);
+ supportedOptions.add(nativeAgentParam);
+ supportedOptions.add(targetAppParam);
+ supportedOptions.add(javaOptsParam);
+ supportedOptions.add(testedJdkParam);
+ }
+
+ private List agents;
+
+ public AODRunnerArgParser(String[] args) {
+ super(args);
+ }
+
+ protected boolean checkOption(String option, String value) {
+ if (super.checkOption(option, value))
+ return true;
+
+ if (!supportedOptions.contains(option))
+ return false;
+
+ if (option.equals(jarAgentParam)) {
+ addAgentInfo(true, value);
+ }
+
+ if (option.equals(nativeAgentParam)) {
+ addAgentInfo(false, value);
+ }
+
+ return true;
+ }
+
+ protected void checkOptions() {
+ if (agents == null) {
+ agents = new ArrayList();
+ }
+ }
+
+ private void addAgentInfo(boolean jarAgent, String unsplittedAgentsString) {
+ if (agents == null) {
+ agents = new ArrayList();
+ }
+
+ String agentStrings[];
+
+ if (unsplittedAgentsString.contains(","))
+ agentStrings = unsplittedAgentsString.split(",");
+ else
+ agentStrings = new String[]{unsplittedAgentsString};
+
+ for (String agentString : agentStrings) {
+ int index = agentString.indexOf('=');
+
+ if (index > 0) {
+ String pathToAgent = agentString.substring(0, index);
+ String options = agentString.substring(index + 1);
+ agents.add(new AgentInformation(jarAgent, pathToAgent, options));
+ } else {
+ agents.add(new AgentInformation(jarAgent, agentString, null));
+ }
+ }
+ }
+
+ public String getTargetApp() {
+ if (!options.containsKey(targetAppParam))
+ throw new TestBug("Target application isn't specified");
+
+ return options.getProperty(targetAppParam);
+ }
+
+ public String getTestedJDK() {
+ if (!options.containsKey(testedJdkParam))
+ throw new TestBug("Tested JDK isn't specified");
+
+ return options.getProperty(testedJdkParam);
+ }
+
+ public String getJavaOpts() {
+ return options.getProperty(javaOptsParam, "");
+ }
+
+ public List getAgents() {
+ return agents;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AODTargetArgParser.java b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AODTargetArgParser.java
new file mode 100644
index 00000000000..a8cdd2c6a19
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AODTargetArgParser.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2008, 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 nsk.share.aod;
+
+import nsk.share.*;
+import java.util.*;
+
+public class AODTargetArgParser extends ArgumentParser {
+
+ public static final String agentsNumberParam = "agentsNumber";
+
+ public static final String socketPortParam = "port";
+
+ private int expectedAgentsNumber;
+
+ private int port;
+
+ private static List supportedOptions;
+
+ static {
+ supportedOptions = new ArrayList();
+ supportedOptions.add(agentsNumberParam);
+ supportedOptions.add(socketPortParam);
+ }
+
+ public AODTargetArgParser(String[] args) {
+ super(args);
+ }
+
+ protected boolean checkOption(String option, String value) {
+ if (super.checkOption(option, value))
+ return true;
+
+ if (!supportedOptions.contains(option))
+ return false;
+
+ if (option.equals(agentsNumberParam)) {
+ expectedAgentsNumber = Integer.parseInt(value);
+ if (expectedAgentsNumber < 0)
+ throw new TestBug("Invalid value of '" + option + "'");
+ } else if (option.equals(socketPortParam)) {
+ port = Integer.parseInt(value);
+ if (port <= 0 || port > 65535)
+ throw new TestBug("Invalid value of '" + option + "':" + port +" (it is expected to be in the range [1..65535]");
+ }
+
+ return true;
+ }
+
+ public int getExpectedAgentsNumber() {
+ if (!options.containsKey(agentsNumberParam))
+ throw new TestBug("Number of expected agents isn't specified");
+
+ return expectedAgentsNumber;
+ }
+
+ public int getPort() {
+ if (!options.containsKey(socketPortParam))
+ return -1;
+
+ return port;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AODTestRunner.java b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AODTestRunner.java
new file mode 100644
index 00000000000..2fa58139da4
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AODTestRunner.java
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2008, 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 nsk.share.aod;
+
+import java.io.*;
+import nsk.share.*;
+import nsk.share.jpda.SocketIOPipe;
+
+/*
+ Class AODTestRunner is part of the framework used in the AttachOnDemand tests
+ (tests against Attach API, API from package com.sun.tools.attach).
+
+ AODTestRunner is used as main class in AttachOnDemand tests, it performs following
+ actions:
+ - starts target application
+
+ - finds VM id for target VM (this id is needed for dynamic attach)
+
+ - by default AODTestRunner tries to attach specified via command line agents to target VM
+ (subclasses can override this default behavior)
+
+ - waits for target application completion
+
+Target application class, agents that should be attached, JDK used to run target application and
+VM options passed to target VM should be specified via command line.
+ */
+public class AODTestRunner {
+
+ public static final String targetAppIdProperty = "vmsqe.aod.targetAppId";
+ public static final String appIdProperty = "vmsqe.aod.AppId";
+
+ public static final long TARGET_APP_CONNECT_TIMEOUT = 5 * 60 * 1000; // 5 min
+
+ public static final long TARGET_APP_WORK_TIMEOUT = 30 * 60 * 1000; // 30 min (standard VM testbase test timeout)
+
+ protected Log log;
+
+ protected SocketIOPipe pipe;
+
+ protected ProcessExecutor targetAppExecutor;
+
+ // target application ready for attach
+ public static final String SIGNAL_READY_FOR_ATTACH = "ready";
+
+ // target application may finish execution
+ public static final String SIGNAL_FINISH = "finish";
+
+ protected AODRunnerArgParser argParser;
+
+ protected AODTestRunner(String[] args) {
+ log = new Log(System.out, true);
+
+ argParser = createArgParser(args);
+ }
+
+ /*
+ * This method is introduced to let subclasses to create its own parsers
+ */
+ protected AODRunnerArgParser createArgParser(String[] args) {
+ return new AODRunnerArgParser(args);
+ }
+
+ protected void doTestActions(String targetVMId) throws Throwable {
+ AgentsAttacher attacher = new AgentsAttacher(targetVMId, argParser.getAgents(), log);
+ attacher.attachAgents();
+ }
+
+ protected String getCurrentVMId() {
+ String currentVMId = "" + ProcessHandle.current().pid();
+ log.display("Current VM id was identified: " + currentVMId);
+
+ return currentVMId;
+ }
+
+ protected void runTest() {
+
+ try {
+ String targetAppId = System.getProperty(targetAppIdProperty);
+ if(targetAppId == null || targetAppId.isEmpty()) {
+ // use PID as default appID
+ targetAppId = "" + ProcessHandle.current().pid();
+ }
+ /*
+ * Create target application id required by the Utils.findVMIdUsingJPS
+ */
+ String targetAppCmd =
+ // path to java
+ argParser.getTestedJDK() + File.separator + "bin" + File.separator + "java " +
+ // VM property to identify VM running target application
+ "-D" + appIdProperty + "=" + targetAppId + " " +
+ // VM opts
+ argParser.getJavaOpts() + " -XX:+EnableDynamicAgentLoading " +
+ // target application class
+ argParser.getTargetApp() + " " +
+ // additional target application parameter - number of
+ // agents that will be attached
+ "-" + AODTargetArgParser.agentsNumberParam + " " + argParser.getAgents().size();
+
+ pipe = SocketIOPipe.createServerIOPipe(log, 0, TARGET_APP_CONNECT_TIMEOUT);
+ targetAppCmd += " -" + AODTargetArgParser.socketPortParam + " " + pipe.getPort();
+
+ log.display("Starting target application: " + targetAppCmd);
+ targetAppExecutor = new ProcessExecutor(targetAppCmd, TARGET_APP_WORK_TIMEOUT, "TargetApp");
+ targetAppExecutor.startProcess();
+
+ /*
+ * Don't try to attach agents until target application isn't initialized
+ */
+ String signal = pipe.readln();
+ log.display("Signal received: '" + signal + "'");
+ if ((signal == null) || !signal.equals(SIGNAL_READY_FOR_ATTACH))
+ throw new TestBug("Unexpected TargetApplication signal: '" + signal + "'");
+
+ String targetVMId = Long.toString(targetAppExecutor.pid());
+ log.display("Target VM id was identified: " + targetVMId);
+
+ doTestActions(targetVMId);
+
+ /*
+ * When test actions finished let target application finish execution
+ */
+ log.display("Sending signal: '" + SIGNAL_FINISH + "'");
+ pipe.println(SIGNAL_FINISH);
+
+ targetAppExecutor.waitForProcess();
+
+ File file = new File(targetAppId);
+ if (file.exists()) {
+ file.deleteOnExit();
+ }
+
+ if (targetAppExecutor.getExitCode() != 0) {
+ throw new Failure("Target application finished with non-zero code " + targetAppExecutor.getExitCode());
+ }
+
+ postTargetExitHook();
+
+ } catch (Failure f) {
+ throw f;
+ } catch (Throwable t) {
+ throw new Failure("Unexpected exception during test execution: " + t, t);
+ } finally {
+ if (pipe != null) {
+ pipe.close();
+ }
+ if (targetAppExecutor != null) {
+ targetAppExecutor.destroyProcess();
+ }
+ }
+ }
+
+ /*
+ * Allow users of this class to specify actions to be taken after the target exits
+ */
+ protected void postTargetExitHook() {
+ // do nothing by default
+ }
+
+ public static String createApplicationId() {
+ return new Long(System.currentTimeMillis()).toString();
+ }
+
+ public static void main(String[] args) {
+ new AODTestRunner(args).runTest();
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AbstractJarAgent.java b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AbstractJarAgent.java
new file mode 100644
index 00000000000..3fa3141a8cd
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AbstractJarAgent.java
@@ -0,0 +1,257 @@
+/*
+ * Copyright (c) 2008, 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 nsk.share.aod;
+
+import java.lang.instrument.*;
+import java.io.*;
+import nsk.share.*;
+
+/*
+
+AbstractJarAgent is base class for java agents used in AttachOnDemand tests
+(tests against Attach API, API from package com.sun.tools.attach).
+
+In all AttachOnDemand tests the same algorithm is used:
+ - java application where agent is loaded to (target application) based on
+ class nsk.share.aod.TargetApplicationWaitingAgents starts and waits when
+ test agents will be loaded
+
+ - special application (nsk.share.jvmti.aod.AgentsAttacher) loads test agents
+ in the target application using Attach API
+
+ - when agent is loaded it notifies target application about that and executes
+ test-specific actions. When agent execution is completed it also notifies
+ target application about that
+
+ - when all test agents finish execution target application checks its status
+ (passed or failed) and also finishes
+
+Each java agent should have method 'agentmain' where only agent initialization should be done,
+main agent's actions should be executed in special thread started from 'agentmain'.
+Class AbstractJarAgent incapsulates actions common for all java agents: agent initialization,
+starting thread executing agent's actions and communication with target application.
+
+In most cases test agents should override only method 'agentActions' and its 'agentmain'
+should contain only call of the method 'AbstractJarAgent.runJarAgent'.
+
+Typical agent class looks like this:
+
+public class agentExample extends AbstractJarAgent {
+
+ protected void init(String[] args) {
+ // parse agent's options and do test-specific initialization
+ }
+
+ protected void agentActions() {
+ // do test specific actions
+ }
+
+ public static void agentmain(final String options, Instrumentation inst) {
+ new agentExample().runJarAgent(options, inst);
+ }
+}
+ */
+abstract public class AbstractJarAgent {
+
+ private boolean finishedSuccessfully = true;
+
+ private Log log;
+
+ protected void display(String message) {
+ log.display(outputPrefix + message);
+ }
+
+ protected void complain(String message) {
+ log.complain(outputPrefix + message);
+ }
+
+ protected void logThrowable(Throwable t) {
+ t.printStackTrace(log.getOutStream());
+ }
+
+ /*
+ * Instrumentation object passed to the 'agentmain' method
+ */
+ protected Instrumentation inst;
+
+ private String name;
+
+ private String outputPrefix;
+
+ private String pathToNewByteCode;
+
+ protected String pathToNewByteCode() {
+ return pathToNewByteCode;
+ }
+
+ /*
+ * Subclasses should report about test failures using this method
+ */
+ protected void setStatusFailed(String errorMessage) {
+ finishedSuccessfully = false;
+ complain("ERROR: " + errorMessage);
+ }
+
+ /*
+ * Initialization method, called from agentmain before method agentActions is called
+ * (it introduced for overriding in subclasses)
+ */
+ protected void init(String[] args) {
+ }
+
+ protected static class AgentOption {
+ public String name;
+ public String value;
+ public AgentOption(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+ }
+
+ protected AgentOption parseAgentArgument(String arg) {
+ int index = arg.indexOf('=');
+ if (index <= 0) {
+ throw new TestBug("Invalid agent parameters format");
+ }
+ return new AgentOption(arg.substring(0, index), arg.substring(index + 1));
+ }
+
+ static protected final String agentNameOption = "-agentName";
+
+ static protected final String pathToNewByteCodeOption = "-pathToNewByteCode";
+
+ /*
+ * Parse agent's options, initialize common parameters
+ */
+ private void defaultInit(String[] args) {
+ for (int i = 0; i < args.length; i++) {
+ AgentOption option = parseAgentArgument(args[i]);
+ if (option.name.equals(agentNameOption)) {
+ name = option.value;
+ outputPrefix = name + ": ";
+ } else if (option.name.equals(pathToNewByteCodeOption)) {
+ pathToNewByteCode = option.value;
+ }
+ }
+
+ if (name == null)
+ throw new TestBug("Agent name wasn't specified");
+
+ log = new Log(System.out, true);
+ }
+
+ /*
+ * Special thread which is started from agentmain method and executing main
+ * agent's actions. When agent completes execution AgentThread notifies
+ * target application about that.
+ */
+ class AgentThread extends Thread {
+
+ AgentThread() {
+ super("Jar agent thread (agent: " + name + ")");
+ }
+
+ public void run() {
+ try {
+ agentActions();
+ } catch (Throwable t) {
+ setStatusFailed("Unexpected exception in the JarAgent: " + t);
+ logThrowable(t);
+ } finally {
+ TargetApplicationWaitingAgents.agentFinished(name, finishedSuccessfully);
+ }
+ }
+ }
+
+ /*
+ * This methods parses agent's options, initializes agent, notifies target application
+ * that agent is started and starts thread executing main agent's actions.
+ * Agents used in AttachOnDemand tests should call this method from its agentmain methods.
+ */
+ public final void runJarAgent(String options, Instrumentation inst) {
+ if (options == null)
+ throw new TestBug("Agent options weren't specified");
+
+ this.inst = inst;
+
+ String[] args = options.split(" ");
+
+ // initialize common parameters
+ defaultInit(args);
+
+ // test-specific initialization
+ init(args);
+
+ // notify target application that agent was loaded and initialized
+ TargetApplicationWaitingAgents.agentLoaded(name);
+
+ // start special thread executing test-specific actions
+ new AgentThread().start();
+ }
+
+ /*
+ * Actions specific for test should be realized in this method.
+ * This method is called from special thread started from agentmain method
+ * after agent initialization
+ */
+ abstract protected void agentActions() throws Throwable;
+
+
+ /*
+ * Create ClassDefinition object for given class, path to the new class file
+ * is specified in the parameter 'pathToByteCode'
+ */
+ protected static ClassDefinition createClassDefinition(Class> klass,
+ String pathToByteCode) throws IOException {
+ File classFile = new File(pathToByteCode + File.separator +
+ klass.getName().replace(".", File.separator) +
+ ".class");
+
+ if (classFile.length() > Integer.MAX_VALUE)
+ throw new Failure("Class file '" + classFile.getName() + " 'too large");
+
+ byte data[] = new byte[(int)classFile.length()];
+
+ DataInputStream in = null;
+ try {
+ in = new DataInputStream(new FileInputStream(classFile));
+ in.readFully(data);
+ } finally {
+ if (in != null)
+ in.close();
+ }
+
+ return new ClassDefinition(klass, data);
+ }
+
+ /*
+ * Redefine given class using path to byte code specified with options -pathToNewByteCode
+ */
+ protected void redefineClass(Class> klass) throws Throwable {
+ if (pathToNewByteCode() == null)
+ throw new TestBug("Path to new class files wasn't specified");
+
+ ClassDefinition newClassDef = createClassDefinition(klass, pathToNewByteCode());
+ inst.redefineClasses(newClassDef);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AgentInformation.java b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AgentInformation.java
new file mode 100644
index 00000000000..312aad7470e
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AgentInformation.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2008, 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 nsk.share.aod;
+
+/*
+ * Class contains information about dynamically attached agent
+ */
+public class AgentInformation {
+
+ // counters used for unique agent names generation
+
+ private static int jarAgentsCounter;
+
+ private static int nativeAgentsCounter;
+
+ public boolean jarAgent;
+
+ public String pathToAgent;
+
+ public String agentOptions;
+
+ public AgentInformation(boolean jarAgent, String pathToAgent, String options, boolean addAgentNameOption) {
+ this.jarAgent = jarAgent;
+ this.pathToAgent = pathToAgent;
+ this.agentOptions = options;
+
+ // add to agent options additional parameter - agent name (it used by nsk.share.aod framework)
+
+ String name;
+
+ if (jarAgent)
+ name = "JarAgent-" + jarAgentsCounter++;
+ else
+ name = "NativeAgent-" + nativeAgentsCounter++;
+
+ if (addAgentNameOption) {
+ if (this.agentOptions == null) {
+ this.agentOptions = "-agentName=" + name;
+ } else {
+ this.agentOptions += " -agentName=" + name;
+ }
+ }
+ }
+
+ public AgentInformation(boolean jarAgent, String pathToAgent, String options) {
+ this(jarAgent, pathToAgent, options, true);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AgentsAttacher.java b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AgentsAttacher.java
new file mode 100644
index 00000000000..c502ca33c8d
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AgentsAttacher.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2008, 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 nsk.share.aod;
+
+import nsk.share.*;
+import java.io.IOException;
+import java.util.*;
+import com.sun.tools.attach.*;
+
+/*
+ * This class loads java and native agents in the running VM using Attach API
+ * (API from package com.sun.tools.attach).
+ */
+public class AgentsAttacher {
+
+ protected String targetVMId;
+
+ protected List agents;
+
+ protected Log log;
+
+ public AgentsAttacher(String targetVMId, List agents, Log log) {
+ this.targetVMId = targetVMId;
+ this.agents = agents;
+ this.log = log;
+ }
+
+ public void attachAgents() {
+ VirtualMachine vm = null;
+
+ try {
+ log.display("Trying to get VirtualMachine object");
+ vm = VirtualMachine.attach(targetVMId);
+ } catch (AttachNotSupportedException e) {
+ log.complain("Unexpected AttachNotSupportedException during VirtualMachine.attach: " + e);
+ e.printStackTrace(log.getOutStream());
+ } catch (IOException e) {
+ log.complain("Unexpected IOException during VirtualMachine.attach: " + e);
+ e.printStackTrace(log.getOutStream());
+ }
+
+ if (vm == null) {
+ failed("Unable to create VirtualMachine object");
+ }
+
+ log.display("VirtualMachine was created: " + vm);
+
+ try {
+ for (AgentInformation agentInfo : agents) {
+ tryToLoadAgent(vm, agentInfo.pathToAgent, agentInfo.agentOptions, agentInfo.jarAgent);
+ }
+ } finally {
+ try {
+ log.display("Detaching from the VM '" + vm + "'");
+ vm.detach();
+ } catch (IOException e) {
+ failed("Unexpected IOException during detaching: " + e, e);
+ }
+ }
+ }
+
+ protected void tryToLoadAgent(VirtualMachine vm, String agent, String agentOptions, boolean jarAgent) {
+ boolean agentLoaded = false;
+
+ Throwable failureCause = null;
+
+ try {
+ if (jarAgent) {
+ log.display("Trying to load jar agent: '" + agent + "' (agent options: '" + agentOptions + "')");
+ vm.loadAgent(agent, agentOptions);
+ } else {
+ log.display("Trying to load native agent: '" + agent + "' (agent options: '" + agentOptions + "')");
+ vm.loadAgentLibrary(agent, agentOptions);
+ }
+ log.display("Agent was loaded");
+ agentLoaded = true;
+ } catch (AgentLoadException e) {
+ failureCause = e;
+ log.complain("Unexpected AgentLoadException during agent loading: " + e);
+ if (jarAgent) {
+ log.complain("(probably the agent does not exist, or cannot be started in the manner specified in "
+ + "the java.lang.instrument specification)");
+ } else {
+ log.complain("(probably agent library does not exist, or cannot be loaded for another reason)");
+ }
+ e.printStackTrace(log.getOutStream());
+ } catch (AgentInitializationException e) {
+ failureCause = e;
+ log.complain("Unexpected AgentInitializationException during agent loading: " + e);
+ if (jarAgent) {
+ log.complain("(agentmain have thrown an exception)");
+ } else {
+ log.complain("Agent_OnAttach function returned an error: " + e.returnValue());
+ }
+ e.printStackTrace(log.getOutStream());
+ } catch (IOException e) {
+ failureCause = e;
+ log.complain("Unexpected IOException during agent loading: " + e);
+ e.printStackTrace(log.getOutStream());
+ }
+
+ if (!agentLoaded) {
+ if (failureCause != null)
+ failed("Couldn't attach agent to the target application", failureCause);
+ else
+ failed("Couldn't attach agent to the target application");
+ }
+ }
+
+ private void failed(String errorMessage) {
+ throw new Failure(errorMessage);
+ }
+
+ private void failed(String errorMessage, Throwable t) {
+ throw new Failure(errorMessage, t);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/DummyTargetApplication.java b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/DummyTargetApplication.java
new file mode 100644
index 00000000000..d628991a4b2
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/DummyTargetApplication.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2008, 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 nsk.share.aod;
+
+import nsk.share.*;
+import nsk.share.jpda.SocketIOPipe;
+
+/*
+Class TargetApplication is part of the framework used in the AttachOnDemand tests
+(tests against Attach API, API from package com.sun.tools.attach).
+
+This class is used in tests where main test application uses Attach API, but doesn't load agents to the another VM.
+In these test there are 2 java applications: main application using Attach API and another
+'dummy' application which should be alive while main application is working.
+
+To synchronize main and dummy application SocketIOPipe is used: when DummyTargetApplication starts
+it sends signal that it is ready for test and waits for signal permitting finish execution
+(socket number used for connection establishing should be passed via command line).
+ */
+public class DummyTargetApplication {
+
+ protected Log log = new Log(System.out, true);
+
+ protected AODTargetArgParser argParser;
+
+ protected SocketIOPipe pipe;
+
+ public DummyTargetApplication(String[] args) {
+ argParser = new AODTargetArgParser(args);
+ }
+
+ protected void targetApplicationActions() {
+ // do nothing by default
+ }
+
+ public void runTargetApplication() {
+ pipe = SocketIOPipe.createClientIOPipe(log, "localhost", argParser.getPort(), 0);
+ log.display("Sending signal '" + AODTestRunner.SIGNAL_READY_FOR_ATTACH + "'");
+ pipe.println(AODTestRunner.SIGNAL_READY_FOR_ATTACH);
+
+ targetApplicationActions();
+
+ String signal = pipe.readln();
+ log.display("Signal received: '" + signal + "'");
+
+ if ((signal == null) || !signal.equals(AODTestRunner.SIGNAL_FINISH))
+ throw new TestBug("Unexpected signal: '" + signal + "'");
+ }
+
+ public static void main(String[] args) {
+ new DummyTargetApplication(args).runTargetApplication();
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/ProcessExecutor.java b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/ProcessExecutor.java
new file mode 100644
index 00000000000..3d8a87f3f97
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/ProcessExecutor.java
@@ -0,0 +1,251 @@
+/*
+ * Copyright (c) 2008, 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 nsk.share.aod;
+
+import java.io.*;
+import java.util.*;
+import nsk.share.*;
+
+public class ProcessExecutor {
+
+ private String[] cmdLine;
+
+ private long timeout;
+
+ private boolean printProcessOutput;
+
+ private String processOutputPrefix;
+
+ private InputStreamReaderThread outReader;
+
+ private InputStreamReaderThread errReader;
+
+ private Process startedProcess;
+
+ private ProcessWaiterThread processWaiter;
+
+ private long expectedFinishTime;
+
+ private volatile boolean executionCompleted;
+
+ private int exitCode;
+
+ private class InputStreamReaderThread extends Thread {
+ private BufferedReader in;
+
+ private String outputPrefix;
+
+ private List output = new ArrayList();
+
+ private volatile boolean streamWasAbruptlyClosed;
+
+ private Throwable unexpectedException;
+
+ public InputStreamReaderThread(InputStream in, String prefix) {
+ this.in = new BufferedReader(new InputStreamReader(in));
+ this.outputPrefix = prefix;
+ setDaemon(true);
+ }
+
+ public void streamWasAbruptlyClosed(boolean newValue) {
+ streamWasAbruptlyClosed = newValue;
+ }
+
+ public void run() {
+ try {
+ while (true) {
+ String line = in.readLine();
+ if (line == null)
+ return;
+
+ output.add(line);
+
+ if (printProcessOutput)
+ System.out.println(outputPrefix + line);
+ }
+ } catch (IOException e) {
+ if (!streamWasAbruptlyClosed) {
+ unexpectedException = e;
+ e.printStackTrace( );
+ }
+ } catch (Throwable t) {
+ unexpectedException = t;
+ t.printStackTrace( );
+ }
+ }
+
+ void checkStatus() {
+ if (unexpectedException != null)
+ throw new Failure("Exception was thrown during InputStreamReaderThread work: " + unexpectedException,
+ unexpectedException);
+ }
+ }
+
+ private class ProcessWaiterThread extends Thread {
+
+ private Throwable unexpectedException;
+
+ private Process process;
+
+ private InputStreamReaderThread outReader;
+
+ private InputStreamReaderThread errReader;
+
+ ProcessWaiterThread(Process process, InputStreamReaderThread outReader, InputStreamReaderThread errReader) {
+ this.process = process;
+ this.outReader = outReader;
+ this.errReader = errReader;
+
+ setDaemon(true);
+ }
+
+ public void run() {
+ try {
+ exitCode = process.waitFor();
+ outReader.join();
+ errReader.join();
+
+ synchronized (ProcessWaiterThread.this) {
+ executionCompleted = true;
+ ProcessWaiterThread.this.notify();
+ }
+ } catch (InterruptedException e) {
+ /*
+ * ProcessWaiterThread is interrupted if started process
+ * didn't finish in expected time
+ */
+ } catch (Throwable t) {
+ unexpectedException = t;
+ t.printStackTrace();
+ }
+ }
+
+ void checkStatus() {
+ if (unexpectedException != null)
+ throw new Failure("Exception was thrown during ProcessWaiterThread work: "
+ + unexpectedException, unexpectedException);
+ }
+ }
+
+ public ProcessExecutor(String cmdLine, long timeout) {
+ this.cmdLine = new String[]{cmdLine};
+ this.timeout = timeout;
+ }
+
+ public ProcessExecutor(String cmdLine, long timeout, String outputPrefix) {
+ this(cmdLine, timeout);
+ this.printProcessOutput = true;
+ this.processOutputPrefix = outputPrefix;
+ }
+
+ public void startProcess() throws IOException {
+ if (cmdLine.length == 1)
+ startedProcess = Runtime.getRuntime().exec(cmdLine[0]);
+ else
+ startedProcess = Runtime.getRuntime().exec(cmdLine);
+
+ expectedFinishTime = System.currentTimeMillis() + timeout;
+
+ outReader = new InputStreamReaderThread(startedProcess.getInputStream(),
+ processOutputPrefix == null ? "" : processOutputPrefix + " (stdout): ");
+ errReader = new InputStreamReaderThread(startedProcess.getErrorStream(),
+ processOutputPrefix == null ? "" : processOutputPrefix + " (stderr): ");
+
+ outReader.start();
+ errReader.start();
+
+ processWaiter = new ProcessWaiterThread(startedProcess, outReader, errReader);
+ processWaiter.start();
+ }
+
+
+ public void waitForProcess() throws InterruptedException {
+ synchronized (processWaiter) {
+ while ((System.currentTimeMillis() < expectedFinishTime) && !executionCompleted) {
+ processWaiter.wait(expectedFinishTime - System.currentTimeMillis());
+ }
+ }
+
+ if (!executionCompleted) {
+ destroyProcessAndWaitThreads();
+
+ executionCompleted = true;
+
+ throw new Failure("Execution timed out (timeout: " + timeout + "ms)");
+ }
+ }
+
+ private void destroyProcessAndWaitThreads() {
+ outReader.streamWasAbruptlyClosed(true);
+ errReader.streamWasAbruptlyClosed(true);
+
+ processWaiter.interrupt();
+ startedProcess.destroy();
+
+ try {
+ outReader.join();
+ errReader.join();
+ processWaiter.join();
+
+ outReader.checkStatus();
+ errReader.checkStatus();
+ processWaiter.checkStatus();
+ } catch (InterruptedException e) {
+ throw new Failure("Unexpected InterruptedException", e);
+ }
+ }
+
+ private void checkProcessState() {
+ if (!executionCompleted)
+ throw new IllegalStateException("Process didn't finish execution");
+ }
+
+ public void destroyProcess() {
+ if (executionCompleted)
+ return;
+
+ destroyProcessAndWaitThreads();
+ }
+
+ public long pid() {
+ return startedProcess.pid();
+ }
+
+ public int getExitCode() {
+ checkProcessState();
+
+ return exitCode;
+ }
+
+ public List getProcessOut() {
+ checkProcessState();
+
+ return outReader.output;
+ }
+
+ public List getProcessErr() {
+ checkProcessState();
+
+ return errReader.output;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/TargetApplicationWaitingAgents.java b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/TargetApplicationWaitingAgents.java
new file mode 100644
index 00000000000..67f4896ea3b
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/TargetApplicationWaitingAgents.java
@@ -0,0 +1,400 @@
+/*
+ * Copyright (c) 2008, 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 nsk.share.aod;
+
+import nsk.share.*;
+import nsk.share.jpda.SocketIOPipe;
+
+import java.util.*;
+
+/*
+Class TargetApplicationWaitingAgents is part of the framework used in the AttachOnDemand tests
+(tests against Attach API, API from package com.sun.tools.attach).
+
+Attach API allows to load so called 'agents' in the running VM. In terms of this framework
+application running in the VM where agent is loaded to is called 'target application'.
+
+TargetApplicationWaitingAgents is base class for target applications used in the AttachOnDemand tests
+(also TargetApplicationWaitingAgents can be used without modifications in tests where target
+application shouldn't execute some test-specific actions).
+
+AttachOnDemand tests requires synchronization between test agents and target application:
+ - before target application can start to execute test-specific actions it
+ should wait when all tests agents will be loaded
+
+ - target application shouldn't finish until all agents finish their work
+
+TargetApplicationWaitingAgents incapsulates actions common for all target applications. TargetApplicationWaitingAgents
+provides 2 methods: 'agentLoaded' and 'agentFinished', test agents use these methods to notify
+target application about its status. When target application based on the TargetApplicationWaitingAgents
+starts it first waits when all test agents will be loaded (number of expected test agents is
+passed via parameter -agentsNumber). After this target application executes test-specific actions,
+waits when all test agents will finish, checks agent's status (passed of failed) and
+finishes.
+
+In most cases test target applications should override only method 'targetApplicationActions' and
+its 'main' method should contain only call of the method 'TargetApplicationWaitingAgents.runTargetApplication'.
+
+Typical target application class looks like this:
+
+public class targetExample extends TargetApplicationWaitingAgents {
+
+ protected void targetApplicationActions() {
+ // do test-specific actions
+ }
+
+ public static void main(String[] args) {
+ new targetExample().runTargetApplication(args);
+ }
+}
+*/
+public class TargetApplicationWaitingAgents {
+
+ private volatile static boolean testFailed = false;
+
+ private static long AGENTS_CONNECTION_TIMEOUT = 5 * 60 * 1000; // 5 min
+
+ private static long AGENTS_FINISHING_TIMEOUT = 5 * 60 * 1000; // 5 min
+
+ private static boolean allAgentsAttached;
+
+ private static List attachedAgents = new ArrayList();
+
+ private static boolean allAgentsFinished;
+
+ private static List finishedAgents = new ArrayList();
+
+ private static boolean targetApplicationInitialized;
+
+ static protected AODTargetArgParser argParser;
+
+ protected static Log log;
+
+ static private Object monitor = new Object();
+
+ /*
+ * Methods
+ * - agentLoaded(String agentName) and
+ * - agentFinished(String agentName, boolean finishedSuccessfully)
+ * are called from test agents to notify target application about its status
+ */
+
+ public static void agentLoaded(String agentName) {
+ synchronized (monitor) {
+ if (!targetApplicationInitialized)
+ waitForTargetApplicationInitialization();
+
+ // check test logic
+ if (attachedAgents.contains(agentName)) {
+ setStatusFailed("Agent '" + agentName + "' already attached");
+
+ // let TargetApplication complete execution in case of error
+ allAgentsAttached = true;
+ monitor.notifyAll();
+
+ throw new TestBug("Agent '" + agentName + "' calls method 'agentLoaded' more than 1 time");
+ } else {
+ attachedAgents.add(agentName);
+
+ log.display("Agent '" + agentName + "' was loaded");
+
+ allAgentsAttached = (attachedAgents.size() == argParser.getExpectedAgentsNumber());
+
+ if (allAgentsAttached)
+ monitor.notifyAll();
+
+ // check test logic
+ if (attachedAgents.size() > argParser.getExpectedAgentsNumber()) {
+ setStatusFailed("Unexpected agent attached (expected agents number: " +
+ argParser.getExpectedAgentsNumber() +
+ ", but " + attachedAgents.size() + " agents were loaded)");
+
+ throw new TestBug("More agents attached than it was expected" +
+ " (expected: " + argParser.getExpectedAgentsNumber() +
+ ", attached: " + attachedAgents.size() + ")");
+ }
+ }
+ }
+ }
+
+ public static void agentFinished(String agentName, boolean finishedSuccessfully) {
+ synchronized (monitor) {
+ // check test logic
+ if (!targetApplicationInitialized)
+ throw new TestBug("Method 'agentFinished' was called before TargetApplication was initialized");
+
+ boolean algorithmError = false;
+ String errorMessage = "Test algorithm error:";
+
+ if (!attachedAgents.contains(agentName)) {
+ algorithmError = true;
+ errorMessage += " agent '" + agentName + "' didn't call method 'agentLoaded';";
+ log.complain(errorMessage);
+ }
+
+ if (finishedAgents.contains(agentName)) {
+ algorithmError = true;
+ errorMessage += " agent '" + agentName + "' already called method 'agentFinished';";
+ log.complain(errorMessage);
+ }
+
+ if (algorithmError) {
+ // let TargetApplication complete execution in case of error
+ allAgentsFinished = true;
+ monitor.notifyAll();
+
+ throw new TestBug(errorMessage);
+ } else {
+ finishedAgents.add(agentName);
+
+ log.display("Agent '" + agentName + "' finished execution (finishedSuccessfully: " + finishedSuccessfully + ")");
+
+ if (!finishedSuccessfully)
+ setStatusFailed("Agent '" + agentName + " finished with error status");
+
+ allAgentsFinished = (finishedAgents.size() == argParser.getExpectedAgentsNumber());
+
+ if (allAgentsAttached)
+ monitor.notifyAll();
+ }
+ }
+ }
+
+ /*
+ * This method is called from the method 'agentLoaded' in case
+ * when target application isn't initialized yet at the moment
+ * when agent is connecting
+ */
+ static private void waitForTargetApplicationInitialization() {
+ synchronized (monitor) {
+ while (!targetApplicationInitialized) {
+ try {
+ monitor.wait();
+ } catch (InterruptedException e) {
+ // should never happen
+ exitAsFailed(e);
+ }
+ }
+ }
+ }
+
+ /*
+ * This method is introduced to let subclasses to create its own parsers
+ */
+ protected AODTargetArgParser createArgParser(String[] args) {
+ return new AODTargetArgParser(args);
+ }
+
+ /*
+ * Target application initialization
+ */
+ private void initTargetApplication(String[] args) {
+ synchronized (monitor) {
+ if (targetApplicationInitialized)
+ throw new TestBug("TargetApplication already initialized");
+
+ log = new Log(System.out, true);
+
+ argParser = createArgParser(args);
+
+ // test-specific initialization
+ init(args);
+
+ targetApplicationInitialized = true;
+ monitor.notifyAll();
+ }
+ }
+
+ static private void waitAgentsConnection() {
+ synchronized (monitor) {
+ long waitFinishTime = System.currentTimeMillis() + AGENTS_CONNECTION_TIMEOUT;
+
+ while (!allAgentsAttached && (System.currentTimeMillis() < waitFinishTime)) {
+ try {
+ monitor.wait(AGENTS_CONNECTION_TIMEOUT);
+ } catch (InterruptedException e) {
+ // should never happen
+ exitAsFailed(e);
+ }
+ }
+ }
+
+ if (!allAgentsAttached) {
+ exitAsFailed("Agents didn't attach in " + AGENTS_CONNECTION_TIMEOUT + "ms, stop execution " +
+ "(expected agents number: " + argParser.getExpectedAgentsNumber() +
+ ", attached agents number: " + attachedAgents.size() + ")");
+ }
+ }
+
+ static private void waitAgentsFinishing() {
+ synchronized (monitor) {
+ long waitFinishTime = System.currentTimeMillis() + AGENTS_FINISHING_TIMEOUT;
+
+ while (!allAgentsFinished && (System.currentTimeMillis() < waitFinishTime)) {
+ try {
+ monitor.wait(AGENTS_FINISHING_TIMEOUT);
+ } catch (InterruptedException e) {
+ // should never happen
+ exitAsFailed(e);
+ }
+ }
+ }
+
+ if (!allAgentsFinished)
+ exitAsFailed("Agents didn't finish in " + AGENTS_FINISHING_TIMEOUT + "ms, stop execution " +
+ "(attached agents number: " + attachedAgents.size() +
+ ", finished agents number: " + finishedAgents.size() + ")");
+ }
+
+ /*
+ * Print error message and set failed status, but don't exit
+ */
+
+ static public void setStatusFailed(String message) {
+ testFailed = true;
+ log.complain(message);
+ }
+
+ static public void setStatusFailed(Throwable t) {
+ testFailed = true;
+ log.complain("Unexpected exception: " + t);
+ t.printStackTrace(log.getOutStream());
+ }
+
+ /*
+ * Print error message and exit with fail status
+ */
+ static protected void exitAsFailed(String errorMessage) {
+ try {
+ log.complain(errorMessage);
+ log.complain("Stop execution");
+ } finally {
+ System.exit(Consts.JCK_STATUS_BASE + Consts.TEST_FAILED);
+ }
+ }
+
+ /*
+ * Print error message and exit with fail status
+ */
+ static protected void exitAsFailed(Throwable t) {
+ try {
+ log.complain("Unexpected exception was thrown during TargetApplication execution: " + t);
+ t.printStackTrace(log.getOutStream());
+ log.display("Stop execution");
+ } finally {
+ System.exit(Consts.JCK_STATUS_BASE + Consts.TEST_FAILED);
+ }
+ }
+
+ /*
+ * Following 3 methods can be overridden in subclasses:
+ *
+ * - init(String[] args)
+ *
+ * - targetApplicationActions()
+ *
+ * - afterAgentsFinished()
+ */
+
+ /*
+ * Test-specific initialization
+ */
+ protected void init(String[] args) {
+
+ }
+
+ protected void targetApplicationActions() throws Throwable {
+ // do nothing by default
+ }
+
+ protected void afterAgentsFinished() {
+ // do nothing by default
+ }
+
+ public final void runTargetApplication(String[] args) {
+ initTargetApplication(args);
+
+ SocketIOPipe pipe = null;
+
+ try {
+ if (argParser.getPort() > 0) {
+ /*
+ * When target application initialized send signal to AODTestRunner
+ */
+ pipe = SocketIOPipe.createClientIOPipe(log, "localhost", argParser.getPort(), 0);
+ log.display("Sending signal '" + AODTestRunner.SIGNAL_READY_FOR_ATTACH + "'");
+ pipe.println(AODTestRunner.SIGNAL_READY_FOR_ATTACH);
+ }
+
+ log.display("Waiting for agents connection");
+ waitAgentsConnection();
+ log.display("All expected agents connected");
+
+ try {
+ targetApplicationActions();
+ } catch (Throwable e) {
+ /*
+ * If something goes wrong during test execution it is better
+ * to exit without waiting for agents
+ */
+
+ if (pipe != null)
+ pipe.close();
+
+ exitAsFailed(e);
+ }
+
+ log.display("Waiting for agents finishing");
+ waitAgentsFinishing();
+ log.display("All agents finished execution");
+
+ afterAgentsFinished();
+
+ if (pipe != null) {
+ /*
+ * Don't finish execution until AODTestRunner attached agents
+ */
+ String signal = pipe.readln();
+ log.display("Signal received: '" + signal + "'");
+ if ((signal == null) || !signal.equals(AODTestRunner.SIGNAL_FINISH))
+ throw new TestBug("Unexpected AODTestRunner signal: '" + signal + "'");
+
+ if (testFailed) {
+ if (pipe != null)
+ pipe.close();
+
+ exitAsFailed("Error happened during TargetApplication execution (see error messages for details)");
+ } else {
+ log.display("Test passed");
+ }
+ }
+ } finally {
+ if (pipe != null)
+ pipe.close();
+ }
+ }
+
+ public static void main(String[] args) {
+ new TargetApplicationWaitingAgents().runTargetApplication(args);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/Utils.java b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/Utils.java
new file mode 100644
index 00000000000..8febc17e6de
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/Utils.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2008, 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 nsk.share.aod;
+
+import java.io.File;
+
+import nsk.share.*;
+
+public class Utils {
+
+ // prevent class instantiation
+ private Utils() {
+ }
+
+ public static final long JPS_WORK_TIMEOUT = 60000; // 1 min
+
+ /**
+ * Find id of VM with certain value of property key. Method findVMIdUsingJPS
+ * runs 'jps -v' and seeks in jps output line containing this unique string,
+ * discovered string should also contain VM id.
+ *
+ * @param jdkPath - path to jdk
+ * @param key - name of property
+ * @param value - value of property
+ * @return VM id
+ */
+ public static String findVMIdUsingJPS(String jdkPath, String key, String value) {
+ try {
+ if (value == null) {
+ return null;
+ }
+ String idString = key + "=" + value;
+ String jpsPath = jdkPath + File.separator + "bin" + File.separator + "jps";
+
+ while (true) {
+ ProcessExecutor executor = new ProcessExecutor(jpsPath + " -v", JPS_WORK_TIMEOUT, "jps -v");
+ executor.startProcess();
+ executor.waitForProcess();
+
+ if (executor.getExitCode() != 0) {
+ throw new Failure("jps finished with non-zero code " + executor.getExitCode());
+ }
+
+ for (String jpsOutLine : executor.getProcessOut()) {
+ if (jpsOutLine.contains(idString)) {
+ if (jpsOutLine.indexOf(' ') < 0)
+ throw new Failure("Unexpected format of the jps output '" + jpsOutLine + " (line doesn't contain space)");
+
+ return jpsOutLine.substring(0, jpsOutLine.indexOf(' '));
+ }
+ }
+ Thread.sleep(100);
+ }
+ } catch (Failure f) {
+ throw f;
+ } catch (Throwable t) {
+ throw new Failure("Unexpected exception during jps execution: " + t, t);
+ }
+ }
+
+ public static String findCurrentVMIdUsingJPS(String jdkPath) {
+ /*
+ * VM should be run with special property which allows to find VM id using jps
+ * (see comments for method Utils.findVMIdUsingJPS)
+ */
+ String applicationId = System.getProperty(AODTestRunner.targetAppIdProperty);
+ if (applicationId == null)
+ throw new TestBug("Property '" + AODTestRunner.targetAppIdProperty + "' isn't defined");
+
+ String targetVMId = Utils.findVMIdUsingJPS(jdkPath, AODTestRunner.targetAppIdProperty, applicationId);
+
+ return targetVMId;
+ }
+
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/aod.c b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/aod.c
new file mode 100644
index 00000000000..6956ce55516
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/aod.c
@@ -0,0 +1,288 @@
+/*
+ * Copyright (c) 2008, 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.
+ */
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static volatile int internalError = 0;
+
+/*
+ * This function can be used to inform AOD framework that some non critical for test logic
+ * error happened inside shared function (e.g. JVMTI Deallocate failed).
+ *
+ * If this function was called status of all finishing AOD agents is changed to failed.
+ */
+
+void nsk_aod_internal_error() {
+ NSK_COMPLAIN0("WARNING: some error happened inside common function, see log for details\n");
+ internalError = 1;
+}
+
+void nsk_free_options(Options* options) {
+ if (options != NULL) {
+ int i;
+ for (i = 0; i < NSK_AOD_MAX_OPTIONS; i++) {
+ if (options->names[i] != NULL) {
+ free(options->names[i]);
+ }
+ if (options->values[i] != NULL) {
+ free(options->values[i]);
+ }
+ }
+ free(options);
+ }
+}
+/*
+ * Work with agent options
+ */
+
+/*
+ * Parse options and create structure Options
+ */
+static Options* nsk_aod_createOptionsObject(char* optionsString) {
+ int i = 0;
+ Options* options;
+ char* name;
+ char* value;
+ char* sep;
+
+ if (optionsString == NULL) {
+ NSK_COMPLAIN0("options were not passed to the native agent\n");
+ return NULL;
+ }
+ options = (Options*) malloc(sizeof(Options));
+ memset(options, 0, sizeof(Options));
+ options->size = 0;
+ name = optionsString;
+ while (name != NULL && i < NSK_AOD_MAX_OPTIONS) {
+ sep = strchr(name, '=');
+ if (sep == NULL) { // name not found
+ NSK_COMPLAIN1("Invalid options format: '%s'\n", optionsString);
+ nsk_free_options(options);
+ return NULL;
+ }
+ *sep = '\0';
+ options->names[i] = strdup(name);
+ value = sep + 1;
+ if (*value == '\0') { // value not found
+ NSK_COMPLAIN1("Option '%s' is empty\n", options->names[i]);
+ nsk_free_options(options);
+ return NULL;
+ }
+ sep = strchr(value, ' ');
+ if (sep != NULL) {
+ *sep = '\0';
+ name = sep + 1;
+ } else {
+ name = strchr(value, '\0');
+ }
+ options->values[i] = strdup(value);
+ i++;
+
+ if (*name == '\0') {
+ name = NULL;
+ }
+ }
+ if (name != NULL) {
+ NSK_COMPLAIN1("WARNING: not all options were parsed, only %d options can be specified\n",
+ NSK_AOD_MAX_OPTIONS);
+ }
+ options->size = i;
+ return options;
+}
+
+Options* nsk_aod_createOptions(char* optionsString) {
+ Options* options;
+
+ if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptionsObject(optionsString)) != NULL))
+ return NULL;
+
+ if (!NSK_VERIFY(nsk_aod_optionSpecified(options, NSK_AOD_AGENT_NAME_OPTION))) {
+ NSK_COMPLAIN0("Agent name wasn't specified\n");
+ return NULL;
+ }
+
+ /*
+ * verbose mode is true by default
+ */
+ nsk_setVerboseMode(NSK_TRUE);
+
+ if (nsk_aod_optionSpecified(options, NSK_AOD_VERBOSE_OPTION)) {
+ if (strcmp(nsk_aod_getOptionValue(options, NSK_AOD_VERBOSE_OPTION), "false") == 0)
+ nsk_setVerboseMode(NSK_FALSE);
+ }
+
+ return options;
+}
+
+const char* nsk_aod_getOptionValue(Options* options, const char* option) {
+ int i;
+
+ if (!NSK_VERIFY(options != NULL)) {
+ NSK_COMPLAIN0("Options NULL\n");
+ return NULL;
+ }
+
+ for(i = 0; i < options->size; i++) {
+ if (strcmp(option, options->names[i]) == 0) {
+ return options->values[i];
+ }
+ }
+
+ NSK_COMPLAIN1("Option '%s' isn't defined\n", option);
+
+ return NULL;
+}
+
+int nsk_aod_optionSpecified(Options* options, const char* option) {
+ int i;
+
+ if (!NSK_VERIFY(options != NULL)) {
+ NSK_COMPLAIN0("Options NULL\n");
+ return NSK_FALSE;
+ }
+
+ for(i = 0; i < options->size; i++) {
+ if (strcmp(option, options->names[i]) == 0) {
+ return NSK_TRUE;
+ }
+ }
+
+ return NSK_FALSE;
+}
+
+/*
+ * Agent synchronization with target application
+ */
+
+static const char* TARGET_APP_CLASS_NAME = "nsk/share/aod/TargetApplicationWaitingAgents";
+
+static const char* AGENT_LOADED_METHOD_NAME = "agentLoaded";
+static const char* AGENT_LOADED_METHOD_SIGNATURE = "(Ljava/lang/String;)V";
+
+static const char* AGENT_FINISHED_METHOD_NAME = "agentFinished";
+static const char* AGENT_FINISHED_METHOD_SIGNATURE = "(Ljava/lang/String;Z)V";
+
+static jclass targetAppClass = NULL;
+static jmethodID agentLoadedMethod = NULL;
+static jmethodID agentFinishedMethod = NULL;
+
+// this function is used to notify target application that native agent has been loaded
+int nsk_aod_agentLoaded(JNIEnv* jni, const char* agentName) {
+ jstring agentNameString;
+
+ NSK_DISPLAY1("Agent %s is loaded\n", agentName);
+
+ if (targetAppClass == NULL) {
+ /*
+ * FindClass returns local reference, to cache reference to target application class
+ * global reference should be created
+ */
+ jclass localTargetAppClass;
+ if (!NSK_JNI_VERIFY(jni, (localTargetAppClass =
+ NSK_CPP_STUB2(FindClass, jni, TARGET_APP_CLASS_NAME)) != NULL)) {
+ return NSK_FALSE;
+ }
+
+ if (!NSK_JNI_VERIFY(jni, (targetAppClass =
+ NSK_CPP_STUB2(NewGlobalRef, jni, localTargetAppClass)) != NULL)) {
+ return NSK_FALSE;
+ }
+ }
+
+ if (agentLoadedMethod == NULL) {
+ if (!NSK_JNI_VERIFY(jni, (agentLoadedMethod =
+ NSK_CPP_STUB4(GetStaticMethodID, jni, targetAppClass,
+ AGENT_LOADED_METHOD_NAME, AGENT_LOADED_METHOD_SIGNATURE)) != NULL))
+ return NSK_FALSE;
+ }
+
+ if (!NSK_JNI_VERIFY(jni, (agentNameString =
+ NSK_CPP_STUB2(NewStringUTF, jni, agentName)) != NULL))
+ return NSK_FALSE;
+
+ NSK_CPP_STUB4(CallStaticVoidMethod, jni, targetAppClass, agentLoadedMethod, agentNameString);
+
+ return NSK_TRUE;
+}
+
+// this function is used to notify target application that native agent has been finished execution
+int nsk_aod_agentFinished(JNIEnv* jni, const char* agentName, int success) {
+ jstring agentNameString;
+
+ if (!targetAppClass) {
+ NSK_COMPLAIN1("%s: TEST LOGIC ERROR: method 'agentFinished' was called before "\
+ "targetAppClass was initialized\n", agentName);
+ return NSK_FALSE;
+ }
+
+ if (internalError && success) {
+ success = 0;
+ NSK_COMPLAIN1("Status of agent '%s' is 'passed', but some error happened during test execution "\
+ "(see log for details), change agent status to 'failed'\n",
+ agentName);
+ }
+
+ NSK_DISPLAY2("Agent %s finished (success: %d)\n", agentName, success);
+
+ if (agentFinishedMethod == NULL) {
+ if (!NSK_JNI_VERIFY(jni, (agentFinishedMethod =
+ NSK_CPP_STUB4(GetStaticMethodID, jni, targetAppClass,
+ AGENT_FINISHED_METHOD_NAME, AGENT_FINISHED_METHOD_SIGNATURE)) != NULL))
+ return NSK_FALSE;
+ }
+
+ if (!NSK_JNI_VERIFY(jni, (agentNameString = NSK_CPP_STUB2(NewStringUTF, jni, agentName)) != NULL))
+ return NSK_FALSE;
+
+ NSK_CPP_STUB5(CallStaticVoidMethod, jni, targetAppClass,
+ agentFinishedMethod, agentNameString, success ? JNI_TRUE : JNI_FALSE);
+
+ return NSK_TRUE;
+}
+
+/*
+ * Auxiliary functions
+ */
+
+// JNI env creation
+
+JNIEnv* nsk_aod_createJNIEnv(JavaVM* vm) {
+ JNIEnv* jni;
+ NSK_CPP_STUB3(GetEnv, vm, (void**)&jni, JNI_VERSION_1_2);
+
+ NSK_VERIFY(jni != NULL);
+
+ return jni;
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/aod.h b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/aod.h
new file mode 100644
index 00000000000..a6bb112645e
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/aod.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2008, 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.
+ */
+#ifndef NSK_SHARE_AOD_H
+#define NSK_SHARE_AOD_H
+
+#include
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This function can be used to inform AOD framework that some non-critical for test logic
+ * error happened inside shared function (e.g. JVMTI Deallocate failed).
+ *
+ * If this function was called status of all finishing AOD agents is changed to failed.
+ */
+
+void nsk_aod_internal_error();
+
+/*
+ * Work with agent options
+ */
+
+#define NSK_AOD_MAX_OPTIONS 10
+
+#define NSK_AOD_AGENT_NAME_OPTION "-agentName"
+#define NSK_AOD_VERBOSE_OPTION "-verbose"
+
+typedef struct {
+ char* names[NSK_AOD_MAX_OPTIONS];
+ char* values[NSK_AOD_MAX_OPTIONS];
+ int size;
+} Options;
+
+Options* nsk_aod_createOptions(char* optionsString);
+
+const char* nsk_aod_getOptionValue(Options* options, const char* option);
+
+int nsk_aod_optionSpecified(Options* options, const char* option);
+
+/*
+ * Agent synchronization with target application
+ */
+
+// this function is used to notify target application that native agent has been loaded
+int nsk_aod_agentLoaded(JNIEnv* jni, const char* agentName);
+
+// this function is used to notify target application that native agent has been finished execution
+int nsk_aod_agentFinished(JNIEnv* jni, const char* agentName, int success);
+
+
+// JNI env creation
+
+JNIEnv* nsk_aod_createJNIEnv(JavaVM* vm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* END OF NSK_SHARE_AOD_H */
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/classload/ClassPathNonDelegatingClassLoader.java b/test/hotspot/jtreg/vmTestbase/nsk/share/classload/ClassPathNonDelegatingClassLoader.java
new file mode 100644
index 00000000000..b99a91dfad2
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/classload/ClassPathNonDelegatingClassLoader.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.classload;
+
+import java.io.*;
+import java.util.*;
+
+import nsk.share.FileUtils;
+
+/**
+ * Custom classloader that does not delegate to it's parent.
+ *
+ * It can load classes from classpath that have name containing
+ * "Class" (any package).
+ */
+public class ClassPathNonDelegatingClassLoader extends ClassLoader {
+ private String [] classPath;
+
+ public ClassPathNonDelegatingClassLoader() {
+ classPath = System.getProperty("java.class.path").split(File.pathSeparator);
+ }
+
+ public synchronized Class loadClass(String name, boolean resolve)
+ throws ClassNotFoundException {
+ Class c = findLoadedClass(name);
+ if (c != null) {
+ System.out.println("Found class: " + name);
+ return c;
+ }
+ if (name.contains("Class")) {
+ String newName = name.replace('.', '/');
+ return loadClassFromFile(name, newName + ".class", resolve);
+ } else {
+ return findSystemClass(name);
+ }
+ }
+
+ private Class loadClassFromFile(String name, String fname, boolean resolve)
+ throws ClassNotFoundException {
+ try {
+ File target = new File("");
+
+ for(int i = 0; i < classPath.length; ++i) {
+ target = new File(classPath[i] + File.separator + fname);
+ if (target.exists())
+ break;
+ }
+ if (!target.exists())
+ throw new java.io.FileNotFoundException();
+ byte[] buffer = FileUtils.readFile(target);
+ Class c = defineClass(name, buffer, 0, buffer.length);
+ if (resolve)
+ resolveClass(c);
+ return c;
+ } catch (IOException e) {
+ throw new ClassNotFoundException("Exception while reading classfile data", e);
+ }
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/classload/GeneratingClassLoader.java b/test/hotspot/jtreg/vmTestbase/nsk/share/classload/GeneratingClassLoader.java
new file mode 100644
index 00000000000..37215400e97
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/classload/GeneratingClassLoader.java
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.classload;
+
+import java.io.*;
+import java.util.*;
+import nsk.share.*;
+
+/**
+ * Classloader that generates classes on the fly.
+ *
+ * This classloader can load classes with name starting with 'Class'.
+ * It will use nsk.share.classload.TemplateClass as template and will
+ * replace class name in the bytecode of template class. It can be used
+ * for example to detect memory leaks in class loading or to quickly
+ * fill PermGen.
+ */
+public class GeneratingClassLoader extends ClassLoader {
+ public static final String DEFAULT_CLASSNAME = TemplateClass.class.getName();
+ public static final String PREFIX = "Class";
+
+ private final String [] classPath;
+ private byte[] bytecode;
+ private int[] offsets;
+ private final String encoding = "UTF8";
+ private final String templateClassName;
+ private final byte[] templateClassNameBytes;
+
+ /**
+ * Create generating class loader that will use class file
+ * for given class from classpath as template.
+ */
+ public GeneratingClassLoader(String templateClassName) {
+ this.templateClassName = templateClassName;
+ classPath = System.getProperty("java.class.path").split(File.pathSeparator);
+ try {
+ templateClassNameBytes = templateClassName.getBytes(encoding);
+ } catch (UnsupportedEncodingException e) {
+ throw new TestBug(e);
+ }
+ }
+
+ /**
+ * Create generating class loader that will use class file
+ * for nsk.share.classload.TemplateClass as template.
+ */
+ public GeneratingClassLoader() {
+ this("nsk.share.classload.TemplateClass");
+ }
+
+ public int getNameLength() {
+ return templateClassName.length();
+ }
+
+ public String getPrefix() {
+ return PREFIX;
+ }
+
+ public String getClassName(int number) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(PREFIX);
+ sb.append(number);
+ int n = templateClassName.length() - sb.length();
+ for (int i = 0; i < n; ++i)
+ sb.append("_");
+ return sb.toString();
+ }
+
+ public synchronized Class loadClass(String name) throws ClassNotFoundException {
+ return loadClass(name, false);
+ }
+
+ public synchronized Class loadClass(String name, boolean resolve)
+ throws ClassNotFoundException {
+ Class c = findLoadedClass(name);
+ if (c != null)
+ return c;
+ if (!name.startsWith(PREFIX))
+ return super.loadClass(name, resolve);
+ if (name.length() != templateClassName.length())
+ throw new ClassNotFoundException("Only can load classes with name.length() = " + getNameLength() + " got: '" + name + "' length: " + name.length());
+ byte[] bytecode = getPatchedByteCode(name);
+ c = defineClass(name, bytecode, 0, bytecode.length);
+ if (resolve)
+ resolveClass(c);
+ return c;
+ }
+
+ private byte[] getPatchedByteCode(String name) throws ClassNotFoundException {
+ try {
+ byte[] bytecode = getByteCode();
+ String fname = name.replace(".", File.separator);
+ byte[] replaceBytes = fname.getBytes(encoding);
+ for (int offset : offsets) {
+ for (int i = 0; i < replaceBytes.length; ++i)
+ bytecode[offset + i] = replaceBytes[i];
+ }
+ return bytecode;
+ } catch (UnsupportedEncodingException e) {
+ throw new TestBug(e);
+ } catch (IOException e) {
+ throw new TestBug(e);
+ }
+ }
+
+ private byte[] getByteCode() throws ClassNotFoundException {
+ if (bytecode == null)
+ readByteCode();
+ if (offsets == null) {
+ getOffsets(bytecode);
+ if (offsets == null)
+ throw new TestBug("Class name not found in template class file");
+ }
+ return (byte[]) bytecode.clone();
+ }
+
+ private void readByteCode() throws ClassNotFoundException {
+ String fname = templateClassName.replace(".", File.separator) + ".class";
+ File target = null;
+ for (int i = 0; i < classPath.length; ++i) {
+ target = new File(classPath[i] + File.separator + fname);
+ if (target.exists())
+ break;
+ }
+
+ if (target == null || !target.exists())
+ throw new ClassNotFoundException("File not found: " + target);
+ try {
+ bytecode = FileUtils.readFile(target);
+ } catch (IOException e) {
+ throw new ClassNotFoundException(templateClassName, e);
+ }
+ }
+
+ private void getOffsets(byte[] bytecode) {
+ List offsets = new ArrayList();
+ if (this.offsets == null) {
+ String pname = templateClassName.replace(".", "/");
+ try {
+ byte[] pnameb = pname.getBytes(encoding);
+ int i = 0;
+ while (true) {
+ while (i < bytecode.length) {
+ int j = 0;
+ while (j < pnameb.length && bytecode[i + j] == pnameb[j])
+ ++j;
+ if (j == pnameb.length)
+ break;
+ i++;
+ }
+ if (i == bytecode.length)
+ break;
+ offsets.add(new Integer(i));
+ i++;
+ }
+ } catch (UnsupportedEncodingException e) {
+ throw new TestBug(e);
+ }
+ this.offsets = new int[offsets.size()];
+ for (int i = 0; i < offsets.size(); ++i)
+ this.offsets[i] = offsets.get(i).intValue();
+ }
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/classload/TemplateClass.java b/test/hotspot/jtreg/vmTestbase/nsk/share/classload/TemplateClass.java
new file mode 100644
index 00000000000..d967c2e313c
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/classload/TemplateClass.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.classload;
+
+public class TemplateClass {
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Algorithms.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Algorithms.java
new file mode 100644
index 00000000000..404dc6498f7
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Algorithms.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2003, 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 nsk.share.gc;
+
+import java.io.*;
+import java.util.*;
+import nsk.share.*;
+import nsk.share.gc.gp.*;
+import nsk.share.test.ExecutionController;
+
+/**
+ * Algorithms class collects main algorithms that are used in
+ * GC testing.
+ */
+public class Algorithms {
+ /** Number of threads that one CPU can manage. */
+ public final static long THREADS_MANAGED_BY_ONE_CPU = 100;
+
+ /** Number of threads that one block of memory can manage. */
+ public final static long THREADS_MANAGED_BY_ONE_BLOCK = 200;
+
+ /** Default maximum number of elements in array. */
+ public final static int MAX_ARRAY_SIZE = 65535;
+
+ // Block of memory is 64M
+ private final static long BLOCK_SIZE = 64 * 1024 * 1024; // 64M
+
+ // Minimal memory chunk size to eat
+ private final static int MIN_MEMORY_CHUNK = 512; // Bytes
+
+ // Number of attempts to print a string. Print may fail because of
+ // OutOfMemoryError, so this constat specifies the number of attemts
+ // to print despite of OOME.
+ private final static int ATTEMPTS_TO_PRINT = 3;
+
+ // This object stores any Failure that is thrown in Gourmand class
+ // and used in eatMemory(int) method
+ private static Failure failure = null;
+
+ // This object is intended for wait()
+ private static Object object = new Object();
+
+ /**
+ * Default constructor.
+ */
+ private Algorithms() {}
+
+ /**
+ * Stresses memory by allocating arrays of bytes. The method allocates
+ * objects in the same thread and does not invoke GC explicitly by
+ * calling System.gc() .
+ *
+ *
+ * Note that this method can throw Failure if any exception
+ * is thrown while eating memory. To avoid OOM while allocating
+ * exception we preallocate it before the lunch starts. It means
+ * that exception stack trace does not correspond to the place
+ * where exception is thrown, but points at start of the method.
+ *
+ * This method uses nsk.share.test.Stresser class to control
+ * it's execution. Consumed number of iterations depends on
+ * available memory.
+ *
+ * @throws nsk.share.Failure if any unexpected exception is
+ * thrown during allocating of the objects.
+ *
+ * @see nsk.share.test.Stresser
+ */
+ public static void eatMemory(ExecutionController stresser) {
+ GarbageUtils.eatMemory(stresser, 50, MIN_MEMORY_CHUNK, 2);
+ }
+
+ /**
+ * Calculates and returns recomended number of threads to start in the
+ * particular machine (with particular amount of memory and number of CPUs).
+ * The returned value is minimum of two values:
+ * {@link #THREADS_MANAGED_BY_ONE_CPU} * (number of processors) and
+ * {@link #THREADS_MANAGED_BY_ONE_BLOCK} * (number of blocks of the memory).
+ *
+ * @return recomended number of threads to start.
+ *
+ */
+ public static int getThreadsCount() {
+ Runtime runtime = Runtime.getRuntime();
+ int processors = runtime.availableProcessors();
+ long maxMemory = runtime.maxMemory();
+ long blocks = Math.round((double) maxMemory / BLOCK_SIZE);
+
+ return (int) Math.min(THREADS_MANAGED_BY_ONE_CPU * processors,
+ THREADS_MANAGED_BY_ONE_BLOCK * blocks);
+ }
+
+ /**
+ * Returns the number of processors available to the Java virtual machine.
+ *
+ * @return number of processors available to the Java virtual machine.
+ *
+ * @see Runtime#availableProcessors
+ *
+ */
+ public static int availableProcessors() {
+ Runtime runtime = Runtime.getRuntime();
+ return runtime.availableProcessors();
+ }
+
+ /**
+ * Makes a few attempts to print the string into specified PrintStream.
+ * If PrintStream.println(String)
throws OutOfMemoryError,
+ * the method waits for a few milliseconds and repeats the attempt.
+ *
+ * @param out PrintStream to print the string.
+ * @param s the string to print.
+ */
+ public static void tryToPrintln(PrintStream out, String s) {
+ for (int i = 0; i < ATTEMPTS_TO_PRINT; i++) {
+ try {
+ out.println(s);
+
+ // The string is printed into the PrintStream
+ return;
+ } catch (OutOfMemoryError e) {
+
+ // Catch the error and wait for a while
+ synchronized(object) {
+ try {
+ object.wait(500);
+ } catch (InterruptedException ie) {
+
+ // Ignore the exception
+ }
+ } // synchronized
+ }
+ }
+ } // tryToPrintln()
+
+ /**
+ * Makes a few attempts to print each stack trace of Throwable
+ * into specified PrintStream. If PrintStream.println(String)
+ * throws OutOfMemoryError, the method waits for a few milliseconds and
+ * repeats the attempt.
+ *
+ * @param out PrintStream to print the string.
+ * @param t the throwable to print.
+ *
+ * @see #tryToPrintln
+ */
+ public static void tryToPrintStack(PrintStream out, Throwable t) {
+ StackTraceElement[] trace = t.getStackTrace();
+
+ for (int i = 0; i < trace.length; i++) {
+ for (int j = 0; j < ATTEMPTS_TO_PRINT; j++) {
+ try {
+ out.println(trace[i].toString());
+
+ // The string is printed into the PrintStream
+ return;
+ } catch (OutOfMemoryError e) {
+
+ // Catch the error and wait for a while
+ synchronized(object) {
+ try {
+ object.wait(500);
+ } catch (InterruptedException ie) {
+
+ // Ignore the exception
+ }
+ } // synchronized
+ } // try
+ } // for j
+ } // for i
+ } // tryToPrintStack()
+
+ /**
+ * Returns recommended size for an array. Default implemetation returns
+ * minimum between size
and
+ * {@link #MAX_ARRAY_SIZE MAX_ARRAY_SIZE}.
+ *
+ * @return recommended size for an array.
+ *
+ */
+ public static int getArraySize(long size) {
+ long min = Math.min(MAX_ARRAY_SIZE, size);
+ return (int) min;
+ } // getArraySize()
+} // class Algorithms
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/AllDiag.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/AllDiag.java
new file mode 100644
index 00000000000..e9f9b42955e
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/AllDiag.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+import nsk.share.runner.RunParams;
+
+/**
+ * Helper that prints information about AllMemoryObjects.
+ */
+public class AllDiag implements Runnable {
+ private long sleepTime;
+
+ public AllDiag() {
+ this(RunParams.getInstance().getSleepTime());
+ }
+
+ public AllDiag(long sleepTime) {
+ this.sleepTime = sleepTime;
+ }
+
+ public void run() {
+ AllMemoryObject.dumpStatistics();
+ // Ensure that interrupt status is not lost
+ if (Thread.currentThread().isInterrupted())
+ return;
+ try {
+ Thread.sleep(sleepTime);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/AllMemoryObject.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/AllMemoryObject.java
new file mode 100644
index 00000000000..cc0ad91b6ad
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/AllMemoryObject.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+import java.io.PrintStream;
+
+/**
+ * An object that occupies approximately given number of bytes in memory
+ * and also records number of allocated instances.
+ */
+public class AllMemoryObject extends MemoryObject {
+ private static int allocatedCount;
+
+ public AllMemoryObject(int size) {
+ super(size);
+ synchronized (AllMemoryObject.class) {
+ ++allocatedCount;
+ }
+ }
+
+ /**
+ * Returns the number of allocated FinMemoryObjects.
+ */
+ public static int getAllocatedCount() {
+ return allocatedCount;
+ }
+
+ public static void dumpStatistics(PrintStream out) {
+ out.println("Object count: " + getAllocatedCount());
+ }
+
+ public static void dumpStatistics() {
+ dumpStatistics(System.out);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/ArgumentHandler.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/ArgumentHandler.java
new file mode 100644
index 00000000000..f9d56730de1
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/ArgumentHandler.java
@@ -0,0 +1,363 @@
+/*
+ * Copyright (c) 2003, 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 nsk.share.gc;
+
+import nsk.share.*;
+
+/**
+ * Parser for GC tests' arguments.
+ *
+ * ArgumentHandler
handles specific command line arguments
+ * related to way of execution of a test in addition to general arguments
+ * recognized by {@link ArgumentParser ArgumentParser
}.
+ *
+ * Following is the list of specific options for ArgumentHandler
:
+ *
+ * -iterations="value "
, where value must either
+ * be "infinity", or an integer number, greater than 0. This parameter
+ * specifies the number of iterations to run the testcase. If the value is
+ * "infinity", then the test will be run for at least gcTimeout
+ * minutes. Otherwise, the testcase will be repeated for
+ * iterations
times.
+ * -gcTimeout="value "
, where value must be an
+ * integer number, greater than 0. If infinity is set to
+ * iterations
, then the test consider gcTimeout
+ * argument to run the test for at least specified number of minutes.
+ * -threads="value "
, where value must be an
+ * integer number, greater than 0. A user may specify the number of threads
+ * to start in the test with that paramenter. However, a test may ignore
+ * this value, if it does know the number of threads to start. It
+ * depends on a test: read its README file.
+ * -memoryEater="value "
, where value must be
+ * either "single", or "multi" string. This argument specifies if a single
+ * thread should be used to eat the whole heap or not. If "multi" string is
+ * assigned to -memoryEater
, then a number of threads will be
+ * started to eat the heap. The number is equal to number of available
+ * processors plus 1.
+ * -largeClassesPath="value "
, where value is a
+ * directory to load large classes from.
+ * -fieldsLimitation="value "
, where value must
+ * be either "over", or "under" string. This argument specifies what classes
+ * should be loaded from largeClassesPath
directory. If
+ * over is set, then the classes that have number of fileds over
+ * JVM limitation should be loaded, otherwise -- classes that have number
+ * of fileds under limitation.
+ *
+ * @see ArgumentParser
+ */
+public class ArgumentHandler extends ArgumentParser {
+
+ // Define all possible arguments
+ private final static String ITERATIONS = "iterations";
+ private final static String AGGREGATION_DEPTH = "aggregationDepth";
+ private final static String GC_TIMEOUT = "gcTimeout";
+ private final static String THREADS = "threads";
+ private final static String MEM_EATER = "memoryEater";
+ private final static String LARGE_CLASSES_PATH = "largeClassesPath";
+ private final static String FIELDS_LIMITATION = "fieldsLimitation";
+
+ // An acceptible value for ITERATIONS
+ private final static String INFINITY = "infinity";
+
+ // Acceptible values for MEM_EATER
+ private final static String ME_SINGLE = "single";
+ private final static String ME_MULTI = "multi";
+
+ // Acceptible values for FIELDS_LIMITATION
+ private final static String FL_OVER = "over";
+ private final static String FL_UNDER = "under";
+
+ /**
+ * Keep a copy of raw command-line arguments and parse them;
+ * but throw an exception on parsing error.
+ *
+ * @param args Array of the raw command-line arguments.
+ *
+ * @throws BadOption If unknown option or illegal option value found
+ *
+ * @see ArgumentParser
+ */
+ public ArgumentHandler(String args[]) {
+ super(args);
+ }
+
+ /**
+ * Returns number of iterations.
+ *
+ * If -iterations="infinity "
, the method returns -1.
+ * If the argument is not set, the method returns 1. Otherwise, the
+ * specified number is returned.
+ *
+ * @return number of iterations.
+ *
+ */
+ public int getIterations() {
+ String value = options.getProperty(ITERATIONS, "1");
+
+ if (INFINITY.equals(value))
+ return -1;
+
+ try {
+ return Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ throw new TestBug("Not an integer value of \"" + ITERATIONS
+ + "\" argument: " + value);
+ }
+ }
+
+
+ /**
+ * Returns the depth of object aggregation.
+ *
+ * If the argument is not set, the method returns 0. Otherwise, the
+ * specified number is returned.
+ *
+ * @return number of aggregation depth.
+ *
+ */
+ public int getAggregationDepth() {
+ String value = options.getProperty(AGGREGATION_DEPTH, "0");
+
+ try {
+ return Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ throw new TestBug("Not an integer value of \"" + AGGREGATION_DEPTH
+ + "\" argument: " + value);
+ }
+ }
+
+
+ /**
+ * Returns number of minutes to run the test.
+ *
+ * @return number of minutes to run the test.
+ *
+ */
+ public int getGCTimeout() {
+ String value = options.getProperty(GC_TIMEOUT);
+
+ try {
+ return Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ throw new TestBug("\"" + GC_TIMEOUT + "\" argument is not defined "
+ + "or is not integer: " + value);
+ }
+ }
+
+ /**
+ * Returns a directory to load large classes from.
+ *
+ * @return a directory to load large classes from.
+ *
+ */
+ public String getLargeClassesPath() {
+ return options.getProperty(LARGE_CLASSES_PATH);
+ }
+
+ /**
+ * Returns number of threads to start in a test. If threads
+ * is not set, the method returns specified number of threads.
+ *
+ * @param defaultValue default value, if threads
is not set.
+ * @return number of threads to start in a test.
+ *
+ */
+ public int getThreads(int defaultValue) {
+ String value = options.getProperty(THREADS);
+
+ if (value == null)
+ return defaultValue;
+
+ try {
+ return Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ throw new TestBug("Not an integer value of \"" + THREADS
+ + "\" argument: " + value);
+ }
+ }
+
+ /**
+ * Returns true if single thread should be used to eat the whole heap,
+ * false otherwise.
+ *
+ * @return true if single thread should be used to eat the whole heap,
+ * false otherwise.
+ *
+ */
+ public boolean isSingleMemoryEater() {
+ String value = options.getProperty(MEM_EATER);
+
+ if (value == null)
+ return true;
+ else if (value.equals(ME_SINGLE))
+ return true;
+ else if (value.equals(ME_MULTI))
+ return false;
+ else
+ throw new TestBug("Value for \"" + MEM_EATER + "\" must be either "
+ + ME_SINGLE + ", or " + ME_MULTI);
+ }
+
+ /**
+ * Returns true if classes with number of fileds over limitation should be
+ * loaded, false otherwise.
+ *
+ * @return true if classes with number of fileds over limitation should be
+ * loaded, false otherwise.
+ *
+ */
+ public boolean isOverFieldsLimitation() {
+ String value = options.getProperty(FIELDS_LIMITATION);
+
+ if (value == null)
+ return false;
+ else if (value.equals(FL_OVER))
+ return true;
+ else if (value.equals(FL_UNDER))
+ return false;
+ else
+ throw new TestBug("Value for \"" + FIELDS_LIMITATION + "\" must be "
+ + "either " + FL_OVER + ", or " + FL_UNDER);
+ }
+
+ /**
+ * Checks if an option is allowed and has proper value.
+ * This method is invoked by parseArguments()
+ *
+ * @param option option name
+ * @param value string representation of value
+ * (could be an empty string too)
+ * null if this option has no value
+ * @return true if option is allowed and has proper value,
+ * false if option is not admissible
+ *
+ * @throws BadOption if option has an illegal value
+ *
+ * @see #parseArguments()
+ */
+ protected boolean checkOption(String option, String value) {
+
+ // Define iterations
+ if (option.equals(ITERATIONS)) {
+ if (INFINITY.equals(value))
+ return true;
+
+ try {
+ int number = Integer.parseInt(value);
+
+ if (number < 1)
+ throw new BadOption(option + ": value must be greater than "
+ + "zero.");
+ } catch (NumberFormatException e) {
+ throw new BadOption("Value for option \"" + option + "\" must "
+ + "be integer or \"" + INFINITY + "\": "
+ + value);
+ }
+ return true;
+ }
+
+ // Define timeout
+ if (option.equals(GC_TIMEOUT)) {
+ try {
+ int number = Integer.parseInt(value);
+
+ if (number < 0)
+ throw new BadOption(option + ": value must be a positive "
+ + "integer");
+ } catch (NumberFormatException e) {
+ throw new BadOption("Value for option \"" + option + "\" must "
+ + "be integer: " + value);
+ }
+ return true;
+ }
+
+ // Define threads
+ if (option.equals(THREADS)) {
+ try {
+ int number = Integer.parseInt(value);
+
+ if (number < 0)
+ throw new BadOption(option + ": value must be a positive "
+ + "integer");
+ } catch (NumberFormatException e) {
+ throw new BadOption("Value for option \"" + option + "\" must "
+ + "be integer: " + value);
+ }
+ return true;
+ }
+
+ // Define path to large classes
+ if (option.equals(LARGE_CLASSES_PATH))
+ return true;
+
+ // Define memory eater
+ if (option.equals(MEM_EATER)) {
+ if ( (ME_SINGLE.equals(value)) || (ME_MULTI.equals(value)) )
+ return true;
+ else
+ throw new BadOption("Value for option \"" + option + "\" must "
+ + "be either " + ME_SINGLE + ", or "
+ + ME_MULTI + ": " + value);
+ }
+
+ // Define fields limitation
+ if (option.equals(FIELDS_LIMITATION)) {
+ if ( (FL_OVER.equals(value)) || (FL_UNDER.equals(value)) )
+ return true;
+ else
+ throw new BadOption("Value for option \"" + option + "\" must "
+ + "be either " + FL_OVER + ", or "
+ + FL_UNDER + ": " + value);
+ }
+
+ // Define aggregationDepth
+ if (option.equals(AGGREGATION_DEPTH)) {
+ try {
+ int number = Integer.parseInt(value);
+
+ if (number < 0)
+ throw new BadOption(option + ": value must be a positive "
+ + "integer");
+ } catch (NumberFormatException e) {
+ throw new BadOption("Value for option \"" + option + "\" must "
+ + "be integer: " + value);
+ }
+ return true;
+ }
+
+ return super.checkOption(option, value);
+ }
+
+ /**
+ * Checks if the values of all options are consistent.
+ * This method is invoked by parseArguments()
+ *
+ * @throws BadOption if options have inconsistent values
+ *
+ * @see ArgumentParser#parseArguments()
+ */
+ protected void checkOptions() {
+ super.checkOptions();
+ }
+} // ArgumentHandler
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Cell.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Cell.java
new file mode 100644
index 00000000000..e2c65087111
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Cell.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+import nsk.share.gc.MemoryObject;
+
+public class Cell extends MemoryObject {
+ private int number;
+
+ public Cell(int size, int number) {
+ super(size - 4);
+ setNumber(number);
+ }
+
+ public final int getNumber() {
+ return number;
+ }
+
+ public final void setNumber(int number) {
+ this.number = number;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/CircularLinkedList.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/CircularLinkedList.java
new file mode 100644
index 00000000000..48cdf041b1a
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/CircularLinkedList.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+public class CircularLinkedList {
+ private int objectSize;
+ private LinkedMemoryObject root;
+
+ /**
+ * Create empty circular linked list.
+ *
+ * @param objectSize size of each node in the list
+ */
+ public CircularLinkedList(int objectSize) {
+ this.objectSize = objectSize;
+ }
+
+ /**
+ * Insert new node in the list.
+ */
+ public void grow() {
+ LinkedMemoryObject newnode = new LinkedMemoryObject(objectSize);
+ if (root == null){
+ root = newnode;
+ root.setNext(root);
+ root.setPrev(root);
+ } else {
+ newnode.setNext(root.getNext());
+ root.getNext().setPrev(newnode);
+ root.setNext(newnode);
+ newnode.setPrev(root);
+ }
+ }
+
+ /**
+ * Get length of the list.
+ *
+ * @return length
+ */
+ public int getLength() {
+ return Memory.getListLength(root);
+ }
+
+ /**
+ * Get length of another list.
+ *
+ * @param list another list
+ * @return length of list
+ */
+ public int getLength(CircularLinkedList list) {
+ return Memory.getListLength(list.root);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/ClassChain.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/ClassChain.java
new file mode 100644
index 00000000000..1e73f340b1b
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/ClassChain.java
@@ -0,0 +1,5035 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+/**
+ * Object with long dependency chain.
+ *
+ * Instantiation of this class forces loading of all classes Class*.
+ */
+public class ClassChain {
+ public ClassChain(){
+ new Class1();
+ }
+}
+
+class Class1 {
+ public Class1(){
+ new Class2();
+ }
+}
+class Class2 {
+ public Class2(){
+ new Class3();
+ }
+}
+class Class3 {
+ public Class3(){
+ new Class4();
+ }
+}
+class Class4 {
+ public Class4(){
+ new Class5();
+ }
+}
+class Class5 {
+ public Class5(){
+ new Class6();
+ }
+}
+class Class6 {
+ public Class6(){
+ new Class7();
+ }
+}
+class Class7 {
+ public Class7(){
+ new Class8();
+ }
+}
+class Class8 {
+ public Class8(){
+ new Class9();
+ }
+}
+class Class9 {
+ public Class9(){
+ new Class10();
+ }
+}
+class Class10 {
+ public Class10(){
+ new Class11();
+ }
+}
+class Class11 {
+ public Class11(){
+ new Class12();
+ }
+}
+class Class12 {
+ public Class12(){
+ new Class13();
+ }
+}
+class Class13 {
+ public Class13(){
+ new Class14();
+ }
+}
+class Class14 {
+ public Class14(){
+ new Class15();
+ }
+}
+class Class15 {
+ public Class15(){
+ new Class16();
+ }
+}
+class Class16 {
+ public Class16(){
+ new Class17();
+ }
+}
+class Class17 {
+ public Class17(){
+ new Class18();
+ }
+}
+class Class18 {
+ public Class18(){
+ new Class19();
+ }
+}
+class Class19 {
+ public Class19(){
+ new Class20();
+ }
+}
+class Class20 {
+ public Class20(){
+ new Class21();
+ }
+}
+class Class21 {
+ public Class21(){
+ new Class22();
+ }
+}
+class Class22 {
+ public Class22(){
+ new Class23();
+ }
+}
+class Class23 {
+ public Class23(){
+ new Class24();
+ }
+}
+class Class24 {
+ public Class24(){
+ new Class25();
+ }
+}
+class Class25 {
+ public Class25(){
+ new Class26();
+ }
+}
+class Class26 {
+ public Class26(){
+ new Class27();
+ }
+}
+class Class27 {
+ public Class27(){
+ new Class28();
+ }
+}
+class Class28 {
+ public Class28(){
+ new Class29();
+ }
+}
+class Class29 {
+ public Class29(){
+ new Class30();
+ }
+}
+class Class30 {
+ public Class30(){
+ new Class31();
+ }
+}
+class Class31 {
+ public Class31(){
+ new Class32();
+ }
+}
+class Class32 {
+ public Class32(){
+ new Class33();
+ }
+}
+class Class33 {
+ public Class33(){
+ new Class34();
+ }
+}
+class Class34 {
+ public Class34(){
+ new Class35();
+ }
+}
+class Class35 {
+ public Class35(){
+ new Class36();
+ }
+}
+class Class36 {
+ public Class36(){
+ new Class37();
+ }
+}
+class Class37 {
+ public Class37(){
+ new Class38();
+ }
+}
+class Class38 {
+ public Class38(){
+ new Class39();
+ }
+}
+class Class39 {
+ public Class39(){
+ new Class40();
+ }
+}
+class Class40 {
+ public Class40(){
+ new Class41();
+ }
+}
+class Class41 {
+ public Class41(){
+ new Class42();
+ }
+}
+class Class42 {
+ public Class42(){
+ new Class43();
+ }
+}
+class Class43 {
+ public Class43(){
+ new Class44();
+ }
+}
+class Class44 {
+ public Class44(){
+ new Class45();
+ }
+}
+class Class45 {
+ public Class45(){
+ new Class46();
+ }
+}
+class Class46 {
+ public Class46(){
+ new Class47();
+ }
+}
+class Class47 {
+ public Class47(){
+ new Class48();
+ }
+}
+class Class48 {
+ public Class48(){
+ new Class49();
+ }
+}
+class Class49 {
+ public Class49(){
+ new Class50();
+ }
+}
+class Class50 {
+ public Class50(){
+ new Class51();
+ }
+}
+class Class51 {
+ public Class51(){
+ new Class52();
+ }
+}
+class Class52 {
+ public Class52(){
+ new Class53();
+ }
+}
+class Class53 {
+ public Class53(){
+ new Class54();
+ }
+}
+class Class54 {
+ public Class54(){
+ new Class55();
+ }
+}
+class Class55 {
+ public Class55(){
+ new Class56();
+ }
+}
+class Class56 {
+ public Class56(){
+ new Class57();
+ }
+}
+class Class57 {
+ public Class57(){
+ new Class58();
+ }
+}
+class Class58 {
+ public Class58(){
+ new Class59();
+ }
+}
+class Class59 {
+ public Class59(){
+ new Class60();
+ }
+}
+class Class60 {
+ public Class60(){
+ new Class61();
+ }
+}
+class Class61 {
+ public Class61(){
+ new Class62();
+ }
+}
+class Class62 {
+ public Class62(){
+ new Class63();
+ }
+}
+class Class63 {
+ public Class63(){
+ new Class64();
+ }
+}
+class Class64 {
+ public Class64(){
+ new Class65();
+ }
+}
+class Class65 {
+ public Class65(){
+ new Class66();
+ }
+}
+class Class66 {
+ public Class66(){
+ new Class67();
+ }
+}
+class Class67 {
+ public Class67(){
+ new Class68();
+ }
+}
+class Class68 {
+ public Class68(){
+ new Class69();
+ }
+}
+class Class69 {
+ public Class69(){
+ new Class70();
+ }
+}
+class Class70 {
+ public Class70(){
+ new Class71();
+ }
+}
+class Class71 {
+ public Class71(){
+ new Class72();
+ }
+}
+class Class72 {
+ public Class72(){
+ new Class73();
+ }
+}
+class Class73 {
+ public Class73(){
+ new Class74();
+ }
+}
+class Class74 {
+ public Class74(){
+ new Class75();
+ }
+}
+class Class75 {
+ public Class75(){
+ new Class76();
+ }
+}
+class Class76 {
+ public Class76(){
+ new Class77();
+ }
+}
+class Class77 {
+ public Class77(){
+ new Class78();
+ }
+}
+class Class78 {
+ public Class78(){
+ new Class79();
+ }
+}
+class Class79 {
+ public Class79(){
+ new Class80();
+ }
+}
+class Class80 {
+ public Class80(){
+ new Class81();
+ }
+}
+class Class81 {
+ public Class81(){
+ new Class82();
+ }
+}
+class Class82 {
+ public Class82(){
+ new Class83();
+ }
+}
+class Class83 {
+ public Class83(){
+ new Class84();
+ }
+}
+class Class84 {
+ public Class84(){
+ new Class85();
+ }
+}
+class Class85 {
+ public Class85(){
+ new Class86();
+ }
+}
+class Class86 {
+ public Class86(){
+ new Class87();
+ }
+}
+class Class87 {
+ public Class87(){
+ new Class88();
+ }
+}
+class Class88 {
+ public Class88(){
+ new Class89();
+ }
+}
+class Class89 {
+ public Class89(){
+ new Class90();
+ }
+}
+class Class90 {
+ public Class90(){
+ new Class91();
+ }
+}
+class Class91 {
+ public Class91(){
+ new Class92();
+ }
+}
+class Class92 {
+ public Class92(){
+ new Class93();
+ }
+}
+class Class93 {
+ public Class93(){
+ new Class94();
+ }
+}
+class Class94 {
+ public Class94(){
+ new Class95();
+ }
+}
+class Class95 {
+ public Class95(){
+ new Class96();
+ }
+}
+class Class96 {
+ public Class96(){
+ new Class97();
+ }
+}
+class Class97 {
+ public Class97(){
+ new Class98();
+ }
+}
+class Class98 {
+ public Class98(){
+ new Class99();
+ }
+}
+class Class99 {
+ public Class99(){
+ new Class100();
+ }
+}
+class Class100 {
+ public Class100(){
+ new Class101();
+ }
+}
+class Class101 {
+ public Class101(){
+ new Class102();
+ }
+}
+class Class102 {
+ public Class102(){
+ new Class103();
+ }
+}
+class Class103 {
+ public Class103(){
+ new Class104();
+ }
+}
+class Class104 {
+ public Class104(){
+ new Class105();
+ }
+}
+class Class105 {
+ public Class105(){
+ new Class106();
+ }
+}
+class Class106 {
+ public Class106(){
+ new Class107();
+ }
+}
+class Class107 {
+ public Class107(){
+ new Class108();
+ }
+}
+class Class108 {
+ public Class108(){
+ new Class109();
+ }
+}
+class Class109 {
+ public Class109(){
+ new Class110();
+ }
+}
+class Class110 {
+ public Class110(){
+ new Class111();
+ }
+}
+class Class111 {
+ public Class111(){
+ new Class112();
+ }
+}
+class Class112 {
+ public Class112(){
+ new Class113();
+ }
+}
+class Class113 {
+ public Class113(){
+ new Class114();
+ }
+}
+class Class114 {
+ public Class114(){
+ new Class115();
+ }
+}
+class Class115 {
+ public Class115(){
+ new Class116();
+ }
+}
+class Class116 {
+ public Class116(){
+ new Class117();
+ }
+}
+class Class117 {
+ public Class117(){
+ new Class118();
+ }
+}
+class Class118 {
+ public Class118(){
+ new Class119();
+ }
+}
+class Class119 {
+ public Class119(){
+ new Class120();
+ }
+}
+class Class120 {
+ public Class120(){
+ new Class121();
+ }
+}
+class Class121 {
+ public Class121(){
+ new Class122();
+ }
+}
+class Class122 {
+ public Class122(){
+ new Class123();
+ }
+}
+class Class123 {
+ public Class123(){
+ new Class124();
+ }
+}
+class Class124 {
+ public Class124(){
+ new Class125();
+ }
+}
+class Class125 {
+ public Class125(){
+ new Class126();
+ }
+}
+class Class126 {
+ public Class126(){
+ new Class127();
+ }
+}
+class Class127 {
+ public Class127(){
+ new Class128();
+ }
+}
+class Class128 {
+ public Class128(){
+ new Class129();
+ }
+}
+class Class129 {
+ public Class129(){
+ new Class130();
+ }
+}
+class Class130 {
+ public Class130(){
+ new Class131();
+ }
+}
+class Class131 {
+ public Class131(){
+ new Class132();
+ }
+}
+class Class132 {
+ public Class132(){
+ new Class133();
+ }
+}
+class Class133 {
+ public Class133(){
+ new Class134();
+ }
+}
+class Class134 {
+ public Class134(){
+ new Class135();
+ }
+}
+class Class135 {
+ public Class135(){
+ new Class136();
+ }
+}
+class Class136 {
+ public Class136(){
+ new Class137();
+ }
+}
+class Class137 {
+ public Class137(){
+ new Class138();
+ }
+}
+class Class138 {
+ public Class138(){
+ new Class139();
+ }
+}
+class Class139 {
+ public Class139(){
+ new Class140();
+ }
+}
+class Class140 {
+ public Class140(){
+ new Class141();
+ }
+}
+class Class141 {
+ public Class141(){
+ new Class142();
+ }
+}
+class Class142 {
+ public Class142(){
+ new Class143();
+ }
+}
+class Class143 {
+ public Class143(){
+ new Class144();
+ }
+}
+class Class144 {
+ public Class144(){
+ new Class145();
+ }
+}
+class Class145 {
+ public Class145(){
+ new Class146();
+ }
+}
+class Class146 {
+ public Class146(){
+ new Class147();
+ }
+}
+class Class147 {
+ public Class147(){
+ new Class148();
+ }
+}
+class Class148 {
+ public Class148(){
+ new Class149();
+ }
+}
+class Class149 {
+ public Class149(){
+ new Class150();
+ }
+}
+class Class150 {
+ public Class150(){
+ new Class151();
+ }
+}
+class Class151 {
+ public Class151(){
+ new Class152();
+ }
+}
+class Class152 {
+ public Class152(){
+ new Class153();
+ }
+}
+class Class153 {
+ public Class153(){
+ new Class154();
+ }
+}
+class Class154 {
+ public Class154(){
+ new Class155();
+ }
+}
+class Class155 {
+ public Class155(){
+ new Class156();
+ }
+}
+class Class156 {
+ public Class156(){
+ new Class157();
+ }
+}
+class Class157 {
+ public Class157(){
+ new Class158();
+ }
+}
+class Class158 {
+ public Class158(){
+ new Class159();
+ }
+}
+class Class159 {
+ public Class159(){
+ new Class160();
+ }
+}
+class Class160 {
+ public Class160(){
+ new Class161();
+ }
+}
+class Class161 {
+ public Class161(){
+ new Class162();
+ }
+}
+class Class162 {
+ public Class162(){
+ new Class163();
+ }
+}
+class Class163 {
+ public Class163(){
+ new Class164();
+ }
+}
+class Class164 {
+ public Class164(){
+ new Class165();
+ }
+}
+class Class165 {
+ public Class165(){
+ new Class166();
+ }
+}
+class Class166 {
+ public Class166(){
+ new Class167();
+ }
+}
+class Class167 {
+ public Class167(){
+ new Class168();
+ }
+}
+class Class168 {
+ public Class168(){
+ new Class169();
+ }
+}
+class Class169 {
+ public Class169(){
+ new Class170();
+ }
+}
+class Class170 {
+ public Class170(){
+ new Class171();
+ }
+}
+class Class171 {
+ public Class171(){
+ new Class172();
+ }
+}
+class Class172 {
+ public Class172(){
+ new Class173();
+ }
+}
+class Class173 {
+ public Class173(){
+ new Class174();
+ }
+}
+class Class174 {
+ public Class174(){
+ new Class175();
+ }
+}
+class Class175 {
+ public Class175(){
+ new Class176();
+ }
+}
+class Class176 {
+ public Class176(){
+ new Class177();
+ }
+}
+class Class177 {
+ public Class177(){
+ new Class178();
+ }
+}
+class Class178 {
+ public Class178(){
+ new Class179();
+ }
+}
+class Class179 {
+ public Class179(){
+ new Class180();
+ }
+}
+class Class180 {
+ public Class180(){
+ new Class181();
+ }
+}
+class Class181 {
+ public Class181(){
+ new Class182();
+ }
+}
+class Class182 {
+ public Class182(){
+ new Class183();
+ }
+}
+class Class183 {
+ public Class183(){
+ new Class184();
+ }
+}
+class Class184 {
+ public Class184(){
+ new Class185();
+ }
+}
+class Class185 {
+ public Class185(){
+ new Class186();
+ }
+}
+class Class186 {
+ public Class186(){
+ new Class187();
+ }
+}
+class Class187 {
+ public Class187(){
+ new Class188();
+ }
+}
+class Class188 {
+ public Class188(){
+ new Class189();
+ }
+}
+class Class189 {
+ public Class189(){
+ new Class190();
+ }
+}
+class Class190 {
+ public Class190(){
+ new Class191();
+ }
+}
+class Class191 {
+ public Class191(){
+ new Class192();
+ }
+}
+class Class192 {
+ public Class192(){
+ new Class193();
+ }
+}
+class Class193 {
+ public Class193(){
+ new Class194();
+ }
+}
+class Class194 {
+ public Class194(){
+ new Class195();
+ }
+}
+class Class195 {
+ public Class195(){
+ new Class196();
+ }
+}
+class Class196 {
+ public Class196(){
+ new Class197();
+ }
+}
+class Class197 {
+ public Class197(){
+ new Class198();
+ }
+}
+class Class198 {
+ public Class198(){
+ new Class199();
+ }
+}
+class Class199 {
+ public Class199(){
+ new Class200();
+ }
+}
+class Class200 {
+ public Class200(){
+ new Class201();
+ }
+}
+class Class201 {
+ public Class201(){
+ new Class202();
+ }
+}
+class Class202 {
+ public Class202(){
+ new Class203();
+ }
+}
+class Class203 {
+ public Class203(){
+ new Class204();
+ }
+}
+class Class204 {
+ public Class204(){
+ new Class205();
+ }
+}
+class Class205 {
+ public Class205(){
+ new Class206();
+ }
+}
+class Class206 {
+ public Class206(){
+ new Class207();
+ }
+}
+class Class207 {
+ public Class207(){
+ new Class208();
+ }
+}
+class Class208 {
+ public Class208(){
+ new Class209();
+ }
+}
+class Class209 {
+ public Class209(){
+ new Class210();
+ }
+}
+class Class210 {
+ public Class210(){
+ new Class211();
+ }
+}
+class Class211 {
+ public Class211(){
+ new Class212();
+ }
+}
+class Class212 {
+ public Class212(){
+ new Class213();
+ }
+}
+class Class213 {
+ public Class213(){
+ new Class214();
+ }
+}
+class Class214 {
+ public Class214(){
+ new Class215();
+ }
+}
+class Class215 {
+ public Class215(){
+ new Class216();
+ }
+}
+class Class216 {
+ public Class216(){
+ new Class217();
+ }
+}
+class Class217 {
+ public Class217(){
+ new Class218();
+ }
+}
+class Class218 {
+ public Class218(){
+ new Class219();
+ }
+}
+class Class219 {
+ public Class219(){
+ new Class220();
+ }
+}
+class Class220 {
+ public Class220(){
+ new Class221();
+ }
+}
+class Class221 {
+ public Class221(){
+ new Class222();
+ }
+}
+class Class222 {
+ public Class222(){
+ new Class223();
+ }
+}
+class Class223 {
+ public Class223(){
+ new Class224();
+ }
+}
+class Class224 {
+ public Class224(){
+ new Class225();
+ }
+}
+class Class225 {
+ public Class225(){
+ new Class226();
+ }
+}
+class Class226 {
+ public Class226(){
+ new Class227();
+ }
+}
+class Class227 {
+ public Class227(){
+ new Class228();
+ }
+}
+class Class228 {
+ public Class228(){
+ new Class229();
+ }
+}
+class Class229 {
+ public Class229(){
+ new Class230();
+ }
+}
+class Class230 {
+ public Class230(){
+ new Class231();
+ }
+}
+class Class231 {
+ public Class231(){
+ new Class232();
+ }
+}
+class Class232 {
+ public Class232(){
+ new Class233();
+ }
+}
+class Class233 {
+ public Class233(){
+ new Class234();
+ }
+}
+class Class234 {
+ public Class234(){
+ new Class235();
+ }
+}
+class Class235 {
+ public Class235(){
+ new Class236();
+ }
+}
+class Class236 {
+ public Class236(){
+ new Class237();
+ }
+}
+class Class237 {
+ public Class237(){
+ new Class238();
+ }
+}
+class Class238 {
+ public Class238(){
+ new Class239();
+ }
+}
+class Class239 {
+ public Class239(){
+ new Class240();
+ }
+}
+class Class240 {
+ public Class240(){
+ new Class241();
+ }
+}
+class Class241 {
+ public Class241(){
+ new Class242();
+ }
+}
+class Class242 {
+ public Class242(){
+ new Class243();
+ }
+}
+class Class243 {
+ public Class243(){
+ new Class244();
+ }
+}
+class Class244 {
+ public Class244(){
+ new Class245();
+ }
+}
+class Class245 {
+ public Class245(){
+ new Class246();
+ }
+}
+class Class246 {
+ public Class246(){
+ new Class247();
+ }
+}
+class Class247 {
+ public Class247(){
+ new Class248();
+ }
+}
+class Class248 {
+ public Class248(){
+ new Class249();
+ }
+}
+class Class249 {
+ public Class249(){
+ new Class250();
+ }
+}
+class Class250 {
+ public Class250(){
+ new Class251();
+ }
+}
+class Class251 {
+ public Class251(){
+ new Class252();
+ }
+}
+class Class252 {
+ public Class252(){
+ new Class253();
+ }
+}
+class Class253 {
+ public Class253(){
+ new Class254();
+ }
+}
+class Class254 {
+ public Class254(){
+ new Class255();
+ }
+}
+class Class255 {
+ public Class255(){
+ new Class256();
+ }
+}
+class Class256 {
+ public Class256(){
+ new Class257();
+ }
+}
+class Class257 {
+ public Class257(){
+ new Class258();
+ }
+}
+class Class258 {
+ public Class258(){
+ new Class259();
+ }
+}
+class Class259 {
+ public Class259(){
+ new Class260();
+ }
+}
+class Class260 {
+ public Class260(){
+ new Class261();
+ }
+}
+class Class261 {
+ public Class261(){
+ new Class262();
+ }
+}
+class Class262 {
+ public Class262(){
+ new Class263();
+ }
+}
+class Class263 {
+ public Class263(){
+ new Class264();
+ }
+}
+class Class264 {
+ public Class264(){
+ new Class265();
+ }
+}
+class Class265 {
+ public Class265(){
+ new Class266();
+ }
+}
+class Class266 {
+ public Class266(){
+ new Class267();
+ }
+}
+class Class267 {
+ public Class267(){
+ new Class268();
+ }
+}
+class Class268 {
+ public Class268(){
+ new Class269();
+ }
+}
+class Class269 {
+ public Class269(){
+ new Class270();
+ }
+}
+class Class270 {
+ public Class270(){
+ new Class271();
+ }
+}
+class Class271 {
+ public Class271(){
+ new Class272();
+ }
+}
+class Class272 {
+ public Class272(){
+ new Class273();
+ }
+}
+class Class273 {
+ public Class273(){
+ new Class274();
+ }
+}
+class Class274 {
+ public Class274(){
+ new Class275();
+ }
+}
+class Class275 {
+ public Class275(){
+ new Class276();
+ }
+}
+class Class276 {
+ public Class276(){
+ new Class277();
+ }
+}
+class Class277 {
+ public Class277(){
+ new Class278();
+ }
+}
+class Class278 {
+ public Class278(){
+ new Class279();
+ }
+}
+class Class279 {
+ public Class279(){
+ new Class280();
+ }
+}
+class Class280 {
+ public Class280(){
+ new Class281();
+ }
+}
+class Class281 {
+ public Class281(){
+ new Class282();
+ }
+}
+class Class282 {
+ public Class282(){
+ new Class283();
+ }
+}
+class Class283 {
+ public Class283(){
+ new Class284();
+ }
+}
+class Class284 {
+ public Class284(){
+ new Class285();
+ }
+}
+class Class285 {
+ public Class285(){
+ new Class286();
+ }
+}
+class Class286 {
+ public Class286(){
+ new Class287();
+ }
+}
+class Class287 {
+ public Class287(){
+ new Class288();
+ }
+}
+class Class288 {
+ public Class288(){
+ new Class289();
+ }
+}
+class Class289 {
+ public Class289(){
+ new Class290();
+ }
+}
+class Class290 {
+ public Class290(){
+ new Class291();
+ }
+}
+class Class291 {
+ public Class291(){
+ new Class292();
+ }
+}
+class Class292 {
+ public Class292(){
+ new Class293();
+ }
+}
+class Class293 {
+ public Class293(){
+ new Class294();
+ }
+}
+class Class294 {
+ public Class294(){
+ new Class295();
+ }
+}
+class Class295 {
+ public Class295(){
+ new Class296();
+ }
+}
+class Class296 {
+ public Class296(){
+ new Class297();
+ }
+}
+class Class297 {
+ public Class297(){
+ new Class298();
+ }
+}
+class Class298 {
+ public Class298(){
+ new Class299();
+ }
+}
+class Class299 {
+ public Class299(){
+ new Class300();
+ }
+}
+class Class300 {
+ public Class300(){
+ new Class301();
+ }
+}
+class Class301 {
+ public Class301(){
+ new Class302();
+ }
+}
+class Class302 {
+ public Class302(){
+ new Class303();
+ }
+}
+class Class303 {
+ public Class303(){
+ new Class304();
+ }
+}
+class Class304 {
+ public Class304(){
+ new Class305();
+ }
+}
+class Class305 {
+ public Class305(){
+ new Class306();
+ }
+}
+class Class306 {
+ public Class306(){
+ new Class307();
+ }
+}
+class Class307 {
+ public Class307(){
+ new Class308();
+ }
+}
+class Class308 {
+ public Class308(){
+ new Class309();
+ }
+}
+class Class309 {
+ public Class309(){
+ new Class310();
+ }
+}
+class Class310 {
+ public Class310(){
+ new Class311();
+ }
+}
+class Class311 {
+ public Class311(){
+ new Class312();
+ }
+}
+class Class312 {
+ public Class312(){
+ new Class313();
+ }
+}
+class Class313 {
+ public Class313(){
+ new Class314();
+ }
+}
+class Class314 {
+ public Class314(){
+ new Class315();
+ }
+}
+class Class315 {
+ public Class315(){
+ new Class316();
+ }
+}
+class Class316 {
+ public Class316(){
+ new Class317();
+ }
+}
+class Class317 {
+ public Class317(){
+ new Class318();
+ }
+}
+class Class318 {
+ public Class318(){
+ new Class319();
+ }
+}
+class Class319 {
+ public Class319(){
+ new Class320();
+ }
+}
+class Class320 {
+ public Class320(){
+ new Class321();
+ }
+}
+class Class321 {
+ public Class321(){
+ new Class322();
+ }
+}
+class Class322 {
+ public Class322(){
+ new Class323();
+ }
+}
+class Class323 {
+ public Class323(){
+ new Class324();
+ }
+}
+class Class324 {
+ public Class324(){
+ new Class325();
+ }
+}
+class Class325 {
+ public Class325(){
+ new Class326();
+ }
+}
+class Class326 {
+ public Class326(){
+ new Class327();
+ }
+}
+class Class327 {
+ public Class327(){
+ new Class328();
+ }
+}
+class Class328 {
+ public Class328(){
+ new Class329();
+ }
+}
+class Class329 {
+ public Class329(){
+ new Class330();
+ }
+}
+class Class330 {
+ public Class330(){
+ new Class331();
+ }
+}
+class Class331 {
+ public Class331(){
+ new Class332();
+ }
+}
+class Class332 {
+ public Class332(){
+ new Class333();
+ }
+}
+class Class333 {
+ public Class333(){
+ new Class334();
+ }
+}
+class Class334 {
+ public Class334(){
+ new Class335();
+ }
+}
+class Class335 {
+ public Class335(){
+ new Class336();
+ }
+}
+class Class336 {
+ public Class336(){
+ new Class337();
+ }
+}
+class Class337 {
+ public Class337(){
+ new Class338();
+ }
+}
+class Class338 {
+ public Class338(){
+ new Class339();
+ }
+}
+class Class339 {
+ public Class339(){
+ new Class340();
+ }
+}
+class Class340 {
+ public Class340(){
+ new Class341();
+ }
+}
+class Class341 {
+ public Class341(){
+ new Class342();
+ }
+}
+class Class342 {
+ public Class342(){
+ new Class343();
+ }
+}
+class Class343 {
+ public Class343(){
+ new Class344();
+ }
+}
+class Class344 {
+ public Class344(){
+ new Class345();
+ }
+}
+class Class345 {
+ public Class345(){
+ new Class346();
+ }
+}
+class Class346 {
+ public Class346(){
+ new Class347();
+ }
+}
+class Class347 {
+ public Class347(){
+ new Class348();
+ }
+}
+class Class348 {
+ public Class348(){
+ new Class349();
+ }
+}
+class Class349 {
+ public Class349(){
+ new Class350();
+ }
+}
+class Class350 {
+ public Class350(){
+ new Class351();
+ }
+}
+class Class351 {
+ public Class351(){
+ new Class352();
+ }
+}
+class Class352 {
+ public Class352(){
+ new Class353();
+ }
+}
+class Class353 {
+ public Class353(){
+ new Class354();
+ }
+}
+class Class354 {
+ public Class354(){
+ new Class355();
+ }
+}
+class Class355 {
+ public Class355(){
+ new Class356();
+ }
+}
+class Class356 {
+ public Class356(){
+ new Class357();
+ }
+}
+class Class357 {
+ public Class357(){
+ new Class358();
+ }
+}
+class Class358 {
+ public Class358(){
+ new Class359();
+ }
+}
+class Class359 {
+ public Class359(){
+ new Class360();
+ }
+}
+class Class360 {
+ public Class360(){
+ new Class361();
+ }
+}
+class Class361 {
+ public Class361(){
+ new Class362();
+ }
+}
+class Class362 {
+ public Class362(){
+ new Class363();
+ }
+}
+class Class363 {
+ public Class363(){
+ new Class364();
+ }
+}
+class Class364 {
+ public Class364(){
+ new Class365();
+ }
+}
+class Class365 {
+ public Class365(){
+ new Class366();
+ }
+}
+class Class366 {
+ public Class366(){
+ new Class367();
+ }
+}
+class Class367 {
+ public Class367(){
+ new Class368();
+ }
+}
+class Class368 {
+ public Class368(){
+ new Class369();
+ }
+}
+class Class369 {
+ public Class369(){
+ new Class370();
+ }
+}
+class Class370 {
+ public Class370(){
+ new Class371();
+ }
+}
+class Class371 {
+ public Class371(){
+ new Class372();
+ }
+}
+class Class372 {
+ public Class372(){
+ new Class373();
+ }
+}
+class Class373 {
+ public Class373(){
+ new Class374();
+ }
+}
+class Class374 {
+ public Class374(){
+ new Class375();
+ }
+}
+class Class375 {
+ public Class375(){
+ new Class376();
+ }
+}
+class Class376 {
+ public Class376(){
+ new Class377();
+ }
+}
+class Class377 {
+ public Class377(){
+ new Class378();
+ }
+}
+class Class378 {
+ public Class378(){
+ new Class379();
+ }
+}
+class Class379 {
+ public Class379(){
+ new Class380();
+ }
+}
+class Class380 {
+ public Class380(){
+ new Class381();
+ }
+}
+class Class381 {
+ public Class381(){
+ new Class382();
+ }
+}
+class Class382 {
+ public Class382(){
+ new Class383();
+ }
+}
+class Class383 {
+ public Class383(){
+ new Class384();
+ }
+}
+class Class384 {
+ public Class384(){
+ new Class385();
+ }
+}
+class Class385 {
+ public Class385(){
+ new Class386();
+ }
+}
+class Class386 {
+ public Class386(){
+ new Class387();
+ }
+}
+class Class387 {
+ public Class387(){
+ new Class388();
+ }
+}
+class Class388 {
+ public Class388(){
+ new Class389();
+ }
+}
+class Class389 {
+ public Class389(){
+ new Class390();
+ }
+}
+class Class390 {
+ public Class390(){
+ new Class391();
+ }
+}
+class Class391 {
+ public Class391(){
+ new Class392();
+ }
+}
+class Class392 {
+ public Class392(){
+ new Class393();
+ }
+}
+class Class393 {
+ public Class393(){
+ new Class394();
+ }
+}
+class Class394 {
+ public Class394(){
+ new Class395();
+ }
+}
+class Class395 {
+ public Class395(){
+ new Class396();
+ }
+}
+class Class396 {
+ public Class396(){
+ new Class397();
+ }
+}
+class Class397 {
+ public Class397(){
+ new Class398();
+ }
+}
+class Class398 {
+ public Class398(){
+ new Class399();
+ }
+}
+class Class399 {
+ public Class399(){
+ new Class400();
+ }
+}
+class Class400 {
+ public Class400(){
+ new Class401();
+ }
+}
+class Class401 {
+ public Class401(){
+ new Class402();
+ }
+}
+class Class402 {
+ public Class402(){
+ new Class403();
+ }
+}
+class Class403 {
+ public Class403(){
+ new Class404();
+ }
+}
+class Class404 {
+ public Class404(){
+ new Class405();
+ }
+}
+class Class405 {
+ public Class405(){
+ new Class406();
+ }
+}
+class Class406 {
+ public Class406(){
+ new Class407();
+ }
+}
+class Class407 {
+ public Class407(){
+ new Class408();
+ }
+}
+class Class408 {
+ public Class408(){
+ new Class409();
+ }
+}
+class Class409 {
+ public Class409(){
+ new Class410();
+ }
+}
+class Class410 {
+ public Class410(){
+ new Class411();
+ }
+}
+class Class411 {
+ public Class411(){
+ new Class412();
+ }
+}
+class Class412 {
+ public Class412(){
+ new Class413();
+ }
+}
+class Class413 {
+ public Class413(){
+ new Class414();
+ }
+}
+class Class414 {
+ public Class414(){
+ new Class415();
+ }
+}
+class Class415 {
+ public Class415(){
+ new Class416();
+ }
+}
+class Class416 {
+ public Class416(){
+ new Class417();
+ }
+}
+class Class417 {
+ public Class417(){
+ new Class418();
+ }
+}
+class Class418 {
+ public Class418(){
+ new Class419();
+ }
+}
+class Class419 {
+ public Class419(){
+ new Class420();
+ }
+}
+class Class420 {
+ public Class420(){
+ new Class421();
+ }
+}
+class Class421 {
+ public Class421(){
+ new Class422();
+ }
+}
+class Class422 {
+ public Class422(){
+ new Class423();
+ }
+}
+class Class423 {
+ public Class423(){
+ new Class424();
+ }
+}
+class Class424 {
+ public Class424(){
+ new Class425();
+ }
+}
+class Class425 {
+ public Class425(){
+ new Class426();
+ }
+}
+class Class426 {
+ public Class426(){
+ new Class427();
+ }
+}
+class Class427 {
+ public Class427(){
+ new Class428();
+ }
+}
+class Class428 {
+ public Class428(){
+ new Class429();
+ }
+}
+class Class429 {
+ public Class429(){
+ new Class430();
+ }
+}
+class Class430 {
+ public Class430(){
+ new Class431();
+ }
+}
+class Class431 {
+ public Class431(){
+ new Class432();
+ }
+}
+class Class432 {
+ public Class432(){
+ new Class433();
+ }
+}
+class Class433 {
+ public Class433(){
+ new Class434();
+ }
+}
+class Class434 {
+ public Class434(){
+ new Class435();
+ }
+}
+class Class435 {
+ public Class435(){
+ new Class436();
+ }
+}
+class Class436 {
+ public Class436(){
+ new Class437();
+ }
+}
+class Class437 {
+ public Class437(){
+ new Class438();
+ }
+}
+class Class438 {
+ public Class438(){
+ new Class439();
+ }
+}
+class Class439 {
+ public Class439(){
+ new Class440();
+ }
+}
+class Class440 {
+ public Class440(){
+ new Class441();
+ }
+}
+class Class441 {
+ public Class441(){
+ new Class442();
+ }
+}
+class Class442 {
+ public Class442(){
+ new Class443();
+ }
+}
+class Class443 {
+ public Class443(){
+ new Class444();
+ }
+}
+class Class444 {
+ public Class444(){
+ new Class445();
+ }
+}
+class Class445 {
+ public Class445(){
+ new Class446();
+ }
+}
+class Class446 {
+ public Class446(){
+ new Class447();
+ }
+}
+class Class447 {
+ public Class447(){
+ new Class448();
+ }
+}
+class Class448 {
+ public Class448(){
+ new Class449();
+ }
+}
+class Class449 {
+ public Class449(){
+ new Class450();
+ }
+}
+class Class450 {
+ public Class450(){
+ new Class451();
+ }
+}
+class Class451 {
+ public Class451(){
+ new Class452();
+ }
+}
+class Class452 {
+ public Class452(){
+ new Class453();
+ }
+}
+class Class453 {
+ public Class453(){
+ new Class454();
+ }
+}
+class Class454 {
+ public Class454(){
+ new Class455();
+ }
+}
+class Class455 {
+ public Class455(){
+ new Class456();
+ }
+}
+class Class456 {
+ public Class456(){
+ new Class457();
+ }
+}
+class Class457 {
+ public Class457(){
+ new Class458();
+ }
+}
+class Class458 {
+ public Class458(){
+ new Class459();
+ }
+}
+class Class459 {
+ public Class459(){
+ new Class460();
+ }
+}
+class Class460 {
+ public Class460(){
+ new Class461();
+ }
+}
+class Class461 {
+ public Class461(){
+ new Class462();
+ }
+}
+class Class462 {
+ public Class462(){
+ new Class463();
+ }
+}
+class Class463 {
+ public Class463(){
+ new Class464();
+ }
+}
+class Class464 {
+ public Class464(){
+ new Class465();
+ }
+}
+class Class465 {
+ public Class465(){
+ new Class466();
+ }
+}
+class Class466 {
+ public Class466(){
+ new Class467();
+ }
+}
+class Class467 {
+ public Class467(){
+ new Class468();
+ }
+}
+class Class468 {
+ public Class468(){
+ new Class469();
+ }
+}
+class Class469 {
+ public Class469(){
+ new Class470();
+ }
+}
+class Class470 {
+ public Class470(){
+ new Class471();
+ }
+}
+class Class471 {
+ public Class471(){
+ new Class472();
+ }
+}
+class Class472 {
+ public Class472(){
+ new Class473();
+ }
+}
+class Class473 {
+ public Class473(){
+ new Class474();
+ }
+}
+class Class474 {
+ public Class474(){
+ new Class475();
+ }
+}
+class Class475 {
+ public Class475(){
+ new Class476();
+ }
+}
+class Class476 {
+ public Class476(){
+ new Class477();
+ }
+}
+class Class477 {
+ public Class477(){
+ new Class478();
+ }
+}
+class Class478 {
+ public Class478(){
+ new Class479();
+ }
+}
+class Class479 {
+ public Class479(){
+ new Class480();
+ }
+}
+class Class480 {
+ public Class480(){
+ new Class481();
+ }
+}
+class Class481 {
+ public Class481(){
+ new Class482();
+ }
+}
+class Class482 {
+ public Class482(){
+ new Class483();
+ }
+}
+class Class483 {
+ public Class483(){
+ new Class484();
+ }
+}
+class Class484 {
+ public Class484(){
+ new Class485();
+ }
+}
+class Class485 {
+ public Class485(){
+ new Class486();
+ }
+}
+class Class486 {
+ public Class486(){
+ new Class487();
+ }
+}
+class Class487 {
+ public Class487(){
+ new Class488();
+ }
+}
+class Class488 {
+ public Class488(){
+ new Class489();
+ }
+}
+class Class489 {
+ public Class489(){
+ new Class490();
+ }
+}
+class Class490 {
+ public Class490(){
+ new Class491();
+ }
+}
+class Class491 {
+ public Class491(){
+ new Class492();
+ }
+}
+class Class492 {
+ public Class492(){
+ new Class493();
+ }
+}
+class Class493 {
+ public Class493(){
+ new Class494();
+ }
+}
+class Class494 {
+ public Class494(){
+ new Class495();
+ }
+}
+class Class495 {
+ public Class495(){
+ new Class496();
+ }
+}
+class Class496 {
+ public Class496(){
+ new Class497();
+ }
+}
+class Class497 {
+ public Class497(){
+ new Class498();
+ }
+}
+class Class498 {
+ public Class498(){
+ new Class499();
+ }
+}
+class Class499 {
+ public Class499(){
+ new Class500();
+ }
+}
+class Class500 {
+ public Class500(){
+ new Class501();
+ }
+}
+class Class501 {
+ public Class501(){
+ new Class502();
+ }
+}
+class Class502 {
+ public Class502(){
+ new Class503();
+ }
+}
+class Class503 {
+ public Class503(){
+ new Class504();
+ }
+}
+class Class504 {
+ public Class504(){
+ new Class505();
+ }
+}
+class Class505 {
+ public Class505(){
+ new Class506();
+ }
+}
+class Class506 {
+ public Class506(){
+ new Class507();
+ }
+}
+class Class507 {
+ public Class507(){
+ new Class508();
+ }
+}
+class Class508 {
+ public Class508(){
+ new Class509();
+ }
+}
+class Class509 {
+ public Class509(){
+ new Class510();
+ }
+}
+class Class510 {
+ public Class510(){
+ new Class511();
+ }
+}
+class Class511 {
+ public Class511(){
+ new Class512();
+ }
+}
+class Class512 {
+ public Class512(){
+ new Class513();
+ }
+}
+class Class513 {
+ public Class513(){
+ new Class514();
+ }
+}
+class Class514 {
+ public Class514(){
+ new Class515();
+ }
+}
+class Class515 {
+ public Class515(){
+ new Class516();
+ }
+}
+class Class516 {
+ public Class516(){
+ new Class517();
+ }
+}
+class Class517 {
+ public Class517(){
+ new Class518();
+ }
+}
+class Class518 {
+ public Class518(){
+ new Class519();
+ }
+}
+class Class519 {
+ public Class519(){
+ new Class520();
+ }
+}
+class Class520 {
+ public Class520(){
+ new Class521();
+ }
+}
+class Class521 {
+ public Class521(){
+ new Class522();
+ }
+}
+class Class522 {
+ public Class522(){
+ new Class523();
+ }
+}
+class Class523 {
+ public Class523(){
+ new Class524();
+ }
+}
+class Class524 {
+ public Class524(){
+ new Class525();
+ }
+}
+class Class525 {
+ public Class525(){
+ new Class526();
+ }
+}
+class Class526 {
+ public Class526(){
+ new Class527();
+ }
+}
+class Class527 {
+ public Class527(){
+ new Class528();
+ }
+}
+class Class528 {
+ public Class528(){
+ new Class529();
+ }
+}
+class Class529 {
+ public Class529(){
+ new Class530();
+ }
+}
+class Class530 {
+ public Class530(){
+ new Class531();
+ }
+}
+class Class531 {
+ public Class531(){
+ new Class532();
+ }
+}
+class Class532 {
+ public Class532(){
+ new Class533();
+ }
+}
+class Class533 {
+ public Class533(){
+ new Class534();
+ }
+}
+class Class534 {
+ public Class534(){
+ new Class535();
+ }
+}
+class Class535 {
+ public Class535(){
+ new Class536();
+ }
+}
+class Class536 {
+ public Class536(){
+ new Class537();
+ }
+}
+class Class537 {
+ public Class537(){
+ new Class538();
+ }
+}
+class Class538 {
+ public Class538(){
+ new Class539();
+ }
+}
+class Class539 {
+ public Class539(){
+ new Class540();
+ }
+}
+class Class540 {
+ public Class540(){
+ new Class541();
+ }
+}
+class Class541 {
+ public Class541(){
+ new Class542();
+ }
+}
+class Class542 {
+ public Class542(){
+ new Class543();
+ }
+}
+class Class543 {
+ public Class543(){
+ new Class544();
+ }
+}
+class Class544 {
+ public Class544(){
+ new Class545();
+ }
+}
+class Class545 {
+ public Class545(){
+ new Class546();
+ }
+}
+class Class546 {
+ public Class546(){
+ new Class547();
+ }
+}
+class Class547 {
+ public Class547(){
+ new Class548();
+ }
+}
+class Class548 {
+ public Class548(){
+ new Class549();
+ }
+}
+class Class549 {
+ public Class549(){
+ new Class550();
+ }
+}
+class Class550 {
+ public Class550(){
+ new Class551();
+ }
+}
+class Class551 {
+ public Class551(){
+ new Class552();
+ }
+}
+class Class552 {
+ public Class552(){
+ new Class553();
+ }
+}
+class Class553 {
+ public Class553(){
+ new Class554();
+ }
+}
+class Class554 {
+ public Class554(){
+ new Class555();
+ }
+}
+class Class555 {
+ public Class555(){
+ new Class556();
+ }
+}
+class Class556 {
+ public Class556(){
+ new Class557();
+ }
+}
+class Class557 {
+ public Class557(){
+ new Class558();
+ }
+}
+class Class558 {
+ public Class558(){
+ new Class559();
+ }
+}
+class Class559 {
+ public Class559(){
+ new Class560();
+ }
+}
+class Class560 {
+ public Class560(){
+ new Class561();
+ }
+}
+class Class561 {
+ public Class561(){
+ new Class562();
+ }
+}
+class Class562 {
+ public Class562(){
+ new Class563();
+ }
+}
+class Class563 {
+ public Class563(){
+ new Class564();
+ }
+}
+class Class564 {
+ public Class564(){
+ new Class565();
+ }
+}
+class Class565 {
+ public Class565(){
+ new Class566();
+ }
+}
+class Class566 {
+ public Class566(){
+ new Class567();
+ }
+}
+class Class567 {
+ public Class567(){
+ new Class568();
+ }
+}
+class Class568 {
+ public Class568(){
+ new Class569();
+ }
+}
+class Class569 {
+ public Class569(){
+ new Class570();
+ }
+}
+class Class570 {
+ public Class570(){
+ new Class571();
+ }
+}
+class Class571 {
+ public Class571(){
+ new Class572();
+ }
+}
+class Class572 {
+ public Class572(){
+ new Class573();
+ }
+}
+class Class573 {
+ public Class573(){
+ new Class574();
+ }
+}
+class Class574 {
+ public Class574(){
+ new Class575();
+ }
+}
+class Class575 {
+ public Class575(){
+ new Class576();
+ }
+}
+class Class576 {
+ public Class576(){
+ new Class577();
+ }
+}
+class Class577 {
+ public Class577(){
+ new Class578();
+ }
+}
+class Class578 {
+ public Class578(){
+ new Class579();
+ }
+}
+class Class579 {
+ public Class579(){
+ new Class580();
+ }
+}
+class Class580 {
+ public Class580(){
+ new Class581();
+ }
+}
+class Class581 {
+ public Class581(){
+ new Class582();
+ }
+}
+class Class582 {
+ public Class582(){
+ new Class583();
+ }
+}
+class Class583 {
+ public Class583(){
+ new Class584();
+ }
+}
+class Class584 {
+ public Class584(){
+ new Class585();
+ }
+}
+class Class585 {
+ public Class585(){
+ new Class586();
+ }
+}
+class Class586 {
+ public Class586(){
+ new Class587();
+ }
+}
+class Class587 {
+ public Class587(){
+ new Class588();
+ }
+}
+class Class588 {
+ public Class588(){
+ new Class589();
+ }
+}
+class Class589 {
+ public Class589(){
+ new Class590();
+ }
+}
+class Class590 {
+ public Class590(){
+ new Class591();
+ }
+}
+class Class591 {
+ public Class591(){
+ new Class592();
+ }
+}
+class Class592 {
+ public Class592(){
+ new Class593();
+ }
+}
+class Class593 {
+ public Class593(){
+ new Class594();
+ }
+}
+class Class594 {
+ public Class594(){
+ new Class595();
+ }
+}
+class Class595 {
+ public Class595(){
+ new Class596();
+ }
+}
+class Class596 {
+ public Class596(){
+ new Class597();
+ }
+}
+class Class597 {
+ public Class597(){
+ new Class598();
+ }
+}
+class Class598 {
+ public Class598(){
+ new Class599();
+ }
+}
+class Class599 {
+ public Class599(){
+ new Class600();
+ }
+}
+class Class600 {
+ public Class600(){
+ new Class601();
+ }
+}
+class Class601 {
+ public Class601(){
+ new Class602();
+ }
+}
+class Class602 {
+ public Class602(){
+ new Class603();
+ }
+}
+class Class603 {
+ public Class603(){
+ new Class604();
+ }
+}
+class Class604 {
+ public Class604(){
+ new Class605();
+ }
+}
+class Class605 {
+ public Class605(){
+ new Class606();
+ }
+}
+class Class606 {
+ public Class606(){
+ new Class607();
+ }
+}
+class Class607 {
+ public Class607(){
+ new Class608();
+ }
+}
+class Class608 {
+ public Class608(){
+ new Class609();
+ }
+}
+class Class609 {
+ public Class609(){
+ new Class610();
+ }
+}
+class Class610 {
+ public Class610(){
+ new Class611();
+ }
+}
+class Class611 {
+ public Class611(){
+ new Class612();
+ }
+}
+class Class612 {
+ public Class612(){
+ new Class613();
+ }
+}
+class Class613 {
+ public Class613(){
+ new Class614();
+ }
+}
+class Class614 {
+ public Class614(){
+ new Class615();
+ }
+}
+class Class615 {
+ public Class615(){
+ new Class616();
+ }
+}
+class Class616 {
+ public Class616(){
+ new Class617();
+ }
+}
+class Class617 {
+ public Class617(){
+ new Class618();
+ }
+}
+class Class618 {
+ public Class618(){
+ new Class619();
+ }
+}
+class Class619 {
+ public Class619(){
+ new Class620();
+ }
+}
+class Class620 {
+ public Class620(){
+ new Class621();
+ }
+}
+class Class621 {
+ public Class621(){
+ new Class622();
+ }
+}
+class Class622 {
+ public Class622(){
+ new Class623();
+ }
+}
+class Class623 {
+ public Class623(){
+ new Class624();
+ }
+}
+class Class624 {
+ public Class624(){
+ new Class625();
+ }
+}
+class Class625 {
+ public Class625(){
+ new Class626();
+ }
+}
+class Class626 {
+ public Class626(){
+ new Class627();
+ }
+}
+class Class627 {
+ public Class627(){
+ new Class628();
+ }
+}
+class Class628 {
+ public Class628(){
+ new Class629();
+ }
+}
+class Class629 {
+ public Class629(){
+ new Class630();
+ }
+}
+class Class630 {
+ public Class630(){
+ new Class631();
+ }
+}
+class Class631 {
+ public Class631(){
+ new Class632();
+ }
+}
+class Class632 {
+ public Class632(){
+ new Class633();
+ }
+}
+class Class633 {
+ public Class633(){
+ new Class634();
+ }
+}
+class Class634 {
+ public Class634(){
+ new Class635();
+ }
+}
+class Class635 {
+ public Class635(){
+ new Class636();
+ }
+}
+class Class636 {
+ public Class636(){
+ new Class637();
+ }
+}
+class Class637 {
+ public Class637(){
+ new Class638();
+ }
+}
+class Class638 {
+ public Class638(){
+ new Class639();
+ }
+}
+class Class639 {
+ public Class639(){
+ new Class640();
+ }
+}
+class Class640 {
+ public Class640(){
+ new Class641();
+ }
+}
+class Class641 {
+ public Class641(){
+ new Class642();
+ }
+}
+class Class642 {
+ public Class642(){
+ new Class643();
+ }
+}
+class Class643 {
+ public Class643(){
+ new Class644();
+ }
+}
+class Class644 {
+ public Class644(){
+ new Class645();
+ }
+}
+class Class645 {
+ public Class645(){
+ new Class646();
+ }
+}
+class Class646 {
+ public Class646(){
+ new Class647();
+ }
+}
+class Class647 {
+ public Class647(){
+ new Class648();
+ }
+}
+class Class648 {
+ public Class648(){
+ new Class649();
+ }
+}
+class Class649 {
+ public Class649(){
+ new Class650();
+ }
+}
+class Class650 {
+ public Class650(){
+ new Class651();
+ }
+}
+class Class651 {
+ public Class651(){
+ new Class652();
+ }
+}
+class Class652 {
+ public Class652(){
+ new Class653();
+ }
+}
+class Class653 {
+ public Class653(){
+ new Class654();
+ }
+}
+class Class654 {
+ public Class654(){
+ new Class655();
+ }
+}
+class Class655 {
+ public Class655(){
+ new Class656();
+ }
+}
+class Class656 {
+ public Class656(){
+ new Class657();
+ }
+}
+class Class657 {
+ public Class657(){
+ new Class658();
+ }
+}
+class Class658 {
+ public Class658(){
+ new Class659();
+ }
+}
+class Class659 {
+ public Class659(){
+ new Class660();
+ }
+}
+class Class660 {
+ public Class660(){
+ new Class661();
+ }
+}
+class Class661 {
+ public Class661(){
+ new Class662();
+ }
+}
+class Class662 {
+ public Class662(){
+ new Class663();
+ }
+}
+class Class663 {
+ public Class663(){
+ new Class664();
+ }
+}
+class Class664 {
+ public Class664(){
+ new Class665();
+ }
+}
+class Class665 {
+ public Class665(){
+ new Class666();
+ }
+}
+class Class666 {
+ public Class666(){
+ new Class667();
+ }
+}
+class Class667 {
+ public Class667(){
+ new Class668();
+ }
+}
+class Class668 {
+ public Class668(){
+ new Class669();
+ }
+}
+class Class669 {
+ public Class669(){
+ new Class670();
+ }
+}
+class Class670 {
+ public Class670(){
+ new Class671();
+ }
+}
+class Class671 {
+ public Class671(){
+ new Class672();
+ }
+}
+class Class672 {
+ public Class672(){
+ new Class673();
+ }
+}
+class Class673 {
+ public Class673(){
+ new Class674();
+ }
+}
+class Class674 {
+ public Class674(){
+ new Class675();
+ }
+}
+class Class675 {
+ public Class675(){
+ new Class676();
+ }
+}
+class Class676 {
+ public Class676(){
+ new Class677();
+ }
+}
+class Class677 {
+ public Class677(){
+ new Class678();
+ }
+}
+class Class678 {
+ public Class678(){
+ new Class679();
+ }
+}
+class Class679 {
+ public Class679(){
+ new Class680();
+ }
+}
+class Class680 {
+ public Class680(){
+ new Class681();
+ }
+}
+class Class681 {
+ public Class681(){
+ new Class682();
+ }
+}
+class Class682 {
+ public Class682(){
+ new Class683();
+ }
+}
+class Class683 {
+ public Class683(){
+ new Class684();
+ }
+}
+class Class684 {
+ public Class684(){
+ new Class685();
+ }
+}
+class Class685 {
+ public Class685(){
+ new Class686();
+ }
+}
+class Class686 {
+ public Class686(){
+ new Class687();
+ }
+}
+class Class687 {
+ public Class687(){
+ new Class688();
+ }
+}
+class Class688 {
+ public Class688(){
+ new Class689();
+ }
+}
+class Class689 {
+ public Class689(){
+ new Class690();
+ }
+}
+class Class690 {
+ public Class690(){
+ new Class691();
+ }
+}
+class Class691 {
+ public Class691(){
+ new Class692();
+ }
+}
+class Class692 {
+ public Class692(){
+ new Class693();
+ }
+}
+class Class693 {
+ public Class693(){
+ new Class694();
+ }
+}
+class Class694 {
+ public Class694(){
+ new Class695();
+ }
+}
+class Class695 {
+ public Class695(){
+ new Class696();
+ }
+}
+class Class696 {
+ public Class696(){
+ new Class697();
+ }
+}
+class Class697 {
+ public Class697(){
+ new Class698();
+ }
+}
+class Class698 {
+ public Class698(){
+ new Class699();
+ }
+}
+class Class699 {
+ public Class699(){
+ new Class700();
+ }
+}
+class Class700 {
+ public Class700(){
+ new Class701();
+ }
+}
+class Class701 {
+ public Class701(){
+ new Class702();
+ }
+}
+class Class702 {
+ public Class702(){
+ new Class703();
+ }
+}
+class Class703 {
+ public Class703(){
+ new Class704();
+ }
+}
+class Class704 {
+ public Class704(){
+ new Class705();
+ }
+}
+class Class705 {
+ public Class705(){
+ new Class706();
+ }
+}
+class Class706 {
+ public Class706(){
+ new Class707();
+ }
+}
+class Class707 {
+ public Class707(){
+ new Class708();
+ }
+}
+class Class708 {
+ public Class708(){
+ new Class709();
+ }
+}
+class Class709 {
+ public Class709(){
+ new Class710();
+ }
+}
+class Class710 {
+ public Class710(){
+ new Class711();
+ }
+}
+class Class711 {
+ public Class711(){
+ new Class712();
+ }
+}
+class Class712 {
+ public Class712(){
+ new Class713();
+ }
+}
+class Class713 {
+ public Class713(){
+ new Class714();
+ }
+}
+class Class714 {
+ public Class714(){
+ new Class715();
+ }
+}
+class Class715 {
+ public Class715(){
+ new Class716();
+ }
+}
+class Class716 {
+ public Class716(){
+ new Class717();
+ }
+}
+class Class717 {
+ public Class717(){
+ new Class718();
+ }
+}
+class Class718 {
+ public Class718(){
+ new Class719();
+ }
+}
+class Class719 {
+ public Class719(){
+ new Class720();
+ }
+}
+class Class720 {
+ public Class720(){
+ new Class721();
+ }
+}
+class Class721 {
+ public Class721(){
+ new Class722();
+ }
+}
+class Class722 {
+ public Class722(){
+ new Class723();
+ }
+}
+class Class723 {
+ public Class723(){
+ new Class724();
+ }
+}
+class Class724 {
+ public Class724(){
+ new Class725();
+ }
+}
+class Class725 {
+ public Class725(){
+ new Class726();
+ }
+}
+class Class726 {
+ public Class726(){
+ new Class727();
+ }
+}
+class Class727 {
+ public Class727(){
+ new Class728();
+ }
+}
+class Class728 {
+ public Class728(){
+ new Class729();
+ }
+}
+class Class729 {
+ public Class729(){
+ new Class730();
+ }
+}
+class Class730 {
+ public Class730(){
+ new Class731();
+ }
+}
+class Class731 {
+ public Class731(){
+ new Class732();
+ }
+}
+class Class732 {
+ public Class732(){
+ new Class733();
+ }
+}
+class Class733 {
+ public Class733(){
+ new Class734();
+ }
+}
+class Class734 {
+ public Class734(){
+ new Class735();
+ }
+}
+class Class735 {
+ public Class735(){
+ new Class736();
+ }
+}
+class Class736 {
+ public Class736(){
+ new Class737();
+ }
+}
+class Class737 {
+ public Class737(){
+ new Class738();
+ }
+}
+class Class738 {
+ public Class738(){
+ new Class739();
+ }
+}
+class Class739 {
+ public Class739(){
+ new Class740();
+ }
+}
+class Class740 {
+ public Class740(){
+ new Class741();
+ }
+}
+class Class741 {
+ public Class741(){
+ new Class742();
+ }
+}
+class Class742 {
+ public Class742(){
+ new Class743();
+ }
+}
+class Class743 {
+ public Class743(){
+ new Class744();
+ }
+}
+class Class744 {
+ public Class744(){
+ new Class745();
+ }
+}
+class Class745 {
+ public Class745(){
+ new Class746();
+ }
+}
+class Class746 {
+ public Class746(){
+ new Class747();
+ }
+}
+class Class747 {
+ public Class747(){
+ new Class748();
+ }
+}
+class Class748 {
+ public Class748(){
+ new Class749();
+ }
+}
+class Class749 {
+ public Class749(){
+ new Class750();
+ }
+}
+class Class750 {
+ public Class750(){
+ new Class751();
+ }
+}
+class Class751 {
+ public Class751(){
+ new Class752();
+ }
+}
+class Class752 {
+ public Class752(){
+ new Class753();
+ }
+}
+class Class753 {
+ public Class753(){
+ new Class754();
+ }
+}
+class Class754 {
+ public Class754(){
+ new Class755();
+ }
+}
+class Class755 {
+ public Class755(){
+ new Class756();
+ }
+}
+class Class756 {
+ public Class756(){
+ new Class757();
+ }
+}
+class Class757 {
+ public Class757(){
+ new Class758();
+ }
+}
+class Class758 {
+ public Class758(){
+ new Class759();
+ }
+}
+class Class759 {
+ public Class759(){
+ new Class760();
+ }
+}
+class Class760 {
+ public Class760(){
+ new Class761();
+ }
+}
+class Class761 {
+ public Class761(){
+ new Class762();
+ }
+}
+class Class762 {
+ public Class762(){
+ new Class763();
+ }
+}
+class Class763 {
+ public Class763(){
+ new Class764();
+ }
+}
+class Class764 {
+ public Class764(){
+ new Class765();
+ }
+}
+class Class765 {
+ public Class765(){
+ new Class766();
+ }
+}
+class Class766 {
+ public Class766(){
+ new Class767();
+ }
+}
+class Class767 {
+ public Class767(){
+ new Class768();
+ }
+}
+class Class768 {
+ public Class768(){
+ new Class769();
+ }
+}
+class Class769 {
+ public Class769(){
+ new Class770();
+ }
+}
+class Class770 {
+ public Class770(){
+ new Class771();
+ }
+}
+class Class771 {
+ public Class771(){
+ new Class772();
+ }
+}
+class Class772 {
+ public Class772(){
+ new Class773();
+ }
+}
+class Class773 {
+ public Class773(){
+ new Class774();
+ }
+}
+class Class774 {
+ public Class774(){
+ new Class775();
+ }
+}
+class Class775 {
+ public Class775(){
+ new Class776();
+ }
+}
+class Class776 {
+ public Class776(){
+ new Class777();
+ }
+}
+class Class777 {
+ public Class777(){
+ new Class778();
+ }
+}
+class Class778 {
+ public Class778(){
+ new Class779();
+ }
+}
+class Class779 {
+ public Class779(){
+ new Class780();
+ }
+}
+class Class780 {
+ public Class780(){
+ new Class781();
+ }
+}
+class Class781 {
+ public Class781(){
+ new Class782();
+ }
+}
+class Class782 {
+ public Class782(){
+ new Class783();
+ }
+}
+class Class783 {
+ public Class783(){
+ new Class784();
+ }
+}
+class Class784 {
+ public Class784(){
+ new Class785();
+ }
+}
+class Class785 {
+ public Class785(){
+ new Class786();
+ }
+}
+class Class786 {
+ public Class786(){
+ new Class787();
+ }
+}
+class Class787 {
+ public Class787(){
+ new Class788();
+ }
+}
+class Class788 {
+ public Class788(){
+ new Class789();
+ }
+}
+class Class789 {
+ public Class789(){
+ new Class790();
+ }
+}
+class Class790 {
+ public Class790(){
+ new Class791();
+ }
+}
+class Class791 {
+ public Class791(){
+ new Class792();
+ }
+}
+class Class792 {
+ public Class792(){
+ new Class793();
+ }
+}
+class Class793 {
+ public Class793(){
+ new Class794();
+ }
+}
+class Class794 {
+ public Class794(){
+ new Class795();
+ }
+}
+class Class795 {
+ public Class795(){
+ new Class796();
+ }
+}
+class Class796 {
+ public Class796(){
+ new Class797();
+ }
+}
+class Class797 {
+ public Class797(){
+ new Class798();
+ }
+}
+class Class798 {
+ public Class798(){
+ new Class799();
+ }
+}
+class Class799 {
+ public Class799(){
+ new Class800();
+ }
+}
+class Class800 {
+ public Class800(){
+ new Class801();
+ }
+}
+class Class801 {
+ public Class801(){
+ new Class802();
+ }
+}
+class Class802 {
+ public Class802(){
+ new Class803();
+ }
+}
+class Class803 {
+ public Class803(){
+ new Class804();
+ }
+}
+class Class804 {
+ public Class804(){
+ new Class805();
+ }
+}
+class Class805 {
+ public Class805(){
+ new Class806();
+ }
+}
+class Class806 {
+ public Class806(){
+ new Class807();
+ }
+}
+class Class807 {
+ public Class807(){
+ new Class808();
+ }
+}
+class Class808 {
+ public Class808(){
+ new Class809();
+ }
+}
+class Class809 {
+ public Class809(){
+ new Class810();
+ }
+}
+class Class810 {
+ public Class810(){
+ new Class811();
+ }
+}
+class Class811 {
+ public Class811(){
+ new Class812();
+ }
+}
+class Class812 {
+ public Class812(){
+ new Class813();
+ }
+}
+class Class813 {
+ public Class813(){
+ new Class814();
+ }
+}
+class Class814 {
+ public Class814(){
+ new Class815();
+ }
+}
+class Class815 {
+ public Class815(){
+ new Class816();
+ }
+}
+class Class816 {
+ public Class816(){
+ new Class817();
+ }
+}
+class Class817 {
+ public Class817(){
+ new Class818();
+ }
+}
+class Class818 {
+ public Class818(){
+ new Class819();
+ }
+}
+class Class819 {
+ public Class819(){
+ new Class820();
+ }
+}
+class Class820 {
+ public Class820(){
+ new Class821();
+ }
+}
+class Class821 {
+ public Class821(){
+ new Class822();
+ }
+}
+class Class822 {
+ public Class822(){
+ new Class823();
+ }
+}
+class Class823 {
+ public Class823(){
+ new Class824();
+ }
+}
+class Class824 {
+ public Class824(){
+ new Class825();
+ }
+}
+class Class825 {
+ public Class825(){
+ new Class826();
+ }
+}
+class Class826 {
+ public Class826(){
+ new Class827();
+ }
+}
+class Class827 {
+ public Class827(){
+ new Class828();
+ }
+}
+class Class828 {
+ public Class828(){
+ new Class829();
+ }
+}
+class Class829 {
+ public Class829(){
+ new Class830();
+ }
+}
+class Class830 {
+ public Class830(){
+ new Class831();
+ }
+}
+class Class831 {
+ public Class831(){
+ new Class832();
+ }
+}
+class Class832 {
+ public Class832(){
+ new Class833();
+ }
+}
+class Class833 {
+ public Class833(){
+ new Class834();
+ }
+}
+class Class834 {
+ public Class834(){
+ new Class835();
+ }
+}
+class Class835 {
+ public Class835(){
+ new Class836();
+ }
+}
+class Class836 {
+ public Class836(){
+ new Class837();
+ }
+}
+class Class837 {
+ public Class837(){
+ new Class838();
+ }
+}
+class Class838 {
+ public Class838(){
+ new Class839();
+ }
+}
+class Class839 {
+ public Class839(){
+ new Class840();
+ }
+}
+class Class840 {
+ public Class840(){
+ new Class841();
+ }
+}
+class Class841 {
+ public Class841(){
+ new Class842();
+ }
+}
+class Class842 {
+ public Class842(){
+ new Class843();
+ }
+}
+class Class843 {
+ public Class843(){
+ new Class844();
+ }
+}
+class Class844 {
+ public Class844(){
+ new Class845();
+ }
+}
+class Class845 {
+ public Class845(){
+ new Class846();
+ }
+}
+class Class846 {
+ public Class846(){
+ new Class847();
+ }
+}
+class Class847 {
+ public Class847(){
+ new Class848();
+ }
+}
+class Class848 {
+ public Class848(){
+ new Class849();
+ }
+}
+class Class849 {
+ public Class849(){
+ new Class850();
+ }
+}
+class Class850 {
+ public Class850(){
+ new Class851();
+ }
+}
+class Class851 {
+ public Class851(){
+ new Class852();
+ }
+}
+class Class852 {
+ public Class852(){
+ new Class853();
+ }
+}
+class Class853 {
+ public Class853(){
+ new Class854();
+ }
+}
+class Class854 {
+ public Class854(){
+ new Class855();
+ }
+}
+class Class855 {
+ public Class855(){
+ new Class856();
+ }
+}
+class Class856 {
+ public Class856(){
+ new Class857();
+ }
+}
+class Class857 {
+ public Class857(){
+ new Class858();
+ }
+}
+class Class858 {
+ public Class858(){
+ new Class859();
+ }
+}
+class Class859 {
+ public Class859(){
+ new Class860();
+ }
+}
+class Class860 {
+ public Class860(){
+ new Class861();
+ }
+}
+class Class861 {
+ public Class861(){
+ new Class862();
+ }
+}
+class Class862 {
+ public Class862(){
+ new Class863();
+ }
+}
+class Class863 {
+ public Class863(){
+ new Class864();
+ }
+}
+class Class864 {
+ public Class864(){
+ new Class865();
+ }
+}
+class Class865 {
+ public Class865(){
+ new Class866();
+ }
+}
+class Class866 {
+ public Class866(){
+ new Class867();
+ }
+}
+class Class867 {
+ public Class867(){
+ new Class868();
+ }
+}
+class Class868 {
+ public Class868(){
+ new Class869();
+ }
+}
+class Class869 {
+ public Class869(){
+ new Class870();
+ }
+}
+class Class870 {
+ public Class870(){
+ new Class871();
+ }
+}
+class Class871 {
+ public Class871(){
+ new Class872();
+ }
+}
+class Class872 {
+ public Class872(){
+ new Class873();
+ }
+}
+class Class873 {
+ public Class873(){
+ new Class874();
+ }
+}
+class Class874 {
+ public Class874(){
+ new Class875();
+ }
+}
+class Class875 {
+ public Class875(){
+ new Class876();
+ }
+}
+class Class876 {
+ public Class876(){
+ new Class877();
+ }
+}
+class Class877 {
+ public Class877(){
+ new Class878();
+ }
+}
+class Class878 {
+ public Class878(){
+ new Class879();
+ }
+}
+class Class879 {
+ public Class879(){
+ new Class880();
+ }
+}
+class Class880 {
+ public Class880(){
+ new Class881();
+ }
+}
+class Class881 {
+ public Class881(){
+ new Class882();
+ }
+}
+class Class882 {
+ public Class882(){
+ new Class883();
+ }
+}
+class Class883 {
+ public Class883(){
+ new Class884();
+ }
+}
+class Class884 {
+ public Class884(){
+ new Class885();
+ }
+}
+class Class885 {
+ public Class885(){
+ new Class886();
+ }
+}
+class Class886 {
+ public Class886(){
+ new Class887();
+ }
+}
+class Class887 {
+ public Class887(){
+ new Class888();
+ }
+}
+class Class888 {
+ public Class888(){
+ new Class889();
+ }
+}
+class Class889 {
+ public Class889(){
+ new Class890();
+ }
+}
+class Class890 {
+ public Class890(){
+ new Class891();
+ }
+}
+class Class891 {
+ public Class891(){
+ new Class892();
+ }
+}
+class Class892 {
+ public Class892(){
+ new Class893();
+ }
+}
+class Class893 {
+ public Class893(){
+ new Class894();
+ }
+}
+class Class894 {
+ public Class894(){
+ new Class895();
+ }
+}
+class Class895 {
+ public Class895(){
+ new Class896();
+ }
+}
+class Class896 {
+ public Class896(){
+ new Class897();
+ }
+}
+class Class897 {
+ public Class897(){
+ new Class898();
+ }
+}
+class Class898 {
+ public Class898(){
+ new Class899();
+ }
+}
+class Class899 {
+ public Class899(){
+ new Class900();
+ }
+}
+class Class900 {
+ public Class900(){
+ new Class901();
+ }
+}
+class Class901 {
+ public Class901(){
+ new Class902();
+ }
+}
+class Class902 {
+ public Class902(){
+ new Class903();
+ }
+}
+class Class903 {
+ public Class903(){
+ new Class904();
+ }
+}
+class Class904 {
+ public Class904(){
+ new Class905();
+ }
+}
+class Class905 {
+ public Class905(){
+ new Class906();
+ }
+}
+class Class906 {
+ public Class906(){
+ new Class907();
+ }
+}
+class Class907 {
+ public Class907(){
+ new Class908();
+ }
+}
+class Class908 {
+ public Class908(){
+ new Class909();
+ }
+}
+class Class909 {
+ public Class909(){
+ new Class910();
+ }
+}
+class Class910 {
+ public Class910(){
+ new Class911();
+ }
+}
+class Class911 {
+ public Class911(){
+ new Class912();
+ }
+}
+class Class912 {
+ public Class912(){
+ new Class913();
+ }
+}
+class Class913 {
+ public Class913(){
+ new Class914();
+ }
+}
+class Class914 {
+ public Class914(){
+ new Class915();
+ }
+}
+class Class915 {
+ public Class915(){
+ new Class916();
+ }
+}
+class Class916 {
+ public Class916(){
+ new Class917();
+ }
+}
+class Class917 {
+ public Class917(){
+ new Class918();
+ }
+}
+class Class918 {
+ public Class918(){
+ new Class919();
+ }
+}
+class Class919 {
+ public Class919(){
+ new Class920();
+ }
+}
+class Class920 {
+ public Class920(){
+ new Class921();
+ }
+}
+class Class921 {
+ public Class921(){
+ new Class922();
+ }
+}
+class Class922 {
+ public Class922(){
+ new Class923();
+ }
+}
+class Class923 {
+ public Class923(){
+ new Class924();
+ }
+}
+class Class924 {
+ public Class924(){
+ new Class925();
+ }
+}
+class Class925 {
+ public Class925(){
+ new Class926();
+ }
+}
+class Class926 {
+ public Class926(){
+ new Class927();
+ }
+}
+class Class927 {
+ public Class927(){
+ new Class928();
+ }
+}
+class Class928 {
+ public Class928(){
+ new Class929();
+ }
+}
+class Class929 {
+ public Class929(){
+ new Class930();
+ }
+}
+class Class930 {
+ public Class930(){
+ new Class931();
+ }
+}
+class Class931 {
+ public Class931(){
+ new Class932();
+ }
+}
+class Class932 {
+ public Class932(){
+ new Class933();
+ }
+}
+class Class933 {
+ public Class933(){
+ new Class934();
+ }
+}
+class Class934 {
+ public Class934(){
+ new Class935();
+ }
+}
+class Class935 {
+ public Class935(){
+ new Class936();
+ }
+}
+class Class936 {
+ public Class936(){
+ new Class937();
+ }
+}
+class Class937 {
+ public Class937(){
+ new Class938();
+ }
+}
+class Class938 {
+ public Class938(){
+ new Class939();
+ }
+}
+class Class939 {
+ public Class939(){
+ new Class940();
+ }
+}
+class Class940 {
+ public Class940(){
+ new Class941();
+ }
+}
+class Class941 {
+ public Class941(){
+ new Class942();
+ }
+}
+class Class942 {
+ public Class942(){
+ new Class943();
+ }
+}
+class Class943 {
+ public Class943(){
+ new Class944();
+ }
+}
+class Class944 {
+ public Class944(){
+ new Class945();
+ }
+}
+class Class945 {
+ public Class945(){
+ new Class946();
+ }
+}
+class Class946 {
+ public Class946(){
+ new Class947();
+ }
+}
+class Class947 {
+ public Class947(){
+ new Class948();
+ }
+}
+class Class948 {
+ public Class948(){
+ new Class949();
+ }
+}
+class Class949 {
+ public Class949(){
+ new Class950();
+ }
+}
+class Class950 {
+ public Class950(){
+ new Class951();
+ }
+}
+class Class951 {
+ public Class951(){
+ new Class952();
+ }
+}
+class Class952 {
+ public Class952(){
+ new Class953();
+ }
+}
+class Class953 {
+ public Class953(){
+ new Class954();
+ }
+}
+class Class954 {
+ public Class954(){
+ new Class955();
+ }
+}
+class Class955 {
+ public Class955(){
+ new Class956();
+ }
+}
+class Class956 {
+ public Class956(){
+ new Class957();
+ }
+}
+class Class957 {
+ public Class957(){
+ new Class958();
+ }
+}
+class Class958 {
+ public Class958(){
+ new Class959();
+ }
+}
+class Class959 {
+ public Class959(){
+ new Class960();
+ }
+}
+class Class960 {
+ public Class960(){
+ new Class961();
+ }
+}
+class Class961 {
+ public Class961(){
+ new Class962();
+ }
+}
+class Class962 {
+ public Class962(){
+ new Class963();
+ }
+}
+class Class963 {
+ public Class963(){
+ new Class964();
+ }
+}
+class Class964 {
+ public Class964(){
+ new Class965();
+ }
+}
+class Class965 {
+ public Class965(){
+ new Class966();
+ }
+}
+class Class966 {
+ public Class966(){
+ new Class967();
+ }
+}
+class Class967 {
+ public Class967(){
+ new Class968();
+ }
+}
+class Class968 {
+ public Class968(){
+ new Class969();
+ }
+}
+class Class969 {
+ public Class969(){
+ new Class970();
+ }
+}
+class Class970 {
+ public Class970(){
+ new Class971();
+ }
+}
+class Class971 {
+ public Class971(){
+ new Class972();
+ }
+}
+class Class972 {
+ public Class972(){
+ new Class973();
+ }
+}
+class Class973 {
+ public Class973(){
+ new Class974();
+ }
+}
+class Class974 {
+ public Class974(){
+ new Class975();
+ }
+}
+class Class975 {
+ public Class975(){
+ new Class976();
+ }
+}
+class Class976 {
+ public Class976(){
+ new Class977();
+ }
+}
+class Class977 {
+ public Class977(){
+ new Class978();
+ }
+}
+class Class978 {
+ public Class978(){
+ new Class979();
+ }
+}
+class Class979 {
+ public Class979(){
+ new Class980();
+ }
+}
+class Class980 {
+ public Class980(){
+ new Class981();
+ }
+}
+class Class981 {
+ public Class981(){
+ new Class982();
+ }
+}
+class Class982 {
+ public Class982(){
+ new Class983();
+ }
+}
+class Class983 {
+ public Class983(){
+ new Class984();
+ }
+}
+class Class984 {
+ public Class984(){
+ new Class985();
+ }
+}
+class Class985 {
+ public Class985(){
+ new Class986();
+ }
+}
+class Class986 {
+ public Class986(){
+ new Class987();
+ }
+}
+class Class987 {
+ public Class987(){
+ new Class988();
+ }
+}
+class Class988 {
+ public Class988(){
+ new Class989();
+ }
+}
+class Class989 {
+ public Class989(){
+ new Class990();
+ }
+}
+class Class990 {
+ public Class990(){
+ new Class991();
+ }
+}
+class Class991 {
+ public Class991(){
+ new Class992();
+ }
+}
+class Class992 {
+ public Class992(){
+ new Class993();
+ }
+}
+class Class993 {
+ public Class993(){
+ new Class994();
+ }
+}
+class Class994 {
+ public Class994(){
+ new Class995();
+ }
+}
+class Class995 {
+ public Class995(){
+ new Class996();
+ }
+}
+class Class996 {
+ public Class996(){
+ new Class997();
+ }
+}
+class Class997 {
+ public Class997(){
+ new Class998();
+ }
+}
+class Class998 {
+ public Class998(){
+ new Class999();
+ }
+}
+class Class999 {
+ public Class999(){
+ new Class1000();
+ }
+}
+class Class1000 {
+ public Class1000(){
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/FinDiag.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/FinDiag.java
new file mode 100644
index 00000000000..58cda02b24f
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/FinDiag.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+import nsk.share.runner.RunParams;
+
+/**
+ * Helper that prints information about FinMemoryObjects.
+ */
+public class FinDiag implements Runnable {
+ private long sleepTime;
+
+ public FinDiag() {
+ this(RunParams.getInstance().getSleepTime());
+ }
+
+ public FinDiag(long sleepTime) {
+ this.sleepTime = sleepTime;
+ }
+
+ public void run() {
+ FinMemoryObject.dumpStatistics();
+ // Ensure that interrupt status is not lost
+ if (Thread.currentThread().isInterrupted())
+ return;
+ try {
+ Thread.sleep(sleepTime);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/FinMemoryObject.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/FinMemoryObject.java
new file mode 100644
index 00000000000..0123d799668
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/FinMemoryObject.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+import java.io.PrintStream;
+
+/**
+ * An object that occupies approximately given number of bytes in memory
+ * and also records number of allocated and finalized instances.
+ */
+public class FinMemoryObject extends FinMemoryObject1 {
+ private static int finalizedCount;
+
+ public FinMemoryObject(int size) {
+ super(size);
+ }
+
+ protected void finalize() {
+ synchronized (FinMemoryObject.class) {
+ ++finalizedCount;
+ }
+ }
+
+ /**
+ * Returns the number of finalized FinMemoryObjects.
+ */
+ public static int getFinalizedCount() {
+ return finalizedCount;
+ }
+
+ /**
+ * Returns the number of live FinMemoryObjects (allocated but not finalized).
+ */
+ public static int getLiveCount() {
+ return allocatedCount - finalizedCount;
+ }
+
+ public static void dumpStatistics(PrintStream out) {
+ Algorithms.tryToPrintln(out, "Object count: " + getLiveCount());
+ }
+
+ public static void dumpStatistics() {
+ dumpStatistics(System.out);
+ }
+
+ public static boolean isAllFinalized() {
+ return getLiveCount() == 0;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/FinMemoryObject1.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/FinMemoryObject1.java
new file mode 100644
index 00000000000..80ffffc589b
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/FinMemoryObject1.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+import java.io.PrintStream;
+import nsk.share.gc.Algorithms;
+
+/**
+ * An object that occupies approximately given number of bytes in memory
+ * and also has finalizer that does nothing.
+ */
+public class FinMemoryObject1 extends MemoryObject {
+ protected static int allocatedCount;
+
+ public FinMemoryObject1(int size) {
+ super(size);
+ synchronized (FinMemoryObject.class) {
+ ++allocatedCount;
+ }
+ }
+
+ protected void finalize() {
+ }
+
+ /**
+ * Returns the number of allocated FinMemoryObjects.
+ */
+ public static int getAllocatedCount() {
+ return allocatedCount;
+ }
+
+ public static void dumpStatistics(PrintStream out) {
+ Algorithms.tryToPrintln(out, "Object count: " + getAllocatedCount());
+ }
+
+ public static void dumpStatistics() {
+ dumpStatistics(System.out);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/GC.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/GC.java
new file mode 100644
index 00000000000..6b33783306f
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/GC.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+import nsk.share.test.*;
+import nsk.share.runner.*;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.gp.GarbageProducerAware;
+import nsk.share.gc.gp.GarbageProducer1Aware;
+import nsk.share.gc.gp.MemoryStrategy;
+import nsk.share.gc.gp.MemoryStrategyAware;
+import nsk.share.gc.gp.GarbageUtils;
+import nsk.share.gc.lock.Lockers;
+import nsk.share.gc.lock.LockersAware;
+import nsk.share.gc.lock.LockerUtils;
+
+/**
+ * Utility methods for GC tests.
+ */
+public class GC extends nsk.share.test.Tests {
+ protected static class GCTestRunner extends TestRunner {
+ private GCParams gcParams;
+ private GarbageProducer garbageProducer;
+ private GarbageProducer garbageProducer1;
+ private MemoryStrategy memoryStrategy;
+ private Lockers lockers;
+
+ public GCTestRunner(Test test, String[] args) {
+ super(test, args);
+ }
+
+ private GCParams getGCParams(String[] args) {
+ if (gcParams == null) {
+ gcParams = GCParams.getInstance();
+ gcParams.parseCommandLine(args);
+ }
+ return gcParams;
+ }
+
+ private GarbageProducer getGarbageProducer(String[] args) {
+ if (garbageProducer == null) {
+ garbageProducer = GarbageUtils.getGarbageProducer(getGCParams(args).getGarbageProducerId());
+ configure(garbageProducer);
+ }
+ return garbageProducer;
+ }
+
+ private GarbageProducer getGarbageProducer1(String[] args) {
+ if (garbageProducer1 == null) {
+ garbageProducer1 = GarbageUtils.getGarbageProducer(getGCParams(args).getGarbageProducer1Id());
+ configure(garbageProducer1);
+ }
+ return garbageProducer1;
+ }
+
+ private MemoryStrategy getMemoryStrategy(String[] args) {
+ if (memoryStrategy == null) {
+ memoryStrategy = MemoryStrategy.fromString(getGCParams(args).getMemoryStrategyId());
+ configure(memoryStrategy);
+ }
+ return memoryStrategy;
+ }
+
+ private Lockers getLockers(String[] args) {
+ if (lockers == null) {
+ lockers = LockerUtils.getLockers(getGCParams(args).getLockersId());
+ configure(lockers);
+ }
+ return lockers;
+ }
+
+ public void configure(Object test) {
+ super.configure(test);
+ if (test instanceof GCParamsAware)
+ ((GCParamsAware) test).setGCParams(getGCParams(args));
+ if (test instanceof GarbageProducerAware)
+ ((GarbageProducerAware) test).setGarbageProducer(getGarbageProducer(args));
+ if (test instanceof GarbageProducer1Aware)
+ ((GarbageProducer1Aware) test).setGarbageProducer1(getGarbageProducer1(args));
+ if (test instanceof MemoryStrategyAware)
+ ((MemoryStrategyAware) test).setMemoryStrategy(getMemoryStrategy(args));
+ if (test instanceof LockersAware)
+ ((LockersAware) test).setLockers(getLockers(args));
+ }
+
+
+ }
+
+ private GC() {
+ }
+
+ public static void runTest(Test test, String[] args) {
+ new GCTestRunner(test, args).run();
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/GCParams.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/GCParams.java
new file mode 100644
index 00000000000..02b65dceb8d
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/GCParams.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+import java.io.PrintStream;
+
+public class GCParams {
+ private String garbageProducerId;
+ private String garbageProducer1Id;
+ private String memoryStrategyId;
+ private String lockersId;
+
+ public final String getGarbageProducerId() {
+ return garbageProducerId;
+ }
+
+ public final void setGarbageProducerId(String garbageProducerId) {
+ this.garbageProducerId = garbageProducerId;
+ }
+
+ public final String getGarbageProducer1Id() {
+ return garbageProducer1Id;
+ }
+
+ public final void setGarbageProducer1Id(String garbageProducer1Id) {
+ this.garbageProducer1Id = garbageProducer1Id;
+ }
+
+ public final String getMemoryStrategyId() {
+ return memoryStrategyId;
+ }
+
+ public final void setMemoryStrategyId(String memoryStrategyId) {
+ this.memoryStrategyId = memoryStrategyId;
+ }
+
+ public final String getLockersId() {
+ return lockersId;
+ }
+
+ public final void setLockersId(String lockersId) {
+ this.lockersId = lockersId;
+ }
+
+ public void parseCommandLine(String[] args) {
+ if (args == null)
+ return;
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i].equals("-gp"))
+ garbageProducerId = args[++i];
+ else if (args[i].equals("-gp1"))
+ garbageProducer1Id = args[++i];
+ else if (args[i].equals("-ms"))
+ memoryStrategyId = args[++i];
+ else if (args[i].equals("-lockers"))
+ lockersId = args[++i];
+ }
+ printConfig(System.out);
+ }
+
+ public void prinUsage() {
+ }
+
+ public void printConfig(PrintStream out) {
+ }
+
+ private static GCParams instance;
+
+ public static GCParams getInstance() {
+ synchronized (GCParams.class) {
+ if (instance == null)
+ instance = new GCParams();
+ return instance;
+ }
+ }
+
+ public static void setInstance(GCParams gcParams) {
+ synchronized (GCParams.class) {
+ instance = gcParams;
+ }
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/GCParamsAware.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/GCParamsAware.java
new file mode 100644
index 00000000000..190dd9cbf5d
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/GCParamsAware.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+/**
+ * Marker interface to signify that run params are needed.
+ */
+public interface GCParamsAware {
+ public void setGCParams(GCParams gcParams);
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/GCTestBase.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/GCTestBase.java
new file mode 100644
index 00000000000..7421da7b769
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/GCTestBase.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+import nsk.share.test.TestBase;
+import nsk.share.runner.RunParams;
+import nsk.share.runner.RunParamsAware;
+
+public abstract class GCTestBase extends TestBase implements RunParamsAware, GCParamsAware {
+ protected RunParams runParams;
+ protected GCParams gcParams;
+
+ public final void setRunParams(RunParams runParams) {
+ this.runParams = runParams;
+ }
+
+ public final void setGCParams(GCParams gcParams) {
+ this.gcParams = gcParams;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/IndexPair.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/IndexPair.java
new file mode 100644
index 00000000000..ed48ea3ac38
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/IndexPair.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+public final class IndexPair {
+ private int i, j;
+
+ public IndexPair(int i, int j) {
+ setI(i);
+ setJ(j);
+ }
+
+ public int getI() {
+ return i;
+ }
+
+ public void setI(int i) {
+ this.i = i;
+ }
+
+ public int getJ() {
+ return j;
+ }
+
+ public void setJ(int j) {
+ this.j = j;
+ }
+
+ public boolean equals(IndexPair pair) {
+ return (this.i == pair.i && this.j == pair.j);
+ }
+
+ public boolean equals(Object o) {
+ return o instanceof IndexPair && equals((IndexPair) o);
+ }
+
+ public int hashCode() {
+ return i << 16 + j;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/LinkedMemoryObject.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/LinkedMemoryObject.java
new file mode 100644
index 00000000000..15257903220
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/LinkedMemoryObject.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+/**
+ * An object that occupies approximately given number of bytes in memory
+ * and has forward and backward links to other objects.
+ */
+public class LinkedMemoryObject extends MemoryObject {
+ private LinkedMemoryObject next;
+ private LinkedMemoryObject prev;
+
+ /**
+ * Create an object that occupies given number of bytes.
+ *
+ * @param arraySize size
+ */
+ public LinkedMemoryObject(int size) {
+ super(size - 2 * Memory.getReferenceSize());
+ }
+
+ public LinkedMemoryObject(int size, LinkedMemoryObject next) {
+ super(size - 2 * Memory.getReferenceSize());
+ setNext(next);
+ }
+
+ public LinkedMemoryObject(int size, LinkedMemoryObject next, LinkedMemoryObject prev) {
+ super(size - 2 * Memory.getReferenceSize());
+ setNext(next);
+ setPrev(prev);
+ }
+
+ public final void setNext(LinkedMemoryObject next) {
+ this.next = next;
+ }
+
+ public final void setPrev(LinkedMemoryObject prev) {
+ this.prev = prev;
+ }
+
+ public final LinkedMemoryObject getNext() {
+ return next;
+ }
+
+ public final LinkedMemoryObject getPrev() {
+ return prev;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Matrix.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Matrix.java
new file mode 100644
index 00000000000..73587b7a06f
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Matrix.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+public class Matrix {
+ private int cellSize;
+ private int matrixSize;
+ private Cell matrix[][];
+ private int nKnockedOut; // number of cells "nulled out"
+
+ public Matrix(int matrixSize, int cellSize) {
+ this.matrixSize = matrixSize;
+ this.cellSize = cellSize;
+ matrix = new Cell[matrixSize][matrixSize];
+ populate();
+ }
+
+ public void populate() {
+ for (int i = 0; i < matrixSize ; i++) {
+ for( int j = 0 ; j < matrixSize ; j++) {
+ matrix[i][j] = new Cell(cellSize, i);
+ }
+ }
+ }
+
+ public int returnArrayBound() {
+ return matrixSize - 1;
+ }
+
+ public synchronized void clear(int i, int j) {
+ matrix[i][j] = null;
+ ++nKnockedOut;
+ }
+
+ public synchronized void repopulate(int i, int j) {
+ matrix[i][j] = new Cell(cellSize, i + j);
+ --nKnockedOut;
+ }
+
+ public synchronized void resetCellCount() {
+ nKnockedOut = 0;
+ }
+
+ public synchronized int getCellCount() {
+ return nKnockedOut;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Memory.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Memory.java
new file mode 100644
index 00000000000..f5c70671e5e
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Memory.java
@@ -0,0 +1,513 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+import nsk.share.test.LocalRandom;
+import java.io.PrintStream;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.tree.*;
+import nsk.share.gc.gp.MemoryStrategy;
+import nsk.share.log.Log;
+
+/**
+ * Different utility methods to work with memory objects.
+ */
+public final class Memory {
+ private static int bits = 0;
+ private static int referenceSize = 0;
+ private static int objectExtraSize = 0;
+
+ private Memory() {
+ }
+
+ private static int getBits() {
+ if (bits == 0)
+ bits = Integer.parseInt(System.getProperty("sun.arch.data.model"));
+ return bits;
+ }
+
+ /**
+ * Get size of one object reference.
+ *
+ * TODO: somehow determine the real value
+ */
+ public static int getReferenceSize() {
+ if (referenceSize == 0)
+ referenceSize = (getBits() == 64) ? 8 : 4;
+ return referenceSize;
+ }
+
+ /**
+ * Get size of primitive type int.
+ */
+ public static int getIntSize() {
+ return 4;
+ }
+
+ /**
+ * Get size of primitive type boolean.
+ */
+ public static int getBooleanSize() {
+ return 1;
+ }
+
+ /**
+ * Get size of primitive type byte.
+ */
+ public static int getByteSize() {
+ return 1;
+ }
+
+ /**
+ * Get size of primitive type char.
+ */
+ public static int getCharSize() {
+ return 2;
+ }
+
+ /**
+ * Get size of primitive type short.
+ */
+ public static int getShortSize() {
+ return 2;
+ }
+
+ /**
+ * Get size of primitive type long.
+ */
+ public static int getLongSize() {
+ return 8;
+ }
+
+ /**
+ * Get size of primitive type float.
+ */
+ public static int getFloatSize() {
+ return 4;
+ }
+
+ /**
+ * Get size of primitive type double.
+ */
+ public static int getDoubleSize() {
+ return 8;
+ }
+
+ /**
+ * Get how many extra bytes an object occupies in the heap
+ * compared to sum of it's fields.
+ *
+ * TODO: somehow determine the real value
+ */
+ public static int getObjectExtraSize() {
+ if (objectExtraSize == 0)
+ objectExtraSize = 2 * getReferenceSize();
+ return objectExtraSize;
+ }
+ /**
+ * Get how many extra bytes an array occupies in the heap
+ * compared to sum of it's fields.
+ *
+ * TODO: somehow determine the real value
+ */
+ public static int getArrayExtraSize() {
+ return getObjectExtraSize();
+ }
+
+ /**
+ * Return size of reference object (SoftReference, WeakReference, PhantomReference)
+ */
+ public static int getReferenceObjectSize() {
+ return getReferenceSize() + getObjectExtraSize();
+ }
+
+ /**
+ * Get an approximate length of array that will occupy a given memory.
+ *
+ * @param memory size of memory
+ * @param objectSize size of each object in array
+ * @return length of array
+ */
+ public static int getArrayLength(long memory, long objectSize) {
+ int referenceSize = getReferenceSize();
+ int arrayExtraSize = getArrayExtraSize();
+ return (int) Math.min(
+ (memory - arrayExtraSize) / (objectSize + referenceSize),
+ Integer.MAX_VALUE
+ );
+ }
+
+ /**
+ * Get an approximate size of array of given length and object size.
+ *
+ * @param length length of arary
+ * @param objectSize size of object in array
+ * @return size of array
+ */
+ public static long getArraySize(int length, long objectSize) {
+ return getObjectExtraSize() + length * (objectSize + getReferenceSize());
+ }
+
+ /**
+ * Calculate approximate size of biggest of MemoryObjects.
+ */
+ public static long getMemoryObjectSize(long size) {
+ return size + 2 * getReferenceSize() + getObjectExtraSize();
+ }
+
+ /**
+ * Calculate approximate size of linked list in memory.
+ *
+ * @param length length of list
+ * @param size size of object
+ * @return size
+ */
+ public static long getListSize(int length, int size) {
+ return getObjectExtraSize() + length * (getReferenceSize() + getMemoryObjectSize(size));
+ }
+
+ /**
+ * Calculate length of linear or circular linked list.
+ *
+ * @param mobj head of list
+ * @return length of list
+ */
+ public static int getListLength(LinkedMemoryObject mobj) {
+ LinkedMemoryObject tobj = mobj;
+ int length = 0;
+ do {
+ ++length;
+ tobj = tobj.getNext();
+ } while (tobj != null && tobj != mobj);
+ return length;
+ }
+
+ /**
+ * Calculate length of array of linear or circular linked lists.
+ *
+ * @param mobjs array containting heads of lists
+ * @return length of all lists
+ */
+ public static int getListsLength(LinkedMemoryObject[] mobjs) {
+ int length = 0;
+ for (int i = 0; i < mobjs.length; ++i) {
+ LinkedMemoryObject mobj = mobjs[i];
+ if (mobj != null)
+ length += getListLength(mobj);
+ }
+ return length;
+ }
+
+ /**
+ * Calculate size of all objects in linear or circular linked list.
+ *
+ * @param mobj head of list
+ * @return size of list
+ */
+ public static long getListSize(LinkedMemoryObject mobj) {
+ LinkedMemoryObject tobj = mobj;
+ long size = 0;
+ do {
+ size += tobj.getSize();
+ tobj = tobj.getNext();
+ } while (tobj != null && tobj != mobj);
+ return size;
+ }
+
+ /**
+ * Calculate size of array of linear or circular linked lists.
+ *
+ * @param mobjs array containting heads of lists
+ * @return size of all lists
+ */
+ public static long getListsSize(LinkedMemoryObject[] mobjs) {
+ long size = 0;
+ for (int i = 0; i < mobjs.length; ++i) {
+ LinkedMemoryObject mobj = mobjs[i];
+ if (mobj != null)
+ size += getListSize(mobj);
+ }
+ return size;
+ }
+
+ /**
+ * Create singly linked linear list of objects of fixed size.
+ *
+ * @param depth length of list
+ * @param size size of each object
+ * @return head of created list or null if depth = 0
+ */
+ public static LinkedMemoryObject makeLinearList(int depth, int size) {
+ LinkedMemoryObject mobj = null;
+ for (int i = 0; i < depth; ++i)
+ mobj = new LinkedMemoryObject(size, mobj);
+ return mobj;
+ }
+
+ /**
+ * Create singly linked linear list of objects of varying size.
+ *
+ * @param depth length of list
+ * @param size maximum size of each object
+ * @return head of created list or null if depth = 0
+ */
+ public static LinkedMemoryObject makeRandomLinearList(int depth, int size) {
+ if (depth == 0)
+ return null;
+ LinkedMemoryObject mobj = new LinkedMemoryObject(size);
+ for (int i = 0; i < depth - 1; ++i)
+ mobj = new LinkedMemoryObject(LocalRandom.nextInt(size), mobj);
+ return mobj;
+ }
+
+ /**
+ * Create singly linked circular linear list of objects of fixed size.
+ *
+ * @param depth length of list
+ * @param size size of each object
+ * @return head of created list or null if depth = 0
+ */
+ public static LinkedMemoryObject makeCircularList(int depth, int size) {
+ if (depth == 0)
+ return null;
+ LinkedMemoryObject mobj = new LinkedMemoryObject(size);
+ LinkedMemoryObject tmpobj = mobj;
+ for (int i = 1; i < depth; i++)
+ mobj = new LinkedMemoryObject(size, mobj);
+ tmpobj.setNext(mobj);
+ return tmpobj;
+ }
+
+ /**
+ * Create singly linked circular linear list of objects of varying size.
+ *
+ * @param depth length of list
+ * @param size maximum size of each object
+ * @return head of created list or null if depth = 0
+ */
+ public static LinkedMemoryObject makeRandomCircularList(int depth, int size) {
+ if (depth == 0)
+ return null;
+ LinkedMemoryObject mobj = new LinkedMemoryObject(size);
+ LinkedMemoryObject tmpobj = mobj;
+ for (int i = 0; i < depth - 1; i++)
+ mobj = new LinkedMemoryObject(LocalRandom.nextInt(size), mobj);
+ tmpobj.setNext(mobj);
+ return tmpobj;
+ }
+
+ /**
+ * Create new nonbranchy binary tree.
+ *
+ * Each node in the tree except leaves always has left son. A node
+ * will have right son with probability branchiness.
+ *
+ * @param numberOfNodes number of nodes
+ * @param branchiness branchiness
+ * @param size size of each node
+ * @return root of created tree
+ */
+ public static LinkedMemoryObject makeNonbranchyTree(int numberOfNodes, float branchiness, int size) {
+ LinkedMemoryObject root = null;
+ LinkedMemoryObject current = null;
+ if (numberOfNodes == 0)
+ return null;
+ else if (numberOfNodes == 1)
+ return new LinkedMemoryObject(size);
+ else if (numberOfNodes == 2)
+ return new LinkedMemoryObject(size, makeNonbranchyTree(1, branchiness, size));
+ else {
+ if (LocalRandom.nextFloat() < branchiness) {
+ int numberOfLeftNodes = LocalRandom.nextInt(1, numberOfNodes - 1);
+ int numberOfRightNodes = numberOfNodes - 1 - numberOfLeftNodes;
+ return new LinkedMemoryObject(
+ size,
+ makeNonbranchyTree(numberOfLeftNodes, branchiness, size),
+ makeNonbranchyTree(numberOfRightNodes, branchiness, size)
+ );
+ } else {
+ return new LinkedMemoryObject(size, makeNonbranchyTree(numberOfNodes - 1, branchiness, size));
+ }
+ }
+ }
+
+ /**
+ * Create a balanced tree of given height.
+ *
+ * @param height height of the tree
+ * @param size size of each node
+ * @return created tree
+ */
+ public static Tree makeBalancedTree(int height, long size) {
+ return new Tree(makeBalancedTreeNode(height, size));
+ }
+
+ /**
+ * Get a number of nodes in balanced tree of given height.
+ *
+ * @param heigh height of the tree
+ * @return number of nodes
+ */
+ public static int balancedTreeNodes(int height) {
+ if (height == 0)
+ return 0;
+ int n = 1;
+ while (height > 1) {
+ n *= 2;
+ height--;
+ }
+ return n * 2 - 1;
+ }
+
+ /**
+ * Get approximate memory size occupied by balanced tree
+ * of given height and given node size.
+ *
+ * @param height height of the tree
+ * @param nodeSize size of each node
+ * @return memory size
+ */
+ public static long balancedTreeSize(int height, long nodeSize) {
+ return balancedTreeNodes(height) * nodeSize;
+ }
+
+ /**
+ * Get a height of balanced tree with given number of nodes.
+ *
+ * @param nodes number of nodes
+ * @return height of the tree
+ */
+ public static int balancedTreeHeightFromNodes(int nodes) {
+ if (nodes == 0)
+ return 0;
+ int h = 1;
+ long n = 1;
+ while (n + n - 1 <= nodes) {
+ n = n + n;
+ h = h + 1;
+ }
+ return h - 1;
+ }
+
+ /**
+ * Get approximate height of balanced tree which will occupy
+ * given memory with given node size.
+ *
+ * @param memory memory size
+ * @param nodeSize size of each node
+ * @return approximate height of the tree
+ */
+ public static int balancedTreeHeightFromMemory(long memory, long nodeSize) {
+ return balancedTreeHeightFromNodes((int) (memory / nodeSize));
+ }
+
+ /**
+ * Create balanced tree of given height and node size.
+ *
+ * @param height height of the tree
+ * @param size size of each node
+ * @return root of created tree
+ */
+ public static TreeNode makeBalancedTreeNode(int height, long size) {
+ if (height == 0)
+ return null;
+ else
+ return new TreeNode(size, makeBalancedTreeNode(height - 1, size), makeBalancedTreeNode(height - 1, size));
+ }
+
+ /**
+ * Create balanced tree of given height and node size.
+ *
+ * @param height height of the tree
+ * @param size size of each node
+ * @return root of created tree
+ */
+ public static TreeNode makeBalancedTreeNode(int height, long size, GarbageProducer gp) {
+ if (height == 0)
+ return null;
+ else
+ return new TreeNode(size, gp, makeBalancedTreeNode(height - 1, size), makeBalancedTreeNode(height - 1, size));
+ }
+
+ /**
+ * Determine if given tree is a balanced tree.
+ *
+ * @param tree tree
+ * @return true if tree is balanced
+ */
+ public static boolean isBalancedTree(TreeNode tree) {
+ return
+ tree.getActualHeight() == tree.getHeight() &&
+ tree.getShortestPath() == tree.getHeight();
+ }
+
+ /**
+ * Fill an array of MemoryObject's with new objects of given size.
+ *
+ * @param array array
+ * @param count number of objects to create
+ * @param size size of each object
+ */
+ public static void fillArray(MemoryObject[] array, int count, int size) {
+ for (int i = 0; i < count; ++i)
+ array[i] = new MemoryObject(size);
+ }
+
+ /**
+ * Fill an array of MemoryObject's with new objects of random size.
+ *
+ * @param array array
+ * @param count number of objects to create
+ * @param size maximum size of each object
+ */
+ public static void fillArrayRandom(MemoryObject[] array, int count, int size) {
+ for (int i = 0; i < count; ++i)
+ array[i] = new MemoryObject(LocalRandom.nextInt(size));
+ }
+
+ /**
+ * Fill an array of MemoryObject's with new objects of random size.
+ *
+ * @param array array
+ * @param count number of objects to create
+ * @param size maximum size of each object
+ */
+ public static void fillArrayRandom(LinkedMemoryObject[] array, int count, int size) {
+ for (int i = 0; i < count; ++i)
+ array[i] = new LinkedMemoryObject(LocalRandom.nextInt(size));
+ }
+
+ public static void dumpStatistics(PrintStream out) {
+ out.println(Runtime.getRuntime().freeMemory());
+ out.flush();
+ }
+
+ public static void dumpStatistics(Log log) {
+ log.info(Runtime.getRuntime().freeMemory());
+ }
+
+ public static void dumpStatistics() {
+ dumpStatistics(System.out);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/MemoryObject.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/MemoryObject.java
new file mode 100644
index 00000000000..66dd77aebea
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/MemoryObject.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+/**
+ * An object that occupies approximately given number of bytes in memory.
+ */
+public class MemoryObject {
+ private static int diff = (int) Memory.getObjectExtraSize();
+ private byte storage[];
+
+ /**
+ * Create an object that occupies given number of bytes.
+ *
+ * @param size size
+ */
+ public MemoryObject(int size) {
+ if (size > diff)
+ storage = new byte[size - diff];
+ }
+
+ public final byte[] getStorage() {
+ return storage;
+ }
+
+ public final int getSize() {
+ return storage.length;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/NonbranchyTree.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/NonbranchyTree.java
new file mode 100644
index 00000000000..4f51b140e1c
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/NonbranchyTree.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2003, 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 nsk.share.gc;
+
+import java.io.*;
+import java.util.*;
+
+import nsk.share.test.ExecutionController;
+
+/**
+ * NonbranchyTree defines a tree structure. Each node of the tree
+ * always has one son. A node may have the second son with probability
+ * branchiness .
+ */
+public class NonbranchyTree {
+
+ /** Minimal size of each node (in bytes) */
+ public final static int MIN_NODE_SIZE = 20;
+ private Node root;
+ private Random random;
+ private int numberOfNodes;
+ private float branchiness;
+ private int size;
+ private ExecutionController controller;
+
+ /**
+ * Creates a new tree with number of nodes not more than
+ * numberOfNodes . The implementation uses recursion to build the
+ * tree, so if StackOverflowError or OutOfMemoryError is
+ * thrown, the recursion is stopped and the method finishes building of the
+ * tree. Each node consists of byte[] of length size .
+ *
+ * @param numberOfNodes maximum number of nodes for the tree.
+ * @param branchiness probability for each node to have the second son.
+ * @param size number of bytes to store in a node.
+ *
+ * @throws IllegalArgumentException if numberOfNodes is
+ * less than 1; or branchiness is greater than 1, or less
+ * or equal than 0; or size is less than 1.
+ *
+ */
+ public NonbranchyTree(int numberOfNodes, float branchiness, int size) {
+ this(numberOfNodes, branchiness, size, new Random(System.currentTimeMillis()), null);
+ initTree();
+ }
+
+ public NonbranchyTree(int numberOfNodes, float branchiness, int size, ExecutionController controller) {
+ this(numberOfNodes, branchiness, size, new Random(System.currentTimeMillis()), controller);
+ initTree();
+ }
+
+ private NonbranchyTree(int numberOfNodes, float branchiness, int size, Random random, ExecutionController controller) {
+ this.numberOfNodes = numberOfNodes;
+ this.branchiness = branchiness;
+ this.size = size;
+ this.random = random;
+ this.controller = controller;
+ }
+
+ private void initTree() {
+ if (numberOfNodes < 1) {
+ throw new IllegalArgumentException("Illegal number of nodes: "
+ + numberOfNodes + ", must be at "
+ + "least 1.");
+ }
+ if ( (branchiness >= 1) || (branchiness <= 0) ) {
+ throw new IllegalArgumentException("Illegal value of branchiness: "
+ + numberOfNodes + ", must be at "
+ + "greater than 0 and less than "
+ + " 1.");
+ }
+ if (size < 1) {
+ throw new IllegalArgumentException("Illegal size of nodes: "
+ + size + ", must be at least 1.");
+ }
+ root = createTree(numberOfNodes, size);
+ }
+
+ // Create a new tree with specified number of nodes and size of each node
+ private Node createTree(int numberOfNodes, int size) {
+ // Make sure we respect the controller and stop test after
+ // given time.
+ if (controller != null && !controller.continueExecution()) {
+ return null;
+ }
+
+ Node node = new Node(size);
+ try {
+ if (numberOfNodes == 0) {
+ // No more nodes need to be built
+ return null;
+ } else if (numberOfNodes == 1) {
+ return node;
+ } else if (numberOfNodes == 2) {
+ node.left = createTree(1, size);
+ return node;
+ } else {
+ // Create a few nodes
+ if (makeRightNode()) {
+ // The node will have two sons
+ int leftNodes = 1 + random.nextInt(numberOfNodes - 2);
+ int rightNodes = numberOfNodes - 1 - leftNodes;
+
+ node.left = createTree(leftNodes, size);
+ node.right = createTree(rightNodes, size);
+ } else {
+ // The node will have just one son
+ Node leftTree = createTree(numberOfNodes - 1, size);
+ node.left = leftTree;
+ }
+ return node;
+ } // if
+ } catch(StackOverflowError e) {
+ // No more memory for such long tree
+ return node;
+ } catch(OutOfMemoryError e) {
+ // No more memory for such long tree
+ return node;
+ } // try
+ } // createTree()
+
+ // Define the "branchiness" of the tree
+ private boolean makeRightNode() {
+ return (random.nextFloat() < branchiness);
+ }
+
+ /**
+ * Bends the tree. A son of a leaf of the tree is set to the root node.
+ *
+ */
+ public void bend() {
+ bend(root);
+ }
+
+ // Bend the tree: make a reference from a leat of the tree to the specified
+ // node
+ private void bend(Node markedNode) {
+ Node node = root;
+
+ while ( (node.left != null) || (node.right != null) )
+ node = node.left;
+ node.right = markedNode;
+ }
+
+ /**
+ * Prints the whole tree from the root to the defined PrintStream.
+ *
+ * @param out PrintStream to print the tree in
+ *
+ */
+ public void print(PrintStream out) {
+ print(out, root);
+ }
+
+ // Print the sub-tree from the specified node and down
+ private void print(PrintStream out, Node node) {
+ node.print(out);
+ if (node.left != null)
+ print(out, node.left);
+ if (node.right != null)
+ print(out, node.right);
+ }
+}
+
+// The class defines a node of a tree
+class Node {
+ Node left;
+ Node right;
+ byte[] core;
+
+ Node(int size) {
+ left = null;
+ right = null;
+ core = new byte[size];
+
+ // Initizlize the core array
+ for (int i = 0; i < size; i++)
+ core[i] = (byte) i;
+ }
+
+ // Print the node info
+ void print(PrintStream out) {
+ out.println("node = " + this + " (" + left + ", " + right + ")");
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/OOMStress.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/OOMStress.java
new file mode 100644
index 00000000000..76a7f99a3ce
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/OOMStress.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016, 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 nsk.share.gc;
+
+/**
+ * Marker interface to tell that a something stresses OOM.
+ */
+public interface OOMStress {
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/ThreadedGCTest.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/ThreadedGCTest.java
new file mode 100644
index 00000000000..cd99bd31b8b
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/ThreadedGCTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2005, 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 nsk.share.gc;
+
+import nsk.share.runner.*;
+import nsk.share.test.ExecutionController;
+import nsk.share.Consts;
+
+/**
+ * Test that executes a number of tasks.
+ *
+ * How these tasks are used is determined by MultiRunner.
+ * Usually they are executed in separate threads in cycle
+ * for some time or for some iterations.
+ *
+ * @see nsk.share.runner.MultiRunner
+ * @see nsk.share.runner.ThreadsRunner
+ */
+public abstract class ThreadedGCTest extends GCTestBase implements MultiRunnerAware {
+ private MultiRunner runner;
+
+ /**
+ * Create a task with index i.
+ *
+ * Subclasses should to override this method
+ * to created neccessary tasks.
+ *
+ * @param i index of task
+ * @return task to run or null
+ */
+ protected abstract Runnable createRunnable(int i);
+
+ protected ExecutionController getExecutionController() {
+ return runner.getExecutionController();
+ }
+
+ protected final boolean runThreads() {
+ for (int i = 0; i < runParams.getNumberOfThreads(); ++i) {
+ Runnable runnable = createRunnable(i);
+ if (runnable != null)
+ runner.add(runnable);
+ }
+ runner.run();
+ return runner.isSuccessful();
+ }
+
+ public void run() {
+ if (!runThreads())
+ setFailed(true);
+ }
+
+ public final void setRunner(MultiRunner runner) {
+ this.runner = runner;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/TwoFieldsObject.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/TwoFieldsObject.java
new file mode 100644
index 00000000000..369925fb7e4
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/TwoFieldsObject.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc;
+
+/**
+ * An object with two fields of same type.
+ */
+public class TwoFieldsObject {
+ private T left, right;
+
+ public TwoFieldsObject(T left, T right) {
+ setLeft(left);
+ setRight(right);
+ }
+
+ public final void setLeft(T left) {
+ this.left = left;
+ }
+
+ public final void setRight(T right) {
+ this.right = right;
+ }
+
+ public final T getLeft() {
+ return left;
+ }
+
+ public final T getRight() {
+ return right;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/classes/Classes.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/classes/Classes.java
new file mode 100644
index 00000000000..8883a06306f
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/classes/Classes.java
@@ -0,0 +1,5024 @@
+/*
+ * Copyright (c) 2009, 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 nsk.share.gc.classes;
+
+class Class1 {
+ public Class1(){
+
+ }
+}
+class Class2 {
+ public Class2(){
+
+ }
+}
+class Class3 {
+ public Class3(){
+
+ }
+}
+class Class4 {
+ public Class4(){
+
+ }
+}
+class Class5 {
+ public Class5(){
+
+ }
+}
+class Class6 {
+ public Class6(){
+
+ }
+}
+class Class7 {
+ public Class7(){
+
+ }
+}
+class Class8 {
+ public Class8(){
+
+ }
+}
+class Class9 {
+ public Class9(){
+
+ }
+}
+class Class10 {
+ public Class10(){
+
+ }
+}
+class Class11 {
+ public Class11(){
+
+ }
+}
+class Class12 {
+ public Class12(){
+
+ }
+}
+class Class13 {
+ public Class13(){
+
+ }
+}
+class Class14 {
+ public Class14(){
+
+ }
+}
+class Class15 {
+ public Class15(){
+
+ }
+}
+class Class16 {
+ public Class16(){
+
+ }
+}
+class Class17 {
+ public Class17(){
+
+ }
+}
+class Class18 {
+ public Class18(){
+
+ }
+}
+class Class19 {
+ public Class19(){
+
+ }
+}
+class Class20 {
+ public Class20(){
+
+ }
+}
+class Class21 {
+ public Class21(){
+
+ }
+}
+class Class22 {
+ public Class22(){
+
+ }
+}
+class Class23 {
+ public Class23(){
+
+ }
+}
+class Class24 {
+ public Class24(){
+
+ }
+}
+class Class25 {
+ public Class25(){
+
+ }
+}
+class Class26 {
+ public Class26(){
+
+ }
+}
+class Class27 {
+ public Class27(){
+
+ }
+}
+class Class28 {
+ public Class28(){
+
+ }
+}
+class Class29 {
+ public Class29(){
+
+ }
+}
+class Class30 {
+ public Class30(){
+
+ }
+}
+class Class31 {
+ public Class31(){
+
+ }
+}
+class Class32 {
+ public Class32(){
+
+ }
+}
+class Class33 {
+ public Class33(){
+
+ }
+}
+class Class34 {
+ public Class34(){
+
+ }
+}
+class Class35 {
+ public Class35(){
+
+ }
+}
+class Class36 {
+ public Class36(){
+
+ }
+}
+class Class37 {
+ public Class37(){
+
+ }
+}
+class Class38 {
+ public Class38(){
+
+ }
+}
+class Class39 {
+ public Class39(){
+
+ }
+}
+class Class40 {
+ public Class40(){
+
+ }
+}
+class Class41 {
+ public Class41(){
+
+ }
+}
+class Class42 {
+ public Class42(){
+
+ }
+}
+class Class43 {
+ public Class43(){
+
+ }
+}
+class Class44 {
+ public Class44(){
+
+ }
+}
+class Class45 {
+ public Class45(){
+
+ }
+}
+class Class46 {
+ public Class46(){
+
+ }
+}
+class Class47 {
+ public Class47(){
+
+ }
+}
+class Class48 {
+ public Class48(){
+
+ }
+}
+class Class49 {
+ public Class49(){
+
+ }
+}
+class Class50 {
+ public Class50(){
+
+ }
+}
+class Class51 {
+ public Class51(){
+
+ }
+}
+class Class52 {
+ public Class52(){
+
+ }
+}
+class Class53 {
+ public Class53(){
+
+ }
+}
+class Class54 {
+ public Class54(){
+
+ }
+}
+class Class55 {
+ public Class55(){
+
+ }
+}
+class Class56 {
+ public Class56(){
+
+ }
+}
+class Class57 {
+ public Class57(){
+
+ }
+}
+class Class58 {
+ public Class58(){
+
+ }
+}
+class Class59 {
+ public Class59(){
+
+ }
+}
+class Class60 {
+ public Class60(){
+
+ }
+}
+class Class61 {
+ public Class61(){
+
+ }
+}
+class Class62 {
+ public Class62(){
+
+ }
+}
+class Class63 {
+ public Class63(){
+
+ }
+}
+class Class64 {
+ public Class64(){
+
+ }
+}
+class Class65 {
+ public Class65(){
+
+ }
+}
+class Class66 {
+ public Class66(){
+
+ }
+}
+class Class67 {
+ public Class67(){
+
+ }
+}
+class Class68 {
+ public Class68(){
+
+ }
+}
+class Class69 {
+ public Class69(){
+
+ }
+}
+class Class70 {
+ public Class70(){
+
+ }
+}
+class Class71 {
+ public Class71(){
+
+ }
+}
+class Class72 {
+ public Class72(){
+
+ }
+}
+class Class73 {
+ public Class73(){
+
+ }
+}
+class Class74 {
+ public Class74(){
+
+ }
+}
+class Class75 {
+ public Class75(){
+
+ }
+}
+class Class76 {
+ public Class76(){
+
+ }
+}
+class Class77 {
+ public Class77(){
+
+ }
+}
+class Class78 {
+ public Class78(){
+
+ }
+}
+class Class79 {
+ public Class79(){
+
+ }
+}
+class Class80 {
+ public Class80(){
+
+ }
+}
+class Class81 {
+ public Class81(){
+
+ }
+}
+class Class82 {
+ public Class82(){
+
+ }
+}
+class Class83 {
+ public Class83(){
+
+ }
+}
+class Class84 {
+ public Class84(){
+
+ }
+}
+class Class85 {
+ public Class85(){
+
+ }
+}
+class Class86 {
+ public Class86(){
+
+ }
+}
+class Class87 {
+ public Class87(){
+
+ }
+}
+class Class88 {
+ public Class88(){
+
+ }
+}
+class Class89 {
+ public Class89(){
+
+ }
+}
+class Class90 {
+ public Class90(){
+
+ }
+}
+class Class91 {
+ public Class91(){
+
+ }
+}
+class Class92 {
+ public Class92(){
+
+ }
+}
+class Class93 {
+ public Class93(){
+
+ }
+}
+class Class94 {
+ public Class94(){
+
+ }
+}
+class Class95 {
+ public Class95(){
+
+ }
+}
+class Class96 {
+ public Class96(){
+
+ }
+}
+class Class97 {
+ public Class97(){
+
+ }
+}
+class Class98 {
+ public Class98(){
+
+ }
+}
+class Class99 {
+ public Class99(){
+
+ }
+}
+class Class100 {
+ public Class100(){
+
+ }
+}
+class Class101 {
+ public Class101(){
+
+ }
+}
+class Class102 {
+ public Class102(){
+
+ }
+}
+class Class103 {
+ public Class103(){
+
+ }
+}
+class Class104 {
+ public Class104(){
+
+ }
+}
+class Class105 {
+ public Class105(){
+
+ }
+}
+class Class106 {
+ public Class106(){
+
+ }
+}
+class Class107 {
+ public Class107(){
+
+ }
+}
+class Class108 {
+ public Class108(){
+
+ }
+}
+class Class109 {
+ public Class109(){
+
+ }
+}
+class Class110 {
+ public Class110(){
+
+ }
+}
+class Class111 {
+ public Class111(){
+
+ }
+}
+class Class112 {
+ public Class112(){
+
+ }
+}
+class Class113 {
+ public Class113(){
+
+ }
+}
+class Class114 {
+ public Class114(){
+
+ }
+}
+class Class115 {
+ public Class115(){
+
+ }
+}
+class Class116 {
+ public Class116(){
+
+ }
+}
+class Class117 {
+ public Class117(){
+
+ }
+}
+class Class118 {
+ public Class118(){
+
+ }
+}
+class Class119 {
+ public Class119(){
+
+ }
+}
+class Class120 {
+ public Class120(){
+
+ }
+}
+class Class121 {
+ public Class121(){
+
+ }
+}
+class Class122 {
+ public Class122(){
+
+ }
+}
+class Class123 {
+ public Class123(){
+
+ }
+}
+class Class124 {
+ public Class124(){
+
+ }
+}
+class Class125 {
+ public Class125(){
+
+ }
+}
+class Class126 {
+ public Class126(){
+
+ }
+}
+class Class127 {
+ public Class127(){
+
+ }
+}
+class Class128 {
+ public Class128(){
+
+ }
+}
+class Class129 {
+ public Class129(){
+
+ }
+}
+class Class130 {
+ public Class130(){
+
+ }
+}
+class Class131 {
+ public Class131(){
+
+ }
+}
+class Class132 {
+ public Class132(){
+
+ }
+}
+class Class133 {
+ public Class133(){
+
+ }
+}
+class Class134 {
+ public Class134(){
+
+ }
+}
+class Class135 {
+ public Class135(){
+
+ }
+}
+class Class136 {
+ public Class136(){
+
+ }
+}
+class Class137 {
+ public Class137(){
+
+ }
+}
+class Class138 {
+ public Class138(){
+
+ }
+}
+class Class139 {
+ public Class139(){
+
+ }
+}
+class Class140 {
+ public Class140(){
+
+ }
+}
+class Class141 {
+ public Class141(){
+
+ }
+}
+class Class142 {
+ public Class142(){
+
+ }
+}
+class Class143 {
+ public Class143(){
+
+ }
+}
+class Class144 {
+ public Class144(){
+
+ }
+}
+class Class145 {
+ public Class145(){
+
+ }
+}
+class Class146 {
+ public Class146(){
+
+ }
+}
+class Class147 {
+ public Class147(){
+
+ }
+}
+class Class148 {
+ public Class148(){
+
+ }
+}
+class Class149 {
+ public Class149(){
+
+ }
+}
+class Class150 {
+ public Class150(){
+
+ }
+}
+class Class151 {
+ public Class151(){
+
+ }
+}
+class Class152 {
+ public Class152(){
+
+ }
+}
+class Class153 {
+ public Class153(){
+
+ }
+}
+class Class154 {
+ public Class154(){
+
+ }
+}
+class Class155 {
+ public Class155(){
+
+ }
+}
+class Class156 {
+ public Class156(){
+
+ }
+}
+class Class157 {
+ public Class157(){
+
+ }
+}
+class Class158 {
+ public Class158(){
+
+ }
+}
+class Class159 {
+ public Class159(){
+
+ }
+}
+class Class160 {
+ public Class160(){
+
+ }
+}
+class Class161 {
+ public Class161(){
+
+ }
+}
+class Class162 {
+ public Class162(){
+
+ }
+}
+class Class163 {
+ public Class163(){
+
+ }
+}
+class Class164 {
+ public Class164(){
+
+ }
+}
+class Class165 {
+ public Class165(){
+
+ }
+}
+class Class166 {
+ public Class166(){
+
+ }
+}
+class Class167 {
+ public Class167(){
+
+ }
+}
+class Class168 {
+ public Class168(){
+
+ }
+}
+class Class169 {
+ public Class169(){
+
+ }
+}
+class Class170 {
+ public Class170(){
+
+ }
+}
+class Class171 {
+ public Class171(){
+
+ }
+}
+class Class172 {
+ public Class172(){
+
+ }
+}
+class Class173 {
+ public Class173(){
+
+ }
+}
+class Class174 {
+ public Class174(){
+
+ }
+}
+class Class175 {
+ public Class175(){
+
+ }
+}
+class Class176 {
+ public Class176(){
+
+ }
+}
+class Class177 {
+ public Class177(){
+
+ }
+}
+class Class178 {
+ public Class178(){
+
+ }
+}
+class Class179 {
+ public Class179(){
+
+ }
+}
+class Class180 {
+ public Class180(){
+
+ }
+}
+class Class181 {
+ public Class181(){
+
+ }
+}
+class Class182 {
+ public Class182(){
+
+ }
+}
+class Class183 {
+ public Class183(){
+
+ }
+}
+class Class184 {
+ public Class184(){
+
+ }
+}
+class Class185 {
+ public Class185(){
+
+ }
+}
+class Class186 {
+ public Class186(){
+
+ }
+}
+class Class187 {
+ public Class187(){
+
+ }
+}
+class Class188 {
+ public Class188(){
+
+ }
+}
+class Class189 {
+ public Class189(){
+
+ }
+}
+class Class190 {
+ public Class190(){
+
+ }
+}
+class Class191 {
+ public Class191(){
+
+ }
+}
+class Class192 {
+ public Class192(){
+
+ }
+}
+class Class193 {
+ public Class193(){
+
+ }
+}
+class Class194 {
+ public Class194(){
+
+ }
+}
+class Class195 {
+ public Class195(){
+
+ }
+}
+class Class196 {
+ public Class196(){
+
+ }
+}
+class Class197 {
+ public Class197(){
+
+ }
+}
+class Class198 {
+ public Class198(){
+
+ }
+}
+class Class199 {
+ public Class199(){
+
+ }
+}
+class Class200 {
+ public Class200(){
+
+ }
+}
+class Class201 {
+ public Class201(){
+
+ }
+}
+class Class202 {
+ public Class202(){
+
+ }
+}
+class Class203 {
+ public Class203(){
+
+ }
+}
+class Class204 {
+ public Class204(){
+
+ }
+}
+class Class205 {
+ public Class205(){
+
+ }
+}
+class Class206 {
+ public Class206(){
+
+ }
+}
+class Class207 {
+ public Class207(){
+
+ }
+}
+class Class208 {
+ public Class208(){
+
+ }
+}
+class Class209 {
+ public Class209(){
+
+ }
+}
+class Class210 {
+ public Class210(){
+
+ }
+}
+class Class211 {
+ public Class211(){
+
+ }
+}
+class Class212 {
+ public Class212(){
+
+ }
+}
+class Class213 {
+ public Class213(){
+
+ }
+}
+class Class214 {
+ public Class214(){
+
+ }
+}
+class Class215 {
+ public Class215(){
+
+ }
+}
+class Class216 {
+ public Class216(){
+
+ }
+}
+class Class217 {
+ public Class217(){
+
+ }
+}
+class Class218 {
+ public Class218(){
+
+ }
+}
+class Class219 {
+ public Class219(){
+
+ }
+}
+class Class220 {
+ public Class220(){
+
+ }
+}
+class Class221 {
+ public Class221(){
+
+ }
+}
+class Class222 {
+ public Class222(){
+
+ }
+}
+class Class223 {
+ public Class223(){
+
+ }
+}
+class Class224 {
+ public Class224(){
+
+ }
+}
+class Class225 {
+ public Class225(){
+
+ }
+}
+class Class226 {
+ public Class226(){
+
+ }
+}
+class Class227 {
+ public Class227(){
+
+ }
+}
+class Class228 {
+ public Class228(){
+
+ }
+}
+class Class229 {
+ public Class229(){
+
+ }
+}
+class Class230 {
+ public Class230(){
+
+ }
+}
+class Class231 {
+ public Class231(){
+
+ }
+}
+class Class232 {
+ public Class232(){
+
+ }
+}
+class Class233 {
+ public Class233(){
+
+ }
+}
+class Class234 {
+ public Class234(){
+
+ }
+}
+class Class235 {
+ public Class235(){
+
+ }
+}
+class Class236 {
+ public Class236(){
+
+ }
+}
+class Class237 {
+ public Class237(){
+
+ }
+}
+class Class238 {
+ public Class238(){
+
+ }
+}
+class Class239 {
+ public Class239(){
+
+ }
+}
+class Class240 {
+ public Class240(){
+
+ }
+}
+class Class241 {
+ public Class241(){
+
+ }
+}
+class Class242 {
+ public Class242(){
+
+ }
+}
+class Class243 {
+ public Class243(){
+
+ }
+}
+class Class244 {
+ public Class244(){
+
+ }
+}
+class Class245 {
+ public Class245(){
+
+ }
+}
+class Class246 {
+ public Class246(){
+
+ }
+}
+class Class247 {
+ public Class247(){
+
+ }
+}
+class Class248 {
+ public Class248(){
+
+ }
+}
+class Class249 {
+ public Class249(){
+
+ }
+}
+class Class250 {
+ public Class250(){
+
+ }
+}
+class Class251 {
+ public Class251(){
+
+ }
+}
+class Class252 {
+ public Class252(){
+
+ }
+}
+class Class253 {
+ public Class253(){
+
+ }
+}
+class Class254 {
+ public Class254(){
+
+ }
+}
+class Class255 {
+ public Class255(){
+
+ }
+}
+class Class256 {
+ public Class256(){
+
+ }
+}
+class Class257 {
+ public Class257(){
+
+ }
+}
+class Class258 {
+ public Class258(){
+
+ }
+}
+class Class259 {
+ public Class259(){
+
+ }
+}
+class Class260 {
+ public Class260(){
+
+ }
+}
+class Class261 {
+ public Class261(){
+
+ }
+}
+class Class262 {
+ public Class262(){
+
+ }
+}
+class Class263 {
+ public Class263(){
+
+ }
+}
+class Class264 {
+ public Class264(){
+
+ }
+}
+class Class265 {
+ public Class265(){
+
+ }
+}
+class Class266 {
+ public Class266(){
+
+ }
+}
+class Class267 {
+ public Class267(){
+
+ }
+}
+class Class268 {
+ public Class268(){
+
+ }
+}
+class Class269 {
+ public Class269(){
+
+ }
+}
+class Class270 {
+ public Class270(){
+
+ }
+}
+class Class271 {
+ public Class271(){
+
+ }
+}
+class Class272 {
+ public Class272(){
+
+ }
+}
+class Class273 {
+ public Class273(){
+
+ }
+}
+class Class274 {
+ public Class274(){
+
+ }
+}
+class Class275 {
+ public Class275(){
+
+ }
+}
+class Class276 {
+ public Class276(){
+
+ }
+}
+class Class277 {
+ public Class277(){
+
+ }
+}
+class Class278 {
+ public Class278(){
+
+ }
+}
+class Class279 {
+ public Class279(){
+
+ }
+}
+class Class280 {
+ public Class280(){
+
+ }
+}
+class Class281 {
+ public Class281(){
+
+ }
+}
+class Class282 {
+ public Class282(){
+
+ }
+}
+class Class283 {
+ public Class283(){
+
+ }
+}
+class Class284 {
+ public Class284(){
+
+ }
+}
+class Class285 {
+ public Class285(){
+
+ }
+}
+class Class286 {
+ public Class286(){
+
+ }
+}
+class Class287 {
+ public Class287(){
+
+ }
+}
+class Class288 {
+ public Class288(){
+
+ }
+}
+class Class289 {
+ public Class289(){
+
+ }
+}
+class Class290 {
+ public Class290(){
+
+ }
+}
+class Class291 {
+ public Class291(){
+
+ }
+}
+class Class292 {
+ public Class292(){
+
+ }
+}
+class Class293 {
+ public Class293(){
+
+ }
+}
+class Class294 {
+ public Class294(){
+
+ }
+}
+class Class295 {
+ public Class295(){
+
+ }
+}
+class Class296 {
+ public Class296(){
+
+ }
+}
+class Class297 {
+ public Class297(){
+
+ }
+}
+class Class298 {
+ public Class298(){
+
+ }
+}
+class Class299 {
+ public Class299(){
+
+ }
+}
+class Class300 {
+ public Class300(){
+
+ }
+}
+class Class301 {
+ public Class301(){
+
+ }
+}
+class Class302 {
+ public Class302(){
+
+ }
+}
+class Class303 {
+ public Class303(){
+
+ }
+}
+class Class304 {
+ public Class304(){
+
+ }
+}
+class Class305 {
+ public Class305(){
+
+ }
+}
+class Class306 {
+ public Class306(){
+
+ }
+}
+class Class307 {
+ public Class307(){
+
+ }
+}
+class Class308 {
+ public Class308(){
+
+ }
+}
+class Class309 {
+ public Class309(){
+
+ }
+}
+class Class310 {
+ public Class310(){
+
+ }
+}
+class Class311 {
+ public Class311(){
+
+ }
+}
+class Class312 {
+ public Class312(){
+
+ }
+}
+class Class313 {
+ public Class313(){
+
+ }
+}
+class Class314 {
+ public Class314(){
+
+ }
+}
+class Class315 {
+ public Class315(){
+
+ }
+}
+class Class316 {
+ public Class316(){
+
+ }
+}
+class Class317 {
+ public Class317(){
+
+ }
+}
+class Class318 {
+ public Class318(){
+
+ }
+}
+class Class319 {
+ public Class319(){
+
+ }
+}
+class Class320 {
+ public Class320(){
+
+ }
+}
+class Class321 {
+ public Class321(){
+
+ }
+}
+class Class322 {
+ public Class322(){
+
+ }
+}
+class Class323 {
+ public Class323(){
+
+ }
+}
+class Class324 {
+ public Class324(){
+
+ }
+}
+class Class325 {
+ public Class325(){
+
+ }
+}
+class Class326 {
+ public Class326(){
+
+ }
+}
+class Class327 {
+ public Class327(){
+
+ }
+}
+class Class328 {
+ public Class328(){
+
+ }
+}
+class Class329 {
+ public Class329(){
+
+ }
+}
+class Class330 {
+ public Class330(){
+
+ }
+}
+class Class331 {
+ public Class331(){
+
+ }
+}
+class Class332 {
+ public Class332(){
+
+ }
+}
+class Class333 {
+ public Class333(){
+
+ }
+}
+class Class334 {
+ public Class334(){
+
+ }
+}
+class Class335 {
+ public Class335(){
+
+ }
+}
+class Class336 {
+ public Class336(){
+
+ }
+}
+class Class337 {
+ public Class337(){
+
+ }
+}
+class Class338 {
+ public Class338(){
+
+ }
+}
+class Class339 {
+ public Class339(){
+
+ }
+}
+class Class340 {
+ public Class340(){
+
+ }
+}
+class Class341 {
+ public Class341(){
+
+ }
+}
+class Class342 {
+ public Class342(){
+
+ }
+}
+class Class343 {
+ public Class343(){
+
+ }
+}
+class Class344 {
+ public Class344(){
+
+ }
+}
+class Class345 {
+ public Class345(){
+
+ }
+}
+class Class346 {
+ public Class346(){
+
+ }
+}
+class Class347 {
+ public Class347(){
+
+ }
+}
+class Class348 {
+ public Class348(){
+
+ }
+}
+class Class349 {
+ public Class349(){
+
+ }
+}
+class Class350 {
+ public Class350(){
+
+ }
+}
+class Class351 {
+ public Class351(){
+
+ }
+}
+class Class352 {
+ public Class352(){
+
+ }
+}
+class Class353 {
+ public Class353(){
+
+ }
+}
+class Class354 {
+ public Class354(){
+
+ }
+}
+class Class355 {
+ public Class355(){
+
+ }
+}
+class Class356 {
+ public Class356(){
+
+ }
+}
+class Class357 {
+ public Class357(){
+
+ }
+}
+class Class358 {
+ public Class358(){
+
+ }
+}
+class Class359 {
+ public Class359(){
+
+ }
+}
+class Class360 {
+ public Class360(){
+
+ }
+}
+class Class361 {
+ public Class361(){
+
+ }
+}
+class Class362 {
+ public Class362(){
+
+ }
+}
+class Class363 {
+ public Class363(){
+
+ }
+}
+class Class364 {
+ public Class364(){
+
+ }
+}
+class Class365 {
+ public Class365(){
+
+ }
+}
+class Class366 {
+ public Class366(){
+
+ }
+}
+class Class367 {
+ public Class367(){
+
+ }
+}
+class Class368 {
+ public Class368(){
+
+ }
+}
+class Class369 {
+ public Class369(){
+
+ }
+}
+class Class370 {
+ public Class370(){
+
+ }
+}
+class Class371 {
+ public Class371(){
+
+ }
+}
+class Class372 {
+ public Class372(){
+
+ }
+}
+class Class373 {
+ public Class373(){
+
+ }
+}
+class Class374 {
+ public Class374(){
+
+ }
+}
+class Class375 {
+ public Class375(){
+
+ }
+}
+class Class376 {
+ public Class376(){
+
+ }
+}
+class Class377 {
+ public Class377(){
+
+ }
+}
+class Class378 {
+ public Class378(){
+
+ }
+}
+class Class379 {
+ public Class379(){
+
+ }
+}
+class Class380 {
+ public Class380(){
+
+ }
+}
+class Class381 {
+ public Class381(){
+
+ }
+}
+class Class382 {
+ public Class382(){
+
+ }
+}
+class Class383 {
+ public Class383(){
+
+ }
+}
+class Class384 {
+ public Class384(){
+
+ }
+}
+class Class385 {
+ public Class385(){
+
+ }
+}
+class Class386 {
+ public Class386(){
+
+ }
+}
+class Class387 {
+ public Class387(){
+
+ }
+}
+class Class388 {
+ public Class388(){
+
+ }
+}
+class Class389 {
+ public Class389(){
+
+ }
+}
+class Class390 {
+ public Class390(){
+
+ }
+}
+class Class391 {
+ public Class391(){
+
+ }
+}
+class Class392 {
+ public Class392(){
+
+ }
+}
+class Class393 {
+ public Class393(){
+
+ }
+}
+class Class394 {
+ public Class394(){
+
+ }
+}
+class Class395 {
+ public Class395(){
+
+ }
+}
+class Class396 {
+ public Class396(){
+
+ }
+}
+class Class397 {
+ public Class397(){
+
+ }
+}
+class Class398 {
+ public Class398(){
+
+ }
+}
+class Class399 {
+ public Class399(){
+
+ }
+}
+class Class400 {
+ public Class400(){
+
+ }
+}
+class Class401 {
+ public Class401(){
+
+ }
+}
+class Class402 {
+ public Class402(){
+
+ }
+}
+class Class403 {
+ public Class403(){
+
+ }
+}
+class Class404 {
+ public Class404(){
+
+ }
+}
+class Class405 {
+ public Class405(){
+
+ }
+}
+class Class406 {
+ public Class406(){
+
+ }
+}
+class Class407 {
+ public Class407(){
+
+ }
+}
+class Class408 {
+ public Class408(){
+
+ }
+}
+class Class409 {
+ public Class409(){
+
+ }
+}
+class Class410 {
+ public Class410(){
+
+ }
+}
+class Class411 {
+ public Class411(){
+
+ }
+}
+class Class412 {
+ public Class412(){
+
+ }
+}
+class Class413 {
+ public Class413(){
+
+ }
+}
+class Class414 {
+ public Class414(){
+
+ }
+}
+class Class415 {
+ public Class415(){
+
+ }
+}
+class Class416 {
+ public Class416(){
+
+ }
+}
+class Class417 {
+ public Class417(){
+
+ }
+}
+class Class418 {
+ public Class418(){
+
+ }
+}
+class Class419 {
+ public Class419(){
+
+ }
+}
+class Class420 {
+ public Class420(){
+
+ }
+}
+class Class421 {
+ public Class421(){
+
+ }
+}
+class Class422 {
+ public Class422(){
+
+ }
+}
+class Class423 {
+ public Class423(){
+
+ }
+}
+class Class424 {
+ public Class424(){
+
+ }
+}
+class Class425 {
+ public Class425(){
+
+ }
+}
+class Class426 {
+ public Class426(){
+
+ }
+}
+class Class427 {
+ public Class427(){
+
+ }
+}
+class Class428 {
+ public Class428(){
+
+ }
+}
+class Class429 {
+ public Class429(){
+
+ }
+}
+class Class430 {
+ public Class430(){
+
+ }
+}
+class Class431 {
+ public Class431(){
+
+ }
+}
+class Class432 {
+ public Class432(){
+
+ }
+}
+class Class433 {
+ public Class433(){
+
+ }
+}
+class Class434 {
+ public Class434(){
+
+ }
+}
+class Class435 {
+ public Class435(){
+
+ }
+}
+class Class436 {
+ public Class436(){
+
+ }
+}
+class Class437 {
+ public Class437(){
+
+ }
+}
+class Class438 {
+ public Class438(){
+
+ }
+}
+class Class439 {
+ public Class439(){
+
+ }
+}
+class Class440 {
+ public Class440(){
+
+ }
+}
+class Class441 {
+ public Class441(){
+
+ }
+}
+class Class442 {
+ public Class442(){
+
+ }
+}
+class Class443 {
+ public Class443(){
+
+ }
+}
+class Class444 {
+ public Class444(){
+
+ }
+}
+class Class445 {
+ public Class445(){
+
+ }
+}
+class Class446 {
+ public Class446(){
+
+ }
+}
+class Class447 {
+ public Class447(){
+
+ }
+}
+class Class448 {
+ public Class448(){
+
+ }
+}
+class Class449 {
+ public Class449(){
+
+ }
+}
+class Class450 {
+ public Class450(){
+
+ }
+}
+class Class451 {
+ public Class451(){
+
+ }
+}
+class Class452 {
+ public Class452(){
+
+ }
+}
+class Class453 {
+ public Class453(){
+
+ }
+}
+class Class454 {
+ public Class454(){
+
+ }
+}
+class Class455 {
+ public Class455(){
+
+ }
+}
+class Class456 {
+ public Class456(){
+
+ }
+}
+class Class457 {
+ public Class457(){
+
+ }
+}
+class Class458 {
+ public Class458(){
+
+ }
+}
+class Class459 {
+ public Class459(){
+
+ }
+}
+class Class460 {
+ public Class460(){
+
+ }
+}
+class Class461 {
+ public Class461(){
+
+ }
+}
+class Class462 {
+ public Class462(){
+
+ }
+}
+class Class463 {
+ public Class463(){
+
+ }
+}
+class Class464 {
+ public Class464(){
+
+ }
+}
+class Class465 {
+ public Class465(){
+
+ }
+}
+class Class466 {
+ public Class466(){
+
+ }
+}
+class Class467 {
+ public Class467(){
+
+ }
+}
+class Class468 {
+ public Class468(){
+
+ }
+}
+class Class469 {
+ public Class469(){
+
+ }
+}
+class Class470 {
+ public Class470(){
+
+ }
+}
+class Class471 {
+ public Class471(){
+
+ }
+}
+class Class472 {
+ public Class472(){
+
+ }
+}
+class Class473 {
+ public Class473(){
+
+ }
+}
+class Class474 {
+ public Class474(){
+
+ }
+}
+class Class475 {
+ public Class475(){
+
+ }
+}
+class Class476 {
+ public Class476(){
+
+ }
+}
+class Class477 {
+ public Class477(){
+
+ }
+}
+class Class478 {
+ public Class478(){
+
+ }
+}
+class Class479 {
+ public Class479(){
+
+ }
+}
+class Class480 {
+ public Class480(){
+
+ }
+}
+class Class481 {
+ public Class481(){
+
+ }
+}
+class Class482 {
+ public Class482(){
+
+ }
+}
+class Class483 {
+ public Class483(){
+
+ }
+}
+class Class484 {
+ public Class484(){
+
+ }
+}
+class Class485 {
+ public Class485(){
+
+ }
+}
+class Class486 {
+ public Class486(){
+
+ }
+}
+class Class487 {
+ public Class487(){
+
+ }
+}
+class Class488 {
+ public Class488(){
+
+ }
+}
+class Class489 {
+ public Class489(){
+
+ }
+}
+class Class490 {
+ public Class490(){
+
+ }
+}
+class Class491 {
+ public Class491(){
+
+ }
+}
+class Class492 {
+ public Class492(){
+
+ }
+}
+class Class493 {
+ public Class493(){
+
+ }
+}
+class Class494 {
+ public Class494(){
+
+ }
+}
+class Class495 {
+ public Class495(){
+
+ }
+}
+class Class496 {
+ public Class496(){
+
+ }
+}
+class Class497 {
+ public Class497(){
+
+ }
+}
+class Class498 {
+ public Class498(){
+
+ }
+}
+class Class499 {
+ public Class499(){
+
+ }
+}
+class Class500 {
+ public Class500(){
+
+ }
+}
+class Class501 {
+ public Class501(){
+
+ }
+}
+class Class502 {
+ public Class502(){
+
+ }
+}
+class Class503 {
+ public Class503(){
+
+ }
+}
+class Class504 {
+ public Class504(){
+
+ }
+}
+class Class505 {
+ public Class505(){
+
+ }
+}
+class Class506 {
+ public Class506(){
+
+ }
+}
+class Class507 {
+ public Class507(){
+
+ }
+}
+class Class508 {
+ public Class508(){
+
+ }
+}
+class Class509 {
+ public Class509(){
+
+ }
+}
+class Class510 {
+ public Class510(){
+
+ }
+}
+class Class511 {
+ public Class511(){
+
+ }
+}
+class Class512 {
+ public Class512(){
+
+ }
+}
+class Class513 {
+ public Class513(){
+
+ }
+}
+class Class514 {
+ public Class514(){
+
+ }
+}
+class Class515 {
+ public Class515(){
+
+ }
+}
+class Class516 {
+ public Class516(){
+
+ }
+}
+class Class517 {
+ public Class517(){
+
+ }
+}
+class Class518 {
+ public Class518(){
+
+ }
+}
+class Class519 {
+ public Class519(){
+
+ }
+}
+class Class520 {
+ public Class520(){
+
+ }
+}
+class Class521 {
+ public Class521(){
+
+ }
+}
+class Class522 {
+ public Class522(){
+
+ }
+}
+class Class523 {
+ public Class523(){
+
+ }
+}
+class Class524 {
+ public Class524(){
+
+ }
+}
+class Class525 {
+ public Class525(){
+
+ }
+}
+class Class526 {
+ public Class526(){
+
+ }
+}
+class Class527 {
+ public Class527(){
+
+ }
+}
+class Class528 {
+ public Class528(){
+
+ }
+}
+class Class529 {
+ public Class529(){
+
+ }
+}
+class Class530 {
+ public Class530(){
+
+ }
+}
+class Class531 {
+ public Class531(){
+
+ }
+}
+class Class532 {
+ public Class532(){
+
+ }
+}
+class Class533 {
+ public Class533(){
+
+ }
+}
+class Class534 {
+ public Class534(){
+
+ }
+}
+class Class535 {
+ public Class535(){
+
+ }
+}
+class Class536 {
+ public Class536(){
+
+ }
+}
+class Class537 {
+ public Class537(){
+
+ }
+}
+class Class538 {
+ public Class538(){
+
+ }
+}
+class Class539 {
+ public Class539(){
+
+ }
+}
+class Class540 {
+ public Class540(){
+
+ }
+}
+class Class541 {
+ public Class541(){
+
+ }
+}
+class Class542 {
+ public Class542(){
+
+ }
+}
+class Class543 {
+ public Class543(){
+
+ }
+}
+class Class544 {
+ public Class544(){
+
+ }
+}
+class Class545 {
+ public Class545(){
+
+ }
+}
+class Class546 {
+ public Class546(){
+
+ }
+}
+class Class547 {
+ public Class547(){
+
+ }
+}
+class Class548 {
+ public Class548(){
+
+ }
+}
+class Class549 {
+ public Class549(){
+
+ }
+}
+class Class550 {
+ public Class550(){
+
+ }
+}
+class Class551 {
+ public Class551(){
+
+ }
+}
+class Class552 {
+ public Class552(){
+
+ }
+}
+class Class553 {
+ public Class553(){
+
+ }
+}
+class Class554 {
+ public Class554(){
+
+ }
+}
+class Class555 {
+ public Class555(){
+
+ }
+}
+class Class556 {
+ public Class556(){
+
+ }
+}
+class Class557 {
+ public Class557(){
+
+ }
+}
+class Class558 {
+ public Class558(){
+
+ }
+}
+class Class559 {
+ public Class559(){
+
+ }
+}
+class Class560 {
+ public Class560(){
+
+ }
+}
+class Class561 {
+ public Class561(){
+
+ }
+}
+class Class562 {
+ public Class562(){
+
+ }
+}
+class Class563 {
+ public Class563(){
+
+ }
+}
+class Class564 {
+ public Class564(){
+
+ }
+}
+class Class565 {
+ public Class565(){
+
+ }
+}
+class Class566 {
+ public Class566(){
+
+ }
+}
+class Class567 {
+ public Class567(){
+
+ }
+}
+class Class568 {
+ public Class568(){
+
+ }
+}
+class Class569 {
+ public Class569(){
+
+ }
+}
+class Class570 {
+ public Class570(){
+
+ }
+}
+class Class571 {
+ public Class571(){
+
+ }
+}
+class Class572 {
+ public Class572(){
+
+ }
+}
+class Class573 {
+ public Class573(){
+
+ }
+}
+class Class574 {
+ public Class574(){
+
+ }
+}
+class Class575 {
+ public Class575(){
+
+ }
+}
+class Class576 {
+ public Class576(){
+
+ }
+}
+class Class577 {
+ public Class577(){
+
+ }
+}
+class Class578 {
+ public Class578(){
+
+ }
+}
+class Class579 {
+ public Class579(){
+
+ }
+}
+class Class580 {
+ public Class580(){
+
+ }
+}
+class Class581 {
+ public Class581(){
+
+ }
+}
+class Class582 {
+ public Class582(){
+
+ }
+}
+class Class583 {
+ public Class583(){
+
+ }
+}
+class Class584 {
+ public Class584(){
+
+ }
+}
+class Class585 {
+ public Class585(){
+
+ }
+}
+class Class586 {
+ public Class586(){
+
+ }
+}
+class Class587 {
+ public Class587(){
+
+ }
+}
+class Class588 {
+ public Class588(){
+
+ }
+}
+class Class589 {
+ public Class589(){
+
+ }
+}
+class Class590 {
+ public Class590(){
+
+ }
+}
+class Class591 {
+ public Class591(){
+
+ }
+}
+class Class592 {
+ public Class592(){
+
+ }
+}
+class Class593 {
+ public Class593(){
+
+ }
+}
+class Class594 {
+ public Class594(){
+
+ }
+}
+class Class595 {
+ public Class595(){
+
+ }
+}
+class Class596 {
+ public Class596(){
+
+ }
+}
+class Class597 {
+ public Class597(){
+
+ }
+}
+class Class598 {
+ public Class598(){
+
+ }
+}
+class Class599 {
+ public Class599(){
+
+ }
+}
+class Class600 {
+ public Class600(){
+
+ }
+}
+class Class601 {
+ public Class601(){
+
+ }
+}
+class Class602 {
+ public Class602(){
+
+ }
+}
+class Class603 {
+ public Class603(){
+
+ }
+}
+class Class604 {
+ public Class604(){
+
+ }
+}
+class Class605 {
+ public Class605(){
+
+ }
+}
+class Class606 {
+ public Class606(){
+
+ }
+}
+class Class607 {
+ public Class607(){
+
+ }
+}
+class Class608 {
+ public Class608(){
+
+ }
+}
+class Class609 {
+ public Class609(){
+
+ }
+}
+class Class610 {
+ public Class610(){
+
+ }
+}
+class Class611 {
+ public Class611(){
+
+ }
+}
+class Class612 {
+ public Class612(){
+
+ }
+}
+class Class613 {
+ public Class613(){
+
+ }
+}
+class Class614 {
+ public Class614(){
+
+ }
+}
+class Class615 {
+ public Class615(){
+
+ }
+}
+class Class616 {
+ public Class616(){
+
+ }
+}
+class Class617 {
+ public Class617(){
+
+ }
+}
+class Class618 {
+ public Class618(){
+
+ }
+}
+class Class619 {
+ public Class619(){
+
+ }
+}
+class Class620 {
+ public Class620(){
+
+ }
+}
+class Class621 {
+ public Class621(){
+
+ }
+}
+class Class622 {
+ public Class622(){
+
+ }
+}
+class Class623 {
+ public Class623(){
+
+ }
+}
+class Class624 {
+ public Class624(){
+
+ }
+}
+class Class625 {
+ public Class625(){
+
+ }
+}
+class Class626 {
+ public Class626(){
+
+ }
+}
+class Class627 {
+ public Class627(){
+
+ }
+}
+class Class628 {
+ public Class628(){
+
+ }
+}
+class Class629 {
+ public Class629(){
+
+ }
+}
+class Class630 {
+ public Class630(){
+
+ }
+}
+class Class631 {
+ public Class631(){
+
+ }
+}
+class Class632 {
+ public Class632(){
+
+ }
+}
+class Class633 {
+ public Class633(){
+
+ }
+}
+class Class634 {
+ public Class634(){
+
+ }
+}
+class Class635 {
+ public Class635(){
+
+ }
+}
+class Class636 {
+ public Class636(){
+
+ }
+}
+class Class637 {
+ public Class637(){
+
+ }
+}
+class Class638 {
+ public Class638(){
+
+ }
+}
+class Class639 {
+ public Class639(){
+
+ }
+}
+class Class640 {
+ public Class640(){
+
+ }
+}
+class Class641 {
+ public Class641(){
+
+ }
+}
+class Class642 {
+ public Class642(){
+
+ }
+}
+class Class643 {
+ public Class643(){
+
+ }
+}
+class Class644 {
+ public Class644(){
+
+ }
+}
+class Class645 {
+ public Class645(){
+
+ }
+}
+class Class646 {
+ public Class646(){
+
+ }
+}
+class Class647 {
+ public Class647(){
+
+ }
+}
+class Class648 {
+ public Class648(){
+
+ }
+}
+class Class649 {
+ public Class649(){
+
+ }
+}
+class Class650 {
+ public Class650(){
+
+ }
+}
+class Class651 {
+ public Class651(){
+
+ }
+}
+class Class652 {
+ public Class652(){
+
+ }
+}
+class Class653 {
+ public Class653(){
+
+ }
+}
+class Class654 {
+ public Class654(){
+
+ }
+}
+class Class655 {
+ public Class655(){
+
+ }
+}
+class Class656 {
+ public Class656(){
+
+ }
+}
+class Class657 {
+ public Class657(){
+
+ }
+}
+class Class658 {
+ public Class658(){
+
+ }
+}
+class Class659 {
+ public Class659(){
+
+ }
+}
+class Class660 {
+ public Class660(){
+
+ }
+}
+class Class661 {
+ public Class661(){
+
+ }
+}
+class Class662 {
+ public Class662(){
+
+ }
+}
+class Class663 {
+ public Class663(){
+
+ }
+}
+class Class664 {
+ public Class664(){
+
+ }
+}
+class Class665 {
+ public Class665(){
+
+ }
+}
+class Class666 {
+ public Class666(){
+
+ }
+}
+class Class667 {
+ public Class667(){
+
+ }
+}
+class Class668 {
+ public Class668(){
+
+ }
+}
+class Class669 {
+ public Class669(){
+
+ }
+}
+class Class670 {
+ public Class670(){
+
+ }
+}
+class Class671 {
+ public Class671(){
+
+ }
+}
+class Class672 {
+ public Class672(){
+
+ }
+}
+class Class673 {
+ public Class673(){
+
+ }
+}
+class Class674 {
+ public Class674(){
+
+ }
+}
+class Class675 {
+ public Class675(){
+
+ }
+}
+class Class676 {
+ public Class676(){
+
+ }
+}
+class Class677 {
+ public Class677(){
+
+ }
+}
+class Class678 {
+ public Class678(){
+
+ }
+}
+class Class679 {
+ public Class679(){
+
+ }
+}
+class Class680 {
+ public Class680(){
+
+ }
+}
+class Class681 {
+ public Class681(){
+
+ }
+}
+class Class682 {
+ public Class682(){
+
+ }
+}
+class Class683 {
+ public Class683(){
+
+ }
+}
+class Class684 {
+ public Class684(){
+
+ }
+}
+class Class685 {
+ public Class685(){
+
+ }
+}
+class Class686 {
+ public Class686(){
+
+ }
+}
+class Class687 {
+ public Class687(){
+
+ }
+}
+class Class688 {
+ public Class688(){
+
+ }
+}
+class Class689 {
+ public Class689(){
+
+ }
+}
+class Class690 {
+ public Class690(){
+
+ }
+}
+class Class691 {
+ public Class691(){
+
+ }
+}
+class Class692 {
+ public Class692(){
+
+ }
+}
+class Class693 {
+ public Class693(){
+
+ }
+}
+class Class694 {
+ public Class694(){
+
+ }
+}
+class Class695 {
+ public Class695(){
+
+ }
+}
+class Class696 {
+ public Class696(){
+
+ }
+}
+class Class697 {
+ public Class697(){
+
+ }
+}
+class Class698 {
+ public Class698(){
+
+ }
+}
+class Class699 {
+ public Class699(){
+
+ }
+}
+class Class700 {
+ public Class700(){
+
+ }
+}
+class Class701 {
+ public Class701(){
+
+ }
+}
+class Class702 {
+ public Class702(){
+
+ }
+}
+class Class703 {
+ public Class703(){
+
+ }
+}
+class Class704 {
+ public Class704(){
+
+ }
+}
+class Class705 {
+ public Class705(){
+
+ }
+}
+class Class706 {
+ public Class706(){
+
+ }
+}
+class Class707 {
+ public Class707(){
+
+ }
+}
+class Class708 {
+ public Class708(){
+
+ }
+}
+class Class709 {
+ public Class709(){
+
+ }
+}
+class Class710 {
+ public Class710(){
+
+ }
+}
+class Class711 {
+ public Class711(){
+
+ }
+}
+class Class712 {
+ public Class712(){
+
+ }
+}
+class Class713 {
+ public Class713(){
+
+ }
+}
+class Class714 {
+ public Class714(){
+
+ }
+}
+class Class715 {
+ public Class715(){
+
+ }
+}
+class Class716 {
+ public Class716(){
+
+ }
+}
+class Class717 {
+ public Class717(){
+
+ }
+}
+class Class718 {
+ public Class718(){
+
+ }
+}
+class Class719 {
+ public Class719(){
+
+ }
+}
+class Class720 {
+ public Class720(){
+
+ }
+}
+class Class721 {
+ public Class721(){
+
+ }
+}
+class Class722 {
+ public Class722(){
+
+ }
+}
+class Class723 {
+ public Class723(){
+
+ }
+}
+class Class724 {
+ public Class724(){
+
+ }
+}
+class Class725 {
+ public Class725(){
+
+ }
+}
+class Class726 {
+ public Class726(){
+
+ }
+}
+class Class727 {
+ public Class727(){
+
+ }
+}
+class Class728 {
+ public Class728(){
+
+ }
+}
+class Class729 {
+ public Class729(){
+
+ }
+}
+class Class730 {
+ public Class730(){
+
+ }
+}
+class Class731 {
+ public Class731(){
+
+ }
+}
+class Class732 {
+ public Class732(){
+
+ }
+}
+class Class733 {
+ public Class733(){
+
+ }
+}
+class Class734 {
+ public Class734(){
+
+ }
+}
+class Class735 {
+ public Class735(){
+
+ }
+}
+class Class736 {
+ public Class736(){
+
+ }
+}
+class Class737 {
+ public Class737(){
+
+ }
+}
+class Class738 {
+ public Class738(){
+
+ }
+}
+class Class739 {
+ public Class739(){
+
+ }
+}
+class Class740 {
+ public Class740(){
+
+ }
+}
+class Class741 {
+ public Class741(){
+
+ }
+}
+class Class742 {
+ public Class742(){
+
+ }
+}
+class Class743 {
+ public Class743(){
+
+ }
+}
+class Class744 {
+ public Class744(){
+
+ }
+}
+class Class745 {
+ public Class745(){
+
+ }
+}
+class Class746 {
+ public Class746(){
+
+ }
+}
+class Class747 {
+ public Class747(){
+
+ }
+}
+class Class748 {
+ public Class748(){
+
+ }
+}
+class Class749 {
+ public Class749(){
+
+ }
+}
+class Class750 {
+ public Class750(){
+
+ }
+}
+class Class751 {
+ public Class751(){
+
+ }
+}
+class Class752 {
+ public Class752(){
+
+ }
+}
+class Class753 {
+ public Class753(){
+
+ }
+}
+class Class754 {
+ public Class754(){
+
+ }
+}
+class Class755 {
+ public Class755(){
+
+ }
+}
+class Class756 {
+ public Class756(){
+
+ }
+}
+class Class757 {
+ public Class757(){
+
+ }
+}
+class Class758 {
+ public Class758(){
+
+ }
+}
+class Class759 {
+ public Class759(){
+
+ }
+}
+class Class760 {
+ public Class760(){
+
+ }
+}
+class Class761 {
+ public Class761(){
+
+ }
+}
+class Class762 {
+ public Class762(){
+
+ }
+}
+class Class763 {
+ public Class763(){
+
+ }
+}
+class Class764 {
+ public Class764(){
+
+ }
+}
+class Class765 {
+ public Class765(){
+
+ }
+}
+class Class766 {
+ public Class766(){
+
+ }
+}
+class Class767 {
+ public Class767(){
+
+ }
+}
+class Class768 {
+ public Class768(){
+
+ }
+}
+class Class769 {
+ public Class769(){
+
+ }
+}
+class Class770 {
+ public Class770(){
+
+ }
+}
+class Class771 {
+ public Class771(){
+
+ }
+}
+class Class772 {
+ public Class772(){
+
+ }
+}
+class Class773 {
+ public Class773(){
+
+ }
+}
+class Class774 {
+ public Class774(){
+
+ }
+}
+class Class775 {
+ public Class775(){
+
+ }
+}
+class Class776 {
+ public Class776(){
+
+ }
+}
+class Class777 {
+ public Class777(){
+
+ }
+}
+class Class778 {
+ public Class778(){
+
+ }
+}
+class Class779 {
+ public Class779(){
+
+ }
+}
+class Class780 {
+ public Class780(){
+
+ }
+}
+class Class781 {
+ public Class781(){
+
+ }
+}
+class Class782 {
+ public Class782(){
+
+ }
+}
+class Class783 {
+ public Class783(){
+
+ }
+}
+class Class784 {
+ public Class784(){
+
+ }
+}
+class Class785 {
+ public Class785(){
+
+ }
+}
+class Class786 {
+ public Class786(){
+
+ }
+}
+class Class787 {
+ public Class787(){
+
+ }
+}
+class Class788 {
+ public Class788(){
+
+ }
+}
+class Class789 {
+ public Class789(){
+
+ }
+}
+class Class790 {
+ public Class790(){
+
+ }
+}
+class Class791 {
+ public Class791(){
+
+ }
+}
+class Class792 {
+ public Class792(){
+
+ }
+}
+class Class793 {
+ public Class793(){
+
+ }
+}
+class Class794 {
+ public Class794(){
+
+ }
+}
+class Class795 {
+ public Class795(){
+
+ }
+}
+class Class796 {
+ public Class796(){
+
+ }
+}
+class Class797 {
+ public Class797(){
+
+ }
+}
+class Class798 {
+ public Class798(){
+
+ }
+}
+class Class799 {
+ public Class799(){
+
+ }
+}
+class Class800 {
+ public Class800(){
+
+ }
+}
+class Class801 {
+ public Class801(){
+
+ }
+}
+class Class802 {
+ public Class802(){
+
+ }
+}
+class Class803 {
+ public Class803(){
+
+ }
+}
+class Class804 {
+ public Class804(){
+
+ }
+}
+class Class805 {
+ public Class805(){
+
+ }
+}
+class Class806 {
+ public Class806(){
+
+ }
+}
+class Class807 {
+ public Class807(){
+
+ }
+}
+class Class808 {
+ public Class808(){
+
+ }
+}
+class Class809 {
+ public Class809(){
+
+ }
+}
+class Class810 {
+ public Class810(){
+
+ }
+}
+class Class811 {
+ public Class811(){
+
+ }
+}
+class Class812 {
+ public Class812(){
+
+ }
+}
+class Class813 {
+ public Class813(){
+
+ }
+}
+class Class814 {
+ public Class814(){
+
+ }
+}
+class Class815 {
+ public Class815(){
+
+ }
+}
+class Class816 {
+ public Class816(){
+
+ }
+}
+class Class817 {
+ public Class817(){
+
+ }
+}
+class Class818 {
+ public Class818(){
+
+ }
+}
+class Class819 {
+ public Class819(){
+
+ }
+}
+class Class820 {
+ public Class820(){
+
+ }
+}
+class Class821 {
+ public Class821(){
+
+ }
+}
+class Class822 {
+ public Class822(){
+
+ }
+}
+class Class823 {
+ public Class823(){
+
+ }
+}
+class Class824 {
+ public Class824(){
+
+ }
+}
+class Class825 {
+ public Class825(){
+
+ }
+}
+class Class826 {
+ public Class826(){
+
+ }
+}
+class Class827 {
+ public Class827(){
+
+ }
+}
+class Class828 {
+ public Class828(){
+
+ }
+}
+class Class829 {
+ public Class829(){
+
+ }
+}
+class Class830 {
+ public Class830(){
+
+ }
+}
+class Class831 {
+ public Class831(){
+
+ }
+}
+class Class832 {
+ public Class832(){
+
+ }
+}
+class Class833 {
+ public Class833(){
+
+ }
+}
+class Class834 {
+ public Class834(){
+
+ }
+}
+class Class835 {
+ public Class835(){
+
+ }
+}
+class Class836 {
+ public Class836(){
+
+ }
+}
+class Class837 {
+ public Class837(){
+
+ }
+}
+class Class838 {
+ public Class838(){
+
+ }
+}
+class Class839 {
+ public Class839(){
+
+ }
+}
+class Class840 {
+ public Class840(){
+
+ }
+}
+class Class841 {
+ public Class841(){
+
+ }
+}
+class Class842 {
+ public Class842(){
+
+ }
+}
+class Class843 {
+ public Class843(){
+
+ }
+}
+class Class844 {
+ public Class844(){
+
+ }
+}
+class Class845 {
+ public Class845(){
+
+ }
+}
+class Class846 {
+ public Class846(){
+
+ }
+}
+class Class847 {
+ public Class847(){
+
+ }
+}
+class Class848 {
+ public Class848(){
+
+ }
+}
+class Class849 {
+ public Class849(){
+
+ }
+}
+class Class850 {
+ public Class850(){
+
+ }
+}
+class Class851 {
+ public Class851(){
+
+ }
+}
+class Class852 {
+ public Class852(){
+
+ }
+}
+class Class853 {
+ public Class853(){
+
+ }
+}
+class Class854 {
+ public Class854(){
+
+ }
+}
+class Class855 {
+ public Class855(){
+
+ }
+}
+class Class856 {
+ public Class856(){
+
+ }
+}
+class Class857 {
+ public Class857(){
+
+ }
+}
+class Class858 {
+ public Class858(){
+
+ }
+}
+class Class859 {
+ public Class859(){
+
+ }
+}
+class Class860 {
+ public Class860(){
+
+ }
+}
+class Class861 {
+ public Class861(){
+
+ }
+}
+class Class862 {
+ public Class862(){
+
+ }
+}
+class Class863 {
+ public Class863(){
+
+ }
+}
+class Class864 {
+ public Class864(){
+
+ }
+}
+class Class865 {
+ public Class865(){
+
+ }
+}
+class Class866 {
+ public Class866(){
+
+ }
+}
+class Class867 {
+ public Class867(){
+
+ }
+}
+class Class868 {
+ public Class868(){
+
+ }
+}
+class Class869 {
+ public Class869(){
+
+ }
+}
+class Class870 {
+ public Class870(){
+
+ }
+}
+class Class871 {
+ public Class871(){
+
+ }
+}
+class Class872 {
+ public Class872(){
+
+ }
+}
+class Class873 {
+ public Class873(){
+
+ }
+}
+class Class874 {
+ public Class874(){
+
+ }
+}
+class Class875 {
+ public Class875(){
+
+ }
+}
+class Class876 {
+ public Class876(){
+
+ }
+}
+class Class877 {
+ public Class877(){
+
+ }
+}
+class Class878 {
+ public Class878(){
+
+ }
+}
+class Class879 {
+ public Class879(){
+
+ }
+}
+class Class880 {
+ public Class880(){
+
+ }
+}
+class Class881 {
+ public Class881(){
+
+ }
+}
+class Class882 {
+ public Class882(){
+
+ }
+}
+class Class883 {
+ public Class883(){
+
+ }
+}
+class Class884 {
+ public Class884(){
+
+ }
+}
+class Class885 {
+ public Class885(){
+
+ }
+}
+class Class886 {
+ public Class886(){
+
+ }
+}
+class Class887 {
+ public Class887(){
+
+ }
+}
+class Class888 {
+ public Class888(){
+
+ }
+}
+class Class889 {
+ public Class889(){
+
+ }
+}
+class Class890 {
+ public Class890(){
+
+ }
+}
+class Class891 {
+ public Class891(){
+
+ }
+}
+class Class892 {
+ public Class892(){
+
+ }
+}
+class Class893 {
+ public Class893(){
+
+ }
+}
+class Class894 {
+ public Class894(){
+
+ }
+}
+class Class895 {
+ public Class895(){
+
+ }
+}
+class Class896 {
+ public Class896(){
+
+ }
+}
+class Class897 {
+ public Class897(){
+
+ }
+}
+class Class898 {
+ public Class898(){
+
+ }
+}
+class Class899 {
+ public Class899(){
+
+ }
+}
+class Class900 {
+ public Class900(){
+
+ }
+}
+class Class901 {
+ public Class901(){
+
+ }
+}
+class Class902 {
+ public Class902(){
+
+ }
+}
+class Class903 {
+ public Class903(){
+
+ }
+}
+class Class904 {
+ public Class904(){
+
+ }
+}
+class Class905 {
+ public Class905(){
+
+ }
+}
+class Class906 {
+ public Class906(){
+
+ }
+}
+class Class907 {
+ public Class907(){
+
+ }
+}
+class Class908 {
+ public Class908(){
+
+ }
+}
+class Class909 {
+ public Class909(){
+
+ }
+}
+class Class910 {
+ public Class910(){
+
+ }
+}
+class Class911 {
+ public Class911(){
+
+ }
+}
+class Class912 {
+ public Class912(){
+
+ }
+}
+class Class913 {
+ public Class913(){
+
+ }
+}
+class Class914 {
+ public Class914(){
+
+ }
+}
+class Class915 {
+ public Class915(){
+
+ }
+}
+class Class916 {
+ public Class916(){
+
+ }
+}
+class Class917 {
+ public Class917(){
+
+ }
+}
+class Class918 {
+ public Class918(){
+
+ }
+}
+class Class919 {
+ public Class919(){
+
+ }
+}
+class Class920 {
+ public Class920(){
+
+ }
+}
+class Class921 {
+ public Class921(){
+
+ }
+}
+class Class922 {
+ public Class922(){
+
+ }
+}
+class Class923 {
+ public Class923(){
+
+ }
+}
+class Class924 {
+ public Class924(){
+
+ }
+}
+class Class925 {
+ public Class925(){
+
+ }
+}
+class Class926 {
+ public Class926(){
+
+ }
+}
+class Class927 {
+ public Class927(){
+
+ }
+}
+class Class928 {
+ public Class928(){
+
+ }
+}
+class Class929 {
+ public Class929(){
+
+ }
+}
+class Class930 {
+ public Class930(){
+
+ }
+}
+class Class931 {
+ public Class931(){
+
+ }
+}
+class Class932 {
+ public Class932(){
+
+ }
+}
+class Class933 {
+ public Class933(){
+
+ }
+}
+class Class934 {
+ public Class934(){
+
+ }
+}
+class Class935 {
+ public Class935(){
+
+ }
+}
+class Class936 {
+ public Class936(){
+
+ }
+}
+class Class937 {
+ public Class937(){
+
+ }
+}
+class Class938 {
+ public Class938(){
+
+ }
+}
+class Class939 {
+ public Class939(){
+
+ }
+}
+class Class940 {
+ public Class940(){
+
+ }
+}
+class Class941 {
+ public Class941(){
+
+ }
+}
+class Class942 {
+ public Class942(){
+
+ }
+}
+class Class943 {
+ public Class943(){
+
+ }
+}
+class Class944 {
+ public Class944(){
+
+ }
+}
+class Class945 {
+ public Class945(){
+
+ }
+}
+class Class946 {
+ public Class946(){
+
+ }
+}
+class Class947 {
+ public Class947(){
+
+ }
+}
+class Class948 {
+ public Class948(){
+
+ }
+}
+class Class949 {
+ public Class949(){
+
+ }
+}
+class Class950 {
+ public Class950(){
+
+ }
+}
+class Class951 {
+ public Class951(){
+
+ }
+}
+class Class952 {
+ public Class952(){
+
+ }
+}
+class Class953 {
+ public Class953(){
+
+ }
+}
+class Class954 {
+ public Class954(){
+
+ }
+}
+class Class955 {
+ public Class955(){
+
+ }
+}
+class Class956 {
+ public Class956(){
+
+ }
+}
+class Class957 {
+ public Class957(){
+
+ }
+}
+class Class958 {
+ public Class958(){
+
+ }
+}
+class Class959 {
+ public Class959(){
+
+ }
+}
+class Class960 {
+ public Class960(){
+
+ }
+}
+class Class961 {
+ public Class961(){
+
+ }
+}
+class Class962 {
+ public Class962(){
+
+ }
+}
+class Class963 {
+ public Class963(){
+
+ }
+}
+class Class964 {
+ public Class964(){
+
+ }
+}
+class Class965 {
+ public Class965(){
+
+ }
+}
+class Class966 {
+ public Class966(){
+
+ }
+}
+class Class967 {
+ public Class967(){
+
+ }
+}
+class Class968 {
+ public Class968(){
+
+ }
+}
+class Class969 {
+ public Class969(){
+
+ }
+}
+class Class970 {
+ public Class970(){
+
+ }
+}
+class Class971 {
+ public Class971(){
+
+ }
+}
+class Class972 {
+ public Class972(){
+
+ }
+}
+class Class973 {
+ public Class973(){
+
+ }
+}
+class Class974 {
+ public Class974(){
+
+ }
+}
+class Class975 {
+ public Class975(){
+
+ }
+}
+class Class976 {
+ public Class976(){
+
+ }
+}
+class Class977 {
+ public Class977(){
+
+ }
+}
+class Class978 {
+ public Class978(){
+
+ }
+}
+class Class979 {
+ public Class979(){
+
+ }
+}
+class Class980 {
+ public Class980(){
+
+ }
+}
+class Class981 {
+ public Class981(){
+
+ }
+}
+class Class982 {
+ public Class982(){
+
+ }
+}
+class Class983 {
+ public Class983(){
+
+ }
+}
+class Class984 {
+ public Class984(){
+
+ }
+}
+class Class985 {
+ public Class985(){
+
+ }
+}
+class Class986 {
+ public Class986(){
+
+ }
+}
+class Class987 {
+ public Class987(){
+
+ }
+}
+class Class988 {
+ public Class988(){
+
+ }
+}
+class Class989 {
+ public Class989(){
+
+ }
+}
+class Class990 {
+ public Class990(){
+
+ }
+}
+class Class991 {
+ public Class991(){
+
+ }
+}
+class Class992 {
+ public Class992(){
+
+ }
+}
+class Class993 {
+ public Class993(){
+
+ }
+}
+class Class994 {
+ public Class994(){
+
+ }
+}
+class Class995 {
+ public Class995(){
+
+ }
+}
+class Class996 {
+ public Class996(){
+
+ }
+}
+class Class997 {
+ public Class997(){
+
+ }
+}
+class Class998 {
+ public Class998(){
+
+ }
+}
+class Class999 {
+ public Class999(){
+
+ }
+}
+class Class1000 {
+ public Class1000(){
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/DerivedProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/DerivedProducer.java
new file mode 100644
index 00000000000..c9483a26bab
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/DerivedProducer.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp;
+
+/**
+ * Garbage producer that uses another garbage producer
+ * to implement it's functionality.
+ */
+public abstract class DerivedProducer implements GarbageProducer {
+ private GarbageProducer parent;
+
+ public DerivedProducer(GarbageProducer
parent) {
+ setParent(parent);
+ }
+
+ protected P createParent(long memory) {
+ return parent.create(memory);
+ }
+
+ protected void validateParent(P obj) {
+ parent.validate(obj);
+ }
+
+ public final GarbageProducer
getParent() {
+ return parent;
+ }
+
+ public final void setParent(GarbageProducer
parent) {
+ this.parent = parent;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/DerivedStrategyProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/DerivedStrategyProducer.java
new file mode 100644
index 00000000000..9d6834a37e1
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/DerivedStrategyProducer.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp;
+
+/**
+ * Derived garbage producer that uses a memory strategy.
+ */
+public abstract class DerivedStrategyProducer extends DerivedProducer {
+ protected MemoryStrategy memoryStrategy;
+
+ public DerivedStrategyProducer(GarbageProducer parent, MemoryStrategy memoryStrategy) {
+ super(parent);
+ }
+
+ public final void setMemoryStrategy(MemoryStrategy memoryStrategy) {
+ this.memoryStrategy = memoryStrategy;
+ }
+
+ public final MemoryStrategy getMemoryStrategy() {
+ return memoryStrategy;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageProducer.java
new file mode 100644
index 00000000000..d703885a0c6
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageProducer.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp;
+
+/**
+ * Interface that defines a way to produce garbage.
+ */
+public interface GarbageProducer {
+ /**
+ * Produce garbage of given size.
+ *
+ * @param memory size in bytes
+ * @return produced garbage
+ */
+ public T create(long memory);
+
+ /**
+ * Validate earlier produced object.
+ *
+ * @param obj earlier produced garbage
+ * @throws TestFailure if validation fails
+ */
+ public void validate(T obj);
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageProducer1Aware.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageProducer1Aware.java
new file mode 100644
index 00000000000..e5f65c8a937
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageProducer1Aware.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp;
+
+/**
+ * Marker interface for getting GarbageProducer.
+ */
+public interface GarbageProducer1Aware {
+ public void setGarbageProducer1(GarbageProducer gp);
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageProducerAware.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageProducerAware.java
new file mode 100644
index 00000000000..f7ef1289869
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageProducerAware.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp;
+
+/**
+ * Marker interface for getting GarbageProducer.
+ */
+public interface GarbageProducerAware {
+ public void setGarbageProducer(GarbageProducer gp);
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageProducers.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageProducers.java
new file mode 100644
index 00000000000..38169bd99a2
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageProducers.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp;
+
+import java.util.List;
+import java.util.ArrayList;
+import nsk.share.gc.gp.array.*;
+import nsk.share.gc.gp.string.*;
+
+/**
+ * Factory for garbage producers
+ */
+public class GarbageProducers {
+ private List primitiveArrayProducers;
+ private List arrayProducers;
+ private List> stringProducers;
+ private List allProducers;
+
+ /**
+ * Get all primitive array producers.
+ */
+ public List getPrimitiveArrayProducers() {
+ if (primitiveArrayProducers == null) {
+ primitiveArrayProducers = new ArrayList();
+ primitiveArrayProducers.add(new ByteArrayProducer());
+ primitiveArrayProducers.add(new BooleanArrayProducer());
+ primitiveArrayProducers.add(new ShortArrayProducer());
+ primitiveArrayProducers.add(new CharArrayProducer());
+ primitiveArrayProducers.add(new IntArrayProducer());
+ primitiveArrayProducers.add(new LongArrayProducer());
+ primitiveArrayProducers.add(new FloatArrayProducer());
+ primitiveArrayProducers.add(new DoubleArrayProducer());
+ }
+ return primitiveArrayProducers;
+ }
+
+ /**
+ * Get all array producers.
+ */
+ public List getArrayProducers() {
+ if (arrayProducers == null) {
+ arrayProducers = new ArrayList();
+ arrayProducers.addAll(getPrimitiveArrayProducers());
+ arrayProducers.add(new ObjectArrayProducer());
+ }
+ return arrayProducers;
+ }
+
+ /**
+ * Get all string producers.
+ */
+ public List> getStringProducers() {
+ if (stringProducers == null) {
+ stringProducers = new ArrayList>();
+ stringProducers.add(new RandomStringProducer());
+ stringProducers.add(new InternedStringProducer());
+ }
+ return stringProducers;
+ }
+
+ public List getAllProducers() {
+ if (allProducers == null) {
+ allProducers = new ArrayList();
+ allProducers.addAll(getArrayProducers());
+ allProducers.addAll(getStringProducers());
+ }
+ return allProducers;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageUtils.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageUtils.java
new file mode 100644
index 00000000000..333bf070b68
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageUtils.java
@@ -0,0 +1,398 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.*;
+import nsk.share.gc.gp.array.*;
+import nsk.share.gc.gp.string.*;
+import nsk.share.gc.gp.list.*;
+import nsk.share.gc.gp.tree.*;
+import nsk.share.gc.gp.misc.*;
+import nsk.share.gc.gp.classload.*;
+import nsk.share.gc.Memory;
+import nsk.share.TestBug;
+import nsk.share.test.*;
+
+/**
+ * Utility methods for garbage producers.
+ */
+public final class GarbageUtils {
+ private static final int ALLOCATION_LIMIT = 50000000; //50 Mb
+ private static GarbageProducers garbageProducers;
+ private static List primitiveArrayProducers;
+ private static List arrayProducers;
+ private static final GarbageProducer byteArrayProducer = new ByteArrayProducer();
+ public static enum OOM_TYPE {
+ ANY (),
+ HEAP("Java heap space"),
+ METASPACE("Metaspace", "Compressed class space");
+
+ private final String[] expectedStrings;
+ OOM_TYPE(String... expectedStrings) {
+ this.expectedStrings = expectedStrings;
+ }
+
+ /**
+ * Returns true if the given error message matches
+ * one of expected strings.
+ */
+ public boolean accept(String errorMessage) {
+ if (expectedStrings == null || expectedStrings.length == 0 || errorMessage == null) {
+ return true;
+ }
+ for (String s: expectedStrings) {
+ if (errorMessage.indexOf(s) != -1) {
+ return true;
+ }
+ }
+ return false;
+ }
+ };
+
+ // Force loading of OOM_TYPE and calling of enum contrusctors when loading GarbageUtils class.
+ public static final Object[] thisIsGarbageArray_theOnlyPurposeForCreatingItAndDeclaringItPublicIsToInitializeIntancesOfOOMEnumberation = new Object[] { OOM_TYPE.ANY, OOM_TYPE.HEAP, OOM_TYPE.METASPACE };
+
+ // Force early loading of classes that might otherwise unexpectedly fail
+ // class loading during testing due to high memory pressure.
+ public static final StringWriter preloadStringWriter = new StringWriter(1);
+ public static final PrintWriter preloadPrintWriter = new PrintWriter(preloadStringWriter);
+
+ private GarbageUtils() {
+ }
+
+ /**
+ * Eat memory using execution controller that waits for 2 minutes.
+ * @return number of OOME occured
+ */
+ public static int eatMemory() {
+ return eatMemory(2 * 60 * 1000);
+ }
+
+ /**
+ * Eat memory using execution controller that waits for timeout.
+ * @return number of OOME occured
+ */
+ public static int eatMemory(final long timeout) {
+ return eatMemory(new ExecutionController() {
+ final long initialTime = System.currentTimeMillis();
+
+ @Override
+ public void start(long stdIterations) {}
+
+ @Override
+ public boolean iteration() {return false;}
+
+ @Override
+ public boolean continueExecution() {
+ return System.currentTimeMillis() - initialTime < timeout;
+ }
+
+ @Override
+ public long getIteration() {return 0;}
+
+ @Override
+ public void finish() {}
+ });
+ }
+
+
+ /**
+ * Eat memory using given execution controller and garbage producer.
+ *
+ * @param stresser execution controller
+ * @param gp garbage producer
+ * @return number of OOME occured
+ */
+ public static int eatMemory(ExecutionController stresser) {
+ return eatMemory(stresser, byteArrayProducer, 50, 100, 2, OOM_TYPE.ANY);
+ }
+
+ /**
+ * Eat memory using given execution controller and garbage producer.
+ *
+ * @param stresser execution controller
+ * @param gp garbage producer
+ * @return number of OOME occured
+ */
+ public static int eatMemory(ExecutionController stresser, GarbageProducer gp) {
+ return eatMemory(stresser, gp, 50, 100, 2, OOM_TYPE.ANY);
+ }
+
+ /**
+ * Eat memory using given garbage producer and given factor.
+ *
+ * @param gp garbage producer
+ * @param factor factor to divide the array size by
+ * @return number of OOME occured
+ */
+ public static int eatMemory(ExecutionController stresser, GarbageProducer gp, long factor) {
+ return eatMemory(stresser, gp, 50, 100, factor, OOM_TYPE.ANY);
+ }
+
+ /**
+ * Eat memory using default(byte[]) garbage producer.
+ *
+ * Note that this method can throw Failure if any exception
+ * is thrown while eating memory. To avoid OOM while allocating
+ * exception we preallocate it before the lunch starts. It means
+ * that exception stack trace does not correspond to the place
+ * where exception is thrown, but points at start of the method.
+ *
+ * @param stresser stresser
+ * @param initialFactor determines which portion of initial memory initial chunk will be
+ * @param minMemoryChunk determines when to stop
+ * @param factor factor to divide the array size by
+ * @return number of OOME occured
+ */
+ public static int eatMemory(ExecutionController stresser,long initialFactor, long minMemoryChunk, long factor) {
+ return eatMemory(stresser, byteArrayProducer, initialFactor, minMemoryChunk, factor, OOM_TYPE.ANY);
+ }
+
+ /**
+ * Eat memory using given garbage producer.
+ *
+ * Note that this method can throw Failure if any exception
+ * is thrown while eating memory. To avoid OOM while allocating
+ * exception we preallocate it before the lunch starts. It means
+ * that exception stack trace does not correspond to the place
+ * where exception is thrown, but points at start of the method.
+ *
+ * @param stresser stresser to use
+ * @param gp garbage producer
+ * @param initialFactor determines which portion of initial memory initial chunk will be
+ * @param minMemoryChunk determines when to stop
+ * @param factor factor to divide the array size by. A value of 0 means that method returns after first OOME
+ * @param type of OutOfMemory Exception: Java heap space or Metadata space
+ * @return number of OOME occured
+ */
+ public static int eatMemory(ExecutionController stresser, GarbageProducer gp, long initialFactor, long minMemoryChunk, long factor) {
+ return eatMemory(stresser, gp, initialFactor, minMemoryChunk, factor, OOM_TYPE.ANY);
+ }
+
+ /**
+ * Eat memory using given garbage producer.
+ *
+ * Note that this method can throw Failure if any exception
+ * is thrown while eating memory. To avoid OOM while allocating
+ * exception we preallocate it before the lunch starts. It means
+ * that exception stack trace does not correspond to the place
+ * where exception is thrown, but points at start of the method.
+ *
+ * @param stresser stresser to use
+ * @param gp garbage producer
+ * @param initialFactor determines which portion of initial memory initial chunk will be
+ * @param minMemoryChunk determines when to stop
+ * @param factor factor to divide the array size by. A value of 0 means that method returns after first OOME
+ * @param type of OutOfMemory Exception: Java heap space or Metadata space
+ * @return number of OOME occured
+ */
+ public static int eatMemory(ExecutionController stresser, GarbageProducer gp, long initialFactor, long minMemoryChunk, long factor, OOM_TYPE type) {
+ int numberOfOOMEs = 0;
+ try {
+ StringWriter sw = new StringWriter(10000);
+ PrintWriter pw = new PrintWriter(sw);
+ byte[] someMemory = new byte[200000]; //200 Kb
+ try {
+ Runtime runtime = Runtime.getRuntime();
+ long maxMemory = runtime.maxMemory();
+ long maxMemoryChunk = maxMemory / initialFactor;
+ long chunk = maxMemoryChunk;
+ chunk = chunk > ALLOCATION_LIMIT ? ALLOCATION_LIMIT : chunk;
+ int allocations = 0;
+ List storage = new ArrayList();
+
+ while (chunk > minMemoryChunk && stresser.continueExecution()) {
+ try {
+ storage.add(gp.create(chunk));
+ if (Thread.currentThread().isInterrupted()) {
+ return numberOfOOMEs;
+ }
+ // if we are able to eat chunk*factor let
+ // try to increase size of chunk
+ if (chunk * factor < maxMemoryChunk
+ && factor != 0 && allocations++ == factor + 1) {
+ chunk = chunk * factor;
+ allocations = 0;
+ }
+ } catch (OutOfMemoryError e) {
+ someMemory = null;
+ if (type != OOM_TYPE.ANY) {
+ e.printStackTrace(pw);
+ pw.close();
+ if (type.accept(sw.toString())) {
+ numberOfOOMEs++;
+ } else {
+ // Trying to catch situation when Java generates OOM different type that test trying to catch
+ throw new TestBug("Test throw OOM of unexpected type." + sw.toString());
+ }
+ } else {
+ numberOfOOMEs++;
+ }
+ allocations = 0;
+ if (factor == 0) {
+ return numberOfOOMEs;
+ } else {
+ chunk = chunk / factor;
+ }
+ }
+ }
+ } catch (OutOfMemoryError e) {
+ someMemory = null;
+ if (type != OOM_TYPE.ANY) {
+ e.printStackTrace(pw);
+ pw.close();
+ if (type.accept(sw.toString())) {
+ numberOfOOMEs++;
+ } else {
+ // Trying to catch situation when Java generates OOM different type that test trying to catch
+ throw new TestBug("Test throw OOM of unexpected type." + sw.toString());
+ }
+ } else {
+ numberOfOOMEs++;
+ }
+ // all memory is eaten now even before we start, just return
+ }
+ } catch (OutOfMemoryError e) {
+ numberOfOOMEs++;
+ }
+ return numberOfOOMEs;
+ }
+
+ /**
+ * Get all primitive array producers.
+ */
+ public static List getPrimitiveArrayProducers() {
+ return getGarbageProducers().getPrimitiveArrayProducers();
+ }
+
+ /**
+ * Get all array producers.
+ */
+ public static List getArrayProducers() {
+ return getGarbageProducers().getArrayProducers();
+ }
+
+ /**
+ * Determine size of each object in array which will occupy given
+ * memory with distribution determined by given memory strategy.
+ */
+ public static long getArraySize(long memory, MemoryStrategy memoryStrategy) {
+ return memoryStrategy.getSize(memory - Memory.getArrayExtraSize(), Memory.getReferenceSize());
+ }
+
+ /**
+ * Determine object count in array which will occupy given
+ * memory with distribution determined by given memory strategy.
+ */
+ public static int getArrayCount(long memory, MemoryStrategy memoryStrategy) {
+ return memoryStrategy.getCount(memory - Memory.getArrayExtraSize(), Memory.getReferenceSize());
+ }
+
+ /**
+ * Get garbage producer by identifier.
+ *
+ * @param id identifier
+ * @return garbage producer for this identifier
+ */
+ public static GarbageProducer getGarbageProducer(String id) {
+ if (id == null || id.equals("byteArr"))
+ return new ByteArrayProducer();
+ else if (id.equals("booleanArr"))
+ return new BooleanArrayProducer();
+ else if (id.equals("shortArr"))
+ return new ShortArrayProducer();
+ else if (id.equals("charArr"))
+ return new CharArrayProducer();
+ else if (id.equals("intArr"))
+ return new IntArrayProducer();
+ else if (id.equals("longArr"))
+ return new LongArrayProducer();
+ else if (id.equals("floatArr"))
+ return new FloatArrayProducer();
+ else if (id.equals("doubleArr"))
+ return new DoubleArrayProducer();
+ else if (id.equals("objectArr"))
+ return new ObjectArrayProducer();
+ else if (id.equals("randomString"))
+ return new RandomStringProducer();
+ else if (id.equals("simpleString"))
+ return new SimpleStringProducer();
+ else if (id.startsWith("interned("))
+ return new InternedStringProducer(getGarbageProducer(getInBrackets(id)));
+ else if (id.startsWith("linearList("))
+ return new LinearListProducer(MemoryStrategy.fromString(getInBrackets(id)));
+ else if (id.startsWith("circularList("))
+ return new CircularListProducer(MemoryStrategy.fromString(getInBrackets(id)));
+ else if (id.startsWith("nonbranchyTree("))
+ return new NonbranchyTreeProducer(MemoryStrategy.fromString(getInBrackets(id)));
+ else if (id.equals("class"))
+ return new GeneratedClassProducer();
+ else if (id.startsWith("hashed("))
+ return new HashedGarbageProducer(getGarbageProducer(getInBrackets(id)));
+ else if (id.startsWith("random("))
+ return new RandomProducer(getGarbageProducerList(getInBrackets(id)));
+ else if (id.startsWith("twofields("))
+ return new TwoFieldsObjectProducer(getGarbageProducer(getInBrackets(id)));
+ else if (id.startsWith("arrayof("))
+ return new ArrayOfProducer(getGarbageProducer(getInBrackets(id)));
+ else if (id.startsWith("trace("))
+ return new TraceProducer(getGarbageProducer(getInBrackets(id)));
+ else
+ throw new TestBug("Invalid garbage producer identifier: " + id);
+ }
+
+ private static String getInBrackets(String s) {
+ int n1 = s.indexOf('(');
+ if (n1 == -1)
+ throw new TestBug("Opening bracket not found: " + s);
+ int n2 = s.lastIndexOf(')');
+ if (n2 == -1)
+ throw new TestBug("Closing bracket not found: " + s);
+ return s.substring(n1 + 1, n2);
+ }
+
+ private static List getGarbageProducerList(String s) {
+ if (s.equals("primitiveArrays"))
+ return getPrimitiveArrayProducers();
+ else if (s.equals("arrays"))
+ return getArrayProducers();
+ else {
+ String[] ids = s.split(",");
+ List garbageProducers = new ArrayList(ids.length);
+ for (int i = 0; i < ids.length; ++i)
+ garbageProducers.add(getGarbageProducer(ids[i]));
+ return garbageProducers;
+ //throw new TestBug("Invalid id for list of garbage producers: " + id);
+ }
+ }
+
+ public static GarbageProducers getGarbageProducers() {
+ if (garbageProducers == null)
+ garbageProducers = new GarbageProducers();
+ return garbageProducers;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/MemoryStrategy.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/MemoryStrategy.java
new file mode 100644
index 00000000000..4afaf11fb77
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/MemoryStrategy.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp;
+
+import nsk.share.TestBug;
+
+/**
+ * This class encapsulates notions like "many objects of small size",
+ * "small number of objects of big size".
+ */
+public abstract class MemoryStrategy {
+ private static int smallNumber = 100;
+ public abstract long getSize(long memory);
+ public abstract long getSize(long memory, long objectExtra);
+ public abstract int getCount(long memory);
+ public abstract int getCount(long memory, long objectExtra);
+
+ protected MemoryStrategy() {
+ }
+
+ /**
+ * Small object size, big number of objects.
+ */
+ public static final MemoryStrategy LOW = new MemoryStrategy() {
+ public long getSize(long memory) {
+ return getSize(memory, 0);
+ }
+
+ public long getSize(long memory, long objectExtra) {
+ return smallNumber;
+ }
+
+ public int getCount(long memory) {
+ return getCount(memory, 0);
+ }
+
+ public int getCount(long memory, long objectExtra) {
+ return (int) Math.min(Integer.MAX_VALUE, memory / (getSize(memory) + objectExtra));
+ }
+
+ public String toString() {
+ return "low";
+ }
+ };
+
+ /**
+ * Medium object size, medium number of objects.
+ */
+ public static final MemoryStrategy MEDIUM = new MemoryStrategy() {
+ public long getSize(long memory) {
+ return getSize(memory, 0);
+ }
+
+ public long getSize(long memory, long objectExtra) {
+ return Math.round(Math.floor(Math.sqrt(memory)));
+ }
+
+ public int getCount(long memory) {
+ return getCount(memory, 0);
+ }
+
+ public int getCount(long memory, long objectExtra) {
+ return (int) Math.min(Integer.MAX_VALUE, memory / (getSize(memory) + objectExtra));
+ }
+
+ public String toString() {
+ return "medium";
+ }
+ };
+
+ /**
+ * Big object size, small number of objects.
+ */
+ public static final MemoryStrategy HIGH = new MemoryStrategy() {
+ public long getSize(long memory) {
+ return getSize(memory, 0);
+ }
+
+ public long getSize(long memory, long objectExtra) {
+ return memory / getCount(memory, objectExtra);
+ }
+
+ public int getCount(long memory) {
+ return getCount(memory, 0);
+ }
+
+ public int getCount(long memory, long objectExtra) {
+ return smallNumber;
+ }
+
+ public String toString() {
+ return "high";
+ }
+ };
+
+ /**
+ * Get memory strategy by identifier.
+ *
+ * @param id identifier
+ * @return memory strategy for this identifier
+ * @throws TestBug if id is invalid
+ */
+ public static MemoryStrategy fromString(String id) {
+ if (id.equalsIgnoreCase("low"))
+ return LOW;
+ else if (id.equalsIgnoreCase("medium"))
+ return MEDIUM;
+ else if (id.equalsIgnoreCase("high"))
+ return HIGH;
+ else
+ throw new TestBug("Unknown memory strategy identifier: " + id);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/MemoryStrategyAware.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/MemoryStrategyAware.java
new file mode 100644
index 00000000000..22a4755aa34
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/MemoryStrategyAware.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp;
+
+/**
+ * Marker interface for getting MemoryStrategy.
+ */
+public interface MemoryStrategyAware {
+ public void setMemoryStrategy(MemoryStrategy memoryStrategy);
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/RandomProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/RandomProducer.java
new file mode 100644
index 00000000000..0200856eeff
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/RandomProducer.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp;
+
+import java.util.List;
+import nsk.share.test.LocalRandom;
+
+/**
+ * Garbage producer that randomly creates objects using
+ * one garbage producer from the list.
+ */
+public class RandomProducer implements GarbageProducer {
+ private List> producers;
+
+ public RandomProducer(List> producers) {
+ this.producers = producers;
+ }
+
+ public T create(long memory) {
+ return producers.get(LocalRandom.nextInt(producers.size())).create(memory);
+ }
+
+ public void validate(T obj) {
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/ArrayOfProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/ArrayOfProducer.java
new file mode 100644
index 00000000000..5df59b2d969
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/ArrayOfProducer.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.array;
+
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.gp.DerivedProducer;
+import nsk.share.gc.gp.GarbageUtils;
+import nsk.share.gc.gp.MemoryStrategy;
+import nsk.share.gc.Memory;
+import nsk.share.TestFailure;
+
+/**
+ * GarbageProducer implementation that produces arrays of objects
+ * determined by parent garbage producer. A memory strategy is
+ * used to determine how memory is distributed between array size
+ * and size of each object in array.
+ */
+public class ArrayOfProducer extends DerivedProducer {
+ private int n;
+
+ public ArrayOfProducer(GarbageProducer parent, int n) {
+ super(parent);
+ this.n = n;
+ }
+
+ public ArrayOfProducer(GarbageProducer parent) {
+ this(parent, 2);
+ }
+
+ public Object[] create(long memory) {
+ Object[] array = new Object[n];
+ long objectSize = (memory - Memory.getArrayExtraSize() - Memory.getReferenceSize() * n) / n;
+ for (int i = 0; i < n; ++i)
+ array[i] = createParent(objectSize);
+ return array;
+ }
+
+ public void validate(Object[] obj) {
+ for (int i = 0; i < obj.length; ++i)
+ validateParent((T) obj[i]);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/ArrayProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/ArrayProducer.java
new file mode 100644
index 00000000000..5182bb894b0
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/ArrayProducer.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.array;
+
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.gp.DerivedStrategyProducer;
+import nsk.share.gc.gp.GarbageUtils;
+import nsk.share.gc.gp.MemoryStrategy;
+import nsk.share.gc.Memory;
+import nsk.share.TestFailure;
+
+/**
+ * GarbageProducer implementation that produces arrays of objects
+ * determined by parent garbage producer. A memory strategy is
+ * used to determine how memory is distributed between array size
+ * and size of each object in array.
+ */
+public class ArrayProducer extends DerivedStrategyProducer {
+ public ArrayProducer(GarbageProducer parent, MemoryStrategy memoryStrategy) {
+ super(parent, memoryStrategy);
+ }
+
+ public Object[] create(long memory) {
+ long objectSize = GarbageUtils.getArraySize(memory, memoryStrategy);
+ int objectCount = GarbageUtils.getArrayCount(memory, memoryStrategy);
+ Object[] array = new Object[objectCount];
+ for (int i = 0; i < objectCount; ++i)
+ array[i] = createParent(objectSize);
+ return array;
+ }
+
+ public void validate(Object[] obj) {
+ for (int i = 0; i < obj.length; ++i)
+ validateParent((T) obj[i]);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/BooleanArrayProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/BooleanArrayProducer.java
new file mode 100644
index 00000000000..d0665e8044a
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/BooleanArrayProducer.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.array;
+
+import nsk.share.test.LocalRandom;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.Memory;
+import nsk.share.TestFailure;
+
+/**
+ * GarbageProducer implementation that produces byte arrays.
+ */
+public class BooleanArrayProducer implements GarbageProducer {
+ public boolean[] create(long memory) {
+ boolean[] arr = new boolean[Memory.getArrayLength(memory, Memory.getBooleanSize())];
+ LocalRandom.nextBooleans(arr);
+ return arr;
+ }
+
+ public void validate(boolean[] arr) {
+ LocalRandom.validate(arr);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/ByteArrayProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/ByteArrayProducer.java
new file mode 100644
index 00000000000..2469e371192
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/ByteArrayProducer.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.array;
+
+import nsk.share.test.LocalRandom;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.Memory;
+import nsk.share.TestFailure;
+
+/**
+ * GarbageProducer implementation that produces byte arrays.
+ */
+public class ByteArrayProducer implements GarbageProducer {
+ public byte[] create(long memory) {
+ byte[] arr = new byte[Memory.getArrayLength(memory, 1)];
+ LocalRandom.nextBytes(arr);
+ return arr;
+ }
+
+ public void validate(byte[] arr) {
+ LocalRandom.validate(arr);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/CharArrayProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/CharArrayProducer.java
new file mode 100644
index 00000000000..95db54db286
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/CharArrayProducer.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.array;
+
+import nsk.share.test.LocalRandom;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.Memory;
+import nsk.share.TestFailure;
+
+/**
+ * GarbageProducer implementation that produces int arrays.
+ */
+public class CharArrayProducer implements GarbageProducer {
+ public char[] create(long memory) {
+ char[] arr = new char[Memory.getArrayLength(memory, Memory.getCharSize())];
+ LocalRandom.nextChars(arr);
+ return arr;
+ }
+
+ public void validate(char[] arr) {
+ LocalRandom.validate(arr);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/DoubleArrayProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/DoubleArrayProducer.java
new file mode 100644
index 00000000000..4735434f402
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/DoubleArrayProducer.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.array;
+
+import nsk.share.test.LocalRandom;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.Memory;
+
+/**
+ * GarbageProducer implementation that produces double arrays.
+ */
+public class DoubleArrayProducer implements GarbageProducer {
+ public double[] create(long memory) {
+ double[] arr = new double[Memory.getArrayLength(memory, Memory.getDoubleSize())];
+ LocalRandom.nextDoubles(arr);
+ return arr;
+ }
+
+ public void validate(double[] arr) {
+ LocalRandom.validate(arr);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/FloatArrayProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/FloatArrayProducer.java
new file mode 100644
index 00000000000..4fc1f435f73
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/FloatArrayProducer.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.array;
+
+import nsk.share.test.LocalRandom;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.Memory;
+
+/**
+ * GarbageProducer implementation that produces float arrays.
+ */
+public class FloatArrayProducer implements GarbageProducer {
+ public float[] create(long memory) {
+ float[] arr = new float[Memory.getArrayLength(memory, Memory.getFloatSize())];
+ LocalRandom.nextFloats(arr);
+ return arr;
+ }
+
+ public void validate(float[] arr) {
+ LocalRandom.validate(arr);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/IntArrayProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/IntArrayProducer.java
new file mode 100644
index 00000000000..cae41f92e33
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/IntArrayProducer.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.array;
+
+import nsk.share.test.LocalRandom;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.Memory;
+import nsk.share.TestFailure;
+
+/**
+ * GarbageProducer implementation that produces int arrays.
+ */
+public class IntArrayProducer implements GarbageProducer {
+ public int[] create(long memory) {
+ int[] arr = new int[Memory.getArrayLength(memory, Memory.getIntSize())];
+ LocalRandom.nextInts(arr);
+ return arr;
+ }
+
+ public void validate(int[] arr) {
+ LocalRandom.validate(arr);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/LongArrayProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/LongArrayProducer.java
new file mode 100644
index 00000000000..7753664cee8
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/LongArrayProducer.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.array;
+
+import nsk.share.test.LocalRandom;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.Memory;
+import nsk.share.TestFailure;
+
+/**
+ * GarbageProducer implementation that produces long arrays.
+ */
+public class LongArrayProducer implements GarbageProducer {
+ public long[] create(long memory) {
+ long[] arr = new long[Memory.getArrayLength(memory, Memory.getLongSize())];
+ LocalRandom.nextLongs(arr);
+ return arr;
+ }
+
+ public void validate(long[] arr) {
+ LocalRandom.validate(arr);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/ObjectArrayProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/ObjectArrayProducer.java
new file mode 100644
index 00000000000..710b8494fde
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/ObjectArrayProducer.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.array;
+
+import nsk.share.test.LocalRandom;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.Memory;
+
+/**
+ * GarbageProducer implementation that produces object arrays.
+ */
+public class ObjectArrayProducer implements GarbageProducer {
+ public Object[] create(long memory) {
+ return new Object[Memory.getArrayLength(memory, Memory.getObjectExtraSize())];
+ }
+
+ public void validate(Object[] arr) {
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/ShortArrayProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/ShortArrayProducer.java
new file mode 100644
index 00000000000..026ff72a595
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/array/ShortArrayProducer.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.array;
+
+import nsk.share.test.LocalRandom;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.Memory;
+import nsk.share.TestFailure;
+
+/**
+ * GarbageProducer implementation that produces short arrays.
+ */
+public class ShortArrayProducer implements GarbageProducer {
+ public short[] create(long memory) {
+ short[] arr = new short[Memory.getArrayLength(memory, Memory.getShortSize())];
+ LocalRandom.nextShorts(arr);
+ return arr;
+ }
+
+ public void validate(short[] arr) {
+ LocalRandom.validate(arr);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/classload/GeneratedClassProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/classload/GeneratedClassProducer.java
new file mode 100644
index 00000000000..acd830a02be
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/classload/GeneratedClassProducer.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.classload;
+
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.classload.GeneratingClassLoader;
+import nsk.share.classload.GeneratingClassLoader;
+import nsk.share.gc.gp.GarbageUtils;
+import nsk.share.test.LocalRandom;
+
+/**
+ * Garbage producer that creates classes loaded with GeneratingClassLoader.
+ *
+ * Note: this class is not thread-safe.
+ */
+public class GeneratedClassProducer implements GarbageProducer {
+ private int number;
+ private String className;
+ private StringBuilder sb = new StringBuilder();
+ private int minPerClassLoader = 50;
+ private int maxPerClassLoader = 150;
+ private int count;
+ private GeneratingClassLoader loader = new GeneratingClassLoader();
+
+ public GeneratedClassProducer() {
+ this(GeneratingClassLoader.DEFAULT_CLASSNAME);
+ }
+
+ public GeneratedClassProducer(String className) {
+ this.className = className;
+ }
+
+ private String getNewName() {
+ sb.delete(0, sb.length());
+ sb.append("Class");
+ sb.append(number);
+ int n = loader.getNameLength() - sb.length();
+ for (int i = 0; i < n; ++i)
+ sb.append('_');
+ return sb.toString();
+ }
+
+ public Class create(long memory) {
+ try {
+ if (number++ > maxPerClassLoader || loader == null) {
+ loader = new GeneratingClassLoader(className);
+ count = LocalRandom.nextInt(minPerClassLoader, maxPerClassLoader);
+ number = 0;
+ }
+ return loader.loadClass(getNewName());
+ } catch (ClassNotFoundException e) {
+ throw convertException(e);
+ }
+ }
+
+ public void validate(Class cl) {
+ }
+
+ protected RuntimeException convertException(Exception e) {
+ return new RuntimeException(e);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/list/CircularListProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/list/CircularListProducer.java
new file mode 100644
index 00000000000..1f54b97ed55
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/list/CircularListProducer.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.list;
+
+import nsk.share.gc.LinkedMemoryObject;
+import nsk.share.gc.Memory;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.gp.MemoryStrategy;
+
+/**
+ * Garbage producer that produces circular linked lists.
+ */
+public class CircularListProducer implements GarbageProducer {
+ private MemoryStrategy memoryStrategy;
+
+ public CircularListProducer(MemoryStrategy memoryStrategy) {
+ this.memoryStrategy = memoryStrategy;
+ }
+
+ public LinkedMemoryObject create(long memory) {
+ long objectSize = memoryStrategy.getSize(memory);
+ int objectCount = memoryStrategy.getCount(memory);
+ return Memory.makeCircularList(objectCount, (int) objectSize);
+ }
+
+ public void validate(LinkedMemoryObject obj) {
+ LinkedMemoryObject o = obj;
+ while (o != null && o != obj)
+ o = o.getNext();
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/list/LinearListProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/list/LinearListProducer.java
new file mode 100644
index 00000000000..f23b0e7e7e9
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/list/LinearListProducer.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.list;
+
+import nsk.share.gc.LinkedMemoryObject;
+import nsk.share.gc.Memory;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.gp.MemoryStrategy;
+
+/**
+ * Garbage producer that produces linear linked lists.
+ */
+public class LinearListProducer implements GarbageProducer {
+ private MemoryStrategy memoryStrategy;
+
+ public LinearListProducer(MemoryStrategy memoryStrategy) {
+ this.memoryStrategy = memoryStrategy;
+ }
+
+ public LinkedMemoryObject create(long memory) {
+ long objectSize = memoryStrategy.getSize(memory);
+ int objectCount = memoryStrategy.getCount(memory);
+ return Memory.makeLinearList(objectCount, (int) objectSize);
+ }
+
+ public void validate(LinkedMemoryObject obj) {
+ LinkedMemoryObject o = obj;
+ while (o != null && o != obj)
+ o = o.getNext();
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/misc/HashedGarbageProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/misc/HashedGarbageProducer.java
new file mode 100644
index 00000000000..db24db8b9a7
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/misc/HashedGarbageProducer.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.misc;
+
+import nsk.share.gc.gp.DerivedProducer;
+import nsk.share.gc.gp.GarbageProducer;
+
+/*
+ * Garbage producer that also calls {@link java.lang.System#identityHashCode(java.lang.Object)} on produced object.
+ */
+
+/*
+ The description is misleading. I looked at some old email, and the
+ goal is to stress the code that deals with displaced mark words, so
+ the description should be more like "Stress tests for displaced mark
+ words." In hotspot, each object has a mark word that stores several
+ things about the object including its hash code (if it has one) and
+ lock state. Most objects never have a hash code and are never locked,
+ so the mark word is empty.
+
+ Most of our garbage collectors use the mark word temporarily during GC
+ to store a 'forwarding pointer.' It's not important what that is, but
+ it means that objects that have a hash code or that are locked have to
+ have the mark word saved during GC and then restored at the end of GC.
+ We want to exercise this saving/restoring code. So a test case should
+ have a large percentage (40-50%) of objects that either have a hash
+ code or are locked.
+
+ */
+public class HashedGarbageProducer extends DerivedProducer {
+ public HashedGarbageProducer(GarbageProducer parent) {
+ super(parent);
+ }
+
+ public T create(long memory) {
+ T obj = createParent(memory);
+ System.identityHashCode(obj);
+ return obj;
+ }
+
+ public void validate(T obj) {
+ validateParent(obj);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/misc/TraceProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/misc/TraceProducer.java
new file mode 100644
index 00000000000..af96e831f61
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/misc/TraceProducer.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.misc;
+
+import nsk.share.gc.gp.DerivedProducer;
+import nsk.share.gc.gp.GarbageProducer;
+
+/*
+ * GarbageProducer that traces the production.
+ */
+public class TraceProducer extends DerivedProducer {
+ private String prid;
+
+ public TraceProducer(GarbageProducer parent) {
+ super(parent);
+ prid = "Create (" + parent + "): ";
+ }
+
+ public T create(long memory) {
+ T obj = createParent(memory);
+ System.out.println(prid + memory);
+ return obj;
+ }
+
+ public void validate(T obj) {
+ validateParent(obj);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/misc/TwoFieldsObjectProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/misc/TwoFieldsObjectProducer.java
new file mode 100644
index 00000000000..d02ba08d3b1
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/misc/TwoFieldsObjectProducer.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.misc;
+
+import nsk.share.gc.Memory;
+import nsk.share.gc.*;
+import nsk.share.gc.gp.*;
+
+/**
+ * GarbageProducer that produces object with two fields which
+ * reference objects producer by parent garbage producer.
+ */
+public class TwoFieldsObjectProducer extends DerivedProducer, T> {
+ public TwoFieldsObjectProducer(GarbageProducer parent) {
+ super(parent);
+ }
+
+ public TwoFieldsObject create(long memory) {
+ long memoryT = (memory - Memory.getObjectExtraSize() - 2 * Memory.getReferenceSize()) / 2;
+ return new TwoFieldsObject(createParent(memoryT), createParent(memoryT));
+ }
+
+ public void validate(TwoFieldsObject obj) {
+ validateParent(obj.getLeft());
+ validateParent(obj.getRight());
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/obj/AllMemoryObjectProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/obj/AllMemoryObjectProducer.java
new file mode 100644
index 00000000000..a7742624c7e
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/obj/AllMemoryObjectProducer.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.obj;
+
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.AllMemoryObject;
+
+public class AllMemoryObjectProducer implements GarbageProducer {
+ public AllMemoryObject create(long memory) {
+ return new AllMemoryObject((int) memory);
+ }
+
+ public void validate(AllMemoryObject obj) {
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/obj/FinMemoryObject1Producer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/obj/FinMemoryObject1Producer.java
new file mode 100644
index 00000000000..c5d75824d82
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/obj/FinMemoryObject1Producer.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.obj;
+
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.FinMemoryObject1;
+
+public class FinMemoryObject1Producer implements GarbageProducer {
+ public FinMemoryObject1 create(long memory) {
+ return new FinMemoryObject1((int) memory);
+ }
+
+ public void validate(FinMemoryObject1 obj) {
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/obj/FinMemoryObjectProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/obj/FinMemoryObjectProducer.java
new file mode 100644
index 00000000000..1fc93f979e3
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/obj/FinMemoryObjectProducer.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.obj;
+
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.FinMemoryObject;
+
+public class FinMemoryObjectProducer implements GarbageProducer {
+ public FinMemoryObject create(long memory) {
+ return new FinMemoryObject((int) memory);
+ }
+
+ public void validate(FinMemoryObject obj) {
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/obj/MemoryObjectProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/obj/MemoryObjectProducer.java
new file mode 100644
index 00000000000..6ece69c9c34
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/obj/MemoryObjectProducer.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.obj;
+
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.MemoryObject;
+
+public class MemoryObjectProducer implements GarbageProducer {
+ public MemoryObject create(long memory) {
+ return new MemoryObject((int) memory);
+ }
+
+ public void validate(MemoryObject obj) {
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/string/InternedStringProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/string/InternedStringProducer.java
new file mode 100644
index 00000000000..8d6986d3983
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/string/InternedStringProducer.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.string;
+
+import nsk.share.gc.gp.DerivedProducer;
+import nsk.share.gc.gp.GarbageProducer;
+
+/**
+ * Garbage producer that creates interned strings.
+ */
+public class InternedStringProducer extends DerivedProducer {
+ public InternedStringProducer() {
+ this(new RandomStringProducer());
+ }
+
+ public InternedStringProducer(GarbageProducer parent) {
+ super(parent);
+ }
+
+ public String create(long memory) {
+ return createParent(memory).intern();
+ }
+
+ public void validate(String s) {
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/string/RandomStringProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/string/RandomStringProducer.java
new file mode 100644
index 00000000000..2291b3b539f
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/string/RandomStringProducer.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.string;
+
+import nsk.share.test.*;
+import nsk.share.gc.Memory;
+import nsk.share.gc.gp.GarbageProducer;
+
+/**
+ * Garbage producer that creates random strings.
+ */
+public class RandomStringProducer implements GarbageProducer {
+
+ private int stringLengthLowerBound = 10;
+
+ public RandomStringProducer() {
+ }
+
+ public RandomStringProducer(int stringLengthLowerBound) {
+ this.stringLengthLowerBound = stringLengthLowerBound;
+ }
+
+ public String create(long memory) {
+ int stringLengthUpperBound = (int) Math.min(memory / 2 - Memory.getObjectExtraSize(), Integer.MAX_VALUE);
+ if (stringLengthUpperBound < stringLengthLowerBound) {
+ stringLengthLowerBound = stringLengthUpperBound;
+ }
+ int length = stringLengthLowerBound + LocalRandom.nextInt(stringLengthUpperBound - stringLengthLowerBound);
+ char[] arr = new char[length];
+ for (int i = 0; i < length; ++i) {
+ arr[i] = (char) LocalRandom.nextInt();
+ }
+ return new String(arr);
+ }
+
+ public void setStringLengthLowerBound(int stringLengthLowerBound) {
+ this.stringLengthLowerBound = stringLengthLowerBound;
+ }
+
+ public void validate(String s) {
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/string/SimpleStringProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/string/SimpleStringProducer.java
new file mode 100644
index 00000000000..c6e4e8fe3ef
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/string/SimpleStringProducer.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011, 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 nsk.share.gc.gp.string;
+
+import nsk.share.test.*;
+import nsk.share.gc.gp.GarbageProducer;
+
+/**
+ * Garbage producer that creates simple strings.
+ */
+public class SimpleStringProducer implements GarbageProducer {
+
+
+ public String create(long memory) {
+ long length = memory/8;
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < length; ++i)
+ sb.append((char) LocalRandom.nextInt());
+ return sb.toString();
+ }
+
+
+ public void validate(String s) {
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/tree/NonbranchyTreeProducer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/tree/NonbranchyTreeProducer.java
new file mode 100644
index 00000000000..a966ce75d2d
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/tree/NonbranchyTreeProducer.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.gp.tree;
+
+import nsk.share.gc.*;
+import nsk.share.gc.gp.*;
+import nsk.share.gc.Memory;
+
+public class NonbranchyTreeProducer implements GarbageProducer, MemoryStrategyAware {
+ private MemoryStrategy memoryStrategy;
+ private float branchiness;
+
+ public NonbranchyTreeProducer(MemoryStrategy memoryStrategy) {
+ this(memoryStrategy, 0.75f);
+ }
+
+ public NonbranchyTreeProducer(MemoryStrategy memoryStrategy, float branchiness) {
+ setMemoryStrategy(memoryStrategy);
+ setBranchiness(branchiness);
+ }
+
+ public LinkedMemoryObject create(long memory) {
+ long objectSize = memoryStrategy.getSize(memory);
+ int objectCount = memoryStrategy.getCount(memory);
+ return Memory.makeNonbranchyTree(objectCount, branchiness, (int) objectSize);
+ }
+
+ public void validate(LinkedMemoryObject obj) {
+ }
+
+ public final void setMemoryStrategy(MemoryStrategy memoryStrategy) {
+ this.memoryStrategy = memoryStrategy;
+ }
+
+ public final void setBranchiness(float branchiness) {
+ this.branchiness = branchiness;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/CriticalSectionLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/CriticalSectionLocker.java
new file mode 100644
index 00000000000..e909a742f44
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/CriticalSectionLocker.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock;
+
+import nsk.share.TestBug;
+import nsk.share.gc.lock.Locker;
+
+/**
+ * CriticalSectionLocker represents a way to lock a resource
+ * by entering some critical section.
+ */
+public abstract class CriticalSectionLocker implements Locker {
+ private transient boolean enabled = false;
+ private transient boolean locked = false;
+ private Object sync = new Object();
+ private Thread thread;
+ private Throwable exception;
+
+ private final Runnable runnable = new Runnable() {
+ public void run() {
+ //System.out.println("Running");
+ try {
+ do {
+ synchronized (sync) {
+ while (enabled && !locked) {
+ try {
+ sync.wait();
+ } catch (InterruptedException e) {
+ }
+ }
+ if (!enabled)
+ break;
+ }
+ do {
+ criticalSection();
+ } while (locked);
+ } while (enabled);
+ // System.out.println("Exiting");
+ } catch (RuntimeException t) {
+ t.printStackTrace();
+ exception = t;
+ throw t;
+ }
+ }
+ };
+
+ public CriticalSectionLocker() {
+ }
+
+ /**
+ * Enter critical section.
+ *
+ */
+ protected abstract void criticalSection();
+
+ public void enable() {
+ synchronized (sync) {
+ if (enabled)
+ throw new TestBug("Locker already enabled.");
+// System.out.println("Enabling " + this);
+ enabled = true;
+ thread = new Thread(runnable, "Locker: " + runnable);
+ thread.setDaemon(true);
+ thread.start();
+ }
+ }
+
+ public void lock() {
+ synchronized (sync) {
+ if (locked)
+ throw new TestBug("Locker already locked.");
+// System.out.println("Locking " + this);
+ locked = true;
+ sync.notifyAll();
+ }
+ }
+
+ public void unlock() {
+ synchronized (sync) {
+ if (!locked)
+ throw new TestBug("Locker not locked.");
+// System.out.println("Unocking " + this);
+ locked = false;
+ sync.notifyAll();
+ }
+ }
+
+ public void disable() {
+ synchronized (sync) {
+ if (!enabled)
+ throw new TestBug("Locker not enabled.");
+// System.out.println("Disabling " + this);
+ enabled = false;
+ sync.notifyAll();
+ }
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ throw new TestBug(e);
+ }
+ }
+
+ public Throwable getException() {
+ return exception;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/CriticalSectionObjectLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/CriticalSectionObjectLocker.java
new file mode 100644
index 00000000000..2a92a5f93e0
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/CriticalSectionObjectLocker.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock;
+
+import nsk.share.TestBug;
+import nsk.share.gc.gp.GarbageProducer;
+import nsk.share.gc.gp.DerivedProducer;
+
+/**
+ * CriticalSectionLocker represents a way to lock
+ * a resource by entering some critical section of
+ * code.
+ */
+public abstract class CriticalSectionObjectLocker extends CriticalSectionTimedLocker implements Locker {
+ public T obj;
+
+ public CriticalSectionObjectLocker(T obj) {
+ this.obj = obj;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/CriticalSectionTimedLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/CriticalSectionTimedLocker.java
new file mode 100644
index 00000000000..b0d63f05dc4
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/CriticalSectionTimedLocker.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock;
+
+import nsk.share.TestBug;
+import nsk.share.gc.lock.Locker;
+
+/**
+ * CriticalSectionTimedLocker represents a way to lock a resource
+ * by entering some critical section for some time.
+ */
+public abstract class CriticalSectionTimedLocker extends CriticalSectionLocker {
+ private long enterTime;
+ private long sleepTime;
+
+ public CriticalSectionTimedLocker() {
+ this(5000, 10);
+ }
+
+ public CriticalSectionTimedLocker(long enterTime, long sleepTime) {
+ setEnterTime(enterTime);
+ setSleepTime(sleepTime);
+ }
+
+ protected final void criticalSection() {
+ criticalSection(enterTime, sleepTime);
+ }
+
+ /**
+ * Enter critical section for enterTime.
+ *
+ * Usually, something is done in a loop inside this critical section.
+ * In this case, sleepTime is time to sleep after each iteration.
+ */
+ protected abstract void criticalSection(long enterTime, long sleepTime);
+
+ public final void setEnterTime(long enterTime) {
+ this.enterTime = enterTime;
+ }
+
+ public final void setSleepTime(long sleepTime) {
+ this.sleepTime = sleepTime;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/Locker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/Locker.java
new file mode 100644
index 00000000000..f6996e8975f
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/Locker.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock;
+
+import nsk.share.gc.gp.GarbageProducer;
+
+/**
+ * Locker represents a way to lock a resource
+ * which may be critical for GC to work.
+ */
+public interface Locker {
+ /**
+ * Enable this locker and make necessary preparations.
+ */
+ public void enable();
+
+ /**
+ * Lock an object.
+ *
+ * There can be multiple calls to this, but to lock
+ * again, one must first unlock.
+ */
+ public void lock();
+
+ /**
+ * Unlock an object.
+ *
+ */
+ public void unlock();
+
+ /**
+ * Get any exceptions that occured.
+ *
+ * @return exception or null if there none
+ */
+ public Throwable getException();
+
+ /**
+ * Disable this locker and make necessary cleanups.
+ */
+ public void disable();
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/LockerUtils.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/LockerUtils.java
new file mode 100644
index 00000000000..503479a25ca
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/LockerUtils.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock;
+
+import nsk.share.TestBug;
+import nsk.share.gc.lock.jni.JNILockers;
+import nsk.share.gc.lock.malloc.MallocLockers;
+import nsk.share.gc.lock.jvmti.JVMTIAllocLockers;
+import nsk.share.gc.lock.jniref.*;
+
+/**
+ * Utility methods for lockers.
+ */
+public class LockerUtils {
+ private LockerUtils() {
+ }
+
+ /**
+ * Obtain Lockers by id.
+ *
+ * @param id identifier of Lockers
+ */
+ public static Lockers getLockers(String id) {
+ if (id == null || id.equals("jni"))
+ return new JNILockers();
+ else if (id.equals("jniGlobalRef"))
+ return new JNIGlobalRefLockers();
+ else if (id.equals("jniLocalRef"))
+ return new JNILocalRefLockers();
+ else if (id.equals("jniRef"))
+ return new JNIRefLockers();
+ else if (id.equals("jniWeakGlobalRef"))
+ return new JNIWeakGlobalRefLockers();
+ else if (id.equals("malloc"))
+ return new MallocLockers();
+ else if (id.equals("jvmtiAlloc"))
+ return new JVMTIAllocLockers();
+ else
+ throw new TestBug("Invalid lockers id: " + id);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/Lockers.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/Lockers.java
new file mode 100644
index 00000000000..a2349df8c1e
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/Lockers.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock;
+
+import nsk.share.gc.gp.GarbageProducer;
+
+public interface Lockers {
+ public Locker createLocker(T obj);
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/LockersAware.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/LockersAware.java
new file mode 100644
index 00000000000..7ce89ee6631
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/LockersAware.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock;
+
+/**
+ * Marker interface for getting Locker.
+ */
+public interface LockersAware {
+ public void setLockers(Lockers locker);
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/MultiLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/MultiLocker.java
new file mode 100644
index 00000000000..c5c8333af77
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/MultiLocker.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * MultiLocker is just a locker that uses several lockers.
+ */
+public class MultiLocker implements Locker {
+ private List> lockers;
+
+ public MultiLocker() {
+ this(new ArrayList>());
+ }
+
+ public MultiLocker(List> lockers) {
+ this.lockers = lockers;
+ }
+
+ public void enable() {
+ for (Locker locker : lockers)
+ locker.enable();
+ }
+
+ public void lock() {
+ for (Locker locker : lockers)
+ locker.lock();
+ }
+
+ public void unlock() {
+ for (Locker locker : lockers)
+ locker.unlock();
+ }
+
+ public Throwable getException() {
+ return null;
+ }
+
+ public void disable() {
+ for (Locker locker : lockers)
+ locker.disable();
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/BooleanArrayCriticalLocker.c b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/BooleanArrayCriticalLocker.c
new file mode 100644
index 00000000000..244bc2e3b32
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/BooleanArrayCriticalLocker.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+#include
+#include
+#include
+#include "jni_tools.h"
+
+static jfieldID objFieldId = NULL;
+
+/*
+ * Class: nsk_share_gc_lock_jni_BooleanArrayCriticalLocker
+ * Method: criticalNative
+ * Signature: ([Z)Z
+ */
+JNIEXPORT jboolean JNICALL Java_nsk_share_gc_lock_jni_BooleanArrayCriticalLocker_criticalNative
+(JNIEnv *env, jobject this, jlong enterTime, jlong sleepTime) {
+ jsize size, i;
+ jbooleanArray arr;
+ jboolean *pa;
+ jboolean hash = JNI_TRUE;
+ time_t start_time, current_time;
+
+ if (objFieldId == NULL) {
+ jclass class = (*env)->GetObjectClass(env, this);
+ if (class == NULL) {
+ printf("Error: GetObjectClass returned NULL\n");
+ return JNI_FALSE;
+ }
+ objFieldId = (*env)->GetFieldID(env, class, "obj", "Ljava/lang/Object;");
+ if (objFieldId == NULL) {
+ printf("Error: GetFieldID returned NULL\n");
+ return JNI_FALSE;
+ }
+ }
+ arr = (*env)->GetObjectField(env, this, objFieldId);
+ if (arr == NULL) {
+ printf("Error: GetObjectField returned NULL\n");
+ return JNI_FALSE;
+ }
+ (*env)->SetObjectField(env, this, objFieldId, NULL);
+ size = (*env)->GetArrayLength(env, arr);
+ start_time = time(NULL);
+ enterTime /= 1000;
+ current_time = 0;
+ while (current_time - start_time < enterTime) {
+ pa = (*env)->GetPrimitiveArrayCritical(env, arr, NULL);
+ if (pa != NULL) {
+ for (i = 0; i < size; ++i)
+ hash ^= pa[i];
+ } else {
+ hash = JNI_FALSE;
+ }
+ mssleep((long) sleepTime);
+ (*env)->ReleasePrimitiveArrayCritical(env, arr, pa, 0);
+ mssleep((long) sleepTime);
+ current_time = time(NULL);
+ }
+ (*env)->SetObjectField(env, this, objFieldId, arr);
+ return hash;
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/BooleanArrayCriticalLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/BooleanArrayCriticalLocker.java
new file mode 100644
index 00000000000..ef3af17ffdf
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/BooleanArrayCriticalLocker.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jni;
+
+import nsk.share.gc.lock.CriticalSectionObjectLocker;
+import nsk.share.TestFailure;
+
+public class BooleanArrayCriticalLocker extends CriticalSectionObjectLocker {
+ private native boolean criticalNative(long enterTime, long sleepTime);
+
+ static {
+ System.loadLibrary("BooleanArrayCriticalLocker");
+ }
+
+ public BooleanArrayCriticalLocker(boolean[] obj) {
+ super(obj);
+ }
+
+ protected void criticalSection(long enterTime, long sleepTime) {
+ boolean javaHash = hashValue(obj);
+ boolean nativeHash = criticalNative(enterTime, sleepTime);
+ if (nativeHash && nativeHash != javaHash)
+ throw new TestFailure("Native hash: " + nativeHash + " != Java hash: " + javaHash);
+ }
+
+ private boolean hashValue(boolean[] obj) {
+ boolean hash = true;
+ for (int i = 0; i < obj.length; ++i)
+ hash ^= obj[i];
+ return hash;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ByteArrayCriticalLocker.c b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ByteArrayCriticalLocker.c
new file mode 100644
index 00000000000..5347f7e8c19
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ByteArrayCriticalLocker.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+#include
+#include
+#include
+#include "jni_tools.h"
+
+static jfieldID objFieldId = NULL;
+
+/*
+ * Class: nsk_share_gc_lock_jni_ByteArrayCriticalLocker
+ * Method: criticalNative
+ */
+JNIEXPORT jbyte JNICALL Java_nsk_share_gc_lock_jni_ByteArrayCriticalLocker_criticalNative
+(JNIEnv *env, jobject this, jlong enterTime, jlong sleepTime) {
+ jsize size, i;
+ jbyteArray arr;
+ jbyte *pa;
+ jbyte hash = 0;
+ time_t start_time, current_time;
+
+ if (objFieldId == NULL) {
+ jclass class = (*env)->GetObjectClass(env, this);
+ if (class == NULL) {
+ printf("Error: GetObjectClass returned NULL\n");
+ return 0;
+ }
+ objFieldId = (*env)->GetFieldID(env, class, "obj", "Ljava/lang/Object;");
+ if (objFieldId == NULL) {
+ printf("Error: GetFieldID returned NULL\n");
+ return 0;
+ }
+ }
+ arr = (*env)->GetObjectField(env, this, objFieldId);
+ if (arr == NULL) {
+ printf("Error: GetObjectField returned NULL\n");
+ return 0;
+ }
+ (*env)->SetObjectField(env, this, objFieldId, NULL);
+ size = (*env)->GetArrayLength(env, arr);
+ start_time = time(NULL);
+ enterTime /= 1000;
+ current_time = 0;
+ while (current_time - start_time < enterTime) {
+ pa = (*env)->GetPrimitiveArrayCritical(env, arr, NULL);
+ if (pa != NULL) {
+ for (i = 0; i < size; ++i)
+ hash ^= pa[i];
+ } else {
+ hash = 0;
+ }
+ mssleep((long) sleepTime);
+ (*env)->ReleasePrimitiveArrayCritical(env, arr, pa, 0);
+ mssleep((long) sleepTime);
+ current_time = time(NULL);
+ }
+ (*env)->SetObjectField(env, this, objFieldId, arr);
+ return hash;
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ByteArrayCriticalLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ByteArrayCriticalLocker.java
new file mode 100644
index 00000000000..f7a28713a44
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ByteArrayCriticalLocker.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jni;
+
+import nsk.share.gc.lock.CriticalSectionObjectLocker;
+import nsk.share.TestFailure;
+
+public class ByteArrayCriticalLocker extends CriticalSectionObjectLocker {
+ private native byte criticalNative(long enterTime, long sleepTime);
+
+ static {
+ System.loadLibrary("ByteArrayCriticalLocker");
+ }
+
+ public ByteArrayCriticalLocker(byte[] obj) {
+ super(obj);
+ }
+ protected void criticalSection(long enterTime, long sleepTime) {
+ byte javaHash = hashValue(obj);
+ byte nativeHash = criticalNative(enterTime, sleepTime);
+ if (nativeHash != 0 && nativeHash != javaHash)
+ throw new TestFailure("Native hash: " + nativeHash + " != Java hash: " + javaHash);
+ }
+
+
+ private byte hashValue(byte[] obj) {
+ byte hash = 0;
+ for (int i = 0; i < obj.length; ++i)
+ hash ^= obj[i];
+ return hash;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/CharArrayCriticalLocker.c b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/CharArrayCriticalLocker.c
new file mode 100644
index 00000000000..91ad693e6ee
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/CharArrayCriticalLocker.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+#include
+#include
+#include
+#include "jni_tools.h"
+
+static jfieldID objFieldId = NULL;
+
+/*
+ * Class: nsk_share_gc_lock_jni_CharArrayCriticalLocker
+ * Method: criticalNative
+ * Signature: ([Z)Z
+ */
+JNIEXPORT jchar JNICALL Java_nsk_share_gc_lock_jni_CharArrayCriticalLocker_criticalNative
+(JNIEnv *env, jobject this, jlong enterTime, jlong sleepTime) {
+ jsize size, i;
+ jcharArray arr;
+ jchar *pa;
+ jchar hash = 0;
+ time_t start_time, current_time;
+
+ if (objFieldId == NULL) {
+ jclass class = (*env)->GetObjectClass(env, this);
+ if (class == NULL) {
+ printf("Error: GetObjectClass returned NULL\n");
+ return 0;
+ }
+ objFieldId = (*env)->GetFieldID(env, class, "obj", "Ljava/lang/Object;");
+ if (objFieldId == NULL) {
+ printf("Error: GetFieldID returned NULL\n");
+ return 0;
+ }
+ }
+ arr = (*env)->GetObjectField(env, this, objFieldId);
+ if (arr == NULL) {
+ printf("Error: GetObjectField returned NULL\n");
+ return JNI_FALSE;
+ }
+ (*env)->SetObjectField(env, this, objFieldId, NULL);
+ size = (*env)->GetArrayLength(env, arr);
+ start_time = time(NULL);
+ current_time = 0;
+ enterTime /= 1000;
+ while (current_time - start_time < enterTime) {
+ pa = (*env)->GetPrimitiveArrayCritical(env, arr, NULL);
+ if (pa != NULL) {
+ for (i = 0; i < size; ++i)
+ hash ^= pa[i];
+ } else {
+ hash = 0;
+ }
+ mssleep((long) sleepTime);
+ (*env)->ReleasePrimitiveArrayCritical(env, arr, pa, 0);
+ mssleep((long) sleepTime);
+ current_time = time(NULL);
+ }
+ (*env)->SetObjectField(env, this, objFieldId, arr);
+ return hash;
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/CharArrayCriticalLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/CharArrayCriticalLocker.java
new file mode 100644
index 00000000000..4fd98b86955
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/CharArrayCriticalLocker.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jni;
+
+import nsk.share.gc.lock.CriticalSectionObjectLocker;
+import nsk.share.TestFailure;
+
+public class CharArrayCriticalLocker extends CriticalSectionObjectLocker {
+ private native char criticalNative(long enterTime, long sleepTime);
+
+ static {
+ System.loadLibrary("CharArrayCriticalLocker");
+ }
+
+ public CharArrayCriticalLocker(char[] obj) {
+ super(obj);
+ }
+
+ protected void criticalSection(long enterTime, long sleepTime) {
+ char javaHash = hashValue(obj);
+ char nativeHash = criticalNative(enterTime, sleepTime);
+ if (nativeHash != 0 && nativeHash != javaHash)
+ throw new TestFailure("Native hash: " + nativeHash + " != Java hash: " + javaHash);
+ }
+
+ private char hashValue(char[] obj) {
+ char hash = 0;
+ for (int i = 0; i < obj.length; ++i)
+ hash ^= obj[i];
+ return hash;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/DoubleArrayCriticalLocker.c b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/DoubleArrayCriticalLocker.c
new file mode 100644
index 00000000000..2e70012f2b2
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/DoubleArrayCriticalLocker.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+#include
+#include
+#include
+#include "jni_tools.h"
+
+static jfieldID objFieldId = NULL;
+
+/*
+ * Class: nsk_share_gc_lock_jni_DoubleArrayCriticalLocker
+ * Method: criticalNative
+ * Signature: ([Z)Z
+ */
+JNIEXPORT jdouble JNICALL Java_nsk_share_gc_lock_jni_DoubleArrayCriticalLocker_criticalNative
+(JNIEnv *env, jobject this, jlong enterTime, jlong sleepTime) {
+ jsize size, i;
+ jdoubleArray arr;
+ jdouble *pa;
+ jdouble hash = 0;
+ time_t start_time, current_time;
+
+ if (objFieldId == NULL) {
+ jclass class = (*env)->GetObjectClass(env, this);
+ if (class == NULL) {
+ printf("Error: GetObjectClass returned NULL\n");
+ return 0;
+ }
+ objFieldId = (*env)->GetFieldID(env, class, "obj", "Ljava/lang/Object;");
+ if (objFieldId == NULL) {
+ printf("Error: GetFieldID returned NULL\n");
+ return 0;
+ }
+ }
+ arr = (*env)->GetObjectField(env, this, objFieldId);
+ if (arr == NULL) {
+ printf("Error: GetObjectField returned NULL\n");
+ return JNI_FALSE;
+ }
+ (*env)->SetObjectField(env, this, objFieldId, NULL);
+ size = (*env)->GetArrayLength(env, arr);
+ start_time = time(NULL);
+ enterTime /= 1000;
+ current_time = 0;
+ while (current_time - start_time < enterTime) {
+ pa = (*env)->GetPrimitiveArrayCritical(env, arr, NULL);
+ if (pa != NULL) {
+ for (i = 0; i < size; ++i)
+ hash += pa[i];
+ } else {
+ hash = 0;
+ }
+ mssleep((long) sleepTime);
+ (*env)->ReleasePrimitiveArrayCritical(env, arr, pa, 0);
+ mssleep((long) sleepTime);
+ current_time = time(NULL);
+ }
+ (*env)->SetObjectField(env, this, objFieldId, arr);
+ return hash;
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/DoubleArrayCriticalLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/DoubleArrayCriticalLocker.java
new file mode 100644
index 00000000000..c3ab24527a5
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/DoubleArrayCriticalLocker.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jni;
+
+import nsk.share.gc.lock.CriticalSectionObjectLocker;
+import nsk.share.TestFailure;
+
+public class DoubleArrayCriticalLocker extends CriticalSectionObjectLocker {
+ private native double criticalNative(long enterTime, long sleepTime);
+
+ static {
+ System.loadLibrary("DoubleArrayCriticalLocker");
+ }
+
+ public DoubleArrayCriticalLocker(double[] obj) {
+ super(obj);
+ }
+
+ protected void criticalSection(long enterTime, long sleepTime) {
+ double javaHash = hashValue(obj);
+ double nativeHash = criticalNative(enterTime, sleepTime);
+ if (nativeHash != 0 && nativeHash != javaHash)
+ throw new TestFailure("Native hash: " + nativeHash + " != Java hash: " + javaHash);
+ }
+
+ private double hashValue(double[] obj) {
+ double hash = 0;
+ for (int i = 0; i < obj.length; ++i)
+ hash += obj[i];
+ return hash;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/FloatArrayCriticalLocker.c b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/FloatArrayCriticalLocker.c
new file mode 100644
index 00000000000..c5720c46381
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/FloatArrayCriticalLocker.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+#include
+#include
+#include
+#include "jni_tools.h"
+
+static jfieldID objFieldId = NULL;
+
+/*
+ * Class: nsk_share_gc_lock_jni_FloatArrayCriticalLocker
+ * Method: criticalNative
+ * Signature: ([Z)Z
+ */
+JNIEXPORT jfloat JNICALL Java_nsk_share_gc_lock_jni_FloatArrayCriticalLocker_criticalNative
+(JNIEnv *env, jobject this, jlong enterTime, jlong sleepTime) {
+ jsize size, i;
+ jfloatArray arr;
+ jfloat *pa;
+ jfloat hash = 0;
+ time_t start_time, current_time;
+
+ if (objFieldId == NULL) {
+ jclass class = (*env)->GetObjectClass(env, this);
+ if (class == NULL) {
+ printf("Error: GetObjectClass returned NULL\n");
+ return 0;
+ }
+ objFieldId = (*env)->GetFieldID(env, class, "obj", "Ljava/lang/Object;");
+ if (objFieldId == NULL) {
+ printf("Error: GetFieldID returned NULL\n");
+ return 0;
+ }
+ }
+ arr = (*env)->GetObjectField(env, this, objFieldId);
+ if (arr == NULL) {
+ printf("Error: GetObjectField returned NULL\n");
+ return JNI_FALSE;
+ }
+ (*env)->SetObjectField(env, this, objFieldId, NULL);
+ size = (*env)->GetArrayLength(env, arr);
+ start_time = time(NULL);
+ enterTime /= 1000;
+ current_time = 0;
+ while (current_time - start_time < enterTime) {
+ pa = (*env)->GetPrimitiveArrayCritical(env, arr, NULL);
+ if (pa != NULL) {
+ for (i = 0; i < size; ++i)
+ hash += pa[i];
+ } else {
+ hash = 0;
+ }
+ mssleep((long) sleepTime);
+ (*env)->ReleasePrimitiveArrayCritical(env, arr, pa, 0);
+ mssleep((long) sleepTime);
+ current_time = time(NULL);
+ }
+ (*env)->SetObjectField(env, this, objFieldId, arr);
+ return hash;
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/FloatArrayCriticalLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/FloatArrayCriticalLocker.java
new file mode 100644
index 00000000000..5009136dc4b
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/FloatArrayCriticalLocker.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jni;
+
+import nsk.share.gc.lock.CriticalSectionObjectLocker;
+import nsk.share.TestFailure;
+
+public class FloatArrayCriticalLocker extends CriticalSectionObjectLocker {
+ private native float criticalNative(long enterTime, long sleepTime);
+
+ static {
+ System.loadLibrary("FloatArrayCriticalLocker");
+ }
+
+ public FloatArrayCriticalLocker(float[] obj) {
+ super(obj);
+ }
+
+ protected void criticalSection(long enterTime, long sleepTime) {
+ float javaHash = hashValue(obj);
+ float nativeHash = criticalNative(enterTime, sleepTime);
+ if (nativeHash != 0 && nativeHash != javaHash)
+ throw new TestFailure("Native hash: " + nativeHash + " != Java hash: " + javaHash);
+ }
+
+ private float hashValue(float[] obj) {
+ float hash = 0;
+ for (int i = 0; i < obj.length; ++i)
+ hash += obj[i];
+ return hash;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/IntArrayCriticalLocker.c b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/IntArrayCriticalLocker.c
new file mode 100644
index 00000000000..cd0074f14a3
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/IntArrayCriticalLocker.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+#include
+#include
+#include
+#include "jni_tools.h"
+
+static jfieldID objFieldId = NULL;
+
+/*
+ * Class: nsk_share_gc_lock_jni_IntArrayCriticalLocker
+ * Method: criticalNative
+ * Signature: ([Z)Z
+ */
+JNIEXPORT jint JNICALL Java_nsk_share_gc_lock_jni_IntArrayCriticalLocker_criticalNative
+(JNIEnv *env, jobject this, jlong enterTime, jlong sleepTime) {
+ jsize size, i;
+ jintArray arr;
+ jint *pa;
+ jint hash = 0;
+ time_t start_time, current_time;
+
+ if (objFieldId == NULL) {
+ jclass class = (*env)->GetObjectClass(env, this);
+ if (class == NULL) {
+ printf("Error: GetObjectClass returned NULL\n");
+ return 0;
+ }
+ objFieldId = (*env)->GetFieldID(env, class, "obj", "Ljava/lang/Object;");
+ if (objFieldId == NULL) {
+ printf("Error: GetFieldID returned NULL\n");
+ return 0;
+ }
+ }
+ arr = (*env)->GetObjectField(env, this, objFieldId);
+ if (arr == NULL) {
+ printf("Error: GetObjectField returned NULL\n");
+ return JNI_FALSE;
+ }
+ (*env)->SetObjectField(env, this, objFieldId, NULL);
+ size = (*env)->GetArrayLength(env, arr);
+ start_time = time(NULL);
+ enterTime /= 1000;
+ current_time = 0;
+ while (current_time - start_time < enterTime) {
+ pa = (*env)->GetPrimitiveArrayCritical(env, arr, NULL);
+ if (pa != NULL) {
+ for (i = 0; i < size; ++i)
+ hash ^= pa[i];
+ } else {
+ hash = 0;
+ }
+ mssleep((long) sleepTime);
+ (*env)->ReleasePrimitiveArrayCritical(env, arr, pa, 0);
+ mssleep((long) sleepTime);
+ current_time = time(NULL);
+ }
+ (*env)->SetObjectField(env, this, objFieldId, arr);
+ return hash;
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/IntArrayCriticalLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/IntArrayCriticalLocker.java
new file mode 100644
index 00000000000..bbd3d799fc6
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/IntArrayCriticalLocker.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jni;
+
+import nsk.share.gc.lock.CriticalSectionObjectLocker;
+import nsk.share.TestFailure;
+
+public class IntArrayCriticalLocker extends CriticalSectionObjectLocker {
+ private native int criticalNative(long enterTime, long sleepTime);
+
+ static {
+ System.loadLibrary("IntArrayCriticalLocker");
+ }
+
+ public IntArrayCriticalLocker(int[] obj) {
+ super(obj);
+ }
+
+ protected void criticalSection(long enterTime, long sleepTime) {
+ int javaHash = hashValue(obj);
+ int nativeHash = criticalNative(enterTime, sleepTime);
+ if (nativeHash != 0 && nativeHash != javaHash)
+ throw new TestFailure("Native hash: " + nativeHash + " != Java hash: " + javaHash);
+ }
+
+ private int hashValue(int[] obj) {
+ int hash = 0;
+ for (int i = 0; i < obj.length; ++i)
+ hash ^= obj[i];
+ return hash;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/JNILockers.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/JNILockers.java
new file mode 100644
index 00000000000..1ebca961afc
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/JNILockers.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jni;
+
+import nsk.share.TestBug;
+import nsk.share.gc.lock.Lockers;
+import nsk.share.gc.lock.Locker;
+
+public class JNILockers implements Lockers {
+ public Locker createLocker(Object obj) {
+ if (obj instanceof String)
+ return new StringCriticalLocker((String) obj);
+ if (obj instanceof boolean[])
+ return new BooleanArrayCriticalLocker((boolean[]) obj);
+ if (obj instanceof byte[])
+ return new ByteArrayCriticalLocker((byte[]) obj);
+ if (obj instanceof char[])
+ return new CharArrayCriticalLocker((char[]) obj);
+ if (obj instanceof double[])
+ return new DoubleArrayCriticalLocker((double[]) obj);
+ if (obj instanceof float[])
+ return new FloatArrayCriticalLocker((float[]) obj);
+ if (obj instanceof int[])
+ return new IntArrayCriticalLocker((int[]) obj);
+ if (obj instanceof long[])
+ return new LongArrayCriticalLocker((long[]) obj);
+ if (obj instanceof short[])
+ return new ShortArrayCriticalLocker((short[]) obj);
+ throw new TestBug("Cannot create locker for: " + obj);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/LongArrayCriticalLocker.c b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/LongArrayCriticalLocker.c
new file mode 100644
index 00000000000..6a58cd47ee6
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/LongArrayCriticalLocker.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+#include
+#include
+#include
+#include "jni_tools.h"
+
+static jfieldID objFieldId = NULL;
+
+/*
+ * Class: nsk_share_gc_lock_jni_LongArrayCriticalLocker
+ * Method: criticalNative
+ * Signature: ([Z)Z
+ */
+JNIEXPORT jlong JNICALL Java_nsk_share_gc_lock_jni_LongArrayCriticalLocker_criticalNative
+(JNIEnv *env, jobject this, jlong enterTime, jlong sleepTime) {
+ jsize size, i;
+ jlongArray arr;
+ jlong *pa;
+ jlong hash = 0;
+ time_t start_time, current_time;
+
+ if (objFieldId == NULL) {
+ jclass class = (*env)->GetObjectClass(env, this);
+ if (class == NULL) {
+ printf("Error: GetObjectClass returned NULL\n");
+ return 0;
+ }
+ objFieldId = (*env)->GetFieldID(env, class, "obj", "Ljava/lang/Object;");
+ if (objFieldId == NULL) {
+ printf("Error: GetFieldID returned NULL\n");
+ return 0;
+ }
+ }
+ arr = (*env)->GetObjectField(env, this, objFieldId);
+ if (arr == NULL) {
+ printf("Error: GetObjectField returned NULL\n");
+ return JNI_FALSE;
+ }
+ (*env)->SetObjectField(env, this, objFieldId, NULL);
+ size = (*env)->GetArrayLength(env, arr);
+ start_time = time(NULL);
+ enterTime /= 1000;
+ current_time = 0;
+ while (current_time - start_time < enterTime) {
+ pa = (*env)->GetPrimitiveArrayCritical(env, arr, NULL);
+ if (pa != NULL) {
+ for (i = 0; i < size; ++i)
+ hash ^= pa[i];
+ } else {
+ hash = 0;
+ }
+ mssleep((long) sleepTime);
+ (*env)->ReleasePrimitiveArrayCritical(env, arr, pa, 0);
+ mssleep((long) sleepTime);
+ current_time = time(NULL);
+ }
+ (*env)->SetObjectField(env, this, objFieldId, arr);
+ return hash;
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/LongArrayCriticalLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/LongArrayCriticalLocker.java
new file mode 100644
index 00000000000..bcb55e45758
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/LongArrayCriticalLocker.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jni;
+
+import nsk.share.gc.lock.CriticalSectionObjectLocker;
+import nsk.share.TestFailure;
+
+public class LongArrayCriticalLocker extends CriticalSectionObjectLocker {
+ private native long criticalNative(long enterTime, long sleepTime);
+
+ static {
+ System.loadLibrary("LongArrayCriticalLocker");
+ }
+
+ public LongArrayCriticalLocker(long[] obj) {
+ super(obj);
+ }
+
+ protected void criticalSection(long enterTime, long sleepTime) {
+ long javaHash = hashValue(obj);
+ long nativeHash = criticalNative(enterTime, sleepTime);
+ if (nativeHash != 0 && nativeHash != javaHash)
+ throw new TestFailure("Native hash: " + nativeHash + " != Java hash: " + javaHash);
+ }
+
+ private long hashValue(long[] obj) {
+ long hash = 0;
+ for (int i = 0; i < obj.length; ++i)
+ hash ^= obj[i];
+ return hash;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ShortArrayCriticalLocker.c b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ShortArrayCriticalLocker.c
new file mode 100644
index 00000000000..e69173323bb
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ShortArrayCriticalLocker.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+#include
+#include
+#include
+#include "jni_tools.h"
+
+static jfieldID objFieldId = NULL;
+
+/*
+ * Class: nsk_share_gc_lock_jni_ShortArrayCriticalLocker
+ * Method: criticalNative
+ * Signature: ([Z)Z
+ */
+JNIEXPORT jshort JNICALL Java_nsk_share_gc_lock_jni_ShortArrayCriticalLocker_criticalNative
+(JNIEnv *env, jobject this, jlong enterTime, jlong sleepTime) {
+ jsize size, i;
+ jshortArray arr;
+ jshort *pa;
+ jshort hash = 0;
+ time_t start_time, current_time;
+
+ if (objFieldId == NULL) {
+ jclass class = (*env)->GetObjectClass(env, this);
+ if (class == NULL) {
+ printf("Error: GetObjectClass returned NULL\n");
+ return 0;
+ }
+ objFieldId = (*env)->GetFieldID(env, class, "obj", "Ljava/lang/Object;");
+ if (objFieldId == NULL) {
+ printf("Error: GetFieldID returned NULL\n");
+ return 0;
+ }
+ }
+ arr = (*env)->GetObjectField(env, this, objFieldId);
+ if (arr == NULL) {
+ printf("Error: GetObjectField returned NULL\n");
+ return JNI_FALSE;
+ }
+ (*env)->SetObjectField(env, this, objFieldId, NULL);
+ size = (*env)->GetArrayLength(env, arr);
+ start_time = time(NULL);
+ enterTime /= 1000;
+ current_time = 0;
+ while (current_time - start_time < enterTime) {
+ pa = (*env)->GetPrimitiveArrayCritical(env, arr, NULL);
+ if (pa != NULL) {
+ for (i = 0; i < size; ++i)
+ hash ^= pa[i];
+ } else {
+ hash = 0;
+ }
+ mssleep((long) sleepTime);
+ (*env)->ReleasePrimitiveArrayCritical(env, arr, pa, 0);
+ mssleep((long) sleepTime);
+ current_time = time(NULL);
+ }
+ (*env)->SetObjectField(env, this, objFieldId, arr);
+ return hash;
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ShortArrayCriticalLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ShortArrayCriticalLocker.java
new file mode 100644
index 00000000000..774d6b7cb28
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ShortArrayCriticalLocker.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jni;
+
+import nsk.share.gc.lock.CriticalSectionObjectLocker;
+import nsk.share.TestFailure;
+
+public class ShortArrayCriticalLocker extends CriticalSectionObjectLocker {
+ private native short criticalNative(long enterTime, long sleepTime);
+
+ static {
+ System.loadLibrary("ShortArrayCriticalLocker");
+ }
+
+ public ShortArrayCriticalLocker(short[] obj) {
+ super(obj);
+ }
+
+ protected void criticalSection(long enterTime, long sleepTime) {
+ short javaHash = hashValue(obj);
+ short nativeHash = criticalNative(enterTime, sleepTime);
+ if (nativeHash != 0 && nativeHash != javaHash)
+ throw new TestFailure("Native hash: " + nativeHash + " != Java hash: " + javaHash);
+ }
+
+ private short hashValue(short[] obj) {
+ short hash = 0;
+ for (int i = 0; i < obj.length; ++i)
+ hash ^= obj[i];
+ return hash;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/StringCriticalLocker.c b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/StringCriticalLocker.c
new file mode 100644
index 00000000000..4eb6b8bbd3e
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/StringCriticalLocker.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+#include
+#include
+#include
+#include "jni_tools.h"
+
+static jfieldID objFieldId = NULL;
+
+/*
+ * Class: nsk_share_gc_lock_jni_StringCriticalLocker
+ * Method: criticalNative
+ * Signature: ([Z)Z
+ */
+JNIEXPORT jchar JNICALL Java_nsk_share_gc_lock_jni_StringCriticalLocker_criticalNative
+(JNIEnv *env, jobject this, jlong enterTime, jlong sleepTime) {
+ jsize size, i;
+ jstring str;
+ const jchar *pa;
+ jchar hash = 0;
+ time_t start_time, current_time;
+
+ if (objFieldId == NULL) {
+ jclass class = (*env)->GetObjectClass(env, this);
+ if (class == NULL) {
+ printf("Error: GetObjectClass returned NULL\n");
+ return JNI_FALSE;
+ }
+ objFieldId = (*env)->GetFieldID(env, class, "obj", "Ljava/lang/Object;");
+ if (objFieldId == NULL) {
+ printf("Error: GetFieldID returned NULL\n");
+ return JNI_FALSE;
+ }
+ }
+ str = (*env)->GetObjectField(env, this, objFieldId);
+ if (str == NULL) {
+ printf("Error: GetObjectField returned NULL\n");
+ return JNI_FALSE;
+ }
+ (*env)->SetObjectField(env, this, objFieldId, NULL);
+ size = (*env)->GetStringLength(env, str);
+ start_time = time(NULL);
+ enterTime /= 1000;
+ current_time = 0;
+ while (current_time - start_time < enterTime) {
+ pa = (*env)->GetStringCritical(env, str, NULL);
+ if (pa != NULL) {
+ for (i = 0; i < size; ++i)
+ hash ^= pa[i];
+ } else {
+ hash = JNI_FALSE;
+ }
+ mssleep((long) sleepTime);
+ (*env)->ReleaseStringCritical(env, str, pa);
+ mssleep((long) sleepTime);
+ current_time = time(NULL);
+ }
+ (*env)->SetObjectField(env, this, objFieldId, str);
+ return hash;
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/StringCriticalLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/StringCriticalLocker.java
new file mode 100644
index 00000000000..478fb86414c
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/StringCriticalLocker.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jni;
+
+import nsk.share.gc.lock.CriticalSectionObjectLocker;
+import nsk.share.gc.gp.string.RandomStringProducer;
+import nsk.share.TestFailure;
+
+public class StringCriticalLocker extends CriticalSectionObjectLocker {
+ private native char criticalNative(long enterTime, long sleepTime);
+
+ static {
+ System.loadLibrary("StringCriticalLocker");
+ }
+
+ public StringCriticalLocker(String obj) {
+ super(obj);
+ }
+
+ protected void criticalSection(long enterTime, long sleepTime) {
+// System.out.println("Lock: " + s);
+ char javaHash = hashValue(obj);
+ char nativeHash = criticalNative(enterTime, sleepTime);
+ if (nativeHash != 0 && nativeHash != javaHash)
+// throw new TestFailure("Native hash: " + nativeHash + " != Java hash: " + javaHash);
+ throw new TestFailure("Native hash differs from java hash");
+ }
+
+ private char hashValue(String s) {
+ char hash = 0;
+ for (int i = 0; i < s.length(); ++i)
+ hash ^= s.charAt(i);
+ return hash;
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.c b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.c
new file mode 100644
index 00000000000..deebad377f1
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+#include
+#include
+#include
+#include "jni_tools.h"
+
+static jfieldID objFieldId = NULL;
+
+/*
+ * Class: nsk_share_gc_lock_jniref_JNIGlobalRefLocker
+ * Method: criticalNative
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIGlobalRefLocker_criticalNative
+ (JNIEnv *env, jobject this, jlong enterTime, jlong sleepTime) {
+ jobject obj;
+ jobject gref;
+ time_t start_time, current_time;
+
+ if (objFieldId == NULL) {
+ jclass class = (*env)->GetObjectClass(env, this);
+ if (class == NULL) {
+ printf("Error: GetObjectClass returned NULL\n");
+ return;
+ }
+ objFieldId = (*env)->GetFieldID(env, class, "obj", "Ljava/lang/Object;");
+ if (objFieldId == NULL) {
+ printf("Error: GetFieldID returned NULL\n");
+ return;
+ }
+ }
+ obj = (*env)->GetObjectField(env, this, objFieldId);
+ if (obj == NULL) {
+ printf("Error: GetObjectField returned NULL\n");
+ return;
+ }
+ (*env)->SetObjectField(env, this, objFieldId, NULL);
+ start_time = time(NULL);
+ enterTime /= 1000;
+ current_time = 0;
+ while (current_time - start_time < enterTime) {
+ gref = (*env)->NewGlobalRef(env, obj);
+ mssleep((long) sleepTime);
+ (*env)->DeleteGlobalRef(env, gref);
+ mssleep((long) sleepTime);
+ current_time = time(NULL);
+ }
+ (*env)->SetObjectField(env, this, objFieldId, obj);
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.java
new file mode 100644
index 00000000000..d1b706559c2
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jniref;
+
+import nsk.share.gc.lock.CriticalSectionObjectLocker;
+import nsk.share.TestFailure;
+
+/**
+ * Locker that uses JNI function NewGlobalRef.
+ */
+public class JNIGlobalRefLocker extends CriticalSectionObjectLocker {
+ private native void criticalNative(long enterTime, long sleepTime);
+
+ static {
+ System.loadLibrary("JNIGlobalRefLocker");
+ }
+
+ public JNIGlobalRefLocker(Object obj) {
+ super(obj);
+ }
+
+ protected void criticalSection(long enterTime, long sleepTime) {
+ criticalNative(enterTime, sleepTime);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLockers.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLockers.java
new file mode 100644
index 00000000000..e18ccfcb25c
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLockers.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jniref;
+
+import nsk.share.TestBug;
+import nsk.share.gc.lock.Lockers;
+import nsk.share.gc.lock.Locker;
+
+public class JNIGlobalRefLockers implements Lockers {
+ public Locker createLocker(Object obj) {
+ return new JNIGlobalRefLocker(obj);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLocker.c b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLocker.c
new file mode 100644
index 00000000000..bb8a478b76e
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLocker.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+#include
+#include
+#include
+#include "jni_tools.h"
+
+static jfieldID objFieldId = NULL;
+
+/*
+ * Class: nsk_share_gc_lock_jniref_JNILocalRefLocker
+ * Method: criticalNative
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNILocalRefLocker_criticalNative
+ (JNIEnv *env, jobject this, jlong enterTime, jlong sleepTime) {
+ jobject obj;
+ jobject gref;
+ time_t start_time, current_time;
+
+ if (objFieldId == NULL) {
+ jclass class = (*env)->GetObjectClass(env, this);
+ if (class == NULL) {
+ printf("Error: GetObjectClass returned NULL\n");
+ return;
+ }
+ objFieldId = (*env)->GetFieldID(env, class, "obj", "Ljava/lang/Object;");
+ if (objFieldId == NULL) {
+ printf("Error: GetFieldID returned NULL\n");
+ return;
+ }
+ }
+ obj = (*env)->GetObjectField(env, this, objFieldId);
+ if (obj == NULL) {
+ printf("Error: GetObjectField returned NULL\n");
+ return;
+ }
+ (*env)->SetObjectField(env, this, objFieldId, NULL);
+ start_time = time(NULL);
+ enterTime /= 1000;
+ current_time = 0;
+ while (current_time - start_time < enterTime) {
+ gref = (*env)->NewLocalRef(env, obj);
+ mssleep((long) sleepTime);
+ (*env)->DeleteLocalRef(env, gref);
+ mssleep((long) sleepTime);
+ current_time = time(NULL);
+ }
+ (*env)->SetObjectField(env, this, objFieldId, obj);
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLocker.java
new file mode 100644
index 00000000000..4e17e1d7ea6
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLocker.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jniref;
+
+import nsk.share.gc.lock.CriticalSectionObjectLocker;
+import nsk.share.TestFailure;
+
+/**
+ * Locker that uses JNI function NewLocalRef.
+ */
+public class JNILocalRefLocker extends CriticalSectionObjectLocker {
+ private native void criticalNative(long enterTime, long sleepTime);
+
+ static {
+ System.loadLibrary("JNILocalRefLocker");
+ }
+
+ public JNILocalRefLocker(Object obj) {
+ super(obj);
+ }
+
+ protected void criticalSection(long enterTime, long sleepTime) {
+ criticalNative(enterTime, sleepTime);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLockers.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLockers.java
new file mode 100644
index 00000000000..d4041127cd6
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLockers.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jniref;
+
+import nsk.share.TestBug;
+import nsk.share.gc.lock.Lockers;
+import nsk.share.gc.lock.Locker;
+
+public class JNILocalRefLockers implements Lockers {
+ public Locker createLocker(Object obj) {
+ return new JNILocalRefLocker(obj);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLocker.c b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLocker.c
new file mode 100644
index 00000000000..55e6eddfb47
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLocker.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+#include
+#include
+#include
+#include "jni_tools.h"
+
+static jfieldID objFieldId = NULL;
+
+/*
+ * Class: nsk_share_gc_lock_jniref_JNIRefLocker
+ * Method: criticalNative
+ * Signature: (JJ)V
+ */
+JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIRefLocker_criticalNative
+ (JNIEnv *env, jobject this, jlong enterTime, jlong sleepTime) {
+ jobject obj;
+ jobject gref, lref, gwref;
+ time_t start_time, current_time;
+
+ if (objFieldId == NULL) {
+ jclass class = (*env)->GetObjectClass(env, this);
+ if (class == NULL) {
+ printf("Error: GetObjectClass returned NULL\n");
+ return;
+ }
+ objFieldId = (*env)->GetFieldID(env, class, "obj", "Ljava/lang/Object;");
+ if (objFieldId == NULL) {
+ printf("Error: GetFieldID returned NULL\n");
+ return;
+ }
+ }
+ obj = (*env)->GetObjectField(env, this, objFieldId);
+ if (obj == NULL) {
+ printf("Error: GetObjectField returned NULL\n");
+ return;
+ }
+ (*env)->SetObjectField(env, this, objFieldId, NULL);
+ start_time = time(NULL);
+ enterTime /= 1000;
+ current_time = 0;
+ while (current_time - start_time < enterTime) {
+ gref = (*env)->NewGlobalRef(env, obj);
+ lref = (*env)->NewLocalRef(env, obj);
+ gwref = (*env)->NewWeakGlobalRef(env, obj);
+ mssleep((long) sleepTime);
+ (*env)->DeleteGlobalRef(env, gref);
+ (*env)->DeleteLocalRef(env, lref);
+ (*env)->DeleteWeakGlobalRef(env, gwref);
+ mssleep((long) sleepTime);
+ current_time = time(NULL);
+ }
+ (*env)->SetObjectField(env, this, objFieldId, obj);
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLocker.java
new file mode 100644
index 00000000000..67b91b29abd
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLocker.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jniref;
+
+import nsk.share.gc.lock.CriticalSectionObjectLocker;
+import nsk.share.TestFailure;
+
+/**
+ * JNIRefLocker locks objects using JNI functions
+ * NewGlobalRef, NewLocalRef, NewWeakGlobalRef
+ */
+public class JNIRefLocker extends CriticalSectionObjectLocker {
+ private native void criticalNative(long enterTime, long sleepTime);
+
+ static {
+ System.loadLibrary("JNIRefLocker");
+ }
+
+ public JNIRefLocker(Object obj) {
+ super(obj);
+ }
+
+ protected void criticalSection(long enterTime, long sleepTime) {
+ criticalNative(enterTime, sleepTime);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLockers.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLockers.java
new file mode 100644
index 00000000000..0e37811cb01
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLockers.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2007, 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 nsk.share.gc.lock.jniref;
+
+import nsk.share.TestBug;
+import nsk.share.gc.lock.Lockers;
+import nsk.share.gc.lock.Locker;
+
+public class JNIRefLockers implements Lockers {
+ public Locker createLocker(Object obj) {
+ return new JNIRefLocker(obj);
+ }
+}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIWeakGlobalRefLocker.c b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIWeakGlobalRefLocker.c
new file mode 100644
index 00000000000..9670aa4e3e2
--- /dev/null
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIWeakGlobalRefLocker.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+#include
+#include