changeset 50753:dd501973095c

8199271: [TESTBUG] open source VM testbase stress tests Reviewed-by: mseledtsov, sspitsyn, erikj
author lmesnik
date Thu, 17 May 2018 16:21:27 -0700
parents 2f59dc95847d
children 12fc7bf488ec
files make/test/JtregNativeHotspot.gmk test/hotspot/jtreg/TEST.groups test/hotspot/jtreg/vmTestbase/nsk/stress/except/TEST.properties test/hotspot/jtreg/vmTestbase/nsk/stress/except/except001.java test/hotspot/jtreg/vmTestbase/nsk/stress/except/except002.java test/hotspot/jtreg/vmTestbase/nsk/stress/except/except003.java test/hotspot/jtreg/vmTestbase/nsk/stress/except/except004.java test/hotspot/jtreg/vmTestbase/nsk/stress/except/except005.java test/hotspot/jtreg/vmTestbase/nsk/stress/except/except006.java test/hotspot/jtreg/vmTestbase/nsk/stress/except/except007.java test/hotspot/jtreg/vmTestbase/nsk/stress/except/except008.java test/hotspot/jtreg/vmTestbase/nsk/stress/except/except009.java test/hotspot/jtreg/vmTestbase/nsk/stress/except/except010.java test/hotspot/jtreg/vmTestbase/nsk/stress/except/except011.java test/hotspot/jtreg/vmTestbase/nsk/stress/except/except011oops.java test/hotspot/jtreg/vmTestbase/nsk/stress/except/except012.java test/hotspot/jtreg/vmTestbase/nsk/stress/jni/GarbageGenerator.java test/hotspot/jtreg/vmTestbase/nsk/stress/jni/Interrupter.java test/hotspot/jtreg/vmTestbase/nsk/stress/jni/Synchronizer.java test/hotspot/jtreg/vmTestbase/nsk/stress/jni/TEST.properties test/hotspot/jtreg/vmTestbase/nsk/stress/jni/gclocker/gcl001.java test/hotspot/jtreg/vmTestbase/nsk/stress/jni/gclocker/libgcl001.c test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnihelper.h test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnistress001.java test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnistress002.java test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnistress003.java test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnistress004.java test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnistress005.java test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnistress006.java test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnistress007.java test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress001.c test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress002.c test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress003.c test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress004.c test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress005.c test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress006.c test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress007.c test/hotspot/jtreg/vmTestbase/nsk/stress/network/TEST.properties test/hotspot/jtreg/vmTestbase/nsk/stress/network/network001.java test/hotspot/jtreg/vmTestbase/nsk/stress/network/network002.java test/hotspot/jtreg/vmTestbase/nsk/stress/network/network003.java test/hotspot/jtreg/vmTestbase/nsk/stress/network/network004.java test/hotspot/jtreg/vmTestbase/nsk/stress/network/network005.java test/hotspot/jtreg/vmTestbase/nsk/stress/network/network006.java test/hotspot/jtreg/vmTestbase/nsk/stress/numeric/TEST.properties test/hotspot/jtreg/vmTestbase/nsk/stress/numeric/numeric001.java test/hotspot/jtreg/vmTestbase/nsk/stress/numeric/numeric002.java test/hotspot/jtreg/vmTestbase/nsk/stress/numeric/numeric003.java test/hotspot/jtreg/vmTestbase/nsk/stress/numeric/numeric004.java test/hotspot/jtreg/vmTestbase/nsk/stress/numeric/numeric005.java test/hotspot/jtreg/vmTestbase/nsk/stress/numeric/numeric006.java test/hotspot/jtreg/vmTestbase/nsk/stress/numeric/numeric007.java test/hotspot/jtreg/vmTestbase/nsk/stress/numeric/numeric008.java test/hotspot/jtreg/vmTestbase/nsk/stress/numeric/numeric009.java test/hotspot/jtreg/vmTestbase/nsk/stress/numeric/numeric010.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/TEST.properties test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack001.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack002.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack003.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack004.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack005.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack006.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack007.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack008.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack009.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack010.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack011.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack012.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack013.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack014.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack015.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack016.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack017.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack018.java test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack019.java test/hotspot/jtreg/vmTestbase/nsk/stress/strace/libstrace003.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/libstrace004.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/libstrace005.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/libstrace006.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/libstrace008.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/libstrace009.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/libstrace011.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/libstrace012.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/libstrace014.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/libstrace015.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/nsk_strace.h test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace001.java test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace002.java test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace003.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace003.java test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace004.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace004.java test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace005.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace005.java test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace006.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace006.java test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace007.java test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace008.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace008.java test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace009.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace009.java test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace010.java test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace011.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace011.java test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace012.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace012.java test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace013.java test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace014.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace014.java test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace015.c test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace015.java test/hotspot/jtreg/vmTestbase/nsk/stress/thread/TEST.properties test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread001.java test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread002.java test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread005.java test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread006.java test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread007.java test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread008.java
diffstat 118 files changed, 28387 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/make/test/JtregNativeHotspot.gmk	Thu May 17 14:52:47 2018 -0700
+++ b/make/test/JtregNativeHotspot.gmk	Thu May 17 16:21:27 2018 -0700
@@ -109,6 +109,13 @@
     -I$(VM_TESTBASE_DIR)/nsk/share/native \
     -I$(VM_TESTBASE_DIR)/nsk/share/jni
 
+NSK_STRACE_INCLUDES := \
+    -I$(VM_TESTBASE_DIR)/nsk/share/native \
+    -I$(VM_TESTBASE_DIR)/nsk/share/jni
+
+NSK_STRESS_JNI_INCLUDES := \
+    -I$(VM_TESTBASE_DIR)/nsk/stress/jni
+
 BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libProcessUtils := $(VM_SHARE_INCLUDES)
 
 BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libThreadController := $(NSK_MONITORING_INCLUDES)
@@ -150,6 +157,20 @@
 BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libJNIRefLocker := $(NSK_GC_LOCK_REF_INCLUDES)
 BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libJNIWeakGlobalRefLocker := $(NSK_GC_LOCK_REF_INCLUDES)
 
+
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libstrace003 := $(NSK_STRACE_INCLUDES)
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libstrace004 := $(NSK_STRACE_INCLUDES)
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libstrace005 := $(NSK_STRACE_INCLUDES)
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libstrace006 := $(NSK_STRACE_INCLUDES)
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libstrace008 := $(NSK_STRACE_INCLUDES)
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libstrace009 := $(NSK_STRACE_INCLUDES)
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libstrace011 := $(NSK_STRACE_INCLUDES)
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libstrace012 := $(NSK_STRACE_INCLUDES)
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libstrace014 := $(NSK_STRACE_INCLUDES)
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libstrace015 := $(NSK_STRACE_INCLUDES)
+
+BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libgcl001 := $(NSK_STRESS_JNI_INCLUDES)
+
 ################################################################################
 
 # Platform specific setup
--- a/test/hotspot/jtreg/TEST.groups	Thu May 17 14:52:47 2018 -0700
+++ b/test/hotspot/jtreg/TEST.groups	Thu May 17 16:21:27 2018 -0700
@@ -1157,6 +1157,9 @@
   vmTestbase/nsk/jdi/StackFrame/getArgumentValues/getArgumentValues002/getArgumentValues002.java \
   vmTestbase/nsk/jdi/StackFrame/getArgumentValues/getArgumentValues003/getArgumentValues003.java
 
+vmTestbase_nsk_stress = \
+  vmTestbase/nsk/stress
+
 vmTestbase_vm_g1classunloading = \
   vmTestbase/gc/g1/unloading/tests
 
@@ -1264,4 +1267,3 @@
   vmTestbase/heapdump/OnOOMToPath/TestDescription.java \
   vmTestbase/heapdump/JMapHeapCore/TestDescription.java \
   vmTestbase/heapdump/JMapMetaspace/TestDescription.java
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/except/TEST.properties	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 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.
+#
+
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/except/except001.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,291 @@
+/*
+ * Copyright (c) 1999, 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.
+ */
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/except/except001.
+ * VM testbase keywords: [stress, diehard, slow, nonconcurrent, quick]
+ * VM testbase readme:
+ * DESCRIPTION
+ *     This checks if OutOfMemoryError exception is correctly enwrapped into
+ *     InvocationTargetException when thrown inside a method invoked via
+ *     reflection.
+ *     The test tries to occupy all of memory available in the heap by
+ *     allocating lots of new Object() instances. Instances of the "empty"
+ *     type Object are the smallest objects, so they apparently should occupy
+ *     most fine-grained fragments in the heap. Thus, there apparently should
+ *     not remain any free space to incarnate new Throwable instance, and VM
+ *     possibly could crash while trying to throw new OutOfMemoryError and
+ *     enwrap it into new InvocationTargetException instance.
+ *     By the way, the test checks time elapsed to allocate memory. Both
+ *     classic VM and HotSpot seem to fall into poor performance of memory
+ *     allocation when heap is almost over. E.g.: HotSpot 1.3-betaH may spend
+ *     more than 1 minute to allocate next Object in this case (tested on
+ *     Pentium-II, 350MHz, 128Mb RAM). To avoid this problem, the test enforce
+ *     OutOfMemoryError if more then 5 minutes is spent to allocate "last bytes"
+ *     of memory.
+ * COMMENTS
+ *     HotSpot releases 1.0-fcsE (both Win32 and Sparc), and 1.3-betaH (Win32)
+ *     fail on this test due to poor performance of memory allocation.
+ *         #4248801 (P3/S5) slow memory allocation when heap is almost exhausted
+ *     Despite this bug is treated fixed in HotSpot 1.0.1, it still does suffer
+ *     slow memory allocation when running on PC having 64Mb or less of RAM.
+ *     There is also a workaround involved to avoid the following bugs known
+ *     for HotSpot and for classic VM:
+ *         #4239841 (P1/S5) 1.1: poor garbage collector performance  (HotSpot bug)
+ *         #4245060 (P4/S5) poor garbage collector performance       (Classic VM bug)
+ *     However, printing of the test's error messages, warnings, and of execution
+ *     trace may fail under JDK 1.2 for Win32 even so.
+ *     HotSpot 2.0-devA (Win32) crashes due to the known HotSpot bug:
+ *         #4239828 (P1/S4) 1.3c1: VM crashes when heap is exhausted
+ *
+ * @run main/othervm -Xms50M -Xmx200M nsk.stress.except.except001
+ */
+
+package nsk.stress.except;
+
+import java.io.PrintStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * This checks if <code>OutOfMemoryError</code> exception is correctly
+ * enwrapped into <code>InvocationTargetException</code> when thrown inside
+ * a method invoked via reflection.
+ * <p>
+ * <p>The test tries to occupy all of memory available in the heap by
+ * allocating lots of new <code>Object()</code> instances. Instances of the
+ * ``empty'' type <code>Object</code> are the smallest objects, so they
+ * apparently should occupy most fine-grained fragments in the heap.
+ * Thus, there apparently should not remain any free space to incarnate new
+ * <code>Throwable</code> instance, and VM possibly could crash while trying
+ * to throw new <code>OutOfMemoryError</code> and enwrap it into new
+ * <code>InvocationTargetException</code> instance.
+ * <p>
+ * <p>By the way, the test checks time elapsed to allocate memory.
+ * Both classic VM and HotSpot seem to fall into poor performance of memory
+ * allocation when heap is almost over. E.g.: HotSpot 1.3-betaH may spend
+ * more than 1 minute to allocate next <code>Object</code> in this case
+ * (tested on Pentium-II, 350MHz, 128Mb RAM). To workaround this problem,
+ * the test enforces <code>OutOfMemoryError</code> if more then 5 minutes
+ * is spent to allocate ``last bytes'' of the memory.
+ */
+public class except001 {
+    /**
+     * This field allows or supresses printing with <code>display()</code>
+     * method.
+     *
+     * @see #display(Object)
+     * @see #complain(Object)
+     * @see #out
+     */
+    private static boolean MODE_VERBOSE = true;
+    /*
+    * Storage for a lot of tiny objects
+    * "static volatile" keywords are for preventing heap optimization
+    */
+    private static volatile Object pool[] = null;
+
+    /**
+     * Print execution trace if <code>MODE_VERBOSE</code> is <code>true</code>
+     * (optional).
+     *
+     * @see #MODE_VERBOSE
+     * @see #complain(Object)
+     * @see #out
+     */
+    private static void display(Object message) {
+        if (MODE_VERBOSE)
+            out.println(message.toString());
+        out.flush();
+    }
+
+    /**
+     * Print error <code>message</code>.
+     *
+     * @see #display(Object)
+     * @see #out
+     */
+    private static void complain(Object message) {
+        out.println("# " + message);
+        out.flush();
+    }
+
+    /**
+     * The log-stream assigned at runtime by the method
+     * <code>run(args,out)</code>.
+     *
+     * @see #display(Object)
+     * @see #complain(Object)
+     * @see #run(String[], PrintStream)
+     */
+    private static PrintStream out;
+
+    /**
+     * Try to allocate lots of instances of the type <code>Object</code>.
+     * Such instances are most fine-grained, and thus they should occupy
+     * smallest fragments of free memory in the heap.
+     * <p>
+     * <p>By the way, break the test, if JVM has spent more than
+     * 5 minutes to allocate latest portions of memory.
+     */
+    public static void raiseOutOfMemory() throws OutOfMemoryError {
+        try {
+            // Repository for objects, which should be allocated:
+            int index = 0;
+            for (int size = 1 << 30; size > 0 && pool == null; size >>= 1)
+                try {
+                    pool = new Object[size];
+                } catch (OutOfMemoryError oome) {
+                }
+            if (pool == null)
+                throw new Error("HS bug: cannot allocate new Object[1]");
+
+            // Sum up time spent, when it was hard to JVM to allocate next object
+            // (i.e.: when JVM has spent more than 1 second to allocate new object):
+            double totalDelay = 0;
+            long timeMark = System.currentTimeMillis();
+
+            for (; index < pool.length; index++) {
+                //-------------------------
+                pool[index] = new Object();
+                long nextTimeMark = System.currentTimeMillis();
+                long elapsed = nextTimeMark - timeMark;
+                timeMark = nextTimeMark;
+                //----------------------
+                if (elapsed > 1000) {
+                    double seconds = elapsed / 1000.0;
+                    display(
+                            "pool[" + index +
+                                    "]=new Object(); // elapsed " + seconds + "s");
+                    totalDelay += seconds;
+                    if (totalDelay > 300) {
+                        complain(
+                                "Memory allocation became slow: so heap seems exhausted.");
+                        throw new OutOfMemoryError();
+                    }
+                }
+            }
+
+            // This method should never return:
+            throw new Error("TEST_BUG: failed to provoke OutOfMemoryError");
+        } finally {
+            // Make sure there will be enough memory for next object allocation
+             pool = null;
+        }
+    }
+
+    /**
+     * Invoke the method <code>raiseOutOfMemory()</code> with reflection,
+     * and check if the exception it throws is just
+     * <code>OutOfMemoryError</code> enwrapped into
+     * <code>InvocationTargetException</code> instance.
+     * <p>
+     * <p>Before the test begins, <code>this.out</code> filed is assigned
+     * to the parameter <code>out</code>. Parameter <code>args[]</code>
+     * is ignored.
+     *
+     * @see #raiseOutOfMemory()
+     */
+    public static int run(String args[], PrintStream out) {
+        out.println("# While printing this message, JVM seems to initiate the output");
+        out.println("# stream, so that it will not need more memory to print later,");
+        out.println("# when the heap would fail to provide more memory.");
+        out.println("# ");
+        out.println("# That problem is caused by the known JDK/HotSpot bugs:");
+        out.println("#     4239841 (P1/S5) 1.1: poor garbage collector performance");
+        out.println("#     4245060 (P4/S5) poor garbage collector performance");
+        out.println("# ");
+        out.println("# This message is just intended to work-around that problem.");
+        out.println("# If printing should fail even so.");
+
+        if (args.length > 0) {
+            if (args[0].toLowerCase().startsWith("-v"))
+                MODE_VERBOSE = true;
+        }
+
+        except001.out = out;
+        Class testClass = except001.class;
+        try {
+            Method testMethod = testClass.getMethod("raiseOutOfMemory", new Class [0]);
+            Object junk = testMethod.invoke(null, new Object [0]);
+
+        } catch (InvocationTargetException ite) {
+            Throwable targetException = ite.getTargetException();
+            if (targetException instanceof OutOfMemoryError) {
+                display("OutOfMemoryError thrown as expected.");
+                display("Test passed.");
+                return 0;
+            }
+            complain("Unexpected InvocationTargetException: " + targetException);
+            complain("Test failed.");
+            return 2;
+
+        } catch (Exception exception) {
+            complain("Unexpected exception: " + exception);
+            complain("Test failed.");
+            return 2;
+        }
+        //
+        complain("The test has finished unexpectedly.");
+        complain("Test failed.");
+        return 2;
+    }
+
+    /**
+     * Re-call to <code>run(args,out)</code>, and return JCK-like exit status.
+     * (The stream <code>out</code> is assigned to <code>System.out</code> here.)
+     *
+     * @see #run(String[], PrintStream)
+     */
+    public static void main(String args[]) {
+        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+            // Last try. If there is some exception outside the code, test should end correctly
+            @Override
+            public void uncaughtException(Thread t, Throwable e) {
+                try {
+                    pool = null;
+                    System.gc();
+                    if (e instanceof OutOfMemoryError) {
+                        try {
+                            System.out.println("OOME : Test Skipped");
+                            System.exit(95);
+                        } catch (Throwable ignore) {
+                        } // No code in the handler can provoke correct exceptions.
+                    } else {
+                        e.printStackTrace();
+                        throw (RuntimeException) e;
+                    }
+                } catch (OutOfMemoryError oome) {
+                }
+            }
+        });
+        int exitCode = run(args, System.out);
+        System.exit(exitCode + 95);
+        // JCK-like exit status.
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/except/except002.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,301 @@
+/*
+ * Copyright (c) 1999, 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.
+ */
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/except/except002.
+ * VM testbase keywords: [stress, diehard, slow, nonconcurrent, quick]
+ * VM testbase readme:
+ * DESCRIPTION
+ *     This checks if various exceptions are thrown (and caught) correctly
+ *     when there apparently are no free space in the heap to allocate new
+ *     Throwable instance.
+ *     The test tries to occupy all of memory available in the heap by allocating
+ *     lots of new Object() instances. Instances of the type Object are the smallest
+ *     objects, so they apparently should occupy most fine-grained fragments in the
+ *     heap and leave no free space for new Throwable instance. After that, the test
+ *     provokes various exceptions (e.g.: by executing integer division by 0 and so
+ *     on), and checks if appropriate exceptions are thrown.
+ * COMMENTS
+ *     The test needs a lot of memory to start up, so it should not run under older
+ *     JDK 1.1.x release due to its poorer heap utilization. Also, some checks are
+ *     skipped when testing classic VM, because OutOfMemoryError is correctly thrown
+ *     instead of target exception.
+ *     When the test is being self-initiating (i.e.: eating heap), memory occupation
+ *     is terminated if memory allocation slows down crucially. This is a workaround
+ *     intended to avoid the HotSpot bug:
+ *         #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ *     There is also a workaround involved to avoid the following bugs known
+ *     for HotSpot and for classic VM:
+ *         #4239841 (P1/S5) 1.1: poor garbage collector performance  (HotSpot bug)
+ *         #4245060 (P4/S5) poor garbage collector performance       (Classic VM bug)
+ *     However, printing of the test's error messages, warnings, and of execution
+ *     trace fails under JDK 1.2 for Win32 even so. If the test fails due to this
+ *     problem, exit status 96 is returned instead of 97.
+ *     JDK 1.3 classic VM for Sparc may crash (core dump) due to the known bug:
+ *         #4245057 (P2/S3) VM crashes when heap is exhausted
+ *
+ * @run main/othervm -Xms50M -Xmx200M nsk.stress.except.except002
+ */
+
+package nsk.stress.except;
+
+import java.io.PrintStream;
+
+/**
+ * This checks if various exceptions are thrown (and caught) correctly
+ * when there apparently are no free space in the heap to allocate new
+ * <code>Throwable</code> instance.
+ * <p>
+ * <p>The test tries to occupy all of memory available in the heap by
+ * allocating lots of new <code>Object()</code> instances. Instances of the
+ * type <code>Object</code> are the smallest objects, so they apparently should
+ * occupy most fine-grained fragments in the heap and leave no free space for
+ * new <code>Throwable</code> instance. After that, the test provokes various
+ * exceptions (e.g.: by executing integer division by 0 and so on), and checks
+ * if appropriate exceptions are thrown.
+ * <p>
+ * <p>Note, that memory occupation is terminated if memory allocation slows
+ * down crucially. This is a workaround intended to avoid the HotSpot bug:
+ * <br>&nbsp;&nbsp;
+ * #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ * <p>
+ * <p>There is also a workaround involved to avoid the following bugs known
+ * for HotSpot and for classic VM:
+ * <br>&nbsp;&nbsp;
+ * #4239841 (P1/S5) 1.1: poor garbage collector performance
+ * <br>&nbsp;&nbsp;
+ * #4245060 (P4/S5) poor garbage collector performance
+ * <br>However, printing of the test's error messages, warnings, and of
+ * execution trace may fail even so. If the test fails due to poor GC
+ * performance, exit status 96 is returned instead of 97.
+ * <p>
+ * <p>Also note, that the test needs a lot of memory to start up, so it should
+ * not run under older JDK 1.1.x release due to its poor heap utilization.
+ */
+public class except002 {
+    /**
+     * Either allow or supress printing of execution trace.
+     */
+    private static boolean TRACE_ON = false;
+    /**
+     * Either allow or supress printing of warning messages.
+     */
+    private static final boolean WARN_ON = true;
+    /*
+     * Storage for a lot of tiny objects
+     * "static volatile" keywords are for preventing heap optimization
+     */
+    public static volatile Object pool[] = null;
+    /**
+     * Temporary <code>log</code> for error messages, warnings and/or execution trace.
+     *
+     * @see #messages
+     */
+    private static String log[] = new String[1000]; // up to 1000 messages
+    /**
+     * How many <code>messages</code> were submitted to the <code>log</code>.
+     *
+     * @see #log
+     */
+    private static int messages = 0;
+
+    /**
+     * Re-call to the method <code>run(out)</code> (ignore <code>args[]</code>),
+     * and print the test summary - either test passed of failed.
+     */
+    public static int run(String args[], PrintStream out) {
+        if (args.length > 0) {
+            if (args[0].toLowerCase().startsWith("-v"))
+                TRACE_ON = true;
+        }
+
+        int exitCode = run(out);
+        pool = null;
+        System.gc();
+        // Print the log[] and the test summary:
+        try {
+            for (int i = 0; i < messages; i++)
+                out.println(log[i]);
+            if (exitCode == 0) {
+                if (TRACE_ON)
+                    out.println("Test passed.");
+            } else
+                out.println("Test failed.");
+        } catch (OutOfMemoryError oome) {
+            // Poor performance of garbage collector:
+            exitCode = 1;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Allocate as much <code>Object</code> instances as possible to bring JVM
+     * into stress, and then check if exceptions are correctly thrown accordingly
+     * to various situations like integer division by 0, etc.
+     */
+    private static int run(PrintStream out) {
+        out.println("# While printing this message, JVM seems to initiate the output");
+        out.println("# stream, so that it will not need more memory to print later,");
+        out.println("# when the heap would fail to provide more memory.");
+        out.println("# ");
+        out.println("# Note, that the test maintains especial static log[] field in");
+        out.println("# order to avoid printing when the heap seems exhausted.");
+        out.println("# Nevertheless, printing could arise OutOfMemoryError even");
+        out.println("# after all the memory allocated by the test is released.");
+        out.println("# ");
+        out.println("# That problem is caused by the known JDK/HotSpot bugs:");
+        out.println("#     4239841 (P1/S5) 1.1: poor garbage collector performance");
+        out.println("#     4245060 (P4/S5) poor garbage collector performance");
+        out.println("# ");
+        out.println("# This message is just intended to work-around that problem.");
+        out.println("# If printing should fail even so, the test will return the");
+        out.println("# exit status 96 instead of 97 to indicate the problem.");
+
+        // Prepare some items, which will be used by the test:
+        Object trash = null;
+
+        // Sum up exit code:
+        int exitCode = 0; // apparently PASSED
+        int skipped = 0;  // some checks may correctly suffer OutOfMemoryError
+        // Allocate repository for a lots of tiny objects:
+        for (int size = 1 << 30; size > 0 && pool == null; size >>= 1)
+            try {
+                pool = new Object[size];
+            } catch (OutOfMemoryError oome) {
+            }
+        if (pool == null)
+            throw new Error("HS bug: cannot allocate new Object[1]");
+        int poolSize = pool.length;
+        int index = 0;
+
+        // Sum up time spent, when it was hard to JVM to allocate next object
+        // (i.e.: when JVM has spent more than 1 second to allocate new object):
+        double totalDelay = 0;
+        long timeMark = System.currentTimeMillis();
+        try {
+            for (; index < poolSize; index++) {
+                //-------------------------
+                pool[index] = new Object();
+                long nextTimeMark = System.currentTimeMillis();
+                long elapsed = nextTimeMark - timeMark;
+                timeMark = nextTimeMark;
+                //----------------------
+                if (elapsed > 1000) {
+                    double seconds = elapsed / 1000.0;
+                    if (TRACE_ON)
+                        out.println(
+                                "pool[" + index + "]=new Object(); // elapsed " + seconds + "s");
+                    totalDelay += seconds;
+                    if (totalDelay > 60) {
+                        if (TRACE_ON)
+                            out.println(
+                                    "Memory allocation became slow; so, heap seems exhausted.");
+                        break;
+                    }
+                }
+            }
+        } catch (OutOfMemoryError oome) {
+            if (TRACE_ON)
+                log[messages++] = "Heap seems exhausted - OutOfMemoryError thrown.";
+
+            // Do not release any byte once allocated:
+            pool[index++] = oome;
+        }
+
+        if (index > poolSize - 1000) {
+            if (WARN_ON)
+                log[messages++] = "Warning: pool[] is full; so, checks would not be enough hard...";
+        }
+
+        // Check ClassNotFoundException (positive):
+        try {
+            trash = Class.forName("nsk.stress.except.except002.except002$Abra$Cadabra"); //   correct - should pass
+//          trash = Class.forName("nsk.stress.except.except002.except002.Abra.Cadabra"); // incorrect - should fail
+            if (TRACE_ON)
+                log[messages++] = "Success: ClassNotFoundException (positive)";
+        } catch (ClassNotFoundException cnfe) {
+            log[messages++] = "Failure: ClassNotFoundException (positive)";
+            exitCode = 2;
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: ClassNotFoundException (positive)";
+            skipped++;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Re-call to <code>run(args,out)</code>, and return JCK-like exit status.
+     * (The stream <code>out</code> is assigned to <code>System.out</code> here.)
+     *
+     * @see #run(String[], PrintStream)
+     */
+    public static void main(String args[]) {
+        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+            // Last try. If there is some exception outside the code, test should end correctly
+            @Override
+            public void uncaughtException(Thread t, Throwable e) {
+                try {
+                    pool = null;
+                    log = null;
+                    System.gc();
+                    if (e instanceof OutOfMemoryError) {
+                        try {
+                            System.out.println("OOME : Test Skipped");
+                            System.exit(0);
+                        } catch (Throwable ignore) {
+                        } // No code in the handler can provoke correct exceptions.
+                    } else {
+                        e.printStackTrace();
+                        throw (RuntimeException) e;
+                    }
+                } catch (OutOfMemoryError oome) {
+                }
+            }
+        });
+        int exitCode = run(args, System.out);
+        System.exit(exitCode + 95);
+        // JCK-like exit status.
+    }
+
+    /**
+     * This class should be used to check <code>ClassNotFoundException</code>
+     * and <code>IllegalAccessException</code>.
+     */
+    private static class Abra {
+        /**
+         * Will try to incorrectly find this class as <code>Cadabra</code>
+         * instead of <code>Abra$Cadabra</code>.
+         */
+        public static class Cadabra {
+        }
+
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/except/except003.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 1999, 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.
+ */
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/except/except003.
+ * VM testbase keywords: [stress, diehard, slow, nonconcurrent, quick]
+ * VM testbase readme:
+ * DESCRIPTION
+ *     This checks if various exceptions are thrown (and caught) correctly
+ *     when there apparently are no free space in the heap to allocate new
+ *     Throwable instance.
+ *     The test tries to occupy all of memory available in the heap by allocating
+ *     lots of new Object() instances. Instances of the type Object are the smallest
+ *     objects, so they apparently should occupy most fine-grained fragments in the
+ *     heap and leave no free space for new Throwable instance. After that, the test
+ *     provokes various exceptions (e.g.: by executing integer division by 0 and so
+ *     on), and checks if appropriate exceptions are thrown.
+ * COMMENTS
+ *     The test needs a lot of memory to start up, so it should not run under older
+ *     JDK 1.1.x release due to its poorer heap utilization. Also, some checks are
+ *     skipped when testing classic VM, because OutOfMemoryError is correctly thrown
+ *     instead of target exception.
+ *     When the test is being self-initiating (i.e.: eating heap), memory occupation
+ *     is terminated if memory allocation slows down crucially. This is a workaround
+ *     intended to avoid the HotSpot bug:
+ *         #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ *     There is also a workaround involved to avoid the following bugs known
+ *     for HotSpot and for classic VM:
+ *         #4239841 (P1/S5) 1.1: poor garbage collector performance  (HotSpot bug)
+ *         #4245060 (P4/S5) poor garbage collector performance       (Classic VM bug)
+ *     However, printing of the test's error messages, warnings, and of execution
+ *     trace fails under JDK 1.2 for Win32 even so. If the test fails due to this
+ *     problem, exit status 96 is returned instead of 97.
+ *     JDK 1.3 classic VM for Sparc may crash (core dump) due to the known bug:
+ *         #4245057 (P2/S3) VM crashes when heap is exhausted
+ *
+ * @run main/othervm -Xms50M -Xmx200M nsk.stress.except.except003
+ */
+
+package nsk.stress.except;
+
+import java.io.PrintStream;
+
+/**
+ * This checks if various exceptions are thrown (and caught) correctly
+ * when there apparently are no free space in the heap to allocate new
+ * <code>Throwable</code> instance.
+ * <p>
+ * <p>The test tries to occupy all of memory available in the heap by
+ * allocating lots of new <code>Object()</code> instances. Instances of the
+ * type <code>Object</code> are the smallest objects, so they apparently should
+ * occupy most fine-grained fragments in the heap and leave no free space for
+ * new <code>Throwable</code> instance. After that, the test provokes various
+ * exceptions (e.g.: by executing integer division by 0 and so on), and checks
+ * if appropriate exceptions are thrown.
+ * <p>
+ * <p>Note, that memory occupation is terminated if memory allocation slows
+ * down crucially. This is a workaround intended to avoid the HotSpot bug:
+ * <br>&nbsp;&nbsp;
+ * #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ * <p>
+ * <p>There is also a workaround involved to avoid the following bugs known
+ * for HotSpot and for classic VM:
+ * <br>&nbsp;&nbsp;
+ * #4239841 (P1/S5) 1.1: poor garbage collector performance
+ * <br>&nbsp;&nbsp;
+ * #4245060 (P4/S5) poor garbage collector performance
+ * <br>However, printing of the test's error messages, warnings, and of
+ * execution trace may fail even so. If the test fails due to poor GC
+ * performance, exit status 96 is returned instead of 97.
+ * <p>
+ * <p>Also note, that the test needs a lot of memory to start up, so it should
+ * not run under older JDK 1.1.x release due to its poor heap utilization.
+ */
+public class except003 {
+    /**
+     * Either allow or supress printing of execution trace.
+     */
+    private static boolean TRACE_ON = false;
+    /**
+     * Either allow or supress printing of warning messages.
+     */
+    private static final boolean WARN_ON = true;
+    /*
+    * Storage for a lot of tiny objects
+    * "static volatile" keywords are for preventing heap optimization
+    */
+    private static volatile Object pool[] = null;
+    /**
+     * Temporary <code>log</code> for error messages, warnings and/or execution trace.
+     *
+     * @see #messages
+     */
+    private static String log[] = new String[1000]; // up to 1000 messages
+    /**
+     * How many <code>messages</code> were submitted to the <code>log</code>.
+     *
+     * @see #log
+     */
+    private static int messages = 0;
+
+    /**
+     * Re-call to the method <code>run(out)</code> (ignore <code>args[]</code>),
+     * and print the test summary - either test passed of failed.
+     */
+    public static int run(String args[], PrintStream out) {
+        if (args.length > 0) {
+            if (args[0].toLowerCase().startsWith("-v"))
+                TRACE_ON = true;
+        }
+
+        int exitCode = run(out);
+        pool = null;
+        System.gc();
+        // Print the log[] and the test summary:
+        try {
+            for (int i = 0; i < messages; i++)
+                out.println(log[i]);
+            if (exitCode == 0) {
+                if (TRACE_ON)
+                    out.println("Test passed.");
+            } else
+                out.println("Test failed.");
+        } catch (OutOfMemoryError oome) {
+            // Poor performance of garbage collector:
+            exitCode = 1;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Allocate as much <code>Object</code> instances as possible to bring JVM
+     * into stress, and then check if exceptions are correctly thrown accordingly
+     * to various situations like integer division by 0, etc.
+     */
+    private static int run(PrintStream out) {
+        out.println("# While printing this message, JVM seems to initiate the output");
+        out.println("# stream, so that it will not need more memory to print later,");
+        out.println("# when the heap would fail to provide more memory.");
+        out.println("# ");
+        out.println("# Note, that the test maintains especial static log[] field in");
+        out.println("# order to avoid printing when the heap seems exhausted.");
+        out.println("# Nevertheless, printing could arise OutOfMemoryError even");
+        out.println("# after all the memory allocated by the test is released.");
+        out.println("# ");
+        out.println("# That problem is caused by the known JDK/HotSpot bugs:");
+        out.println("#     4239841 (P1/S5) 1.1: poor garbage collector performance");
+        out.println("#     4245060 (P4/S5) poor garbage collector performance");
+        out.println("# ");
+        out.println("# This message is just intended to work-around that problem.");
+        out.println("# If printing should fail even so, the test will return the");
+        out.println("# exit status 96 instead of 97 to indicate the problem.");
+
+        // Prepare some items, which will be used by the test:
+        Object trash = null;
+
+        // Allocate repository for a lots of tiny objects:
+        pool = null;
+        // Sum up exit code:
+        int exitCode = 0; // apparently PASSED
+        int skipped = 0;  // some checks may correctly suffer OutOfMemoryError
+        for (int size = 1 << 30; size > 0 && pool == null; size >>= 1)
+            try {
+                pool = new Object[size];
+            } catch (OutOfMemoryError oome) {
+            }
+        if (pool == null)
+            throw new Error("HS bug: cannot allocate new Object[1]");
+        int poolSize = pool.length;
+        int index = 0;
+
+        // Sum up time spent, when it was hard to JVM to allocate next object
+        // (i.e.: when JVM has spent more than 1 second to allocate new object):
+        double totalDelay = 0;
+        long timeMark = System.currentTimeMillis();
+        try {
+            for (; index < poolSize; index++) {
+                //-------------------------
+                pool[index] = new Object();
+                long nextTimeMark = System.currentTimeMillis();
+                long elapsed = nextTimeMark - timeMark;
+                timeMark = nextTimeMark;
+                //----------------------
+                if (elapsed > 1000) {
+                    double seconds = elapsed / 1000.0;
+                    if (TRACE_ON)
+                        out.println(
+                                "pool[" + index + "]=new Object(); // elapsed " + seconds + "s");
+                    totalDelay += seconds;
+                    if (totalDelay > 60) {
+                        if (TRACE_ON)
+                            out.println(
+                                    "Memory allocation became slow; so, heap seems exhausted.");
+                        break;
+                    }
+                }
+            }
+        } catch (OutOfMemoryError oome) {
+            if (TRACE_ON)
+                log[messages++] = "Heap seems exhausted - OutOfMemoryError thrown.";
+
+            // Do not release any byte once allocated:
+            pool[index++] = oome;
+        }
+
+        if (index > poolSize - 1000) {
+            if (WARN_ON)
+                log[messages++] = "Warning: pool[] is full; so, checks would not be enough hard...";
+        }
+
+        // Check ClassNotFoundException (negative):
+        try {
+//          trash = Class.forName("nsk.stress.except.except003.except003$Abra$Cadabra"); //   correct - should pass
+            trash = Class.forName("nsk.stress.except.except003.except003.Abra.Cadabra"); // incorrect - should fail
+            log[messages++] = "Failure: ClassNotFoundException (negative)";
+            exitCode = 2;
+        } catch (ClassNotFoundException cnfe) {
+            if (TRACE_ON)
+                log[messages++] = "Success: ClassNotFoundException (negative)";
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: ClassNotFoundException (negative)";
+            skipped++;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Re-call to <code>run(args,out)</code>, and return JCK-like exit status.
+     * (The stream <code>out</code> is assigned to <code>System.out</code> here.)
+     *
+     * @see #run(String[], PrintStream)
+     */
+    public static void main(String args[]) {
+        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+            // Last try. If there is some exception outside the code, test should end correctly
+            @Override
+            public void uncaughtException(Thread t, Throwable e) {
+                try {
+                    pool = null;
+                    log = null;
+                    System.gc();
+                    if (e instanceof OutOfMemoryError) {
+                        try {
+                            System.out.println("OOME : Test Skipped");
+                            System.exit(95);
+                        } catch (Throwable ignore) {
+                        } // No code in the handler can provoke correct exceptions.
+                    } else {
+                        e.printStackTrace();
+                        throw (RuntimeException) e;
+                    }
+                } catch (OutOfMemoryError oome) {
+                }
+            }
+        });
+        int exitCode = run(args, System.out);
+        System.exit(exitCode + 95);
+        // JCK-like exit status.
+    }
+
+    /**
+     * This class should be used to check <code>ClassNotFoundException</code>
+     * and <code>IllegalAccessException</code>.
+     */
+    private static class Abra {
+        /**
+         * Will try to incorrectly find this class as <code>Cadabra</code>
+         * instead of <code>Abra$Cadabra</code>.
+         */
+        public static class Cadabra {
+        }
+
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/except/except004.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,553 @@
+/*
+ * Copyright (c) 1999, 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.
+ */
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/except/except004.
+ * VM testbase keywords: [stress, diehard, slow, nonconcurrent, quick]
+ * VM testbase readme:
+ * DESCRIPTION
+ *     This checks if various exceptions are thrown (and caught) correctly
+ *     when there apparently are no free space in the heap to allocate new
+ *     Throwable instance.
+ *     The test tries to occupy all of memory available in the heap by allocating
+ *     lots of new Object() instances. Instances of the type Object are the smallest
+ *     objects, so they apparently should occupy most fine-grained fragments in the
+ *     heap and leave no free space for new Throwable instance. After that, the test
+ *     provokes various exceptions (e.g.: by executing integer division by 0 and so
+ *     on), and checks if appropriate exceptions are thrown.
+ * COMMENTS
+ *     The test needs a lot of memory to start up, so it should not run under older
+ *     JDK 1.1.x release due to its poorer heap utilization. Also, some checks are
+ *     skipped when testing classic VM, because OutOfMemoryError is correctly thrown
+ *     instead of target exception.
+ *     When the test is being self-initiating (i.e.: eating heap), memory occupation
+ *     is terminated if memory allocation slows down crucially. This is a workaround
+ *     intended to avoid the HotSpot bug:
+ *         #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ *     There is also a workaround involved to avoid the following bugs known
+ *     for HotSpot and for classic VM:
+ *         #4239841 (P1/S5) 1.1: poor garbage collector performance  (HotSpot bug)
+ *         #4245060 (P4/S5) poor garbage collector performance       (Classic VM bug)
+ *     However, printing of the test's error messages, warnings, and of execution
+ *     trace fails under JDK 1.2 for Win32 even so. If the test fails due to this
+ *     problem, exit status 96 is returned instead of 97.
+ *     JDK 1.3 classic VM for Sparc may crash (core dump) due to the known bug:
+ *         #4245057 (P2/S3) VM crashes when heap is exhausted
+ *
+ * @run main/othervm -Xms50M -Xmx200M -XX:-UseGCOverheadLimit nsk.stress.except.except004
+ */
+
+package nsk.stress.except;
+
+import java.io.PrintStream;
+import java.lang.reflect.Field;
+
+/**
+ * This checks if various exceptions are thrown (and caught) correctly
+ * when there apparently are no free space in the heap to allocate new
+ * <code>Throwable</code> instance.
+ * <p>
+ * <p>The test tries to occupy all of memory available in the heap by
+ * allocating lots of new <code>Object()</code> instances. Instances of the
+ * type <code>Object</code> are the smallest objects, so they apparently should
+ * occupy most fine-grained fragments in the heap and leave no free space for
+ * new <code>Throwable</code> instance. After that, the test provokes various
+ * exceptions (e.g.: by executing integer division by 0 and so on), and checks
+ * if appropriate exceptions are thrown.
+ * <p>
+ * <p>Note, that memory occupation is terminated if memory allocation slows
+ * down crucially. This is a workaround intended to avoid the HotSpot bug:
+ * <br>&nbsp;&nbsp;
+ * #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ * <p>
+ * <p>There is also a workaround involved to avoid the following bugs known
+ * for HotSpot and for classic VM:
+ * <br>&nbsp;&nbsp;
+ * #4239841 (P1/S5) 1.1: poor garbage collector performance
+ * <br>&nbsp;&nbsp;
+ * #4245060 (P4/S5) poor garbage collector performance
+ * <br>However, printing of the test's error messages, warnings, and of
+ * execution trace may fail even so. If the test fails due to poor GC
+ * performance, exit status 96 is returned instead of 97.
+ * <p>
+ * <p>Also note, that the test needs a lot of memory to start up, so it should
+ * not run under older JDK 1.1.x release due to its poor heap utilization.
+ */
+public class except004 {
+    /**
+     * Either allow or supress printing of execution trace.
+     */
+    private static boolean TRACE_ON = false;
+    /**
+     * Either allow or supress printing of warning messages.
+     */
+    private static final boolean WARN_ON = true;
+    /*
+     * Storage for a lot of tiny objects
+     * "static volatile" keywords are for preventing heap optimization
+     */
+    private static volatile Object pool[] = null;
+    /**
+     * Temporary <code>log</code> for error messages, warnings and/or execution trace.
+     *
+     * @see #messages
+     */
+    private static String log[] = new String[1000]; // up to 1000 messages
+    /**
+     * How many <code>messages</code> were submitted to the <code>log</code>.
+     *
+     * @see #log
+     */
+    private static int messages = 0;
+
+    /**
+     * Re-call to the method <code>run(out)</code> (ignore <code>args[]</code>),
+     * and print the test summary - either test passed of failed.
+     */
+    public static int run(String args[], PrintStream out) {
+        if (args.length > 0) {
+            if (args[0].toLowerCase().startsWith("-v"))
+                TRACE_ON = true;
+        }
+
+        int exitCode;
+        try {
+            exitCode = run(out);
+        } finally { // ensure we have free memory for exception processing
+            pool = null;
+            System.gc();
+        }
+        if (TRACE_ON)
+            out.println("Test completed.");
+
+        // Print the log[] and the test summary:
+        try {
+            for (int i = 0; i < messages; i++)
+                out.println(log[i]);
+            if (exitCode == 0) {
+                if (TRACE_ON)
+                    out.println("Test passed.");
+            } else
+                out.println("Test failed.");
+        } catch (OutOfMemoryError oome) {
+            // Poor performance of garbage collector:
+            exitCode = 1;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Allocate as much <code>Object</code> instances as possible to bring JVM
+     * into stress, and then check if exceptions are correctly thrown accordingly
+     * to various situations like integer division by 0, etc.
+     */
+    private static int run(PrintStream out) {
+        out.println("# While printing this message, JVM seems to initiate the output");
+        out.println("# stream, so that it will not need more memory to print later,");
+        out.println("# when the heap would fail to provide more memory.");
+        out.println("# ");
+        out.println("# Note, that the test maintains especial static log[] field in");
+        out.println("# order to avoid printing when the heap seems exhausted.");
+        out.println("# Nevertheless, printing could cause OutOfMemoryError even");
+        out.println("# after all the memory allocated by the test is released.");
+        out.println("# ");
+        out.println("# That problem is caused by the known JDK/HotSpot bugs:");
+        out.println("#     4239841 (P1/S5) 1.1: poor garbage collector performance");
+        out.println("#     4245060 (P4/S5) poor garbage collector performance");
+        out.println("# ");
+        out.println("# This message is just intended to work-around that problem.");
+        out.println("# If printing should fail even so, the test will return the");
+        out.println("# exit status 96 instead of 97 to indicate the problem.");
+
+        // run all tests normally to ensure all needed classes are loaded and
+        // initialized before the heap is exhausted - else we may trigger OOME
+        // in unexpected places.
+        try {
+            if (TRACE_ON)
+                out.println("Running without heap exhaustion");
+            runTests(out, false);
+        } catch (Throwable unexpected) {
+            out.println("Test pre-initialisation failed: " + unexpected);
+            return 2;
+        }
+
+        if (TRACE_ON)
+            out.println("Running with heap exhaustion");
+
+        return runTests(out, true);
+    }
+
+    private static int runTests(PrintStream out, boolean exhaustHeap) {
+        // reset message index
+        messages = 0;
+
+        // Prepare some items, which will be used by the test:
+        Object stringArray[] = new String[1];
+        Object integerValue = new Integer(0);
+        Object doubleValue = new Double(0);
+        Object trash = null;
+        Field abraPrivateField;
+        Field abraIntegerField;
+        Field abraBooleanField;
+        try {
+            abraPrivateField = Abra.class.getDeclaredField("DONT_TOUCH_ME");
+            abraIntegerField = Abra.class.getDeclaredField("MAIN_CYR_NUMBER");
+            abraBooleanField = Abra.class.getDeclaredField("NOT_AN_INTEGER");
+        } catch (NoSuchFieldException nsfe) {
+            out.println("Test initialisation failed: field not found in class Abra");
+            return 2;
+        }
+
+        Abra abra = new Abra("via public constructor");
+        Abra.Cadabra cadabra = new Abra.Cadabra();
+        // Sum up exit code:
+        int exitCode = 0; // apparently PASSED
+        int skipped = 0;  // some checks may correctly suffer OutOfMemoryError
+
+        int poolSize = 0;
+        int index = 0;
+
+        if (exhaustHeap) {
+            pool = null;
+            // Allocate repository for lots of tiny objects:
+            for (int size = 1 << 30; size > 0 && pool == null; size >>= 1) {
+                try {
+                    pool = new Object[size];
+                } catch (OutOfMemoryError oome) {
+                }
+            }
+            if (pool == null)
+                throw new Error("HS bug: cannot allocate new Object[1]");
+            poolSize = pool.length;
+            index = 0;
+
+            // Sum up time spent, when it was hard for JVM to allocate next object
+            // (i.e.: when JVM has spent more than 1 second to allocate new object):
+            double totalDelay = 0;
+            long timeMark = System.currentTimeMillis();
+            try {
+                for (; index < poolSize; index++) {
+                    //-------------------------
+                    pool[index] = new Object();
+                    long nextTimeMark = System.currentTimeMillis();
+                    long elapsed = nextTimeMark - timeMark;
+                    timeMark = nextTimeMark;
+                    //----------------------
+                    if (elapsed > 1000) {
+                        double seconds = elapsed / 1000.0;
+                        if (TRACE_ON)
+                            out.println(
+                                    "pool[" + index + "]=new Object(); // elapsed " + seconds + "s");
+                        totalDelay += seconds;
+                        if (totalDelay > 60) {
+                            if (TRACE_ON)
+                                out.println(
+                                        "Memory allocation became slow; so, heap seems exhausted.");
+                            break;
+                        }
+                    }
+                }
+            } catch (OutOfMemoryError oome) {
+                if (TRACE_ON)
+                    log[messages++] = "Heap seems exhausted - OutOfMemoryError thrown.";
+                // Do not release any byte once allocated:
+                pool[index++] = oome;
+            }
+
+            if (index > poolSize - 1000) {
+                if (WARN_ON)
+                    log[messages++] = "Warning: pool[] is full; so, checks would not be enough hard...";
+            }
+        } else {
+            // pool gets used for array index tests
+            pool = new Object[3];
+            poolSize = pool.length;
+        }
+
+        // Check ArithmeticException:
+        try {
+            int x, y, z;
+            x = y = 0;
+            z = x / y;
+            log[messages++] = "Failure: ArithmeticException";
+            exitCode = 2; // FAILED
+        } catch (ArithmeticException ae) {
+            if (TRACE_ON)
+                log[messages++] = "Success: ArithmeticException";
+            if (exhaustHeap)
+                pool[index++] = ae;
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: ArithmeticException";
+            skipped++;
+        }
+
+        // Check ArrayIndexOutOfBoundsException:
+        try {
+            pool[poolSize] = pool[0];
+            log[messages++] = "Failure: ArrayIndexOutOfBoundsException";
+            exitCode = 2; // FAILED
+        } catch (ArrayIndexOutOfBoundsException aioobe) {
+            if (TRACE_ON)
+                log[messages++] = "Success: ArrayIndexOutOfBoundsException";
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: ArrayIndexOutOfBoundsException";
+            skipped++;
+        }
+
+        // Check ArrayStoreException:
+        try {
+            stringArray[0] = integerValue;
+            log[messages++] = "Failure: ArrayStoreException";
+            exitCode = 2; // FAILED
+        } catch (ArrayStoreException ase) {
+            if (TRACE_ON)
+                log[messages++] = "Success: ArrayStoreException";
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: ArrayStoreException";
+            skipped++;
+        }
+
+        // Check ClassCastException:
+        try {
+            trash = (Double) integerValue;
+            log[messages++] = "Failure: ClassCastException";
+            exitCode = 2; // FAILED
+        } catch (ClassCastException cce) {
+            if (TRACE_ON)
+                log[messages++] = "Success: ClassCastException";
+            if (exhaustHeap)
+                pool[index++] = cce;
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: ClassCastException";
+            skipped++;
+        }
+
+        // Check CloneNotSupportedException:
+        try {
+            trash = abra.clone();    // illegal - should fail
+//          trash = cadabra.clone(); //   legal - should pass
+            log[messages++] = "Failure: CloneNotSupportedException";
+            exitCode = 2; // FAILED
+        } catch (CloneNotSupportedException cnse) {
+            if (TRACE_ON)
+                log[messages++] = "Success: CloneNotSupportedException";
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: CloneNotSupportedException";
+            skipped++;
+        }
+
+        // Check IllegalAccessException (positive):
+        try {
+            int junkIt = abraIntegerField.getInt(null); //   legal - should pass
+//          int junkIt = abraPrivateField.getInt(null); // illegal - should fail
+            if (TRACE_ON)
+                log[messages++] = "Success: IllegalAccessException (positive)";
+        } catch (IllegalAccessException iae) {
+            log[messages++] = "Failure: IllegalAccessException (positive)";
+            exitCode = 2;
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: IllegalAccessException (positive)";
+            skipped++;
+        }
+
+        // Check IllegalAccessException (negative):
+        try {
+//          int junkIt = abraIntegerField.getInt(null); //   legal - should pass
+            int junkIt = abraPrivateField.getInt(null); // illegal - should fail
+            log[messages++] = "Failure: IllegalAccessException (negative)";
+            exitCode = 2; // FAILED
+        } catch (IllegalAccessException iae) {
+            if (TRACE_ON)
+                log[messages++] = "Success: IllegalAccessException (negative)";
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: IllegalAccessException (negative)";
+            skipped++;
+        }
+
+        // Check IllegalArgumentException (positive):
+        try {
+            int junkIt = abraIntegerField.getInt(null); //   legal - should pass
+//          int junkIt = abraBooleanField.getInt(null); // illegal - should fail
+            if (TRACE_ON)
+                log[messages++] = "Success: IllegalArgumentException (positive)";
+        } catch (IllegalAccessException iae) {
+            log[messages++] =
+                    "Failure: IllegalArgumentException (positive) incorrectly thrown IllegalAccessException";
+            exitCode = 2;
+        } catch (IllegalArgumentException iae) {
+            log[messages++] = "Failure: IllegalArgumentException (positive)";
+            exitCode = 2;
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: IllegalArgumentException (positive)";
+            skipped++;
+        }
+
+        // Check IllegalArgumentException (negative):
+        try {
+//          int junkIt = abraIntegerField.getInt(null); //   legal - should pass
+            int junkIt = abraBooleanField.getInt(null); // illegal - should fail
+            log[messages++] = "Failure: IllegalArgumentException (negative)";
+            exitCode = 2; // FAILED
+        } catch (IllegalAccessException iae) {
+            log[messages++] =
+                    "Failure: IllegalArgumentException (negative) incorrectly thrown IllegalAccessException";
+            exitCode = 2;
+        } catch (IllegalArgumentException iae) {
+            if (TRACE_ON)
+                log[messages++] = "Success: IllegalArgumentException (negative)";
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: IllegalArgumentException (negative)";
+            skipped++;
+        }
+
+        // Check IllegalMonitorStateException (positive):
+        try {
+            synchronized (cadabra) {
+                cadabra.notifyAll();    //   legal - should pass
+            }
+//          cadabra.notifyAll();        // illegal - should fail
+            if (TRACE_ON)
+                log[messages++] = "Success: IllegalMonitorStateException (positive)";
+        } catch (IllegalMonitorStateException imse) {
+            log[messages++] = "Failure: IllegalMonitorStateException (positive)";
+            exitCode = 2;
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: IllegalMonitorStateException (positive)";
+            skipped++;
+        }
+
+        // Check IllegalMonitorStateException (negative):
+        try {
+//          synchronized (cadabra) {
+//              cadabra.notifyAll();    //   legal - should pass
+//          }
+            cadabra.notifyAll();        // illegal - should fail
+            log[messages++] = "Failure: IllegalMonitorStateException (negative)";
+            exitCode = 2;
+        } catch (IllegalMonitorStateException imse) {
+            if (TRACE_ON)
+                log[messages++] = "Success: IllegalMonitorStateException (negative)";
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: IllegalMonitorStateException (negative)";
+            skipped++;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Re-call to <code>run(args,out)</code>, and return JCK-like exit status.
+     * (The stream <code>out</code> is assigned to <code>System.out</code> here.)
+     *
+     * @see #run(String[], PrintStream)
+     */
+    public static void main(String args[]) {
+        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+            // Last try. If there is some exception outside the code, test should end correctly
+            @Override
+            public void uncaughtException(Thread t, Throwable e) {
+                try {
+                    pool = null;
+                    log = null;
+                    System.gc();
+                    if (e instanceof OutOfMemoryError) {
+                        try {
+                            System.out.println("OOME : Test Skipped");
+                            System.exit(0);
+                        } catch (Throwable ignore) {
+                        } // No code in the handler can provoke correct exceptions.
+                    } else {
+                        e.printStackTrace();
+                        if (e instanceof RuntimeException)
+                            throw (RuntimeException) e;
+                        else if (e instanceof Error)
+                            throw (Error) e;
+                        else
+                            throw new Error("Unexpected checked exception", e);
+                    }
+                } catch (OutOfMemoryError oome) {
+                }
+            }
+        });
+        int exitCode = run(args, System.out);
+        System.exit(exitCode + 95);
+        // JCK-like exit status.
+    }
+
+    /**
+     * This class should be used to check <code>CloneNotSupportedException</code>,
+     * <code>IllegalAccessException</code>, and <code>IllegalArgumentException</code>.
+     * The class extends <code>except004</code> in order that its (protected)
+     * method <code>clone()</code> be available from <code>except004</code>.
+     */
+    private static class Abra extends except004 {
+        /**
+         * Will try to incorrectly find this class as <code>Cadabra</code>
+         * instead of <code>Abra$Cadabra</code>.
+         */
+        public static class Cadabra implements Cloneable {
+        }
+
+        /**
+         * Will try to incorrectly access to this field from outside this class.
+         */
+        private static final int DONT_TOUCH_ME = 666;
+        /**
+         * Will try to incorrectly access to this field from outside this class.
+         */
+        public static final int MAIN_CYR_NUMBER = 47;
+        /**
+         * Will try to get this field like <code>int<code> zero.
+         */
+        public static final boolean NOT_AN_INTEGER = false;
+
+        /**
+         * Will try to correctly instantiate <code>Abra.Cadabra</code>,
+         * not <code>Abra</code>.
+         */
+        private Abra() {
+        }
+
+        /**
+         * Yet another constructor, which is <code>public</code>.
+         */
+        public Abra(String nothingSpecial) {
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/except/except005.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,319 @@
+/*
+ * Copyright (c) 1999, 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.
+ */
+
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/except/except005.
+ * VM testbase keywords: [stress, diehard, slow, nonconcurrent, quick]
+ * VM testbase readme:
+ * DESCRIPTION
+ *     This checks if various exceptions are thrown (and caught) correctly
+ *     when there apparently are no free space in the heap to allocate new
+ *     Throwable instance.
+ *     The test tries to occupy all of memory available in the heap by allocating
+ *     lots of new Object() instances. Instances of the type Object are the smallest
+ *     objects, so they apparently should occupy most fine-grained fragments in the
+ *     heap and leave no free space for new Throwable instance. After that, the test
+ *     provokes various exceptions (e.g.: by executing integer division by 0 and so
+ *     on), and checks if appropriate exceptions are thrown.
+ * COMMENTS
+ *     The test needs a lot of memory to start up, so it should not run under older
+ *     JDK 1.1.x release due to its poorer heap utilization. Also, some checks are
+ *     skipped when testing classic VM, because OutOfMemoryError is correctly thrown
+ *     instead of target exception.
+ *     When the test is being self-initiating (i.e.: eating heap), memory occupation
+ *     is terminated if memory allocation slows down crucially. This is a workaround
+ *     intended to avoid the HotSpot bug:
+ *         #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ *     There is also a workaround involved to avoid the following bugs known
+ *     for HotSpot and for classic VM:
+ *         #4239841 (P1/S5) 1.1: poor garbage collector performance  (HotSpot bug)
+ *         #4245060 (P4/S5) poor garbage collector performance       (Classic VM bug)
+ *     However, printing of the test's error messages, warnings, and of execution
+ *     trace fails under JDK 1.2 for Win32 even so. If the test fails due to this
+ *     problem, exit status 96 is returned instead of 97.
+ *     JDK 1.3 classic VM for Sparc may crash (core dump) due to the known bug:
+ *         #4245057 (P2/S3) VM crashes when heap is exhausted
+ *
+ * @run main/othervm -Xms50M -Xmx200M nsk.stress.except.except005
+ */
+
+package nsk.stress.except;
+
+import java.io.PrintStream;
+
+/**
+ * This checks if various exceptions are thrown (and caught) correctly
+ * when there apparently are no free space in the heap to allocate new
+ * <code>Throwable</code> instance.
+ * <p>
+ * <p>The test tries to occupy all of memory available in the heap by
+ * allocating lots of new <code>Object()</code> instances. Instances of the
+ * type <code>Object</code> are the smallest objects, so they apparently should
+ * occupy most fine-grained fragments in the heap and leave no free space for
+ * new <code>Throwable</code> instance. After that, the test provokes various
+ * exceptions (e.g.: by executing integer division by 0 and so on), and checks
+ * if appropriate exceptions are thrown.
+ * <p>
+ * <p>Note, that memory occupation is terminated if memory allocation slows
+ * down crucially. This is a workaround intended to avoid the HotSpot bug:
+ * <br>&nbsp;&nbsp;
+ * #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ * <p>
+ * <p>There is also a workaround involved to avoid the following bugs known
+ * for HotSpot and for classic VM:
+ * <br>&nbsp;&nbsp;
+ * #4239841 (P1/S5) 1.1: poor garbage collector performance
+ * <br>&nbsp;&nbsp;
+ * #4245060 (P4/S5) poor garbage collector performance
+ * <br>However, printing of the test's error messages, warnings, and of
+ * execution trace may fail even so. If the test fails due to poor GC
+ * performance, exit status 96 is returned instead of 97.
+ * <p>
+ * <p>Also note, that the test needs a lot of memory to start up, so it should
+ * not run under older JDK 1.1.x release due to its poor heap utilization.
+ */
+public class except005 {
+    /**
+     * Either allow or supress printing of execution trace.
+     */
+    private static boolean TRACE_ON = false;
+    /**
+     * Either allow or supress printing of warning messages.
+     */
+    private static final boolean WARN_ON = true;
+
+    /**
+     * Temporary <code>log</code> for error messages, warnings and/or execution trace.
+     *
+     * @see #messages
+     */
+    private static String log[] = new String[1000]; // up to 1000 messages
+    /**
+     * <code>pool</code> to store tiny objects to fill up the Heap
+     */
+    private static volatile Object pool[] = null;
+    /**
+     * How many <code>messages</code> were submitted to the <code>log</code>.
+     *
+     * @see #log
+     */
+    private static int messages = 0;
+
+    /**
+     * Re-call to the method <code>run(out)</code> (ignore <code>args[]</code>),
+     * and print the test summary - either test passed of failed.
+     */
+    public static int run(String args[], PrintStream out) {
+        if (args.length > 0) {
+            if (args[0].toLowerCase().startsWith("-v"))
+                TRACE_ON = true;
+        }
+
+        int exitCode = run(out);
+        pool = null;
+        System.gc();
+        // Print the log[] and the test summary:
+        try {
+            for (int i = 0; i < messages; i++)
+                out.println(log[i]);
+            if (exitCode == 0) {
+                if (TRACE_ON)
+                    out.println("Test passed.");
+            } else
+                out.println("Test failed.");
+        } catch (OutOfMemoryError oome) {
+            // Poor performance of garbage collector:
+            exitCode = 1;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Allocate as much <code>Object</code> instances as possible to bring JVM
+     * into stress, and then check if exceptions are correctly thrown accordingly
+     * to various situations like integer division by 0, etc.
+     */
+    private static int run(PrintStream out) {
+        out.println("# Test have been updated!");
+        out.println("# stream, so that it will not need more memory to print later,");
+        out.println("# when the heap would fail to provide more memory.");
+        out.println("# ");
+        out.println("# Note, that the test maintains especial static log[] field in");
+        out.println("# order to avoid printing when the heap seems exhausted.");
+        out.println("# Nevertheless, printing could arise OutOfMemoryError even");
+        out.println("# after all the memory allocated by the test is released.");
+        out.println("# ");
+        out.println("# That problem is caused by the known JDK/HotSpot bugs:");
+        out.println("#     4239841 (P1/S5) 1.1: poor garbage collector performance");
+        out.println("#     4245060 (P4/S5) poor garbage collector performance");
+        out.println("# ");
+        out.println("# This message is just intended to work-around that problem.");
+        out.println("# If printing should fail even so, the test will try to return");
+        out.println("# the exit status 96 instead of 97 to indicate the problem.");
+        out.println("# However, the test may fail or even crash on some platforms");
+        out.println("# suffering the bug 4239841 or 4245060.");
+
+        // Sum up exit code:
+        int exitCode = 0; // apparently PASSED
+        int skipped = 0;  // some checks may correctly suffer OutOfMemoryError
+        // Allocate repository for a lots of tiny objects:
+        for (int size = 1 << 30; size > 0 && pool == null; size >>= 1)
+            try {
+                pool = new Object[size];
+            } catch (OutOfMemoryError oome) {
+            }
+        if (pool == null)
+            throw new Error("HS bug: cannot allocate new Object[1]");
+        int poolSize = pool.length;
+        int index = 0;
+
+        // Sum up time spent, when it was hard to JVM to allocate next object
+        // (i.e.: when JVM has spent more than 1 second to allocate new object):
+        double totalDelay = 0;
+        long timeMark = System.currentTimeMillis();
+        try {
+            for (; index < poolSize; index++) {
+                //-------------------------
+                pool[index] = new Object();
+                long nextTimeMark = System.currentTimeMillis();
+                long elapsed = nextTimeMark - timeMark;
+                timeMark = nextTimeMark;
+                //----------------------
+                if (elapsed > 1000) {
+                    double seconds = elapsed / 1000.0;
+                    if (TRACE_ON) {
+                        out.println(
+                                "pool[" + index + "]=new Object(); // elapsed " + seconds + "s");
+                    }
+                    totalDelay += seconds;
+                    if (totalDelay > 60) {
+                        if (TRACE_ON)
+                            out.println(
+                                    "Memory allocation became slow; so, heap seems exhausted.");
+                        break;
+                    }
+                }
+            }
+        } catch (OutOfMemoryError oome) {
+            if (TRACE_ON)
+                log[messages++] = "Heap seems exhausted - OutOfMemoryError thrown.";
+        }
+        if (index > poolSize - 1000) {
+            if (WARN_ON)
+                log[messages++] = "Warning: pool[] is full; so, checks would not be enough hard...";
+        }
+
+        // Check InstantiationException (positive):
+        try {
+//          Object junkIt = Abra_Cadabra.class.newInstance(); // illegal - should fail
+            Object junkIt = Abra.Cadabra.class.newInstance(); //   legal - should pass
+            if (TRACE_ON)
+                log[messages++] = "Success: InstantiationException (positive)";
+        } catch (IllegalAccessException iae) {
+            log[messages++] =
+                    "Failure: InstantiationException (positive) incorrectly thrown IllegalAccessException";
+            pool[index++] = iae;
+            exitCode = 2;
+        } catch (InstantiationException ie) {
+            log[messages++] = "Failure: InstantiationException (positive)";
+            pool[index++] = ie;
+            exitCode = 2;
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: InstantiationException (positive)";
+            pool[index++] = oome;
+            skipped++;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Re-call to <code>run(args,out)</code>, and return JCK-like exit status.
+     * (The stream <code>out</code> is assigned to <code>System.out</code> here.)
+     *
+     * @see #run(String[], PrintStream)
+     */
+    public static void main(String args[]) {
+        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+            // Last try. If there is some OOME, test should end correctly
+            @Override
+            public void uncaughtException(Thread t, Throwable e) {
+                try {
+                    pool = null;
+                    log = null;
+                    System.gc();
+                    if (e instanceof OutOfMemoryError) {
+                        try {
+                            System.out.println("OOME : Test Skipped");
+                            System.exit(0);
+                        } catch (Throwable ignore) {
+                        } // No code in the handler can provoke correct exceptions.
+                    } else {
+                        e.printStackTrace();
+                        throw (RuntimeException) e;
+                    }
+                } catch (OutOfMemoryError oome) {
+                }
+            }
+        });
+        int exitCode = run(args, System.out);
+        System.exit(exitCode + 95);
+        // JCK-like exit status.
+    }
+
+    /**
+     * This class should be used to check <code>CloneNotSupportedException</code>,
+     * <code>IllegalAccessException</code>, and <code>IllegalArgumentException</code>.
+     * The class extends <code>except005</code> in order that its (protected)
+     * method <code>clone()</code> be available from <code>except005</code>.
+     */
+    private static class Abra {
+        /**
+         * Will correctly instantiate <code>Abra.Cadabra</code> object.
+         */
+        public static class Cadabra {
+        }
+
+        /**
+         * Will try to correctly instantiate <code>Abra.Cadabra</code>,
+         * not <code>Abra</code>.
+         */
+        private Abra() {
+        }
+
+    }
+
+    /**
+     * Will try to incorrectly instantiate and object of this class.
+     */
+    private interface Abra_Cadabra {
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/except/except006.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,316 @@
+/*
+ * Copyright (c) 1999, 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.
+ */
+
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/except/except006.
+ * VM testbase keywords: [stress, diehard, slow, nonconcurrent, quick]
+ * VM testbase readme:
+ * DESCRIPTION
+ *     This checks if various exceptions are thrown (and caught) correctly
+ *     when there apparently are no free space in the heap to allocate new
+ *     Throwable instance.
+ *     The test tries to occupy all of memory available in the heap by allocating
+ *     lots of new Object() instances. Instances of the type Object are the smallest
+ *     objects, so they apparently should occupy most fine-grained fragments in the
+ *     heap and leave no free space for new Throwable instance. After that, the test
+ *     provokes various exceptions (e.g.: by executing integer division by 0 and so
+ *     on), and checks if appropriate exceptions are thrown.
+ * COMMENTS
+ *     The test needs a lot of memory to start up, so it should not run under older
+ *     JDK 1.1.x release due to its poorer heap utilization. Also, some checks are
+ *     skipped when testing classic VM, because OutOfMemoryError is correctly thrown
+ *     instead of target exception.
+ *     When the test is being self-initiating (i.e.: eating heap), memory occupation
+ *     is terminated if memory allocation slows down crucially. This is a workaround
+ *     intended to avoid the HotSpot bug:
+ *         #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ *     There is also a workaround involved to avoid the following bugs known
+ *     for HotSpot and for classic VM:
+ *         #4239841 (P1/S5) 1.1: poor garbage collector performance  (HotSpot bug)
+ *         #4245060 (P4/S5) poor garbage collector performance       (Classic VM bug)
+ *     However, printing of the test's error messages, warnings, and of execution
+ *     trace fails under JDK 1.2 for Win32 even so. If the test fails due to this
+ *     problem, exit status 96 is returned instead of 97.
+ *     JDK 1.3 classic VM for Sparc may crash (core dump) due to the known bug:
+ *         #4245057 (P2/S3) VM crashes when heap is exhausted
+ *
+ * @run main/othervm -Xms50M -Xmx200M nsk.stress.except.except006
+ */
+
+package nsk.stress.except;
+
+import java.io.PrintStream;
+
+/**
+ * This checks if various exceptions are thrown (and caught) correctly
+ * when there apparently are no free space in the heap to allocate new
+ * <code>Throwable</code> instance.
+ * <p>
+ * <p>The test tries to occupy all of memory available in the heap by
+ * allocating lots of new <code>Object()</code> instances. Instances of the
+ * type <code>Object</code> are the smallest objects, so they apparently should
+ * occupy most fine-grained fragments in the heap and leave no free space for
+ * new <code>Throwable</code> instance. After that, the test provokes various
+ * exceptions (e.g.: by executing integer division by 0 and so on), and checks
+ * if appropriate exceptions are thrown.
+ * <p>
+ * <p>Note, that memory occupation is terminated if memory allocation slows
+ * down crucially. This is a workaround intended to avoid the HotSpot bug:
+ * <br>&nbsp;&nbsp;
+ * #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ * <p>
+ * <p>There is also a workaround involved to avoid the following bugs known
+ * for HotSpot and for classic VM:
+ * <br>&nbsp;&nbsp;
+ * #4239841 (P1/S5) 1.1: poor garbage collector performance
+ * <br>&nbsp;&nbsp;
+ * #4245060 (P4/S5) poor garbage collector performance
+ * <br>However, printing of the test's error messages, warnings, and of
+ * execution trace may fail even so. If the test fails due to poor GC
+ * performance, exit status 96 is returned instead of 97.
+ * <p>
+ * <p>Also note, that the test needs a lot of memory to start up, so it should
+ * not run under older JDK 1.1.x release due to its poor heap utilization.
+ */
+public class except006 {
+    /**
+     * Either allow or supress printing of execution trace.
+     */
+    private static boolean TRACE_ON = false;
+    /**
+     * Either allow or supress printing of warning messages.
+     */
+    private static final boolean WARN_ON = true;
+    /*
+    * Storage for a lot of tiny objects
+    * "static volatile" keywords are for preventing heap optimization
+    */
+    private static volatile Object pool[] = null;
+    /**
+     * Temporary <code>log</code> for error messages, warnings and/or execution trace.
+     *
+     * @see #messages
+     */
+    private static String log[] = new String[1000]; // up to 1000 messages
+    /**
+     * How many <code>messages</code> were submitted to the <code>log</code>.
+     *
+     * @see #log
+     */
+    private static int messages = 0;
+
+    /**
+     * Re-call to the method <code>run(out)</code> (ignore <code>args[]</code>),
+     * and print the test summary - either test passed of failed.
+     */
+    public static int run(String args[], PrintStream out) {
+        if (args.length > 0) {
+            if (args[0].toLowerCase().startsWith("-v"))
+                TRACE_ON = true;
+        }
+
+        int exitCode = run(out);
+        pool = null;
+        System.gc();
+        // Print the log[] and the test summary:
+        try {
+            for (int i = 0; i < messages; i++)
+                out.println(log[i]);
+            if (exitCode == 0) {
+                if (TRACE_ON)
+                    out.println("Test passed.");
+            } else
+                out.println("Test failed.");
+        } catch (OutOfMemoryError oome) {
+            // Poor performance of garbage collector:
+            exitCode = 1;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Allocate as much <code>Object</code> instances as possible to bring JVM
+     * into stress, and then check if exceptions are correctly thrown accordingly
+     * to various situations like integer division by 0, etc.
+     */
+    private static int run(PrintStream out) {
+        out.println("# While printing this message, JVM seems to initiate the output");
+        out.println("# stream, so that it will not need more memory to print later,");
+        out.println("# when the heap would fail to provide more memory.");
+        out.println("# ");
+        out.println("# Note, that the test maintains especial static log[] field in");
+        out.println("# order to avoid printing when the heap seems exhausted.");
+        out.println("# Nevertheless, printing could arise OutOfMemoryError even");
+        out.println("# after all the memory allocated by the test is released.");
+        out.println("# ");
+        out.println("# That problem is caused by the known JDK/HotSpot bugs:");
+        out.println("#     4239841 (P1/S5) 1.1: poor garbage collector performance");
+        out.println("#     4245060 (P4/S5) poor garbage collector performance");
+        out.println("# ");
+        out.println("# This message is just intended to work-around that problem.");
+        out.println("# If printing should fail even so, the test will try to return");
+        out.println("# the exit status 96 instead of 97 to indicate the problem.");
+        out.println("# However, the test may fail or even crash on some platforms");
+        out.println("# suffering the bug 4239841 or 4245060.");
+
+        // Allocate repository for a lots of tiny objects:
+        for (int size = 1 << 30; size > 0 && pool == null; size >>= 1)
+            try {
+                pool = new Object[size];
+            } catch (OutOfMemoryError oome) {
+            }
+        if (pool == null)
+            throw new Error("HS bug: cannot allocate new Object[1]");
+        int poolSize = pool.length;
+        int index = 0;
+        // Sum up exit code:
+        int exitCode = 0; // apparently PASSED
+        int skipped = 0;  // some checks may correctly suffer OutOfMemoryError
+        Object junkIt;
+        // Sum up time spent, when it was hard to JVM to allocate next object
+        // (i.e.: when JVM has spent more than 1 second to allocate new object):
+        double totalDelay = 0;
+        long timeMark = System.currentTimeMillis();
+        try {
+            for (; index < poolSize; index++) {
+                //-------------------------
+                pool[index] = new Object();
+                long nextTimeMark = System.currentTimeMillis();
+                long elapsed = nextTimeMark - timeMark;
+                timeMark = nextTimeMark;
+                //----------------------
+                if (elapsed > 1000) {
+                    double seconds = elapsed / 1000.0;
+                    if (TRACE_ON)
+                        out.println(
+                                "pool[" + index + "]=new Object(); // elapsed " + seconds + "s");
+                    totalDelay += seconds;
+                    if (totalDelay > 60) {
+                        if (TRACE_ON)
+                            out.println(
+                                    "Memory allocation became slow; so, heap seems exhausted.");
+                        break;
+                    }
+                }
+            }
+        } catch (OutOfMemoryError oome) {
+            if (TRACE_ON)
+                log[messages++] = "Heap seems exhausted - OutOfMemoryError thrown.";
+        }
+        if (index > poolSize - 1000) {
+            if (WARN_ON)
+                log[messages++] = "Warning: pool[] is full; so, checks would not be enough hard...";
+        }
+
+
+        // Check InstantiationException (negative):
+        try {
+            junkIt = Abra_Cadabra.class.newInstance(); // illegal - should fail
+//          Object junkIt = Abra.Cadabra.class.newInstance(); //   legal - should pass
+            log[messages++] = "Failure: InstantiationException (negative)";
+            exitCode = 2;
+        } catch (IllegalAccessException iae) {
+            log[messages++] =
+                    "Failure: InstantiationException (negative) incorrectly thrown IllegalAccessException";
+            exitCode = 2;
+        } catch (InstantiationException ie) {
+            if (TRACE_ON)
+                log[messages++] = "Success: InstantiationException (negative)";
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: InstantiationException (negative)";
+            skipped++;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Re-call to <code>run(args,out)</code>, and return JCK-like exit status.
+     * (The stream <code>out</code> is assigned to <code>System.out</code> here.)
+     *
+     * @see #run(String[], PrintStream)
+     */
+    public static void main(String args[]) {
+        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+            // Last try. If there is some exception outside the code, test should end correctly
+            @Override
+            public void uncaughtException(Thread t, Throwable e) {
+                try {
+                    pool = null;
+                    log = null;
+                    System.gc();
+                    if (e instanceof OutOfMemoryError) {
+                        try {
+                            System.out.println("OOME : Test Skipped");
+                            System.exit(0);
+                        } catch (Throwable ignore) {
+                        } // No code in the handler can provoke correct exceptions.
+                    } else {
+                        e.printStackTrace();
+                        throw (RuntimeException) e;
+                    }
+                } catch (OutOfMemoryError oome) {
+                }
+            }
+        });
+        int exitCode = run(args, System.out);
+        System.exit(exitCode + 95);
+        // JCK-like exit status.
+    }
+
+    /**
+     * This class should be used to check <code>CloneNotSupportedException</code>,
+     * <code>IllegalAccessException</code>, and <code>IllegalArgumentException</code>.
+     * The class extends <code>except006</code> in order that its (protected)
+     * method <code>clone()</code> be available from <code>except006</code>.
+     */
+    private static class Abra {
+        /**
+         * Will correctly instantiate <code>Abra.Cadabra</code> object.
+         */
+        public static class Cadabra {
+        }
+
+        /**
+         * Will try to correctly instantiate <code>Abra.Cadabra</code>,
+         * not <code>Abra</code>.
+         */
+        private Abra() {
+        }
+
+    }
+
+    /**
+     * Will try to incorrectly instantiate and object of this class.
+     */
+    private interface Abra_Cadabra {
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/except/except007.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,380 @@
+/*
+ * Copyright (c) 1999, 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.
+ */
+
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/except/except007.
+ * VM testbase keywords: [stress, diehard, slow, nonconcurrent, quick]
+ * VM testbase readme:
+ * DESCRIPTION
+ *     This checks if various exceptions are thrown (and caught) correctly
+ *     when there apparently are no free space in the heap to allocate new
+ *     Throwable instance.
+ *     The test tries to occupy all of memory available in the heap by allocating
+ *     lots of new Object() instances. Instances of the type Object are the smallest
+ *     objects, so they apparently should occupy most fine-grained fragments in the
+ *     heap and leave no free space for new Throwable instance. After that, the test
+ *     provokes various exceptions (e.g.: by executing integer division by 0 and so
+ *     on), and checks if appropriate exceptions are thrown.
+ * COMMENTS
+ *     The test needs a lot of memory to start up, so it should not run under older
+ *     JDK 1.1.x release due to its poorer heap utilization. Also, some checks are
+ *     skipped when testing classic VM, because OutOfMemoryError is correctly thrown
+ *     instead of target exception.
+ *     When the test is being self-initiating (i.e.: eating heap), memory occupation
+ *     is terminated if memory allocation slows down crucially. This is a workaround
+ *     intended to avoid the HotSpot bug:
+ *         #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ *     There is also a workaround involved to avoid the following bugs known
+ *     for HotSpot and for classic VM:
+ *         #4239841 (P1/S5) 1.1: poor garbage collector performance  (HotSpot bug)
+ *         #4245060 (P4/S5) poor garbage collector performance       (Classic VM bug)
+ *     However, printing of the test's error messages, warnings, and of execution
+ *     trace fails under JDK 1.2 for Win32 even so. If the test fails due to this
+ *     problem, exit status 96 is returned instead of 97.
+ *     JDK 1.3 classic VM for Sparc may crash (core dump) due to the known bug:
+ *         #4245057 (P2/S3) VM crashes when heap is exhausted
+ *
+ * @run main/othervm -Xms50M -Xmx200M nsk.stress.except.except007
+ */
+
+package nsk.stress.except;
+
+import java.io.PrintStream;
+
+/**
+ * This checks if various exceptions are thrown (and caught) correctly
+ * when there apparently are no free space in the heap to allocate new
+ * <code>Throwable</code> instance.
+ * <p>
+ * <p>The test tries to occupy all of memory available in the heap by
+ * allocating lots of new <code>Object()</code> instances. Instances of the
+ * type <code>Object</code> are the smallest objects, so they apparently should
+ * occupy most fine-grained fragments in the heap and leave no free space for
+ * new <code>Throwable</code> instance. After that, the test provokes various
+ * exceptions (e.g.: by executing integer division by 0 and so on), and checks
+ * if appropriate exceptions are thrown.
+ * <p>
+ * <p>Note, that memory occupation is terminated if memory allocation slows
+ * down crucially. This is a workaround intended to avoid the HotSpot bug:
+ * <br>&nbsp;&nbsp;
+ * #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ * <p>
+ * <p>There is also a workaround involved to avoid the following bugs known
+ * for HotSpot and for classic VM:
+ * <br>&nbsp;&nbsp;
+ * #4239841 (P1/S5) 1.1: poor garbage collector performance
+ * <br>&nbsp;&nbsp;
+ * #4245060 (P4/S5) poor garbage collector performance
+ * <br>However, printing of the test's error messages, warnings, and of
+ * execution trace may fail even so. If the test fails due to poor GC
+ * performance, exit status 96 is returned instead of 97.
+ * <p>
+ * <p>Also note, that the test needs a lot of memory to start up, so it should
+ * not run under older JDK 1.1.x release due to its poor heap utilization.
+ */
+public class except007 {
+    /**
+     * Either allow or supress printing of execution trace.
+     */
+    private static boolean TRACE_ON = false;
+    /**
+     * Either allow or supress printing of warning messages.
+     */
+    private static final boolean WARN_ON = true;
+    /*
+     * Storage for a lot of tiny objects
+     * "static volatile" keywords are for preventing heap optimization
+     */
+    private static volatile Object pool[] = null;
+    /**
+     * Temporary <code>log</code> for error messages, warnings and/or execution trace.
+     *
+     * @see #messages
+     */
+    private static String log[] = new String[1000]; // up to 1000 messages
+    /**
+     * How many <code>messages</code> were submitted to the <code>log</code>.
+     *
+     * @see #log
+     */
+    private static int messages = 0;
+
+    /**
+     * Re-call to the method <code>run(out)</code> (ignore <code>args[]</code>),
+     * and print the test summary - either test passed of failed.
+     */
+    public static int run(String args[], PrintStream out) {
+        if (args.length > 0) {
+            if (args[0].toLowerCase().startsWith("-v"))
+                TRACE_ON = true;
+        }
+
+        int exitCode = run(out);
+        pool = null;
+        System.gc();
+        // Print the log[] and the test summary:
+        try {
+            for (int i = 0; i < messages; i++)
+                out.println(log[i]);
+            if (exitCode == 0) {
+                if (TRACE_ON)
+                    out.println("Test passed.");
+            } else
+                out.println("Test failed.");
+        } catch (OutOfMemoryError oome) {
+            // Poor performance of garbage collector:
+            exitCode = 1;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Allocate as much <code>Object</code> instances as possible to bring JVM
+     * into stress, and then check if exceptions are correctly thrown accordingly
+     * to various situations like integer division by 0, etc.
+     */
+    private static int run(PrintStream out) {
+        out.println("# While printing this message, JVM seems to initiate the output");
+        out.println("# stream, so that it will not need more memory to print later,");
+        out.println("# when the heap would fail to provide more memory.");
+        out.println("# ");
+        out.println("# Note, that the test maintains especial static log[] field in");
+        out.println("# order to avoid printing when the heap seems exhausted.");
+        out.println("# Nevertheless, printing could arise OutOfMemoryError even");
+        out.println("# after all the memory allocated by the test is released.");
+        out.println("# ");
+        out.println("# That problem is caused by the known JDK/HotSpot bugs:");
+        out.println("#     4239841 (P1/S5) 1.1: poor garbage collector performance");
+        out.println("#     4245060 (P4/S5) poor garbage collector performance");
+        out.println("# ");
+        out.println("# This message is just intended to work-around that problem.");
+        out.println("# If printing should fail even so, the test will try to return");
+        out.println("# the exit status 96 instead of 97 to indicate the problem.");
+        out.println("# However, the test may fail or even crash on some platforms");
+        out.println("# suffering the bug 4239841 or 4245060.");
+
+        // Prepare some items, which will be used by the test:
+        Thread rabbit = new Rabbit();
+
+        // Allocate repository for a lots of tiny objects:
+        for (int size = 1 << 30; size > 0 && pool == null; size >>= 1)
+            try {
+                pool = new Object[size];
+            } catch (OutOfMemoryError oome) {
+            }
+        if (pool == null)
+            throw new Error("HS bug: cannot allocate new Object[1]");
+        int poolSize = pool.length;
+
+        int index = 0;
+        pool[index++] = new Object();
+
+        // Sum up time spent, when it was hard to JVM to allocate next object
+        // (i.e.: when JVM has spent more than 1 second to allocate new object):
+        double totalDelay = 0;
+        long timeMark = System.currentTimeMillis();
+        try {
+            for (; index < poolSize; index++) {
+                //-------------------------
+                pool[index] = new Object();
+                long nextTimeMark = System.currentTimeMillis();
+                long elapsed = nextTimeMark - timeMark;
+                timeMark = nextTimeMark;
+                //----------------------
+                if (elapsed > 1000) {
+                    double seconds = elapsed / 1000.0;
+                    if (TRACE_ON)
+                        out.println(
+                                "pool[" + index + "]=new Object(); // elapsed " + seconds + "s");
+                    totalDelay += seconds;
+                    if (totalDelay > 60) {
+                        if (TRACE_ON)
+                            out.println(
+                                    "Memory allocation became slow; so, heap seems exhausted.");
+                        break;
+                    }
+                }
+            }
+        } catch (OutOfMemoryError oome) {
+            if (TRACE_ON)
+                log[messages++] = "Heap seems exhausted - OutOfMemoryError thrown.";
+        }
+        if (index > poolSize - 1000) {
+            if (WARN_ON)
+                log[messages++] = "Warning: pool[] is full; so, checks would not be enough hard...";
+        }
+
+        // Sum up exit code:
+        int exitCode = 0; // apparently PASSED
+        int skipped = 0;  // some checks may correctly suffer OutOfMemoryError
+
+        // Check InterruptedException:
+        try {
+            synchronized (rabbit) {
+                rabbit.start();
+                rabbit.wait();
+            }
+            rabbit.interrupt();
+            while (rabbit.isAlive())
+                rabbit.join();
+            Throwable exception = ((Rabbit) rabbit).exception;
+            if (exception == null) {
+                log[messages++] = "Failure: InterruptedException not thrown";
+                exitCode = 2;
+            } else {
+                if (exception instanceof InterruptedException) {
+                    if (TRACE_ON)
+                        log[messages++] =
+                                "Success: InterruptedException thrown as expected";
+                } else if (exception instanceof OutOfMemoryError) {
+                    if (WARN_ON)
+                        log[messages++] = "Skipped: InterruptedException";
+                    skipped++;
+                } else {
+                    log[messages++] =
+                            "Failure: InterruptedException: unexpected exception thrown";
+                    exitCode = 2;
+                }
+                pool[index++] = exception;
+            }
+        } catch (InterruptedException ie) {
+            log[messages++] = "Failure: InterruptedException thrown unexpectedly";
+            exitCode = 2;
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: InterruptedException";
+            skipped++;
+        }
+
+        // Check NegativeArraySizeException:
+        try {
+            int negative = -1;
+            byte array[] = new byte[negative];
+            log[messages++] = "Failure: NegativeArraySizeException not thrown as expected";
+            exitCode = 2;
+        } catch (NegativeArraySizeException ie) {
+            if (TRACE_ON)
+                log[messages++] = "Success: NegativeArraySizeException thrown as expected";
+            pool[index++] = ie;
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: NegativeArraySizeException";
+            skipped++;
+        }
+
+        // Check NullPointerException:
+        try {
+            Double none = null;
+            double oops = none.doubleValue();
+            log[messages++] = "Failure: NullPointerException not thrown as expected";
+            exitCode = 2;
+        } catch (NullPointerException npe) {
+            if (TRACE_ON)
+                log[messages++] = "Success: NullPointerException thrown as expected";
+            pool[index++] = npe;
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: NullPointerException";
+            skipped++;
+        }
+
+        // Check NumberFormatException:
+        try {
+            double oops = Double.parseDouble("3.14159D00"); // FORTRAN-like
+            log[messages++] = "Failure: NumberFormatException not thrown as expected";
+            exitCode = 2;
+        } catch (NumberFormatException nfe) {
+            if (TRACE_ON)
+                log[messages++] = "Success: NumberFormatException thrown as expected";
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] = "Skipped: NumberFormatException";
+            skipped++;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Will shoot a rabbit when it waits -- in order to provoke
+     * InterruptedException.
+     */
+    private static class Rabbit extends Thread {
+        Throwable exception = null;
+
+        public void run() {
+            try {
+                synchronized (this) {
+                    this.notify();
+                    this.wait();
+                }
+            } catch (InterruptedException ie) {
+                exception = ie;
+            } catch (OutOfMemoryError oome) {
+                exception = oome;
+            }
+        }
+
+    }
+
+    /**
+     * Re-call to <code>run(args,out)</code>, and return JCK-like exit status.
+     * (The stream <code>out</code> is assigned to <code>System.out</code> here.)
+     *
+     * @see #run(String[], PrintStream)
+     */
+    public static void main(String args[]) {
+        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+            // Last try. If there is some exception outside the code, test should end correctly
+            @Override
+            public void uncaughtException(Thread t, Throwable e) {
+                try {
+                    pool = null;
+                    log = null;
+                    System.gc();
+                    if (e instanceof OutOfMemoryError) {
+                        try {
+                            System.out.println("OOME : Test Skipped");
+                            System.exit(0);
+                        } catch (Throwable ignore) {
+                        } // No code in the handler can provoke correct exceptions.
+                    } else {
+                        e.printStackTrace();
+                        throw (RuntimeException) e;
+                    }
+                } catch (OutOfMemoryError oome) {
+                }
+            }
+        });
+        int exitCode = run(args, System.out);
+        System.exit(exitCode + 95);
+        // JCK-like exit status.
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/except/except008.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,363 @@
+/*
+ * Copyright (c) 1999, 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.
+ */
+
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/except/except008.
+ * VM testbase keywords: [stress, diehard, slow, nonconcurrent, quick]
+ * VM testbase readme:
+ * DESCRIPTION
+ *     This checks if various exceptions are thrown (and caught) correctly
+ *     when there apparently are no free space in the heap to allocate new
+ *     Throwable instance.
+ *     The test tries to occupy all of memory available in the heap by allocating
+ *     lots of new Object() instances. Instances of the type Object are the smallest
+ *     objects, so they apparently should occupy most fine-grained fragments in the
+ *     heap and leave no free space for new Throwable instance. After that, the test
+ *     provokes various exceptions (e.g.: by executing integer division by 0 and so
+ *     on), and checks if appropriate exceptions are thrown.
+ * COMMENTS
+ *     The test needs a lot of memory to start up, so it should not run under older
+ *     JDK 1.1.x release due to its poorer heap utilization. Also, some checks are
+ *     skipped when testing classic VM, because OutOfMemoryError is correctly thrown
+ *     instead of target exception.
+ *     When the test is being self-initiating (i.e.: eating heap), memory occupation
+ *     is terminated if memory allocation slows down crucially. This is a workaround
+ *     intended to avoid the HotSpot bug:
+ *         #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ *     There is also a workaround involved to avoid the following bugs known
+ *     for HotSpot and for classic VM:
+ *         #4239841 (P1/S5) 1.1: poor garbage collector performance  (HotSpot bug)
+ *         #4245060 (P4/S5) poor garbage collector performance       (Classic VM bug)
+ *     However, printing of the test's error messages, warnings, and of execution
+ *     trace fails under JDK 1.2 for Win32 even so. If the test fails due to this
+ *     problem, exit status 96 is returned instead of 97.
+ *     JDK 1.3 classic VM for Sparc may crash (core dump) due to the known bug:
+ *         #4245057 (P2/S3) VM crashes when heap is exhausted
+ *
+ * @run main/othervm -Xms50M -Xmx200M -XX:-UseGCOverheadLimit nsk.stress.except.except008
+ */
+
+package nsk.stress.except;
+
+import java.io.PrintStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * This checks if various exceptions are thrown (and caught) correctly
+ * when there apparently are no free space in the heap to allocate new
+ * <code>Throwable</code> instance.
+ * <p>
+ * <p>The test tries to occupy all of memory available in the heap by
+ * allocating lots of new <code>Object()</code> instances. Instances of the
+ * type <code>Object</code> are the smallest objects, so they apparently should
+ * occupy most fine-grained fragments in the heap and leave no free space for
+ * new <code>Throwable</code> instance. After that, the test provokes various
+ * exceptions (e.g.: by executing integer division by 0 and so on), and checks
+ * if appropriate exceptions are thrown.
+ * <p>
+ * <p>Note, that memory occupation is terminated if memory allocation slows
+ * down crucially. This is a workaround intended to avoid the HotSpot bug:
+ * <br>&nbsp;&nbsp;
+ * #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ * <p>
+ * <p>There is also a workaround involved to avoid the following bugs known
+ * for HotSpot and for classic VM:
+ * <br>&nbsp;&nbsp;
+ * #4239841 (P1/S5) 1.1: poor garbage collector performance
+ * <br>&nbsp;&nbsp;
+ * #4245060 (P4/S5) poor garbage collector performance
+ * <br>However, printing of the test's error messages, warnings, and of
+ * execution trace may fail even so. If the test fails due to poor GC
+ * performance, exit status 96 is returned instead of 97.
+ * <p>
+ * <p>Also note, that the test needs a lot of memory to start up, so it should
+ * not run under older JDK 1.1.x release due to its poor heap utilization.
+ */
+public class except008 {
+    /**
+     * Either allow or supress printing of execution trace.
+     */
+    private static boolean TRACE_ON = false;
+    /**
+     * Either allow or supress printing of warning messages.
+     */
+    private static final boolean WARN_ON = true;
+    /*
+     * Storage for a lot of tiny objects
+     * "static volatile" keywords are for preventing heap optimization
+     */
+    private static volatile Object pool[] = null;
+    /**
+     * Temporary <code>log</code> for error messages, warnings and/or execution trace.
+     *
+     * @see #messages
+     */
+    private static String log[] = new String[1000]; // up to 1000 messages
+    /**
+     * How many <code>messages</code> were submitted to the <code>log</code>.
+     *
+     * @see #log
+     */
+    private static int messages = 0;
+
+    /**
+     * Re-call to the method <code>run(out)</code> (ignore <code>args[]</code>),
+     * and print the test summary - either test passed of failed.
+     */
+    public static int run(String args[], PrintStream out) {
+        if (args.length > 0) {
+            if (args[0].toLowerCase().startsWith("-v"))
+                TRACE_ON = true;
+        }
+
+        int exitCode = run(out);
+        pool = null;
+        System.gc();
+        // Print the log[] and the test summary:
+        try {
+            for (int i = 0; i < messages; i++)
+                out.println(log[i]);
+            if (exitCode == 0) {
+                if (TRACE_ON)
+                    out.println("Test passed.");
+            } else
+                out.println("Test failed.");
+        } catch (OutOfMemoryError oome) {
+            // Poor performance of garbage collector:
+            exitCode = 1;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Allocate as much <code>Object</code> instances as possible to bring JVM
+     * into stress, and then check if exceptions are correctly thrown accordingly
+     * to various situations like integer division by 0, etc.
+     */
+    private static int run(PrintStream out) {
+        out.println("# While printing this message, JVM seems to initiate the output");
+        out.println("# stream, so that it will not need more memory to print later,");
+        out.println("# when the heap would fail to provide more memory.");
+        out.println("# ");
+        out.println("# Note, that the test maintains especial static log[] field in");
+        out.println("# order to avoid printing when the heap seems exhausted.");
+        out.println("# Nevertheless, printing could arise OutOfMemoryError even");
+        out.println("# after all the memory allocated by the test is released.");
+        out.println("# ");
+        out.println("# That problem is caused by the known JDK/HotSpot bugs:");
+        out.println("#     4239841 (P1/S5) 1.1: poor garbage collector performance");
+        out.println("#     4245060 (P4/S5) poor garbage collector performance");
+        out.println("# ");
+        out.println("# This message is just intended to work-around that problem.");
+        out.println("# If printing should fail even so, the test will try to return");
+        out.println("# the exit status 96 instead of 97 to indicate the problem.");
+        out.println("# However, the test may fail or even crash on some platforms");
+        out.println("# suffering the bug 4239841 or 4245060.");
+
+        // Prepare some items, which will be used by the test:
+        Zoo zoo = new Zoo(); // load the class Zoo
+        Class noArgs[] = new Class[0];
+
+        // Sum up exit code:
+        int exitCode = 0; // apparently PASSED
+        int skipped = 0;  // some checks may correctly suffer OutOfMemoryError
+
+        // Allocate repository for a lots of tiny objects:
+        for (int size = 1 << 30; size > 0 && pool == null; size >>= 1)
+            try {
+                pool = new Object[size];
+            } catch (OutOfMemoryError oome) {
+            }
+        if (pool == null)
+            throw new Error("HS bug: cannot allocate new Object[1]");
+        int poolSize = pool.length;
+
+        int index = 0;
+        pool[index++] = new Object();
+
+        // Sum up time spent, when it was hard to JVM to allocate next object
+        // (i.e.: when JVM has spent more than 1 second to allocate new object):
+        double totalDelay = 0;
+        long timeMark = System.currentTimeMillis();
+        try {
+            for (; index < poolSize; index++) {
+                //-------------------------
+                pool[index] = new Object();
+                long nextTimeMark = System.currentTimeMillis();
+                long elapsed = nextTimeMark - timeMark;
+                timeMark = nextTimeMark;
+                //----------------------
+                if (elapsed > 1000) {
+                    double seconds = elapsed / 1000.0;
+                    if (TRACE_ON)
+                        out.println(
+                                "pool[" + index + "]=new Object(); // elapsed " + seconds + "s");
+                    totalDelay += seconds;
+                    if (totalDelay > 60) {
+                        if (TRACE_ON)
+                            out.println(
+                                    "Memory allocation became slow; so, heap seems exhausted.");
+                        break;
+                    }
+                }
+            }
+        } catch (OutOfMemoryError oome) {
+            if (TRACE_ON)
+                log[messages++] = "Heap seems exhausted - OutOfMemoryError thrown.";
+        }
+
+        if (index > poolSize - 1000) {
+            if (WARN_ON)
+                log[messages++] = "Warning: pool[] is full; so, checks would not be enough hard...";
+        }
+
+        // Check NoSuchFieldException (positive):
+        try {
+            Field valid = Zoo.class.getField("PUBLIC_FIELD");  // should pass
+//          Field wrong = Zoo.class.getField("PRIVATE_FIELD"); // should fail
+            if (TRACE_ON)
+                log[messages++] = "Success: NoSuchFieldException not thrown as expected";
+        } catch (NoSuchFieldException nsfe) {
+            pool[index++] = nsfe;
+            log[messages++] = "Failure: NoSuchFieldException thrown unexpectedly";
+            exitCode = 2;
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] =
+                        "Skipped: NoSuchFieldException positive check - OutOfMemoryError thrown";
+            skipped++;
+        }
+
+        // Check NoSuchFieldException (negative):
+        try {
+//          Field valid = Zoo.class.getField("PUBLIC_FIELD");  // should pass
+            Field wrong = Zoo.class.getField("PRIVATE_FIELD"); // should fail
+            log[messages++] = "Failure: NoSuchFieldException incorrectly not thrown";
+            exitCode = 2;
+        } catch (NoSuchFieldException nsfe) {
+            if (TRACE_ON)
+                log[messages++] = "Success: NoSuchFieldException thrown as expected";
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] =
+                        "NoSuchFieldException negative check - OutOfMemoryError thrown";
+            skipped++;
+        }
+
+        // Check NoSuchMethodException (positive):
+        try {
+            Method valid = Zoo.class.getMethod("PUBLIC_METHOD", noArgs);  // should pass
+//          Method wrong = Zoo.class.getMethod("PRIVATE_METHOD",noArgs); // should fail
+            if (TRACE_ON)
+                log[messages++] = "Success: NoSuchFieldException not thrown as expected";
+        } catch (NoSuchMethodException nsme) {
+            pool[index++] = nsme;
+            log[messages++] = "Failure: NoSuchMethodException thrown unexpectedly";
+            exitCode = 2;
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] =
+                        "Skipped: NoSuchMethodException positive check - OutOfMemoryError thrown";
+            pool[index++] = oome;
+            skipped++;
+        }
+
+        // Check NoSuchMethodException (negative):
+        try {
+//          Method valid = Zoo.class.getMethod("PUBLIC_METHOD",noArgs);  // should pass
+            Method wrong = Zoo.class.getMethod("PRIVATE_METHOD", noArgs); // should fail
+            log[messages++] = "Failure: NoSuchMethodException incorrectly not thrown";
+            exitCode = 2;
+        } catch (NoSuchMethodException nsme) {
+            pool[index++] = nsme;
+            if (TRACE_ON)
+                log[messages++] = "Success: NoSuchFieldException thrown as expected";
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] =
+                        "Skipped: NoSuchMethodException negative check - OutOfMemoryError thrown";
+            skipped++;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Several items used to check reflections.
+     */
+    private static class Zoo {
+        public String PUBLIC_FIELD = "Accessible via reflection";
+        private String PRIVATE_FIELD = "Inaccessible via reflection";
+
+        public String PUBLIC_METHOD() {
+            return "Accessible via reflection";
+        }
+
+        private String PRIVATE_METHOD() {
+            return "Inaccessible via reflection";
+        }
+
+    }
+
+    /**
+     * Re-call to <code>run(args,out)</code>, and return JCK-like exit status.
+     * (The stream <code>out</code> is assigned to <code>System.out</code> here.)
+     *
+     * @see #run(String[], PrintStream)
+     */
+    public static void main(String args[]) {
+        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+            // Last try. If there is some exception outside the code, test should end correctly
+            @Override
+            public void uncaughtException(Thread t, Throwable e) {
+                try {
+                    pool = null;
+                    log = null;
+                    System.gc();
+                    if (e instanceof OutOfMemoryError) {
+                        try {
+                            System.out.println("OOME : Test Skipped");
+                            System.exit(0);
+                        } catch (Throwable ignore) {
+                        } // No code in the handler can provoke correct exceptions.
+                    } else {
+                        e.printStackTrace();
+                        throw (RuntimeException) e;
+                    }
+                } catch (OutOfMemoryError oome) {
+                }
+            }
+        });
+        int exitCode = run(args, System.out);
+        System.exit(exitCode + 95);
+        // JCK-like exit status.
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/except/except009.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,288 @@
+/*
+ * Copyright (c) 1999, 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.
+ */
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/except/except009.
+ * VM testbase keywords: [stress, diehard, slow, nonconcurrent, quick]
+ * VM testbase readme:
+ * DESCRIPTION
+ *     This checks if various exceptions are thrown (and caught) correctly
+ *     when there apparently are no free space in the heap to allocate new
+ *     Throwable instance.
+ *     The test tries to occupy all of memory available in the heap by allocating
+ *     lots of new Object() instances. Instances of the type Object are the smallest
+ *     objects, so they apparently should occupy most fine-grained fragments in the
+ *     heap and leave no free space for new Throwable instance. After that, the test
+ *     provokes various exceptions (e.g.: by executing integer division by 0 and so
+ *     on), and checks if appropriate exceptions are thrown.
+ * COMMENTS
+ *     The test needs a lot of memory to start up, so it should not run under older
+ *     JDK 1.1.x release due to its poorer heap utilization. Also, some checks are
+ *     skipped when testing classic VM, because OutOfMemoryError is correctly thrown
+ *     instead of target exception.
+ *     When the test is being self-initiating (i.e.: eating heap), memory occupation
+ *     is terminated if memory allocation slows down crucially. This is a workaround
+ *     intended to avoid the HotSpot bug:
+ *         #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ *     There is also a workaround involved to avoid the following bugs known
+ *     for HotSpot and for classic VM:
+ *         #4239841 (P1/S5) 1.1: poor garbage collector performance  (HotSpot bug)
+ *         #4245060 (P4/S5) poor garbage collector performance       (Classic VM bug)
+ *     However, printing of the test's error messages, warnings, and of execution
+ *     trace fails under JDK 1.2 for Win32 even so. If the test fails due to this
+ *     problem, exit status 96 is returned instead of 97.
+ *     JDK 1.3 classic VM for Sparc may crash (core dump) due to the known bug:
+ *         #4245057 (P2/S3) VM crashes when heap is exhausted
+ *
+ * @run main/othervm -Xms50M -Xmx200M nsk.stress.except.except009
+ */
+
+package nsk.stress.except;
+
+import java.io.PrintStream;
+
+/**
+ * This checks if various exceptions are thrown (and caught) correctly
+ * when there apparently are no free space in the heap to allocate new
+ * <code>Throwable</code> instance.
+ * <p>
+ * <p>The test tries to occupy all of memory available in the heap by
+ * allocating lots of new <code>Object()</code> instances. Instances of the
+ * type <code>Object</code> are the smallest objects, so they apparently should
+ * occupy most fine-grained fragments in the heap and leave no free space for
+ * new <code>Throwable</code> instance. After that, the test provokes various
+ * exceptions (e.g.: by executing integer division by 0 and so on), and checks
+ * if appropriate exceptions are thrown.
+ * <p>
+ * <p>Note, that memory occupation is terminated if memory allocation slows
+ * down crucially. This is a workaround intended to avoid the HotSpot bug:
+ * <br>&nbsp;&nbsp;
+ * #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ * <p>
+ * <p>There is also a workaround involved to avoid the following bugs known
+ * for HotSpot and for classic VM:
+ * <br>&nbsp;&nbsp;
+ * #4239841 (P1/S5) 1.1: poor garbage collector performance
+ * <br>&nbsp;&nbsp;
+ * #4245060 (P4/S5) poor garbage collector performance
+ * <br>However, printing of the test's error messages, warnings, and of
+ * execution trace may fail even so. If the test fails due to poor GC
+ * performance, exit status 96 is returned instead of 97.
+ * <p>
+ * <p>Also note, that the test needs a lot of memory to start up, so it should
+ * not run under older JDK 1.1.x release due to its poor heap utilization.
+ */
+public class except009 {
+    /**
+     * Either allow or supress printing of execution trace.
+     */
+    private static boolean TRACE_ON = false;
+    /**
+     * Either allow or supress printing of warning messages.
+     */
+    private static final boolean WARN_ON = true;
+    /*
+     * Storage for a lot of tiny objects
+     * "static volatile" keywords are for preventing heap optimization
+     */
+    private static volatile Object pool[] = null;
+    /**
+     * Temporary <code>log</code> for error messages, warnings and/or execution trace.
+     *
+     * @see #messages
+     */
+    private static String log[] = new String[1000]; // up to 1000 messages
+    /**
+     * How many <code>messages</code> were submitted to the <code>log</code>.
+     *
+     * @see #log
+     */
+    private static int messages = 0;
+
+    /**
+     * Re-call to the method <code>run(out)</code> (ignore <code>args[]</code>),
+     * and print the test summary - either test passed of failed.
+     */
+    public static int run(String args[], PrintStream out) {
+        if (args.length > 0) {
+            if (args[0].toLowerCase().startsWith("-v"))
+                TRACE_ON = true;
+        }
+
+        int exitCode = run(out);
+        pool = null;
+        System.gc();
+        // Print the log[] and the test summary:
+        try {
+            for (int i = 0; i < messages; i++)
+                out.println(log[i]);
+            if (exitCode == 0) {
+                if (TRACE_ON)
+                    out.println("Test passed.");
+            } else
+                out.println("Test failed.");
+        } catch (OutOfMemoryError oome) {
+            // Poor performance of garbage collector:
+            exitCode = 1;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Allocate as much <code>Object</code> instances as possible to bring JVM
+     * into stress, and then check if exceptions are correctly thrown accordingly
+     * to various situations like integer division by 0, etc.
+     */
+    private static int run(PrintStream out) {
+        out.println("# While printing this message, JVM seems to initiate the output");
+        out.println("# stream, so that it will not need more memory to print later,");
+        out.println("# when the heap would fail to provide more memory.");
+        out.println("# ");
+        out.println("# Note, that the test maintains especial static log[] field in");
+        out.println("# order to avoid printing when the heap seems exhausted.");
+        out.println("# Nevertheless, printing could arise OutOfMemoryError even");
+        out.println("# after all the memory allocated by the test is released.");
+        out.println("# ");
+        out.println("# That problem is caused by the known JDK/HotSpot bugs:");
+        out.println("#     4239841 (P1/S5) 1.1: poor garbage collector performance");
+        out.println("#     4245060 (P4/S5) poor garbage collector performance");
+        out.println("# ");
+        out.println("# This message is just intended to work-around that problem.");
+        out.println("# If printing should fail even so, the test will try to return");
+        out.println("# the exit status 96 instead of 97 to indicate the problem.");
+        out.println("# However, the test may fail or even crash on some platforms");
+        out.println("# suffering the bug 4239841 or 4245060.");
+
+        // Sum up exit code:
+        int exitCode = 0; // apparently PASSED
+        int skipped = 0;  // some checks may correctly suffer OutOfMemoryError
+        String s = "qwerty";
+        char c;
+        // Allocate repository for a lots of tiny objects:
+        for (int size = 1 << 30; size > 0 && pool == null; size >>= 1)
+            try {
+                pool = new Object[size];
+            } catch (OutOfMemoryError oome) {
+            }
+        if (pool == null)
+            throw new Error("HS bug: cannot allocate new Object[1]");
+        int poolSize = pool.length;
+
+        int index = 0;
+        pool[index++] = new Object();
+
+        // Sum up time spent, when it was hard to JVM to allocate next object
+        // (i.e.: when JVM has spent more than 1 second to allocate new object):
+        double totalDelay = 0;
+        long timeMark = System.currentTimeMillis();
+        try {
+            for (; index < poolSize; index++) {
+                //-------------------------
+                pool[index] = new Object();
+                long nextTimeMark = System.currentTimeMillis();
+                long elapsed = nextTimeMark - timeMark;
+                timeMark = nextTimeMark;
+                //----------------------
+                if (elapsed > 1000) {
+                    double seconds = elapsed / 1000.0;
+                    if (TRACE_ON)
+                        out.println(
+                                "pool[" + index + "]=new Object(); // elapsed " + seconds + "s");
+                    totalDelay += seconds;
+                    if (totalDelay > 60) {
+                        if (TRACE_ON)
+                            out.println(
+                                    "Memory allocation became slow; so, heap seems exhausted.");
+                        break;
+                    }
+                }
+            }
+        } catch (OutOfMemoryError oome) {
+            if (TRACE_ON)
+                log[messages++] = "Heap seems exhausted - OutOfMemoryError thrown.";
+        }
+
+        if (index > poolSize - 1000) {
+            if (WARN_ON)
+                log[messages++] = "Warning: pool[] is full; so, checks would not be enough hard...";
+        }
+
+        // Check StringIndexOutOfBoundsException:
+        try {
+            c = s.charAt(6); // should fail
+            log[messages++] = "Failure: StringIndexOutOfBoundsException incorrectly not thrown";
+            exitCode = 2;
+        } catch (StringIndexOutOfBoundsException sioobe) {
+            pool[index++] = sioobe;
+            if (TRACE_ON)
+                log[messages++] = "Success: StringIndexOutOfBoundsException thrown as expected";
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] =
+                        "Skipped: StringIndexOutOfBoundsException: thrown OutOfMemoryError";
+            skipped++;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Re-call to <code>run(args,out)</code>, and return JCK-like exit status.
+     * (The stream <code>out</code> is assigned to <code>System.out</code> here.)
+     *
+     * @see #run(String[], PrintStream)
+     */
+    public static void main(String args[]) {
+        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+            // Last try. If there is some exceprions outside the code, test should end correctly
+            @Override
+            public void uncaughtException(Thread t, Throwable e) {
+                try {
+                    pool = null;
+                    log = null;
+                    System.gc();
+                    if (e instanceof OutOfMemoryError) {
+                        try {
+                            System.out.println("OOME : Test Skipped");
+                            System.exit(0);
+                        } catch (Throwable ignore) {
+                        } // No code in the handler can provoke correct exceptions.
+                    } else {
+                        e.printStackTrace();
+                        throw (RuntimeException) e;
+                    }
+                } catch (OutOfMemoryError oome) {
+                }
+            }
+        });
+        int exitCode = run(args, System.out);
+        System.exit(exitCode + 95);
+        // JCK-like exit status.
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/except/except010.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,291 @@
+/*
+ * Copyright (c) 1999, 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.
+ */
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/except/except010.
+ * VM testbase keywords: [stress, diehard, slow, nonconcurrent, quick]
+ * VM testbase readme:
+ * DESCRIPTION
+ *     This checks if various exceptions are thrown (and caught) correctly
+ *     when there apparently are no free space in the heap to allocate new
+ *     Throwable instance.
+ *     The test tries to occupy all of memory available in the heap by allocating
+ *     lots of new Object() instances. Instances of the type Object are the smallest
+ *     objects, so they apparently should occupy most fine-grained fragments in the
+ *     heap and leave no free space for new Throwable instance. After that, the test
+ *     provokes various exceptions (e.g.: by executing integer division by 0 and so
+ *     on), and checks if appropriate exceptions are thrown.
+ * COMMENTS
+ *     The test needs a lot of memory to start up, so it should not run under older
+ *     JDK 1.1.x release due to its poorer heap utilization. Also, some checks are
+ *     skipped when testing classic VM, because OutOfMemoryError is correctly thrown
+ *     instead of target exception.
+ *     When the test is being self-initiating (i.e.: eating heap), memory occupation
+ *     is terminated if memory allocation slows down crucially. This is a workaround
+ *     intended to avoid the HotSpot bug:
+ *         #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ *     There is also a workaround involved to avoid the following bugs known
+ *     for HotSpot and for classic VM:
+ *         #4239841 (P1/S5) 1.1: poor garbage collector performance  (HotSpot bug)
+ *         #4245060 (P4/S5) poor garbage collector performance       (Classic VM bug)
+ *     However, printing of the test's error messages, warnings, and of execution
+ *     trace fails under JDK 1.2 for Win32 even so. If the test fails due to this
+ *     problem, exit status 96 is returned instead of 97.
+ *     JDK 1.3 classic VM for Sparc may crash (core dump) due to the known bug:
+ *         #4245057 (P2/S3) VM crashes when heap is exhausted
+ *
+ * @run main/othervm -Xms50M -Xmx200M nsk.stress.except.except010
+ */
+
+package nsk.stress.except;
+
+import java.io.PrintStream;
+
+/**
+ * This checks if various exceptions are thrown (and caught) correctly
+ * when there apparently are no free space in the heap to allocate new
+ * <code>Throwable</code> instance.
+ * <p>
+ * <p>The test tries to occupy all of memory available in the heap by
+ * allocating lots of new <code>Object()</code> instances. Instances of the
+ * type <code>Object</code> are the smallest objects, so they apparently should
+ * occupy most fine-grained fragments in the heap and leave no free space for
+ * new <code>Throwable</code> instance. After that, the test provokes various
+ * exceptions (e.g.: by executing integer division by 0 and so on), and checks
+ * if appropriate exceptions are thrown.
+ * <p>
+ * <p>Note, that memory occupation is terminated if memory allocation slows
+ * down crucially. This is a workaround intended to avoid the HotSpot bug:
+ * <br>&nbsp;&nbsp;
+ * #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ * <p>
+ * <p>There is also a workaround involved to avoid the following bugs known
+ * for HotSpot and for classic VM:
+ * <br>&nbsp;&nbsp;
+ * #4239841 (P1/S5) 1.1: poor garbage collector performance
+ * <br>&nbsp;&nbsp;
+ * #4245060 (P4/S5) poor garbage collector performance
+ * <br>However, printing of the test's error messages, warnings, and of
+ * execution trace may fail even so. If the test fails due to poor GC
+ * performance, exit status 96 is returned instead of 97.
+ * <p>
+ * <p>Also note, that the test needs a lot of memory to start up, so it should
+ * not run under older JDK 1.1.x release due to its poor heap utilization.
+ */
+public class except010 {
+    /**
+     * Either allow or supress printing of execution trace.
+     */
+    private static boolean TRACE_ON = false;
+    /**
+     * Either allow or supress printing of warning messages.
+     */
+    private static final boolean WARN_ON = true;
+    /*
+     * Storage for a lot of tiny objects
+     * "static volatile" keywords are for preventing heap optimization
+     */
+    private static volatile Object pool[] = null;
+    /**
+     * Temporary <code>log</code> for error messages, warnings and/or execution trace.
+     *
+     * @see #messages
+     */
+    private static String log[] = new String[1000]; // up to 1000 messages
+    /**
+     * How many <code>messages</code> were submitted to the <code>log</code>.
+     *
+     * @see #log
+     */
+    private static int messages = 0;
+
+    /**
+     * Re-call to the method <code>run(out)</code> (ignore <code>args[]</code>),
+     * and print the test summary - either test passed of failed.
+     */
+    public static int run(String args[], PrintStream out) {
+        if (args.length > 0) {
+            if (args[0].toLowerCase().startsWith("-v"))
+                TRACE_ON = true;
+        }
+
+        int exitCode = run(out);
+        pool = null;
+        System.gc();
+        // Print the log[] and the test summary:
+        try {
+            for (int i = 0; i < messages; i++)
+                out.println(log[i]);
+            if (exitCode == 0) {
+                if (TRACE_ON)
+                    out.println("Test passed.");
+            } else
+                out.println("Test failed.");
+        } catch (OutOfMemoryError oome) {
+            // Poor performance of garbage collector:
+            exitCode = 1;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Allocate as much <code>Object</code> instances as possible to bring JVM
+     * into stress, and then check if exceptions are correctly thrown accordingly
+     * to various situations like integer division by 0, etc.
+     */
+    private static int run(PrintStream out) {
+        out.println("# While printing this message, JVM seems to initiate the output");
+        out.println("# stream, so that it will not need more memory to print later,");
+        out.println("# when the heap would fail to provide more memory.");
+        out.println("# ");
+        out.println("# Note, that the test maintains especial static log[] field in");
+        out.println("# order to avoid printing when the heap seems exhausted.");
+        out.println("# Nevertheless, printing could arise OutOfMemoryError even");
+        out.println("# after all the memory allocated by the test is released.");
+        out.println("# ");
+        out.println("# That problem is caused by the known JDK/HotSpot bugs:");
+        out.println("#     4239841 (P1/S5) 1.1: poor garbage collector performance");
+        out.println("#     4245060 (P4/S5) poor garbage collector performance");
+        out.println("# ");
+        out.println("# This message is just intended to work-around that problem.");
+        out.println("# If printing should fail even so, the test will try to return");
+        out.println("# the exit status 96 instead of 97 to indicate the problem.");
+        out.println("# However, the test may fail or even crash on some platforms");
+        out.println("# suffering the bug 4239841 or 4245060.");
+
+        // Sum up exit code:
+        int exitCode = 0; // apparently PASSED
+        int skipped = 0;  // some checks may correctly suffer OutOfMemoryError
+
+        // Allocate repository for a lots of tiny objects:
+        for (int size = 1 << 30; size > 0 && pool == null; size >>= 1)
+            try {
+                pool = new Object[size];
+            } catch (OutOfMemoryError oome) {
+            }
+        if (pool == null)
+            throw new Error("HS bug: cannot allocate new Object[1]");
+        int poolSize = pool.length;
+
+        int index = 0;
+        pool[index++] = new Object();
+
+        // Sum up time spent, when it was hard to JVM to allocate next object
+        // (i.e.: when JVM has spent more than 1 second to allocate new object):
+        double totalDelay = 0;
+        long timeMark = System.currentTimeMillis();
+        try {
+            for (; index < poolSize; index++) {
+                //-------------------------
+                pool[index] = new Object();
+                long nextTimeMark = System.currentTimeMillis();
+                long elapsed = nextTimeMark - timeMark;
+                timeMark = nextTimeMark;
+                //----------------------
+                if (elapsed > 1000) {
+                    double seconds = elapsed / 1000.0;
+                    if (TRACE_ON)
+                        out.println(
+                                "pool[" + index + "]=new Object(); // elapsed " + seconds + "s");
+                    totalDelay += seconds;
+                    if (totalDelay > 60) {
+                        if (TRACE_ON)
+                            out.println(
+                                    "Memory allocation became slow; so, heap seems exhausted.");
+                        break;
+                    }
+                }
+            }
+        } catch (OutOfMemoryError oome) {
+            if (TRACE_ON)
+                log[messages++] = "Heap seems exhausted - OutOfMemoryError thrown.";
+        }
+
+        if (index > poolSize - 1000) {
+            if (WARN_ON)
+                log[messages++] = "Warning: pool[] is full; so, checks would not be enough hard...";
+        }
+
+        // Check StackOverflowError:
+        try {
+            goIntoInfiniteRecursion();
+            log[messages++] = "Failure: StackOverflowError failed to throw";
+            exitCode = 2;
+        } catch (StackOverflowError soe) {
+            pool[index++] = soe;
+            if (TRACE_ON)
+                log[messages++] = "Success: StackOverflowError thrown as expected";
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] =
+                        "Skipped: StackOverflowError: thrown OutOfMemoryError";
+            skipped++;
+        }
+
+        return exitCode;
+    }
+
+    private static void goIntoInfiniteRecursion() {
+        goIntoInfiniteRecursion();
+    }
+
+    /**
+     * Re-call to <code>run(args,out)</code>, and return JCK-like exit status.
+     * (The stream <code>out</code> is assigned to <code>System.out</code> here.)
+     *
+     * @see #run(String[], PrintStream)
+     */
+    public static void main(String args[]) {
+        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+            // Last try. If there is some exceptions outside the code, test should end correctly
+            @Override
+            public void uncaughtException(Thread t, Throwable e) {
+                try {
+                    pool = null;
+                    log = null;
+                    System.gc();
+                    if (e instanceof OutOfMemoryError) {
+                        try {
+                            System.out.println("OOME : Test Skipped");
+                            System.exit(0);
+                        } catch (Throwable ignore) {
+                        } // No code in the handler can provoke correct exceptions.
+                    } else {
+                        e.printStackTrace();
+                        throw (RuntimeException) e;
+                    }
+                } catch (OutOfMemoryError oome) {
+                }
+            }
+        });
+        int exitCode = run(args, System.out);
+        System.exit(exitCode + 95);
+        // JCK-like exit status.
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/except/except011.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 1999, 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.
+ */
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/except/except011.
+ * VM testbase keywords: [stress, slow, nonconcurrent, quick]
+ * VM testbase readme:
+ * DESCRIPTION
+ *     This checks if various exceptions are thrown (and caught) correctly
+ *     when there apparently are no free space in the heap to allocate new
+ *     Throwable instance.
+ *     The test tries to occupy all of memory available in the heap by allocating
+ *     lots of new Object() instances. Instances of the type Object are the smallest
+ *     objects, so they apparently should occupy most fine-grained fragments in the
+ *     heap and leave no free space for new Throwable instance. After that, the test
+ *     provokes various exceptions (e.g.: by executing integer division by 0 and so
+ *     on), and checks if appropriate exceptions are thrown.
+ * COMMENTS
+ *     The test needs a lot of memory to start up, so it should not run under older
+ *     JDK 1.1.x release due to its poorer heap utilization. Also, some checks are
+ *     skipped when testing classic VM, because OutOfMemoryError is correctly thrown
+ *     instead of target exception.
+ *     When the test is being self-initiating (i.e.: eating heap), memory occupation
+ *     is terminated if memory allocation slows down crucially. This is a workaround
+ *     intended to avoid the HotSpot bug:
+ *         #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ *     There is also a workaround involved to avoid the following bugs known
+ *     for HotSpot and for classic VM:
+ *         #4239841 (P1/S5) 1.1: poor garbage collector performance  (HotSpot bug)
+ *         #4245060 (P4/S5) poor garbage collector performance       (Classic VM bug)
+ *     However, printing of the test's error messages, warnings, and of execution
+ *     trace fails under JDK 1.2 for Win32 even so. If the test fails due to this
+ *     problem, exit status 96 is returned instead of 97.
+ *     JDK 1.3 classic VM for Sparc may crash (core dump) due to the known bug:
+ *         #4245057 (P2/S3) VM crashes when heap is exhausted
+ *
+ * @run main/othervm -Xms50M -Xmx200M nsk.stress.except.except011
+ */
+
+package nsk.stress.except;
+
+import java.io.PrintStream;
+
+/**
+ * This checks if various exceptions are thrown (and caught) correctly
+ * when there apparently are no free space in the heap to allocate new
+ * <code>Throwable</code> instance.
+ * <p>
+ * <p>The test tries to occupy all of memory available in the heap by
+ * allocating lots of new <code>Object()</code> instances. Instances of the
+ * type <code>Object</code> are the smallest objects, so they apparently should
+ * occupy most fine-grained fragments in the heap and leave no free space for
+ * new <code>Throwable</code> instance. After that, the test provokes various
+ * exceptions (e.g.: by executing integer division by 0 and so on), and checks
+ * if appropriate exceptions are thrown.
+ * <p>
+ * <p>Note, that memory occupation is terminated if memory allocation slows
+ * down crucially. This is a workaround intended to avoid the HotSpot bug:
+ * <br>&nbsp;&nbsp;
+ * #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ * <p>
+ * <p>There is also a workaround involved to avoid the following bugs known
+ * for HotSpot and for classic VM:
+ * <br>&nbsp;&nbsp;
+ * #4239841 (P1/S5) 1.1: poor garbage collector performance
+ * <br>&nbsp;&nbsp;
+ * #4245060 (P4/S5) poor garbage collector performance
+ * <br>However, printing of the test's error messages, warnings, and of
+ * execution trace may fail even so. If the test fails due to poor GC
+ * performance, exit status 96 is returned instead of 97.
+ * <p>
+ * <p>Also note, that the test needs a lot of memory to start up, so it should
+ * not run under older JDK 1.1.x release due to its poor heap utilization.
+ */
+public class except011 {
+    /**
+     * Either allow or supress printing of execution trace.
+     */
+    private static boolean TRACE_ON = false;
+    /**
+     * Either allow or supress printing of warning messages.
+     */
+    private static final boolean WARN_ON = true;
+    /*
+     * Storage for a lot of tiny objects
+     * "static volatile" keywords are for preventing heap optimization
+     */
+    private static volatile Object pool[] = null;
+    /**
+     * Temporary <code>log</code> for error messages, warnings and/or execution trace.
+     *
+     * @see #messages
+     */
+    private static String log[] = new String[1000]; // up to 1000 messages
+    /**
+     * How many <code>messages</code> were submitted to the <code>log</code>.
+     *
+     * @see #log
+     */
+    private static int messages = 0;
+
+    private static final String className = "nsk.stress.except.except011.except011oops";
+
+    /**
+     * Re-call to the method <code>run(out)</code> (ignore <code>args[]</code>),
+     * and print the test summary - either test passed of failed.
+     */
+    public static int run(String args[], PrintStream out) {
+        if (args.length > 0) {
+            if (args[0].toLowerCase().startsWith("-v"))
+                TRACE_ON = true;
+        }
+
+        int exitCode = run(out);
+        pool = null;
+        System.gc();
+        // Print the log[] and the test summary:
+        try {
+            for (int i = 0; i < messages; i++)
+                out.println(log[i]);
+            if (exitCode == 0) {
+                if (TRACE_ON)
+                    out.println("Test passed.");
+            } else
+                out.println("Test failed.");
+        } catch (OutOfMemoryError oome) {
+            // Poor performance of garbage collector:
+            exitCode = 1;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Allocate as much <code>Object</code> instances as possible to bring JVM
+     * into stress, and then check if exceptions are correctly thrown accordingly
+     * to various situations like integer division by 0, etc.
+     */
+    private static int run(PrintStream out) {
+        out.println("# While printing this message, JVM seems to initiate the output");
+        out.println("# stream, so that it will not need more memory to print later,");
+        out.println("# when the heap would fail to provide more memory.");
+        out.println("# ");
+        out.println("# Note, that the test maintains especial static log[] field in");
+        out.println("# order to avoid printing when the heap seems exhausted.");
+        out.println("# Nevertheless, printing could arise OutOfMemoryError even");
+        out.println("# after all the memory allocated by the test is released.");
+        out.println("# ");
+        out.println("# That problem is caused by the known JDK/HotSpot bugs:");
+        out.println("#     4239841 (P1/S5) 1.1: poor garbage collector performance");
+        out.println("#     4245060 (P4/S5) poor garbage collector performance");
+        out.println("# ");
+        out.println("# This message is just intended to work-around that problem.");
+        out.println("# If printing should fail even so, the test will try to return");
+        out.println("# the exit status 96 instead of 97 to indicate the problem.");
+        out.println("# However, the test may fail or even crash on some platforms");
+        out.println("# suffering the bug 4239841 or 4245060.");
+
+        // Sum up exit code:
+        int exitCode = 0; // apparently PASSED
+        int skipped = 0;  // some checks may correctly suffer OutOfMemoryError
+        Class oops;
+        // Allocate repository for a lots of tiny objects:
+        for (int size = 1 << 30; size > 0 && pool == null; size >>= 1)
+            try {
+                pool = new Object[size];
+            } catch (OutOfMemoryError oome) {
+            }
+        if (pool == null)
+            throw new Error("HS bug: cannot allocate new Object[1]");
+        int poolSize = pool.length;
+
+        int index = 0;
+        pool[index++] = new Object();
+
+        // Sum up time spent, when it was hard to JVM to allocate next object
+        // (i.e.: when JVM has spent more than 1 second to allocate new object):
+        double totalDelay = 0;
+        long timeMark = System.currentTimeMillis();
+        try {
+            for (; index < poolSize; index++) {
+                //-------------------------
+                pool[index] = new Object();
+                long nextTimeMark = System.currentTimeMillis();
+                long elapsed = nextTimeMark - timeMark;
+                timeMark = nextTimeMark;
+                //----------------------
+                if (elapsed > 1000) {
+                    double seconds = elapsed / 1000.0;
+                    if (TRACE_ON)
+                        out.println(
+                                "pool[" + index + "]=new Object(); // elapsed " + seconds + "s");
+                    totalDelay += seconds;
+                    if (totalDelay > 60) {
+                        if (TRACE_ON)
+                            out.println(
+                                    "Memory allocation became slow; so, heap seems exhausted.");
+                        break;
+                    }
+                }
+            }
+        } catch (OutOfMemoryError oome) {
+            if (TRACE_ON)
+                log[messages++] = "Heap seems exhausted - OutOfMemoryError thrown.";
+        }
+
+        if (index > poolSize - 1000) {
+            if (WARN_ON)
+                log[messages++] = "Warning: pool[] is full; so, checks would not be enough hard...";
+        }
+
+        // Check ExceptionInInitializerError:
+        try {
+            oops = Class.forName(className);
+            log[messages++] = "Failure: ExceptionInInitializerError failed to throw";
+            exitCode = 2;
+        } catch (ExceptionInInitializerError eiie) {
+            String message = eiie.getException().getMessage();
+            if (!message.equals("except011oops")) {
+                log[messages++] =
+                        "Failure: ExceptionInInitializerError: unexpected target exception";
+                exitCode = 2;
+            } else if (TRACE_ON)
+                log[messages++] = "Success: ExceptionInInitializerError thrown as expected";
+        } catch (ClassNotFoundException cnfe) {
+            log[messages++] = "Failure: ExceptionInInitializerError: target class not found";
+            exitCode = 2;
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] =
+                        "Skipped: ExceptionInInitializerError: thrown OutOfMemoryError";
+            skipped++;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Re-call to <code>run(args,out)</code>, and return JCK-like exit status.
+     * (The stream <code>out</code> is assigned to <code>System.out</code> here.)
+     *
+     * @see #run(String[], PrintStream)
+     */
+    public static void main(String args[]) {
+        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+            // Last try. If there is some OOME, test should end correctly
+            @Override
+            public void uncaughtException(Thread t, Throwable e) {
+                try {
+                    pool = null;
+                    log = null;
+                    System.gc(); // Empty memory to be able to write to the output
+                    if (e instanceof OutOfMemoryError) {
+                        try {
+                            System.out.println("OOME : Test Skipped");
+                            System.exit(0);
+                        } catch (Throwable ignore) {
+                        } // No code in the handler can provoke correct exceptions.
+                    } else {
+                        e.printStackTrace();
+                        throw (RuntimeException) e;
+                    }
+                } catch (OutOfMemoryError oome) {
+                }
+            }
+        });
+        int exitCode = run(args, System.out);
+        System.exit(exitCode + 95);
+        // JCK-like exit status.
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/except/except011oops.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 1999, 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.stress.except;
+
+/**
+ * This class throws exception while static initialization.
+ * The test should load this class via reflection in order
+ * to hold the exception until runtime.
+ *
+ * @see nsk.stress.except.except011
+ */
+public class except011oops {
+    static boolean truth = true;
+
+    static {
+        if (truth)
+            throw new RuntimeException("except011oops");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/except/except012.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,366 @@
+/*
+ * Copyright (c) 1999, 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.
+ */
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/except/except012.
+ * VM testbase keywords: [stress, slow, nonconcurrent, quick]
+ * VM testbase readme:
+ * DESCRIPTION
+ *     This checks if various exceptions are thrown (and caught) correctly
+ *     when there apparently are no free space in the heap to allocate new
+ *     Throwable instance.
+ *     The test tries to occupy all of memory available in the heap by allocating
+ *     lots of new Object() instances. Instances of the type Object are the smallest
+ *     objects, so they apparently should occupy most fine-grained fragments in the
+ *     heap and leave no free space for new Throwable instance. After that, the test
+ *     provokes various exceptions (e.g.: by executing integer division by 0 and so
+ *     on), and checks if appropriate exceptions are thrown.
+ * COMMENTS
+ *     The test needs a lot of memory to start up, so it should not run under older
+ *     JDK 1.1.x release due to its poorer heap utilization. Also, some checks are
+ *     skipped when testing classic VM, because OutOfMemoryError is correctly thrown
+ *     instead of target exception.
+ *     When the test is being self-initiating (i.e.: eating heap), memory occupation
+ *     is terminated if memory allocation slows down crucially. This is a workaround
+ *     intended to avoid the HotSpot bug:
+ *         #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ *     There is also a workaround involved to avoid the following bugs known
+ *     for HotSpot and for classic VM:
+ *         #4239841 (P1/S5) 1.1: poor garbage collector performance  (HotSpot bug)
+ *         #4245060 (P4/S5) poor garbage collector performance       (Classic VM bug)
+ *     However, printing of the test's error messages, warnings, and of execution
+ *     trace fails under JDK 1.2 for Win32 even so. If the test fails due to this
+ *     problem, exit status 96 is returned instead of 97.
+ *     JDK 1.3 classic VM for Sparc may crash (core dump) due to the known bug:
+ *         #4245057 (P2/S3) VM crashes when heap is exhausted
+ *
+ * @run main/othervm -Xms50M -Xmx200M nsk.stress.except.except012
+ */
+
+package nsk.stress.except;
+
+import java.io.PrintStream;
+import java.util.Random;
+
+/**
+ * This checks if various exceptions are thrown (and caught) correctly
+ * when there apparently are no free space in the heap to allocate new
+ * <code>Throwable</code> instance.
+ * <p>
+ * <p>The test tries to occupy all of memory available in the heap by
+ * allocating lots of new <code>Object()</code> instances. Instances of the
+ * type <code>Object</code> are the smallest objects, so they apparently should
+ * occupy most fine-grained fragments in the heap and leave no free space for
+ * new <code>Throwable</code> instance. After that, the test provokes various
+ * exceptions (e.g.: by executing integer division by 0 and so on), and checks
+ * if appropriate exceptions are thrown.
+ * <p>
+ * <p>Note, that memory occupation is terminated if memory allocation slows
+ * down crucially. This is a workaround intended to avoid the HotSpot bug:
+ * <br>&nbsp;&nbsp;
+ * #4248801 (P1/S5) slow memory allocation when heap is almost exhausted
+ * <p>
+ * <p>There is also a workaround involved to avoid the following bugs known
+ * for HotSpot and for classic VM:
+ * <br>&nbsp;&nbsp;
+ * #4239841 (P1/S5) 1.1: poor garbage collector performance
+ * <br>&nbsp;&nbsp;
+ * #4245060 (P4/S5) poor garbage collector performance
+ * <br>However, printing of the test's error messages, warnings, and of
+ * execution trace may fail even so. If the test fails due to poor GC
+ * performance, exit status 96 is returned instead of 97.
+ * <p>
+ * <p>Also note, that the test needs a lot of memory to start up, so it should
+ * not run under older JDK 1.1.x release due to its poor heap utilization.
+ */
+public class except012 {
+    /**
+     * Either allow or supress printing of execution trace.
+     */
+    private static boolean TRACE_ON = false;
+    /**
+     * Either allow or supress printing of warning messages.
+     */
+    private static final boolean WARN_ON = true;
+
+    /**
+     * Temporary <code>log</code> for error messages, warnings and/or execution trace.
+     *
+     * @see #messages
+     */
+    private static String log[] = new String[1000]; // up to 1000 messages
+    /**
+     * How many <code>messages</code> were submitted to the <code>log</code>.
+     *
+     * @see #log
+     */
+    private static int messages = 0;
+    /*
+     * Storage for a lot of tiny objects
+     * "static volatile" keywords are for preventing heap optimization
+     */
+    private static volatile Object pool[] = null;
+
+    /**
+     * Re-call to the method <code>run(out)</code> (ignore <code>args[]</code>),
+     * and print the test summary - either test passed of failed.
+     */
+    public static int run(String args[], PrintStream out) {
+        if (args.length > 0) {
+            if (args[0].toLowerCase().startsWith("-v"))
+                TRACE_ON = true;
+        }
+
+        int exitCode = run(out);
+        pool = null;
+        System.gc();
+        // Print the log[] and the test summary:
+        try {
+            for (int i = 0; i < messages; i++)
+                out.println(log[i]);
+            if (exitCode == 0) {
+                if (TRACE_ON)
+                    out.println("Test passed.");
+            } else
+                out.println("Test failed.");
+        } catch (OutOfMemoryError oome) {
+            // Poor performance of garbage collector:
+            exitCode = 1;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * Allocate as much <code>Object</code> instances as possible to bring JVM
+     * into stress, and then check if exceptions are correctly thrown accordingly
+     * to various situations like integer division by 0, etc.
+     */
+    private static int run(PrintStream out) {
+        out.println("# While printing this message, JVM seems to initiate the output");
+        out.println("# stream, so that it will not need more memory to print later,");
+        out.println("# when the heap would fail to provide more memory.");
+        out.println("# ");
+        out.println("# Note, that the test maintains especial static log[] field in");
+        out.println("# order to avoid printing when the heap seems exhausted.");
+        out.println("# Nevertheless, printing could arise OutOfMemoryError even");
+        out.println("# after all the memory allocated by the test is released.");
+        out.println("# ");
+        out.println("# That problem is caused by the known JDK/HotSpot bugs:");
+        out.println("#     4239841 (P1/S5) 1.1: poor garbage collector performance");
+        out.println("#     4245060 (P4/S5) poor garbage collector performance");
+        out.println("# ");
+        out.println("# This message is just intended to work-around that problem.");
+        out.println("# If printing should fail even so, the test will try to return");
+        out.println("# the exit status 96 instead of 97 to indicate the problem.");
+        out.println("# However, the test may fail or even crash on some platforms");
+        out.println("# suffering the bug 4239841 or 4245060.");
+
+        // Allocate items necessary for the test:
+        CrazyClassLoader crazyClassLoader = new CrazyClassLoader();
+        MustDie threadToDie = new MustDie();
+
+        // Sum up exit code:
+        int exitCode = 0; // apparently PASSED
+        int skipped = 0;  // some checks may correctly suffer OutOfMemoryError
+        // Allocate repository for a lots of tiny objects:
+        for (int size = 1 << 30; size > 0 && pool == null; size >>= 1)
+            try {
+                pool = new Object[size];
+            } catch (OutOfMemoryError oome) {
+            }
+        if (pool == null)
+            throw new Error("HS bug: cannot allocate new Object[1]");
+        int poolSize = pool.length;
+
+        int index = 0;
+        pool[index++] = new Object();
+
+        // Sum up time spent, when it was hard to JVM to allocate next object
+        // (i.e.: when JVM has spent more than 1 second to allocate new object):
+        double totalDelay = 0;
+        long timeMark = System.currentTimeMillis();
+        try {
+            for (; index < poolSize; index++) {
+                //-------------------------
+                pool[index] = new Object();
+                long nextTimeMark = System.currentTimeMillis();
+                long elapsed = nextTimeMark - timeMark;
+                timeMark = nextTimeMark;
+                //----------------------
+                if (elapsed > 1000) {
+                    double seconds = elapsed / 1000.0;
+                    if (TRACE_ON)
+                        out.println(
+                                "pool[" + index + "]=new Object(); // elapsed " + seconds + "s");
+                    totalDelay += seconds;
+                    if (totalDelay > 60) {
+                        if (TRACE_ON)
+                            out.println(
+                                    "Memory allocation became slow; so, heap seems exhausted.");
+                        break;
+                    }
+                }
+            }
+        } catch (OutOfMemoryError oome) {
+            if (TRACE_ON)
+                log[messages++] = "Heap seems exhausted - OutOfMemoryError thrown.";
+        }
+
+        if (index > poolSize - 1000) {
+            if (WARN_ON)
+                log[messages++] = "Warning: pool[] is full; so, checks would not be enough hard...";
+        }
+
+        // Check ClassFormatError:
+        try {
+            Class oops = crazyClassLoader.loadClass("name doesn't matter");
+            log[messages++] = "Failure: ClassFormatError failed to throw";
+            exitCode = 2;
+        } catch (ClassFormatError cfe) {
+            if (TRACE_ON)
+                log[messages++] = "Success: ClassFormatError thrown as expected";
+        } catch (ClassNotFoundException cnfe) {
+            log[messages++] =
+                    "Failure: ClassFormatError: unexpectedly thrown ClassNotFoundException";
+            exitCode = 2;
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] =
+                        "Skipped: ClassFormatError: thrown OutOfMemoryError";
+            skipped++;
+        }
+
+        // Check ThreadDeath:
+        try {
+            threadToDie.start();
+            while (threadToDie.isAlive())
+                threadToDie.join();
+            Throwable exception = threadToDie.exception;
+            if (exception == null) {
+                log[messages++] = "Failure: ThreadDeath failed to throw";
+                exitCode = 2;
+            } else if (exception instanceof OutOfMemoryError) {
+                if (WARN_ON)
+                    log[messages++] =
+                            "Skipped: ThreadDeath: thrown OutOfMemoryError instead";
+            } else if (!(exception instanceof ThreadDeath)) {
+                log[messages++] =
+                        "Failure: ThreadDeath: unexpected exception thrown";
+                exitCode = 2;
+            } else if (TRACE_ON)
+                log[messages++] = "Success: ThreadDeath thrown as expected";
+        } catch (InterruptedException ie) {
+            pool[index++] = ie;
+            log[messages++] =
+                    "Failure: ThreadDeath: thrown InterruptedException instead";
+            exitCode = 2;
+        } catch (OutOfMemoryError oome) {
+            if (WARN_ON)
+                log[messages++] =
+                        "Skipped: ThreadDeath: thrown OutOfMemoryError";
+            skipped++;
+        }
+
+        return exitCode;
+    }
+
+    /**
+     * This class loader provokes <code>ClassFormatError</code>.
+     */
+    private static class CrazyClassLoader extends ClassLoader {
+        public Class loadClass(String name) throws ClassNotFoundException {
+            Class crazyClass = defineClass(null, crazyBytecode, 0, crazyBytecode.length);
+            return crazyClass; // return is unreacable, due to ClassFormatError
+        }
+
+        private static byte crazyBytecode[];
+
+        static {
+            crazyBytecode = new byte[1000];
+            Random random = new Random(0);
+            for (int i = 0; i < crazyBytecode.length; i++)
+                crazyBytecode[i] = (byte) random.nextInt(256);
+        }
+
+    }
+
+    /**
+     * This thread should die in order to check <code>ThreadDeath</code> error.
+     */
+    private static class MustDie extends Thread {
+        Throwable exception = null;
+
+        public void run() {
+            try {
+                stop();
+            } catch (Throwable throwable) {
+                exception = throwable;
+                if (throwable instanceof ThreadDeath)
+                    throw (ThreadDeath) throwable;
+            }
+        }
+
+    }
+
+    /**
+     * Re-call to <code>run(args,out)</code>, and return JCK-like exit status.
+     * (The stream <code>out</code> is assigned to <code>System.out</code> here.)
+     *
+     * @see #run(String[], PrintStream)
+     */
+    public static void main(String args[]) {
+        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+            // Last try. If there is some OOME, test should end correctly
+            @Override
+            public void uncaughtException(Thread t, Throwable e) {
+                try {
+                    pool = null;
+                    System.gc(); // Empty memory to be able to write to the output
+                    if (e instanceof OutOfMemoryError) {
+                        try {
+                            System.out.println("OOME : Test Skipped");
+                            System.exit(0);
+                        } catch (Throwable ignore) {
+                        } // any of the test exceptions are handled in test.#
+                        // No code in the handler can provoke correct exceptions.
+                    } else if (e instanceof ThreadDeath) {
+                    } //ignore since it thrown as expected
+                    else {
+                        e.printStackTrace();
+                        throw (RuntimeException) e;
+                    }
+                } catch (OutOfMemoryError oome) {
+                }
+            }
+        });
+        int exitCode = run(args, System.out);
+        System.exit(exitCode + 95);
+        // JCK-like exit status.
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/GarbageGenerator.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 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.stress.jni;
+
+class GarbageGenerator extends Thread {
+    class Garbage {
+        Garbage() {
+            this(1024);
+        }
+
+        Garbage(int m) {
+            memory = new byte[m];
+        }
+
+        void setNext(Garbage n) {
+            next = n;
+        }
+
+        Garbage getNext() {
+            return next;
+        }
+
+        protected void finalize() {
+        }
+
+        private Garbage next;
+        private byte[] memory;
+    }
+
+    class GarbageRing {
+        GarbageRing() {
+            attachment = new Garbage(0);
+        }
+
+        void add(int size) {
+            Garbage head = attachment.getNext();
+            Garbage g = new Garbage(size);
+            if (head != null) {
+                Garbage oldNext = head.getNext();
+                if (oldNext != null) {
+                    g.setNext(oldNext);
+                    head.setNext(g);
+                    attachment.setNext(g);
+                } else {
+                    g.setNext(head);
+                    head.setNext(g);
+                }
+            } else
+                attachment.setNext(g);
+        }
+
+        void discard() {
+            attachment.setNext(null);
+        }
+
+        private byte[] memory;
+        private Garbage attachment;
+    }
+
+    public void run() {
+        GarbageRing gr = new GarbageRing();
+        int g = 0;
+        while (!done) {
+            for (g = 0; g < ringSize; g++) {
+                gr.add(allocSize);
+                yield();
+            }
+            gr.discard();
+            try {
+                sleep(interval);
+            } catch (InterruptedException e) {
+            }
+        }
+        if (DEBUG) System.out.println("GarbageRing::run(): done");
+    }
+
+    public void setAllocSize(int i) {
+        allocSize = i;
+    }
+
+    public int getAllocSize() {
+        return allocSize;
+    }
+
+    public void setInterval(int i) {
+        interval = i;
+    }
+
+    public int getInterval() {
+        return interval;
+    }
+
+    public void halt() {
+        done = true;
+    }
+
+    private int allocSize = 10000;
+    private int ringSize = 50;
+    private int interval = 1000;
+    private boolean done = false;
+    final private static boolean DEBUG = false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/Interrupter.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 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.stress.jni;
+
+class Interrupter extends Thread {
+    public Interrupter(
+            Thread[] alloc,
+            Synchronizer[] s
+    ) {
+        targets = alloc;
+        sync = s;
+        if (DEBUG) System.out.println("Interrupter created.");
+    }
+
+    public void run() {
+        while (!done) {
+            synchronized (sync[2]) {
+                targets[turn].interrupt();
+            }
+            turn = (turn + 1) % targets.length;
+            try {
+                sleep(interval);
+            } catch (InterruptedException e) {
+            }
+        }
+        if (DEBUG) System.out.println("Interrupter::run(): done");
+    }
+
+    public void setInterval(int i) {
+        interval = i;
+    }
+
+    public int getInterval() {
+        return interval;
+    }
+
+    public void halt() {
+        done = true;
+    }
+
+    Thread[] targets;
+    Synchronizer[] sync;
+    private int turn = 0;
+    private int interval = 1000;
+    private boolean done = false;
+    final private static boolean DEBUG = false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/Synchronizer.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 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.stress.jni;
+
+class Synchronizer {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/TEST.properties	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 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.
+#
+
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/gclocker/gcl001.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,499 @@
+/*
+ * 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.
+ */
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/jni/gclocker/gcl001.
+ * VM testbase keywords: [stress, quick, feature_283, nonconcurrent, exclude]
+ * VM testbase comments: JDK-8199562
+ * VM testbase readme:
+ * DESCRIPTION
+ *     Check compatibility of GC Locker improvements with JNI CS
+ * Two types of concurrent threads are present:
+ * A) Create N 'JNI CS' threads. Each of them will:
+ *    1. Create primitive array and string with random data
+ *    2. Pass it to native method
+ *    3. Sort/Hash data in JNI CS mixing string and array critical sections
+ *    4. Check isCopy == false
+ *    5. Return from native
+ *    6. Check data to be processed correctly
+ * B) Create M ' Garbage producer/memory allocation' threads. Each of them will:
+ *    1. Allocate memory blocks and make them garbage.
+ *    2. Check for OOM errors.
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @ignore JDK-8199562
+ * @run main/othervm/native/timeout=480
+ *      -XX:-UseGCOverheadLimit
+ *      nsk.stress.jni.gclocker.gcl001
+ *      -stressThreadsFactor 8
+ */
+
+package nsk.stress.jni.gclocker;
+
+import nsk.share.gc.GC;
+import nsk.share.gc.ThreadedGCTest;
+import nsk.share.gc.gp.array.BooleanArrayProducer;
+import nsk.share.gc.gp.array.ByteArrayProducer;
+import nsk.share.gc.gp.array.CharArrayProducer;
+import nsk.share.gc.gp.array.DoubleArrayProducer;
+import nsk.share.gc.gp.array.FloatArrayProducer;
+import nsk.share.gc.gp.array.IntArrayProducer;
+import nsk.share.gc.gp.array.LongArrayProducer;
+import nsk.share.gc.gp.array.ShortArrayProducer;
+import nsk.share.test.ExecutionController;
+import nsk.share.test.LocalRandom;
+
+import java.util.Random;
+
+public class gcl001 extends ThreadedGCTest {
+
+    static {
+        System.loadLibrary("gcl001");
+    }
+
+    int maxBlockSize;
+
+    public static void main(String[] args) {
+        GC.runTest(new gcl001(), args);
+    }
+
+    @Override
+    public void run() {
+        // each thread have only one block at the time
+        // so we should occupy less then 60% of heap with live objects
+        long maxSize = runParams.getTestMemory() / runParams.getNumberOfThreads();
+        if (maxSize > Integer.MAX_VALUE - 1) {
+            maxSize = Integer.MAX_VALUE - 1;
+        }
+        maxBlockSize = (int) maxSize;
+        log.info("Maximium block size = " + maxBlockSize);
+        super.run();
+    }
+
+    @Override
+    protected Runnable createRunnable(int i) {
+        if (i < runParams.getNumberOfThreads() / 2) {
+            return CreateJNIWorker(i, maxBlockSize);
+        } else {
+            return new GarbageProducer(maxBlockSize);
+        }
+    }
+
+    public Runnable CreateJNIWorker(int number, int size) {
+        JNIAbstractWorker worker = null;
+        switch (number % 8) {
+            case 0:
+                worker = new JNIBooleanWorker(size);
+                break;
+            case 1:
+                worker = new JNIByteWorker(size);
+                break;
+            case 2:
+                worker = new JNICharWorker(size);
+                break;
+            case 3:
+                worker = new JNIShortWorker(size);
+                break;
+            case 4:
+                worker = new JNIIntWorker(size);
+                break;
+            case 5:
+                worker = new JNILongWorker(size);
+                break;
+            case 6:
+                worker = new JNIFloatWorker(size);
+                break;
+            case 7:
+                worker = new JNIDoubleWorker(size);
+                break;
+        }
+        return worker;
+    }
+
+    int random(int maxSize) {
+        int res = LocalRandom.nextInt(maxSize);
+        return res > 128 ? res : 128;
+    }
+
+    public static Object tmp;
+
+    class GarbageProducer implements Runnable {
+
+        private int maxSize;
+        ExecutionController stresser;
+        ByteArrayProducer bp;
+
+        GarbageProducer(int size) {
+            this.maxSize = size;
+            bp = new ByteArrayProducer();
+        }
+
+        public void run() {
+            if (stresser == null) {
+                stresser = getExecutionController();
+            }
+
+            while (stresser.continueExecution()) {
+                try {
+                    byte[] arr = bp.create(random(maxSize));
+                    tmp = arr;
+                } catch (OutOfMemoryError oome) {
+                    // Do nothing.
+                }
+            }
+        }
+    }
+
+    abstract class JNIAbstractWorker extends JNIWorker implements Runnable {
+
+        ExecutionController stresser;
+        private int maxSize;
+
+        public JNIAbstractWorker(int maxSize) {
+            this.maxSize = maxSize;
+        }
+
+        public void check(boolean condition, String message) {
+            if (!condition) {
+                throw new Error(message);
+            }
+        }
+
+        abstract void doit(int size);
+
+        public void run() {
+            // create array with random elements
+            // store min and max element for further check
+            // create new string
+            // call JNI methods
+            // check min/max as sort result
+            // check string hash
+
+            if (stresser == null) {
+                stresser = getExecutionController();
+            }
+            while (stresser.continueExecution()) {
+                // let make at least several values for long/float
+                try {
+                    doit(random(maxSize));
+                } catch (OutOfMemoryError oome) {
+                    // Do nothing.
+                }
+            }
+        }
+    }
+
+    // BYTE
+    class JNIBooleanWorker extends JNIAbstractWorker {
+
+        BooleanArrayProducer gp = new BooleanArrayProducer();
+
+        public JNIBooleanWorker(int size) {
+            super(size);
+        }
+
+        void doit(int size) {
+
+            boolean[] array = gp.create(size);
+            // just to be sure that we have true & false
+            array[0] = true;
+            array[array.length - 1] = false;
+            String str = "unsupported";
+            int nativeHash = NativeCall(array, str);
+            int javaHash = 0;
+            for (int i = 0; i < str.length(); ++i) {
+                javaHash += (int) str.charAt(i);
+            }
+            check(array[0] == false && array[array.length - 1] == true
+                    && javaHash == nativeHash, "Data validation failure");
+
+        }
+    }
+
+    class JNIByteWorker extends JNIAbstractWorker {
+
+        ByteArrayProducer gp = new ByteArrayProducer();
+
+        public JNIByteWorker(int size) {
+            super(size);
+        }
+
+        void doit(int size) {
+
+            byte[] array = gp.create(size);
+            byte min = Byte.MAX_VALUE, max = Byte.MIN_VALUE;
+            for (int i = 0; i < array.length; ++i) {
+                if (array[i] > max) {
+                    max = array[i];
+                }
+
+                if (array[i] < min) {
+                    min = array[i];
+                }
+            }
+            String str = "Min: " + min + " Max: " + max;
+            int nativeHash = NativeCall(array, str);
+            int javaHash = 0;
+            for (int i = 0; i < str.length(); ++i) {
+                javaHash += (int) str.charAt(i);
+            }
+
+            check(array[0] == min && array[array.length - 1] == max
+                    && javaHash == nativeHash, "Data validation failure");
+
+        }
+    }
+
+    // CHAR
+    class JNICharWorker extends JNIAbstractWorker {
+
+        CharArrayProducer gp = new CharArrayProducer();
+
+        public JNICharWorker(int size) {
+            super(size);
+        }
+
+        void doit(int size) {
+            char[] array = gp.create(size);
+            Random rand = new Random();
+            char min = 0xffff, max = 0;
+            for (int i = 0; i < array.length; ++i) {
+                array[i] = (char) rand.nextInt();
+                if (array[i] > max) {
+                    max = array[i];
+                }
+
+                if (array[i] < min) {
+                    min = array[i];
+                }
+            }
+            String str = "Min: " + min + " Max: " + max;
+            int nativeHash = NativeCall(array, str);
+            int javaHash = 0;
+            for (int i = 0; i < str.length(); ++i) {
+                javaHash += (int) str.charAt(i);
+            }
+
+            check(array[0] == min && array[array.length - 1] == max
+                    && javaHash == nativeHash, "Data validation failure");
+
+        }
+    }
+
+    // SHORT
+    class JNIShortWorker extends JNIAbstractWorker {
+
+        ShortArrayProducer gp = new ShortArrayProducer();
+
+        public JNIShortWorker(int size) {
+            super(size);
+        }
+
+        void doit(int size) {
+
+            short[] array = gp.create(size);
+            short min = Short.MAX_VALUE, max = Short.MIN_VALUE;
+            for (int i = 0; i < array.length; ++i) {
+                if (array[i] > max) {
+                    max = array[i];
+                }
+
+                if (array[i] < min) {
+                    min = array[i];
+                }
+            }
+            String str = "Min: " + min + " Max: " + max;
+            int nativeHash = NativeCall(array, str);
+            int javaHash = 0;
+            for (int i = 0; i < str.length(); ++i) {
+                javaHash += (int) str.charAt(i);
+            }
+
+            check(array[0] == min && array[array.length - 1] == max
+                    && javaHash == nativeHash, "Data validation failure");
+        }
+    }
+
+    // INT
+    class JNIIntWorker extends JNIAbstractWorker {
+
+        IntArrayProducer gp = new IntArrayProducer();
+
+        public JNIIntWorker(int size) {
+            super(size);
+        }
+
+        void doit(int size) {
+            int[] array = gp.create(size);
+            int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
+            for (int i = 0; i < array.length; ++i) {
+                if (array[i] > max) {
+                    max = array[i];
+                }
+
+                if (array[i] < min) {
+                    min = array[i];
+                }
+            }
+            String str = "Min: " + min + " Max: " + max;
+            int nativeHash = NativeCall(array, str);
+            int javaHash = 0;
+            for (int i = 0; i < str.length(); ++i) {
+                javaHash += (int) str.charAt(i);
+            }
+
+            check(array[0] == min && array[array.length - 1] == max
+                    && javaHash == nativeHash, "Data validation failure");
+
+        }
+    }
+
+    // LONG
+    class JNILongWorker extends JNIAbstractWorker {
+
+        LongArrayProducer gp = new LongArrayProducer();
+
+        public JNILongWorker(int size) {
+            super(size);
+        }
+
+        void doit(int size) {
+
+            long[] array = gp.create(size);
+            long min = Long.MAX_VALUE, max = Long.MIN_VALUE;
+            for (int i = 0; i < array.length; ++i) {
+                if (array[i] > max) {
+                    max = array[i];
+                }
+
+                if (array[i] < min) {
+                    min = array[i];
+                }
+            }
+            String str = "Min: " + min + " Max: " + max;
+            int nativeHash = NativeCall(array, str);
+            int javaHash = 0;
+            for (int i = 0; i < str.length(); ++i) {
+                javaHash += (int) str.charAt(i);
+            }
+
+            check(array[0] == min && array[array.length - 1] == max
+                    && javaHash == nativeHash, "Data validation failure");
+
+        }
+    }
+
+    // FLOAT
+    class JNIFloatWorker extends JNIAbstractWorker {
+
+        FloatArrayProducer gp = new FloatArrayProducer();
+
+        public JNIFloatWorker(int size) {
+            super(size);
+        }
+
+        void doit(int size) {
+
+            float[] array = gp.create(size);
+            float min = Float.MAX_VALUE, max = Float.MIN_VALUE;
+            for (int i = 0; i < array.length; ++i) {
+                if (array[i] > max) {
+                    max = array[i];
+                }
+
+                if (array[i] < min) {
+                    min = array[i];
+                }
+            }
+            String str = "Min: " + min + " Max: " + max;
+            int nativeHash = NativeCall(array, str);
+            int javaHash = 0;
+            for (int i = 0; i < str.length(); ++i) {
+                javaHash += (int) str.charAt(i);
+            }
+
+            check(array[0] == min && array[array.length - 1] == max
+                    && javaHash == nativeHash, "Data validation failure");
+        }
+    }
+
+    // DOUBLE
+    class JNIDoubleWorker extends JNIAbstractWorker {
+
+        DoubleArrayProducer gp = new DoubleArrayProducer();
+
+        public JNIDoubleWorker(int size) {
+            super(size);
+        }
+
+        void doit(int size) {
+
+            double[] array = gp.create(size);
+            Random rand = new Random();
+            double min = Double.MAX_VALUE, max = Double.MIN_VALUE;
+            for (int i = 0; i < array.length; ++i) {
+                if (array[i] > max) {
+                    max = array[i];
+                }
+
+                if (array[i] < min) {
+                    min = array[i];
+                }
+            }
+            String str = "Min: " + min + " Max: " + max;
+            int nativeHash = NativeCall(array, str);
+            int javaHash = 0;
+            for (int i = 0; i < str.length(); ++i) {
+                javaHash += (int) str.charAt(i);
+            }
+
+            check(array[0] == min && array[array.length - 1] == max
+                    && javaHash == nativeHash, "Data validation failure");
+        }
+    }
+}
+
+class JNIWorker {
+
+    protected native int NativeCall(boolean[] array, String str);
+
+    protected native int NativeCall(byte[] array, String str);
+
+    protected native int NativeCall(char[] array, String str);
+
+    protected native int NativeCall(short[] array, String str);
+
+    protected native int NativeCall(int[] array, String str);
+
+    protected native int NativeCall(long[] array, String str);
+
+    protected native int NativeCall(float[] array, String str);
+
+    protected native int NativeCall(double[] array, String str);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/gclocker/libgcl001.c	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,200 @@
+/*
+ * 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 <jni.h>
+#include <stdlib.h>
+#include "jnihelper.h"
+
+// compare most java primitive value types
+#define COMP(type) \
+int type##comp(const void *s1, const void *s2)\
+{\
+    type st1 = *((type *)s1);\
+    type st2 = *((type *)s2);\
+    if (st1 < st2)\
+        return -1;\
+    else if (st1 > st2)\
+        return 1;\
+    else\
+        return 0;\
+}
+
+// basic routine: provide critical sections and calculations
+    // enter array CS
+    // check isCopy for native referencing
+    // enter first string CS
+    // leave first string CS
+    // enter second string CS
+    // leave array CS
+    // enter second string CS
+
+#define BODY(type) \
+int hash = 0; int i; jboolean isCopy = JNI_FALSE; jchar *nativeStr; jsize size; type *nativeArray; \
+size = (*env)->GetArrayLength(env, array); CE \
+nativeArray = (type *)(*env)->GetPrimitiveArrayCritical(env, array, &isCopy); CE \
+EnterCS(env); \
+if (isCopy == JNI_TRUE) return 0;\
+qsort(nativeArray, size, sizeof(type), *type##comp);\
+\
+size = (*env)->GetStringLength(env, str); CE \
+nativeStr = (jchar *)(*env)->GetStringCritical(env, str, &isCopy); CE \
+if (isCopy == JNI_TRUE) return 0;\
+for (i = 0; i < size; ++i)\
+    hash += (int)nativeStr[i];\
+\
+(*env)->ReleasePrimitiveArrayCritical(env, array, nativeArray, 0); CE \
+LeaveCS(env); \
+(*env)->ReleaseStringCritical(env, str, nativeStr); CE \
+\
+hash = 0;\
+size = (*env)->GetStringLength(env, str); CE \
+nativeStr = (jchar *)(*env)->GetStringCritical(env, str, &isCopy); CE \
+EnterCS(env); \
+if (isCopy == JNI_TRUE) return 0;\
+for (i = 0; i < size; ++i)\
+    hash += (int)nativeStr[i];\
+LeaveCS(env); \
+(*env)->ReleaseStringCritical(env, str, nativeStr); CE \
+return hash;
+
+static int CSEntered = 0;
+static int CSLeft = 0;
+
+void EnterCS(JNIEnv *env)
+{
+    // unsafe but where are no better ideas
+    //++CSEntered;
+    //printf("CS Entered -> Entered: %d\n", CSEntered);
+//    jclass trace = 0; jmethodID method = 0;
+//    trace = (*env)->FindClass(env, "nsk/stress/jni/gclocker/Trace"); CE
+//    method = (*env)->GetStaticMethodID(env, trace, "EnterCS", "()V"); CE
+//    (*env)->CallStaticVoidMethod(env, trace, method); CE
+}
+
+void LeaveCS(JNIEnv *env)
+{
+    // unsafe but where are no better ideas
+    //++CSLeft;
+    //printf("CS Left -> Completed: %d\tActive: %d\n", CSLeft, CSEntered - CSLeft);
+//    jclass trace = 0; jmethodID method = 0;
+//    trace = (*env)->FindClass(env, "nsk/stress/jni/gclocker/Trace"); CE
+//    method = (*env)->GetStaticMethodID(env, trace, "LeaveCS", "()V"); CE
+//    (*env)->CallStaticVoidMethod(env, trace, method); CE
+}
+
+COMP(jint)
+COMP(jboolean)
+COMP(jchar)
+COMP(jshort)
+COMP(jbyte)
+COMP(jdouble)
+COMP(jfloat)
+COMP(jlong)
+
+/*
+ * Class:     JNIWorker
+ * Method:    NativeCall
+ * Signature: ([ZLjava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_nsk_stress_jni_gclocker_JNIWorker_NativeCall___3ZLjava_lang_String_2
+  (JNIEnv * env, jobject obj, jbooleanArray array, jstring str)
+{
+    BODY(jboolean)
+}
+
+/*
+ * Class:     JNIWorker
+ * Method:    NativeCall
+ * Signature: ([BLjava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_nsk_stress_jni_gclocker_JNIWorker_NativeCall___3BLjava_lang_String_2
+  (JNIEnv * env, jobject obj, jbyteArray array, jstring str)
+{
+    BODY(jbyte)
+}
+
+/*
+ * Class:     JNIWorker
+ * Method:    NativeCall
+ * Signature: ([CLjava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_nsk_stress_jni_gclocker_JNIWorker_NativeCall___3CLjava_lang_String_2
+  (JNIEnv *env, jobject obj, jcharArray array, jstring str)
+{
+    BODY(jchar)
+}
+
+/*
+ * Class:     JNIWorker
+ * Method:    NativeCall
+ * Signature: ([SLjava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_nsk_stress_jni_gclocker_JNIWorker_NativeCall___3SLjava_lang_String_2
+  (JNIEnv *env, jobject obj, jshortArray array, jstring str)
+{
+    BODY(jshort)
+}
+
+/*
+ * Class:     JNIWorker
+ * Method:    NativeCall
+ * Signature: ([ILjava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_nsk_stress_jni_gclocker_JNIWorker_NativeCall___3ILjava_lang_String_2
+  (JNIEnv *env, jobject obj, jintArray array, jstring str)
+{
+    BODY(jint)
+}
+
+/*
+ * Class:     JNIWorker
+ * Method:    NativeCall
+ * Signature: ([JLjava/lang/String;)I
+ */
+
+JNIEXPORT jint JNICALL Java_nsk_stress_jni_gclocker_JNIWorker_NativeCall___3JLjava_lang_String_2
+  (JNIEnv *env, jobject obj, jlongArray array, jstring str)
+{
+    BODY(jlong)
+}
+
+/*
+ * Class:     JNIWorker
+ * Method:    NativeCall
+ * Signature: ([FLjava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_nsk_stress_jni_gclocker_JNIWorker_NativeCall___3FLjava_lang_String_2
+  (JNIEnv *env, jobject obj, jfloatArray array, jstring str)
+{
+    BODY(jfloat)
+}
+
+/*
+ * Class:     JNIWorker
+ * Method:    NativeCall
+ * Signature: ([DLjava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_nsk_stress_jni_gclocker_JNIWorker_NativeCall___3DLjava_lang_String_2
+  (JNIEnv *env, jobject obj, jdoubleArray array, jstring str)
+{
+    BODY(jdouble)
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnihelper.h	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+// Asserts every exception as fatal one
+#define CE {\
+    if ((*env)->ExceptionOccurred(env))\
+    {\
+        puts("Unexpected JNI exception. TEST FAIL.");     \
+        (*env)->ExceptionDescribe(env);                   \
+        (*env)->ExceptionClear(env);\
+        (*env)->FatalError(env, "Unexpected JNI Exception. TEST FAIL."); \
+    }\
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnistress001.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,492 @@
+/*
+ * 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.
+ */
+
+/*
+ * jnistress001 is a class that sets up classes that do the work
+ * for the test.
+ *
+ * The Interrupter objects send interrupts to the JNIters.
+ * The GarbageGenerator objects generate garbage.
+ *
+ * sync[0] synchronizes the test cycles.
+ * sync[1] synchronizes access to exception counters.
+ * sync[2] synchronizes the cycle count update.  It also insures that
+ *         the interrupts do not interfere with the cycle count updates.
+ *         This is because cycle count updates are used to define cycles.
+ */
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/jni/jnistress001.
+ * VM testbase keywords: [stress, quick, feature_283, nonconcurrent]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.stress.jni.jnistress001
+ *      -numTHREADer 20
+ *      -threadInterval 200
+ *      -numInterrupter 2
+ *      -interruptInterval 500
+ *      -numGarbage 80
+ *      -garbageInterval 5
+ *      -numIteration 200
+ */
+
+package nsk.stress.jni;
+
+import nsk.share.Consts;
+import nsk.share.Debug;
+import nsk.share.test.StressOptions;
+
+public class jnistress001 extends Thread {
+
+    /* Maximum number of iterations.    Ignored if <= 0L */
+    static long numIteration = 0L;
+    /* Timeout */
+    static long timeOut;
+    /* Number of test class objects */
+    static int numJNIter = 1;
+    /* Time between JNI stressing by the threads under test */
+    /* (in milliseconds) */
+    static int jniInterval = 10000;
+    /* Number of interrupting threads */
+    static int numInterrupter = 1;
+    /* Time between interrupts in milliseconds */
+    static int interruptInterval = 1000;
+    /* Number of garbage generating threads */
+    static int numGarbage = 1;
+    /* Time between garbage allocations in milliseconds */
+    static int garbageInterval = 1000;
+    // Size of string's array in native method
+    static int jniStringAllocSize = 1000;
+    // Print period for native method
+    static int printPeriod = 200;
+
+    private static StressOptions stressOptions;
+
+    public static void main(String[] argv) {
+        try {
+            int i = 0;
+            int nJNISync = 10;
+            jnistress001 dm = null;
+            boolean errArg = false;
+
+            stressOptions = new StressOptions(argv);
+
+        /* Process arguments */
+            while (!errArg && i < argv.length) {
+            /* Number of iterations. Ignored if <= 0. */
+                if (i < argv.length && argv[i].equals("-numIteration")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numIteration = Long.parseLong(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numTHREADer")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numJNIter = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                        if (numJNIter <= 0) errArg = true;
+                    }
+                } else if (i < argv.length && argv[i].equals("-threadInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            jniInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numInterrupter")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numInterrupter = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-interruptInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            interruptInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numGarbage")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numGarbage = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-garbageInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            garbageInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-jniStringAllocSize")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            jniStringAllocSize = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-printperiod")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            printPeriod = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].startsWith("-stress")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        ++i;
+                    }
+                } else System.out.println("Argument #" + i++ + " is incorrect");
+
+            }
+
+            numIteration *= stressOptions.getIterationsFactor();
+            numJNIter *= stressOptions.getThreadsFactor();
+            numInterrupter *= stressOptions.getThreadsFactor();
+            numGarbage *= stressOptions.getThreadsFactor();
+            timeOut = stressOptions.getTime() * 1000;
+
+            sync = new Synchronizer[10];
+            for (i = 0; i < nJNISync; i++)
+                sync[i] = new Synchronizer();
+            dm = new jnistress001(numIteration, numJNIter, jniInterval,
+                    numInterrupter, interruptInterval, numGarbage, garbageInterval);
+            dm.start();
+
+            try {
+                dm.join(timeOut);
+            } catch (InterruptedException e) {
+                System.out.println("TESTER THREAD WAS INTERRUPTED");
+                System.exit(Consts.TEST_FAILED);
+            }
+
+            if (DEBUG) System.out.println("jnistress001::main(): halt!");
+
+            if (dm.isAlive()) {
+                System.out.println("TIME LIMIT EXCEEDED");
+                dm.halt();
+                if (DEBUG) System.out.println("jnistress001::main(): join!");
+                try {
+                    dm.join(10000L);
+                } catch (InterruptedException e) {
+                    System.out.println("TESTER THREAD WAS INTERRUPTED");
+                    System.exit(Consts.TEST_FAILED);
+                }
+            } else {
+                System.out.println("TESTER THREAD FINISHED");
+            }
+
+            if (DEBUG) System.out.println("jnistress001::main(): zzzz...");
+
+            if (!JNIter001.passed())
+                System.exit(Consts.TEST_FAILED);
+
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    jnistress001(
+            long iters,
+            int nJNI,
+            int jniInterval,
+            int nInter,
+            int iruptInterval,
+            int nGarb,
+            int garbInterval
+    ) {
+        int i = 0;
+        nCycles = iters;
+        /* Should have at least one of nCycles>0 */
+        if (nCycles <= 0) nCycles = Long.MAX_VALUE;
+        jniter = new JNIter001[nJNI];
+        interval = jniInterval;
+        irupt = new Interrupter[nInter];
+        garb = new GarbageGenerator[nGarb];
+        for (i = 0; i < nJNI; i++)
+            jniter[i] = new JNIter001(sync);
+        for (i = 0; i < nInter; i++) {
+            irupt[i] = new Interrupter(jniter, sync);
+            irupt[i].setInterval(iruptInterval);
+        }
+        for (i = 0; i < nGarb; i++) {
+            garb[i] = new GarbageGenerator();
+            garb[i].setInterval(garbInterval);
+        }
+    }
+
+    public void run() {
+        int i = 0;
+        long iCycle = 0L;
+        JNIter001.clearCount();
+        JNIter001.clearInterruptCount();
+        for (i = 0; i < jniter.length; i++)
+            jniter[i].start();
+
+        while (JNIter001.getCount() < jniter.length) {
+            try {
+                sleep(100);
+            } catch (InterruptedException e) {
+            }
+        }
+        JNIter001.clearCount();
+        // JNIter001.clearInterruptCount();
+        synchronized (sync[0]) {
+            sync[0].notifyAll();
+        }
+
+        for (i = 0; i < garb.length; i++)
+            garb[i].start();
+        for (i = 0; i < irupt.length; i++)
+            irupt[i].start();
+
+        if (DEBUG) System.out.println("Cycles=" + nCycles);
+        for (iCycle = 0; iCycle < nCycles && !done && JNIter001.passed(); iCycle++) {
+            System.out.print("Cycle: " + iCycle);
+            try {
+                sleep(interval);
+            } catch (InterruptedException e) {
+            }
+            synchronized (sync[1]) {
+                System.out.println("    Interrupt count=" +
+                        JNIter001.getInterruptCount());
+            }
+            JNIter001.clearCount();
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+            int n = 0;
+            for (i = 0; i < jniter.length; i++)
+                if (jniter[i].finished()) n++;
+            if (n == jniter.length) break;
+        }
+        if (JNIter001.passed()) {  /* Use of setpass was backwards */
+            System.out.println("JNI TEST PASSED");
+        } else {
+            System.out.println("JNI TEST FAILED");
+        }
+        for (i = 0; i < irupt.length; i++)
+            irupt[i].halt();
+        for (i = 0; i < garb.length; i++)
+            garb[i].halt();
+        for (i = 0; i < jniter.length; i++)
+            jniter[i].halt();
+        /* Flush any waiters */
+        if (DEBUG) System.out.println("jnistress001::run(): before sync[0]");
+        synchronized (sync[0]) {
+            sync[0].notifyAll();
+        }
+        if (DEBUG) System.out.println("jnistress001::run(): after sync[0]");
+        for (i = 0; i < irupt.length; i++) {
+            try {
+                irupt[i].join();
+            } catch (InterruptedException e) {
+            }
+        }
+        if (DEBUG) System.out.println("jnistress001::run(): X");
+        for (i = 0; i < garb.length; i++) {
+            try {
+                garb[i].join();
+            } catch (InterruptedException e) {
+            }
+        }
+        if (DEBUG) System.out.println("jnistress001::run(): Y");
+        System.out.println("jniter.length is " + jniter.length);
+        for (i = 0; i < jniter.length; i++) {
+            try {
+                if (jniter[i].isAlive()) {
+                    jniter[i].join();
+                }
+            } catch (InterruptedException e) {
+            }
+        }
+        if (DEBUG) System.out.println("jnistress001::run(): Z");
+    }
+
+    public void halt() {
+        done = true;
+    }
+
+    public boolean finished() {
+        return done;
+    }
+
+    long nCycles = 0;
+    JNIter001[] jniter;
+    static Synchronizer[] sync;
+    private int interval = 100;
+    Interrupter[] irupt;
+    GarbageGenerator[] garb;
+    private boolean done = false;
+    final private static boolean DEBUG = false;
+}
+
+class JNIter001 extends Thread {
+
+    // The native method for testing JNI UTF-8 calls
+    public native String jnistress(String threadName, int nstr, int printPeriod);
+
+    // The native method for testing JNI Unicode calls
+    public native String jnistress1(String threadName, int nstr, int printPeriod);
+
+    static {
+        System.loadLibrary("jnistress001");
+    }
+
+    public JNIter001(Synchronizer[] aSync) {
+        sync = aSync;
+    }
+
+    public void run() {
+        int iter = 0;
+
+        /* Synchronize start of work */
+        incCount();
+        synchronized (sync[0]) {
+            try {
+                sync[0].wait();
+            } catch (InterruptedException e) {
+            }
+        }
+        while (!done && pass) {
+            try {
+                /* Synchronized the JNI stressing */
+                synchronized (sync[2]) {
+                    incCount();
+                }
+                synchronized (sync[0]) {
+                    try {
+                        sync[0].wait();
+                    } catch (InterruptedException e) {
+                        synchronized (sync[1]) {
+                            JNIter001.incInterruptCount();
+                        }
+                    }
+                }
+                synchronized (sync[0]) {
+                    String s1 = jnistress(getName(),
+                            jnistress001.jniStringAllocSize,
+                            jnistress001.printPeriod);
+                    String s2 = jnistress1(getName(),
+                            jnistress001.jniStringAllocSize,
+                            jnistress001.printPeriod);
+                    if (!s1.equals(s2))
+                        System.out.println("Wrong compare in thread " + getName());
+                }
+                if (DEBUG)
+                    System.out.println("We have " + activeCount() +
+                            " threads now.");
+            } catch (Exception e) {
+                synchronized (sync[1]) {
+                    JNIter001.incInterruptCount();
+                }
+            }
+            iter++;
+            iter = iter % CASECOUNT;
+        }
+        if (DEBUG) System.out.println("JNITer::run(): done=" + done);
+        done = true;
+        if (DEBUG) System.out.println("JNITer::run(): pass=" + JNIter001.pass);
+        if (DEBUG) System.out.println("JNITer::run(): done");
+    }
+
+    private synchronized static void incCount() {
+        count++;
+    }
+
+    public static int getCount() {
+        return count;
+    }
+
+    public synchronized static void clearCount() {
+        count = 0;
+    }
+
+    private synchronized static void incInterruptCount() {
+        interruptCount++;
+    }
+
+    public static int getInterruptCount() {
+        return interruptCount;
+    }
+
+    public synchronized static void clearInterruptCount() {
+        interruptCount = 0;
+    }
+
+    public static void halt() {
+        done = true;
+    }
+
+    public boolean finished() {
+        return done;
+    }
+
+    public static boolean passed() {
+        return pass;
+    }
+
+    public static void setpass(boolean value) {
+        pass = value;
+    }
+
+    Synchronizer[] sync;
+    private static int count = 0;
+    private static int interruptCount = 0;
+    private static boolean done = false;
+    private static boolean pass = true;
+    final private static int CASECOUNT = 2;
+    final private static boolean DEBUG = false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnistress002.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,582 @@
+/*
+ * 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.
+ */
+
+/*
+ * jnistress002 is a class that sets up classes that do the work
+ * for the test.
+ *
+ * The Interrupter objects send interrupts to the JNIters.
+ * The GarbageGenerator objects generate garbage.
+ *
+ * sync[0] synchronizes the test cycles.
+ * sync[1] synchronizes access to exception counters.
+ * sync[2] synchronizes the cycle count update. It also insures that
+ * the interrupts do not interfere with the cycle count updates.
+ * This is because cycle count updates are used to define cycles.
+ */
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/jni/jnistress002.
+ * VM testbase keywords: [stress, quick, feature_283, nonconcurrent]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.stress.jni.jnistress002
+ *      -numTHREADer 20
+ *      -threadInterval 200
+ *      -numInterrupter 2
+ *      -interruptInterval 500
+ *      -numGarbage 80
+ *      -garbageInterval 5
+ *      -numIteration 260
+ */
+
+package nsk.stress.jni;
+
+import nsk.share.Consts;
+import nsk.share.Debug;
+import nsk.share.test.StressOptions;
+
+import java.lang.reflect.Field;
+import java.util.Random;
+
+public class jnistress002 extends Thread {
+
+    /* Maximum number of iterations.    Ignored if <= 0L */
+    static long numIteration = 0L;
+    /* Timeout */
+    static long timeOut;
+    /* Number of test class objects */
+    static int numJNIter = 1;
+    /* Time between JNI stressing by the threads under test */
+    /* (in milliseconds) */
+    static int jniInterval = 10000;
+    /* Number of interrupting threads */
+    static int numInterrupter = 1;
+    /* Time between interrupts in milliseconds */
+    static int interruptInterval = 100;
+    /* Number of garbage generating threads */
+    static int numGarbage = 1;
+    /* Time between garbage allocations in milliseconds */
+    static int garbageInterval = 100;
+    // The number of classes for creates via JNI
+    static int jniStringAllocSize = 10000;
+
+    private static StressOptions stressOptions;
+
+    public static void main(String[] argv) {
+        try {
+            int i = 0;
+            int nJNISync = 10;
+            jnistress002 dm = null;
+            boolean errArg = false;
+
+            stressOptions = new StressOptions(argv);
+
+                /* Process arguments */
+            while (!errArg && i < argv.length) {
+                    /* Number of iterations. Ignored if <= 0. */
+                if (i < argv.length && argv[i].equals("-numIteration")) {
+                    ++i;
+                    if (i < argv.length) {
+                        try {
+                            numIteration = Long.parseLong(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numTHREADer")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numJNIter = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                        if (numJNIter <= 0) errArg = true;
+                    }
+                } else if (i < argv.length && argv[i].equals("-threadInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            jniInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numInterrupter")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numInterrupter = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-interruptInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            interruptInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numGarbage")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numGarbage = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-garbageInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            garbageInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-jniStringAllocSize")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            jniStringAllocSize = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].startsWith("-stress")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        ++i;
+                    }
+                } else System.out.println("Argument #" + i++ + " is incorrect");
+            }
+
+            numIteration *= stressOptions.getIterationsFactor();
+            numJNIter *= stressOptions.getThreadsFactor();
+            numInterrupter *= stressOptions.getThreadsFactor();
+            numGarbage *= stressOptions.getThreadsFactor();
+            timeOut = stressOptions.getTime() * 1000;
+
+            sync = new Synchronizer[10];
+            for (i = 0; i < nJNISync; i++)
+                sync[i] = new Synchronizer();
+            dm = new jnistress002(numIteration, numJNIter, jniInterval,
+                    numInterrupter, interruptInterval, numGarbage, garbageInterval);
+            dm.start();
+
+            try {
+                dm.join(timeOut);
+            } catch (InterruptedException e) {
+                System.out.println("TESTER THREAD WAS INTERRUPTED");
+                System.exit(Consts.TEST_FAILED);
+            }
+
+            if (DEBUG) System.out.println("jnistress002::main(): halt!");
+
+            if (dm.isAlive()) {
+                System.out.println("TIME LIMIT EXCEEDED");
+                dm.halt();
+                if (DEBUG) System.out.println("jnistress002::main(): join!");
+                try {
+                    dm.join(10000L);
+                } catch (InterruptedException e) {
+                    System.out.println("TESTER THREAD WAS INTERRUPTED");
+                    System.exit(Consts.TEST_FAILED);
+                }
+            } else {
+                System.out.println("TESTER THREAD FINISHED");
+            }
+
+            if (DEBUG) System.out.println("jnistress002::main(): zzzz...");
+
+            if (!JNIter002.passed())
+                System.exit(Consts.TEST_FAILED);
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    jnistress002(
+            long iters,
+            int nJNI,
+            int jniInterval,
+            int nInter,
+            int iruptInterval,
+            int nGarb,
+            int garbInterval
+    ) {
+        int i = 0;
+        nCycles = iters;
+        /* Should have at least one of nCycles>0 */
+        if (nCycles <= 0) nCycles = Long.MAX_VALUE;
+        jniter = new JNIter002[nJNI];
+        interval = jniInterval;
+        irupt = new Interrupter[nInter];
+        garb = new GarbageGenerator[nGarb];
+        for (i = 0; i < nJNI; i++)
+            jniter[i] = new JNIter002(sync);
+        for (i = 0; i < nInter; i++) {
+            irupt[i] = new Interrupter(jniter, sync);
+            irupt[i].setInterval(iruptInterval);
+        }
+        for (i = 0; i < nGarb; i++) {
+            garb[i] = new GarbageGenerator();
+            garb[i].setInterval(garbInterval);
+
+        }
+
+        // premtive special class loading
+        objectsJNI clStub = new objectsJNI(null, 0, 0, null, 0, 0);
+    }
+
+    public void run() {
+        try {
+            int i = 0;
+            long iCycle = 0L;
+            JNIter002.clearCount();
+            JNIter002.clearInterruptCount();
+            for (i = 0; i < jniter.length; i++)
+                jniter[i].start();
+
+            while (JNIter002.getCount() < jniter.length) {
+                try {
+                    sleep(100);
+                } catch (InterruptedException e) {
+                }
+            }
+            JNIter002.clearCount();
+            // JNIter002.clearInterruptCount();
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+
+            for (i = 0; i < garb.length; i++)
+                garb[i].start();
+            for (i = 0; i < irupt.length - 1; i++)
+                irupt[i].start();
+
+            if (DEBUG) System.out.println("Cycles=" + nCycles);
+            for (iCycle = 0; iCycle < nCycles && !done && JNIter002.passed(); iCycle++) {
+                System.out.print("Cycle: " + iCycle);
+                try {
+                    sleep(interval);
+                } catch (InterruptedException e) {
+                }
+                synchronized (sync[1]) {
+                    System.out.println("    Interrupt count=" +
+                            JNIter002.getInterruptCount());
+                }
+                JNIter002.clearCount();
+                synchronized (sync[0]) {
+                    sync[0].notifyAll();
+                }
+                int n = 0;
+                for (i = 0; i < jniter.length; i++)
+                    if (jniter[i].finished()) n++;
+                if (n == jniter.length) break;
+            }
+            if (JNIter002.passed()) {
+                System.out.println("JNI TEST PASSED");
+            } else {
+                System.out.println("JNI TEST FAILED");
+            }
+            for (i = 0; i < irupt.length; i++)
+                irupt[i].halt();
+            for (i = 0; i < garb.length; i++)
+                garb[i].halt();
+            for (i = 0; i < jniter.length; i++)
+                jniter[i].halt();
+                        /* Flush any waiters */
+            if (DEBUG) System.out.println("jnistress002::run(): before sync[0]");
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+            if (DEBUG) System.out.println("jnistress002::run(): after sync[0]");
+            for (i = 0; i < irupt.length; i++) {
+                try {
+                    irupt[i].join();
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress002::run(): X");
+            for (i = 0; i < garb.length; i++) {
+                try {
+                    garb[i].join();
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress002::run(): Y");
+            System.out.println("jniter.length is " + jniter.length);
+            for (i = 0; i < jniter.length; i++) {
+                try {
+                    if (jniter[i].isAlive()) {
+                        jniter[i].join();
+                    }
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress002::run(): Z");
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    public void halt() {
+        done = true;
+    }
+
+    public boolean finished() {
+        return done;
+    }
+
+    long nCycles = 0;
+    JNIter002[] jniter;
+    static Synchronizer[] sync;
+    private int interval = 100;
+    Interrupter[] irupt;
+    GarbageGenerator[] garb;
+    private boolean done = false;
+    final private static boolean DEBUG = false;
+}
+
+class objectsJNI {
+    public String instName;
+    public int i;
+    public long l;
+    public char[] c;
+    public float f;
+    public double d;
+
+    public objectsJNI(String name,
+                      int intgr,
+                      long lng,
+                      char[] charr,
+                      float flt,
+                      double dbl
+    ) {
+        instName = name;
+        i = intgr;
+        l = lng;
+        f = flt;
+        d = dbl;
+        c = charr;
+    }
+
+    public boolean equals(Object o) {
+
+        if (this.getClass() != o.getClass())
+            return false;
+
+        Field[] fields = o.getClass().getFields();
+        try {
+            for (int i = 0; i < fields.length; i++) {
+                if (fields[i].get(o) instanceof char[]) {
+                    for (int j = 0; j < ((char[]) fields[i].get(this)).length; j++)
+                        if (((char[]) fields[i].get(this))[j] !=
+                                ((char[]) fields[i].get(o))[j]) {
+                            System.out.println(
+                                    "Char arrays have difference in " + j);
+                            return false;
+                        }
+                } else if (!fields[i].get(this).equals(fields[i].get(o))) {
+                    System.out.println(
+                            "The fields No. " + i + " are different");
+                    return false;
+                }
+            }
+        } catch (Exception e) {
+            System.out.println("Error : " + e);
+        }
+        ;
+        return true;
+    }
+}
+
+class JNIter002 extends Thread {
+
+    // The native method for testing JNI Object's calls
+    public native objectsJNI[] jniobjects(String s, int i, long l,
+                                          char[] c, float f, double d);
+
+    static {
+        System.loadLibrary("jnistress002");
+    }
+
+    static Random myRandom = new Random();
+
+    public JNIter002(Synchronizer[] aSync) {
+        sync = aSync;
+    }
+
+    public void run() {
+        try {
+            String s;
+            int i;
+            long l;
+            char[] c;
+            float f;
+            double d;
+            int iter = 0;
+
+                        /* Synchronize start of work */
+            incCount();
+            synchronized (sync[0]) {
+                try {
+                    sync[0].wait();
+                } catch (InterruptedException e) {
+                }
+            }
+            while (!done && pass) {
+                try {
+                                                /* Synchronized the JNI stressing */
+                    synchronized (sync[2]) {
+                        incCount();
+                    }
+                    synchronized (sync[0]) {
+                        try {
+                            sync[0].wait();
+                        } catch (InterruptedException e) {
+                            synchronized (sync[1]) {
+                                JNIter002.incInterruptCount();
+                            }
+                        }
+                    }
+                    synchronized (sync[0]) {
+                        i = myRandom.nextInt(Integer.MAX_VALUE);
+                        l = myRandom.nextLong();
+                        f = myRandom.nextFloat();
+                        d = myRandom.nextDouble();
+                        s = getName();
+                        c = s.toCharArray();
+                        objectsJNI test = new objectsJNI(s, i, l, c, f, d);
+                        Object[] testJNI = jniobjects(s, i, l, c, f, d);
+
+                        for (int j = 0; j < testJNI.length; j++)
+                            if (!testJNI[j].equals(test)) {
+                                System.out.println("Objects are different");
+                                fieldprint("JNI object", testJNI[j]);
+                                fieldprint("Java object", test);
+                                pass = false;
+                            }
+                    }
+                    if (DEBUG) System.out.println("We have " + activeCount() +
+                            " threads now.");
+                    synchronized (this) {
+                        try {
+                            wait(1L);
+                        } catch (InterruptedException e) {
+                            throw new InterruptedException();
+                        }
+                    }
+                } catch (InterruptedException e) {
+                    synchronized (sync[1]) {
+                        JNIter002.incInterruptCount();
+                    }
+                }
+                iter++;
+                iter = iter % CASECOUNT;
+            }
+            if (DEBUG) System.out.println("JNITer::run(): done=" + done);
+            done = true;
+            if (DEBUG) System.out.println("JNITer::run(): pass=" + JNIter002.pass);
+            if (DEBUG) System.out.println("JNIter002::run(): done");
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    private synchronized static void incCount() {
+        count++;
+    }
+
+    public static int getCount() {
+        return count;
+    }
+
+    public synchronized static void clearCount() {
+        count = 0;
+    }
+
+    private synchronized static void incInterruptCount() {
+        interruptCount++;
+    }
+
+    public static int getInterruptCount() {
+        return interruptCount;
+    }
+
+    public synchronized static void clearInterruptCount() {
+        interruptCount = 0;
+    }
+
+    public static void halt() {
+        done = true;
+    }
+
+    public boolean finished() {
+        return done;
+    }
+
+    public static boolean passed() {
+        return pass;
+    }
+
+    Synchronizer[] sync;
+    private static int count = 0;
+    private static int interruptCount = 0;
+    private static boolean done = false;
+    private static boolean pass = true;
+    final private static int CASECOUNT = 2;
+    final private static boolean DEBUG = false;
+
+    static void fieldprint(String s, Object obj) {
+        Field[] fields = obj.getClass().getFields();
+        System.out.println(s);
+        try {
+            for (int i = 0; i < fields.length; i++) {
+                if (fields[i].get(obj) instanceof java.lang.String)
+                    System.out.println(
+                            fields[i] + " = \"" + fields[i].get(obj) + "\"");
+                else if (fields[i].get(obj) instanceof char[])
+                    System.out.println(fields[i] + " = \"" +
+                            new String((char[]) fields[i].get(obj)) + "\"");
+                else
+                    System.out.println(
+                            fields[i] + " = " + fields[i].get(obj));
+            }
+        } catch (Exception e) {
+            System.out.println("Error: " + e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnistress003.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,514 @@
+/*
+ * 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.
+ */
+
+/*
+ * jnistress003 is a class that sets up classes that do the work
+ * for the test.
+ *
+ * The Interrupter objects send interrupts to the JNIters.
+ * The GarbageGenerator objects generate garbage.
+ *
+ * sync[0] synchronizes the test cycles.
+ * sync[1] synchronizes access to exception counters.
+ * sync[2] synchronizes the cycle count update.  It also insures that
+ *         the interrupts do not interfere with the cycle count updates.
+ *         This is because cycle count updates are used to define cycles.
+ */
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/jni/jnistress003.
+ * VM testbase keywords: [stress, quick, feature_283, nonconcurrent]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.stress.jni.jnistress003
+ *      -numTHREADer 20
+ *      -threadInterval 200
+ *      -numInterrupter 2
+ *      -interruptInterval 500
+ *      -numGarbage 80
+ *      -garbageInterval 5
+ *      -numIteration 260
+ */
+
+package nsk.stress.jni;
+
+import nsk.share.Consts;
+import nsk.share.Debug;
+import nsk.share.test.StressOptions;
+
+import java.lang.reflect.Array;
+
+public class jnistress003 extends Thread {
+
+    /* Maximum number of iterations.  Ignored if <= 0L */
+    static long numIteration = 0L;
+    /* Timeout */
+    static long timeOut;
+    /* Number of test class objects */
+    static int numJNIter = 1;
+    /* Time between JNI stressing by the threads under test */
+    /* (in milliseconds) */
+    static int jniInterval = 10000;
+    /* Number of interrupting threads */
+    static int numInterrupter = 1;
+    /* Time between interrupts in milliseconds */
+    static int interruptInterval = 100;
+    /* Number of garbage generating threads */
+    static int numGarbage = 1;
+    /* Time between garbage allocations in milliseconds */
+    static int garbageInterval = 100;
+    // The size of arrays creates via JNI
+    static int SIZE = 5000;
+    // The MAX quantity of creates arrays
+    static int jniStringAllocSize = 100000;
+
+    private static StressOptions stressOptions;
+
+    public static void main(String[] argv) {
+        try {
+            int i = 0;
+            int nJNISync = 10;
+            jnistress003 dm = null;
+            boolean errArg = false;
+
+            stressOptions = new StressOptions(argv);
+
+                        /* Process arguments */
+            while (!errArg && i < argv.length) {
+                            /* Number of iterations. Ignored if <= 0. */
+                if (i < argv.length && argv[i].equals("-numIteration")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numIteration = Long.parseLong(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numTHREADer")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numJNIter = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                        if (numJNIter <= 0) errArg = true;
+                    }
+                } else if (i < argv.length && argv[i].equals("-threadInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            jniInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numInterrupter")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numInterrupter = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-interruptInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            interruptInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numGarbage")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numGarbage = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-garbageInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            garbageInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-arraysize")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            SIZE = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-jniStringAllocSize")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            jniStringAllocSize = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].startsWith("-stress")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        ++i;
+                    }
+                } else System.out.println("Argument #" + i++ + " is incorrect");
+            }
+
+            numIteration *= stressOptions.getIterationsFactor();
+            numJNIter *= stressOptions.getThreadsFactor();
+            numInterrupter *= stressOptions.getThreadsFactor();
+            numGarbage *= stressOptions.getThreadsFactor();
+            timeOut = stressOptions.getTime() * 1000;
+
+            sync = new Synchronizer[10];
+            for (i = 0; i < nJNISync; i++)
+                sync[i] = new Synchronizer();
+            dm = new jnistress003(numIteration, numJNIter, jniInterval,
+                    numInterrupter, interruptInterval,
+                    numGarbage, garbageInterval);
+
+            dm.start();
+
+            try {
+                dm.join(timeOut);
+            } catch (InterruptedException e) {
+                System.out.println("TESTER THREAD WAS INTERRUPTED");
+                System.exit(Consts.TEST_FAILED);
+            }
+
+            if (DEBUG) System.out.println("jnistress003::main(): halt!");
+
+            if (dm.isAlive()) {
+                System.out.println("TIME LIMIT EXCEEDED");
+                dm.halt();
+                if (DEBUG) System.out.println("jnistress003::main(): join!");
+                try {
+                    dm.join(10000L);
+                } catch (InterruptedException e) {
+                    System.out.println("TESTER THREAD WAS INTERRUPTED");
+                    System.exit(Consts.TEST_FAILED);
+                }
+            } else {
+                System.out.println("TESTER THREAD FINISHED");
+            }
+
+            if (DEBUG) System.out.println("jnistress003::main(): zzzz...");
+
+            if (!JNIter003.passed())
+                System.exit(Consts.TEST_FAILED);
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    jnistress003(
+            long iters,
+            int nJNI,
+            int jniInterval,
+            int nInter,
+            int iruptInterval,
+            int nGarb,
+            int garbInterval
+    ) {
+        int i = 0;
+        nCycles = iters;
+        /* Should have at least one of nCycles>0 */
+        if (nCycles <= 0) nCycles = Long.MAX_VALUE;
+        jniter = new JNIter003[nJNI];
+        interval = jniInterval;
+        irupt = new Interrupter[nInter];
+        garb = new GarbageGenerator[nGarb];
+        for (i = 0; i < nJNI; i++)
+            jniter[i] = new JNIter003(sync);
+        for (i = 0; i < nInter; i++) {
+            irupt[i] = new Interrupter(jniter, sync);
+            irupt[i].setInterval(iruptInterval);
+        }
+        for (i = 0; i < nGarb; i++) {
+            garb[i] = new GarbageGenerator();
+            garb[i].setInterval(garbInterval);
+        }
+    }
+
+    public void run() {
+        try {
+            int i = 0;
+            long iCycle = 0L;
+            JNIter003.clearCount();
+            JNIter003.clearInterruptCount();
+            for (i = 0; i < jniter.length; i++)
+                jniter[i].start();
+
+            while (!done && JNIter003.getCount() < jniter.length) {
+                try {
+                    sleep(100);
+                } catch (InterruptedException e) {
+                }
+            }
+            JNIter003.clearCount();
+            // JNIter003.clearInterruptCount();
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+
+            for (i = 0; i < garb.length; i++)
+                garb[i].start();
+            for (i = 0; i < irupt.length; i++)
+                irupt[i].start();
+
+            if (DEBUG) System.out.println("Cycles=" + nCycles);
+            for (iCycle = 0; iCycle < nCycles && !done && JNIter003.passed(); iCycle++) {
+                System.out.print("Cycle: " + iCycle);
+                try {
+                    sleep(interval);
+                } catch (InterruptedException e) {
+                }
+                synchronized (sync[1]) {
+                    System.out.println("  Interrupt count=" +
+                            JNIter003.getInterruptCount());
+                }
+                JNIter003.clearCount();
+                synchronized (sync[0]) {
+                    sync[0].notifyAll();
+                }
+                int n = 0;
+                for (i = 0; i < jniter.length; i++)
+                    if (jniter[i].finished()) n++;
+                if (n == jniter.length) break;
+            }
+            if (JNIter003.passed()) {
+                System.out.println("JNI TEST PASSED");
+            } else {
+                System.out.println("JNI TEST FAILED");
+            }
+            for (i = 0; i < irupt.length; i++)
+                irupt[i].halt();
+            for (i = 0; i < garb.length; i++)
+                garb[i].halt();
+            for (i = 0; i < jniter.length; i++)
+                jniter[i].halt();
+            /* Flush any waiters */
+            if (DEBUG) System.out.println("jnistress003::run(): before sync[0]");
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+            if (DEBUG) System.out.println("jnistress003::run(): after sync[0]");
+            for (i = 0; i < irupt.length; i++) {
+                try {
+                    irupt[i].join();
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress003::run(): X");
+            for (i = 0; i < garb.length; i++) {
+                try {
+                    garb[i].join();
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress003::run(): Y");
+            for (i = 0; i < jniter.length; i++) {
+                try {
+                    if (jniter[i].isAlive()) {
+                        jniter[i].join();
+                    }
+                } catch (InterruptedException e) {
+                }
+            }
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+            if (DEBUG) System.out.println("jnistress003::run(): Z");
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    public void halt() {
+        done = true;
+    }
+
+    public boolean finished() {
+        return done;
+    }
+
+    long nCycles = 0;
+    JNIter003[] jniter;
+    static Synchronizer[] sync;
+    private int interval = 100;
+    Interrupter[] irupt;
+    GarbageGenerator[] garb;
+    private boolean done = false;
+    final private static boolean DEBUG = false;
+}
+
+class JNIter003 extends Thread {
+
+    // The native methods for testing JNI Arrays calls
+
+    public native Object[] jniInitArrays(int size);
+
+    public native boolean jniBodyChangeArray(Object[] orig,
+                                             Object[] clone, int jniStringAllocSize);
+
+    static {
+        System.loadLibrary("jnistress003");
+    }
+
+    public JNIter003(Synchronizer[] aSync) {
+        sync = aSync;
+    }
+
+    public void run() {
+        try {
+            Object[] mainArray;
+            Object[] clonedArray;
+
+            int i, j;
+            int iter = 0;
+
+            /* Synchronize start of work */
+            incCount();
+            synchronized (sync[0]) {
+                try {
+                    sync[0].wait();
+                } catch (InterruptedException e) {
+                }
+            }
+            while (!done && pass) {
+                try {
+                    /* Synchronized the JNI stressing */
+                    synchronized (sync[2]) {
+                        incCount();
+                    }
+                    synchronized (sync[0]) {
+                        try {
+                            sync[0].wait();
+                        } catch (InterruptedException e) {
+                            synchronized (sync[1]) {
+                                JNIter003.incInterruptCount();
+                            }
+                        }
+                    }
+//                  synchronized(sync[0]) {
+                    try {
+                        mainArray = jniInitArrays(jnistress003.SIZE);
+                        clonedArray = (Object[]) mainArray.clone();
+                        JNIter003.pass = jniBodyChangeArray(mainArray, clonedArray,
+                                jnistress003.jniStringAllocSize);
+                        for (i = 0; i < 8; i++)
+                            compared &= Array.get(mainArray, i).equals(Array.get(clonedArray, i));
+                    } catch (OutOfMemoryError e) {
+                        System.out.println("Error: " + e);
+                    }
+//                  }
+                    if (DEBUG)
+                        System.out.println("We have " + activeCount() + " threads now.");
+                    JNIter003.pass = JNIter003.pass && compared;
+                    synchronized (this) {
+                        try {
+                            wait(1L);
+                        } catch (InterruptedException e) {
+                            throw new InterruptedException();
+                        }
+                    }
+                } catch (InterruptedException e) {
+                    synchronized (sync[1]) {
+                        JNIter003.incInterruptCount();
+                    }
+                }
+                iter++;
+                iter = iter % CASECOUNT;
+            }
+            if (DEBUG) System.out.println("JNITer::run(): done=" + done);
+            done = true;
+            if (DEBUG) System.out.println("JNITer::run(): pass=" + JNIter003.pass);
+            if (DEBUG) System.out.println("JNIter003::run(): done");
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    private synchronized static void incCount() {
+        count++;
+    }
+
+    public static int getCount() {
+        return count;
+    }
+
+    public synchronized static void clearCount() {
+        count = 0;
+    }
+
+    private synchronized static void incInterruptCount() {
+        interruptCount++;
+    }
+
+    public static int getInterruptCount() {
+        return interruptCount;
+    }
+
+    public synchronized static void clearInterruptCount() {
+        interruptCount = 0;
+    }
+
+    public void halt() {
+        done = true;
+    }
+
+    public boolean finished() {
+        return done;
+    }
+
+    public static boolean passed() {
+        return pass;
+    }
+
+    Synchronizer[] sync;
+    private static int count = 0;
+    private static int interruptCount = 0;
+    private boolean done = false;
+    private static boolean pass = true;
+    private static boolean compared = true;
+    final private static int CASECOUNT = 2;
+    final private static boolean DEBUG = false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnistress004.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,498 @@
+/*
+ * 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.
+ */
+
+/*
+ * jnistress004 is a class that sets up classes that do the work
+ * for the test.
+ *
+ * The Interrupter objects send interrupts to the JNIters.
+ * The GarbageGenerator objects generate garbage.
+ *
+ * sync[0] synchronizes the test cycles.
+ * sync[1] synchronizes access to exception counters.
+ * sync[2] synchronizes the cycle count update.  It also insures that
+ *         the interrupts do not interfere with the cycle count updates.
+ *         This is because cycle count updates are used to define cycles.
+ */
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/jni/jnistress004.
+ * VM testbase keywords: [stress, quick, feature_283, nonconcurrent]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.stress.jni.jnistress004
+ *      -numTHREADer 20
+ *      -threadInterval 200
+ *      -numInterrupter 2
+ *      -interruptInterval 500
+ *      -numGarbage 80
+ *      -garbageInterval 5
+ *      -numIteration 260
+ */
+
+package nsk.stress.jni;
+
+import nsk.share.Consts;
+import nsk.share.Debug;
+import nsk.share.test.StressOptions;
+
+public class jnistress004 extends Thread {
+
+    /* Maximum number of iterations.  Ignored if <= 0L */
+    static long numIteration = 2L;
+    /* Timeout */
+    static long timeOut;
+    /* Number of test class objects */
+    static int numJNIter = 100;
+    /* Time between JNI stressing by the threads under test */
+    /* (in milliseconds) */
+    static int jniInterval = 25;
+    /* Number of interrupting threads */
+    static int numInterrupter = 10;
+    /* Time between interrupts in milliseconds */
+    static int interruptInterval = 45;
+    /* Number of garbage generating threads */
+    static int numGarbage = 1;
+    /* Time between garbage allocations in milliseconds */
+    static int garbageInterval = 100;
+    // The MAX quantity of critical operations
+    static int jniStringAllocSize = 50000;
+
+    private static StressOptions stressOptions;
+
+    public static void main(String[] argv) {
+        try {
+            int i = 0;
+            int nJNISync = 10;
+            jnistress004 dm = null;
+            boolean errArg = false;
+
+            stressOptions = new StressOptions(argv);
+
+            /* Process arguments */
+            while (!errArg && i < argv.length) {
+                /* Number of iterations. Ignored if <= 0. */
+                if (i < argv.length && argv[i].equals("-numIteration")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numIteration = Long.parseLong(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numTHREADer")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numJNIter = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                        if (numJNIter <= 0) errArg = true;
+                    }
+                } else if (i < argv.length && argv[i].equals("-threadInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            jniInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numInterrupter")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numInterrupter = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-interruptInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            interruptInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numGarbage")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numGarbage = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-garbageInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            garbageInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-jniStringAllocSize")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            jniStringAllocSize = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].startsWith("-stress")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        ++i;
+                    }
+                } else System.out.println("Argument #" + i++ + " is incorrect");
+            }
+
+            numIteration *= stressOptions.getIterationsFactor();
+            numJNIter *= stressOptions.getThreadsFactor();
+            numInterrupter *= stressOptions.getThreadsFactor();
+            numGarbage *= stressOptions.getThreadsFactor();
+            timeOut = stressOptions.getTime() * 1000;
+
+            sync = new Synchronizer[10];
+            for (i = 0; i < nJNISync; i++)
+                sync[i] = new Synchronizer();
+            dm = new jnistress004(numIteration, numJNIter, jniInterval,
+                    numInterrupter, interruptInterval, numGarbage, garbageInterval);
+            dm.start();
+
+            try {
+                dm.join(timeOut);
+            } catch (InterruptedException e) {
+                System.out.println("TESTER THREAD WAS INTERRUPTED");
+                System.exit(Consts.TEST_FAILED);
+            }
+
+            if (DEBUG) System.out.println("jnistress004::main(): halt!");
+
+            if (dm.isAlive()) {
+                System.out.println("TIME LIMIT EXCEEDED");
+                dm.halt();
+                if (DEBUG) System.out.println("jnistress004::main(): join!");
+                try {
+                    dm.join(10000L);
+                } catch (InterruptedException e) {
+                    System.out.println("TESTER THREAD WAS INTERRUPTED");
+                    System.exit(Consts.TEST_FAILED);
+                }
+            } else {
+                System.out.println("TESTER THREAD FINISHED");
+            }
+
+            if (DEBUG) System.out.println("jnistress004::main(): zzzz...");
+
+            if (!JNIter004.passed())
+                System.exit(Consts.TEST_FAILED);
+
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    jnistress004(
+            long iters,
+            int nJNI,
+            int jniInterval,
+            int nInter,
+            int iruptInterval,
+            int nGarb,
+            int garbInterval
+    ) {
+        int i = 0;
+        nCycles = iters;
+        /* Should have at least one of nCycles>0 */
+        if (nCycles <= 0) nCycles = Long.MAX_VALUE;
+        jniter = new JNIter004[nJNI];
+        interval = jniInterval;
+        irupt = new Interrupter[nInter];
+        garb = new GarbageGenerator[nGarb];
+        for (i = 0; i < nJNI; i++)
+            jniter[i] = new JNIter004(sync);
+        for (i = 0; i < nInter; i++) {
+            irupt[i] = new Interrupter(jniter, sync);
+            irupt[i].setInterval(iruptInterval);
+        }
+        for (i = 0; i < nGarb; i++) {
+            garb[i] = new GarbageGenerator();
+            garb[i].setInterval(garbInterval);
+        }
+    }
+
+    public void run() {
+        try {
+            int i = 0;
+            long iCycle = 0L;
+            JNIter004.clearCount();
+            JNIter004.clearInterruptCount();
+            for (i = 0; i < jniter.length; i++)
+                jniter[i].start();
+
+            while (JNIter004.getCount() < jniter.length) {
+                try {
+                    sleep(100);
+                } catch (InterruptedException e) {
+                }
+            }
+            JNIter004.clearCount();
+            // JNIter004.clearInterruptCount();
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+
+            for (i = 0; i < garb.length; i++)
+                garb[i].start();
+            for (i = 0; i < irupt.length; i++)
+                irupt[i].start();
+
+            if (DEBUG) System.out.println("Cycles=" + nCycles);
+            for (iCycle = 0; iCycle < nCycles && !done && JNIter004.passed(); iCycle++) {
+                System.out.print("Cycle: " + iCycle);
+                try {
+                    sleep(interval);
+                } catch (InterruptedException e) {
+                }
+                synchronized (sync[1]) {
+                    System.out.println("  Interrupt count=" +
+                            JNIter004.getInterruptCount());
+                }
+                JNIter004.clearCount();
+                synchronized (sync[0]) {
+                    sync[0].notifyAll();
+                }
+                int n = 0;
+                for (i = 0; i < jniter.length; i++)
+                    if (jniter[i].finished()) n++;
+                if (n == jniter.length) break;
+            }
+            if (JNIter004.passed())
+                System.out.println("JNI TEST PASSED");
+            else
+                System.out.println("JNI TEST FAILED");
+            for (i = 0; i < irupt.length; i++)
+                irupt[i].halt();
+            for (i = 0; i < garb.length; i++)
+                garb[i].halt();
+            for (i = 0; i < jniter.length; i++)
+                jniter[i].halt();
+                        /* Flush any waiters */
+            if (DEBUG) System.out.println("jnistress004::run(): before sync[0]");
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+            if (DEBUG) System.out.println("jnistress004::run(): after sync[0]");
+            for (i = 0; i < irupt.length; i++) {
+                try {
+                    irupt[i].join();
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress004::run(): X");
+            for (i = 0; i < garb.length; i++) {
+                try {
+                    garb[i].join();
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress004::run(): Y");
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+            for (i = 0; i < jniter.length; i++) {
+                try {
+                    if (jniter[i].isAlive()) {
+                        jniter[i].join();
+                    }
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress004::run(): Z");
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    public void halt() {
+        done = true;
+    }
+
+    public boolean finished() {
+        return done;
+    }
+
+    long nCycles = 0;
+    JNIter004[] jniter;
+    static Synchronizer[] sync;
+    private int interval = 100;
+    Interrupter[] irupt;
+    GarbageGenerator[] garb;
+    private boolean done = false;
+    final private static boolean DEBUG = false;
+}
+
+class JNIter004 extends Thread {
+
+    // The native methods for testing JNI critical calls
+    public native char[] CheckSum(String str);
+
+    public native boolean CheckCompare(String name, char[] sum, int upper);
+
+    static {
+        System.loadLibrary("jnistress004");
+    }
+
+    Runtime myRT = Runtime.getRuntime();
+    static int Count = 0;
+
+    public JNIter004(Synchronizer[] aSync) {
+        sync = aSync;
+    }
+
+    public void run() {
+        try {
+            char[] Sum;
+            int iter = 0;
+
+                        /* Synchronize start of work */
+            incCount();
+            synchronized (sync[0]) {
+                try {
+                    sync[0].wait();
+                } catch (InterruptedException e) {
+                }
+            }
+            while (!done && pass) {
+                try {
+                                /* Synchronized the JNI stressing */
+                    synchronized (sync[2]) {
+                        incCount();
+                    }
+                    synchronized (sync[0]) {
+                        try {
+                            sync[0].wait();
+                        } catch (InterruptedException e) {
+                            synchronized (sync[1]) {
+                                JNIter004.incInterruptCount();
+                            }
+                        }
+                    }
+                    synchronized (sync[0]) {
+                        try {
+                            if (Count++ < jnistress004.jniStringAllocSize) {
+                                System.out.println("JAVA: comparing " + (getName()) + " with " + CheckSum(getName()));
+                                if (!CheckCompare(getName(), CheckSum(getName()), jnistress004.jniStringAllocSize))
+                                    pass = true;
+                            }
+                        } catch (OutOfMemoryError e) {
+                            System.out.println("Error in Java code" + e);
+                        }
+                    }
+                    if (DEBUG)
+                        System.out.println(getName() + "\t\t" + myRT.freeMemory());
+                    synchronized (this) {
+                        try {
+                            wait(1L);
+                        } catch (InterruptedException e) {
+                            throw new InterruptedException();
+                        }
+                    }
+                } catch (Exception e) {
+                    synchronized (sync[1]) {
+                        JNIter004.incInterruptCount();
+                    }
+                }
+                iter++;
+                iter = iter % CASECOUNT;
+            }
+            if (DEBUG) System.out.println("JNITer::run(): done=" + done);
+            done = true;
+            if (DEBUG) System.out.println("JNITer::run(): pass=" + JNIter004.pass);
+            if (DEBUG) System.out.println("JNIter004::run(): done");
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    private synchronized static void incCount() {
+        count++;
+    }
+
+    public static int getCount() {
+        return count;
+    }
+
+    public synchronized static void clearCount() {
+        count = 0;
+    }
+
+    private synchronized static void incInterruptCount() {
+        interruptCount++;
+    }
+
+    public static int getInterruptCount() {
+        return interruptCount;
+    }
+
+    public synchronized static void clearInterruptCount() {
+        interruptCount = 0;
+    }
+
+    public static void halt() {
+        done = true;
+    }
+
+    public boolean finished() {
+        return done;
+    }
+
+    public static boolean passed() {
+        return pass;
+    }
+
+    public static void setpass(boolean value) {
+        pass = value;
+    }
+
+    Synchronizer[] sync;
+    private static int count = 0;
+    private static int interruptCount = 0;
+    private static boolean done = false;
+    private static boolean pass = true;
+    final private static int CASECOUNT = 2;
+    final private static boolean DEBUG = false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnistress005.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,506 @@
+/*
+ * 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.
+ */
+
+/*
+ * jnistress005 is a class that sets up classes that do the work
+ * for the test.
+ *
+ * The Interrupter objects send interrupts to the JNIters.
+ * The GarbageGenerator objects generate garbage.
+ *
+ * sync[0] synchronizes the test cycles.
+ * sync[1] synchronizes access to exception counters.
+ * sync[2] synchronizes the cycle count update.  It also insures that
+ *         the interrupts do not interfere with the cycle count updates.
+ *         This is because cycle count updates are used to define cycles.
+ */
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/jni/jnistress005.
+ * VM testbase keywords: [stress, quick, feature_283, nonconcurrent]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.stress.jni.jnistress005
+ *      -numTHREADer 20
+ *      -threadInterval 200
+ *      -numInterrupter 2
+ *      -interruptInterval 500
+ *      -numGarbage 80
+ *      -garbageInterval 5
+ *      -numIteration 260
+ */
+
+package nsk.stress.jni;
+
+import nsk.share.Consts;
+import nsk.share.Debug;
+import nsk.share.test.StressOptions;
+
+public class jnistress005 extends Thread {
+
+    /* Maximum number of iterations.  Ignored if <= 0L */
+    static long numIteration = 0L;
+    /* Timeout */
+    static long timeOut;
+    /* Number of test class objects */
+    static int numJNIter = 1;
+    /* Time between JNI stressing by the threads under test */
+    /* (in milliseconds) */
+    static int jniInterval = 10000;
+    /* Number of interrupting threads */
+    static int numInterrupter = 1;
+    /* Time between interrupts in milliseconds */
+    static int interruptInterval = 100;
+    /* Number of garbage generating threads */
+    static int numGarbage = 1;
+    /* Time between garbage allocations in milliseconds */
+    static int garbageInterval = 100;
+    // The MAX quantity of creates exceptions
+    static int jniStringAllocSize = 15000;
+
+    private static StressOptions stressOptions;
+
+    public static void main(String[] argv) {
+        try {
+            int i = 0;
+            int nJNISync = 10;
+            jnistress005 dm = null;
+            boolean errArg = false;
+
+            stressOptions = new StressOptions(argv);
+
+                        /* Process arguments */
+            while (!errArg && i < argv.length) {
+                            /* Number of iterations. Ignored if <= 0. */
+                if (i < argv.length && argv[i].equals("-numIteration")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numIteration = Long.parseLong(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numTHREADer")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numJNIter = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                        if (numJNIter <= 0) errArg = true;
+                    }
+                } else if (i < argv.length && argv[i].equals("-threadInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            jniInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numInterrupter")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numInterrupter = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-interruptInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            interruptInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numGarbage")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numGarbage = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-garbageInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            garbageInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-jniStringAllocSize")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            jniStringAllocSize = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].startsWith("-stress")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        ++i;
+                    }
+                } else System.out.println("Argument #" + i++ + " is incorrect");
+            }
+
+            numIteration *= stressOptions.getIterationsFactor();
+            numJNIter *= stressOptions.getThreadsFactor();
+            numInterrupter *= stressOptions.getThreadsFactor();
+            numGarbage *= stressOptions.getThreadsFactor();
+            timeOut = stressOptions.getTime() * 1000;
+
+            sync = new Synchronizer[10];
+            for (i = 0; i < nJNISync; i++)
+                sync[i] = new Synchronizer();
+            dm = new jnistress005(numIteration, numJNIter, jniInterval,
+                    numInterrupter, interruptInterval, numGarbage, garbageInterval);
+            dm.start();
+
+            try {
+                dm.join(timeOut);
+            } catch (InterruptedException e) {
+                System.out.println("TESTER THREAD WAS INTERRUPTED");
+                System.exit(Consts.TEST_FAILED);
+            }
+
+            if (DEBUG) System.out.println("jnistress005::main(): halt!");
+
+            if (dm.isAlive()) {
+                System.out.println("TIME LIMIT EXCEEDED");
+                dm.halt();
+                if (DEBUG) System.out.println("jnistress005::main(): join!");
+                try {
+                    dm.join(10000L);
+                } catch (InterruptedException e) {
+                    System.out.println("TESTER THREAD WAS INTERRUPTED");
+                    System.exit(Consts.TEST_FAILED);
+                }
+            } else {
+                System.out.println("TESTER THREAD FINISHED");
+            }
+
+            if (DEBUG) System.out.println("jnistress005::main(): zzzz...");
+
+            if (!JNIter005.passed())
+                System.exit(Consts.TEST_FAILED);
+
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    jnistress005(
+            long iters,
+            int nJNI,
+            int jniInterval,
+            int nInter,
+            int iruptInterval,
+            int nGarb,
+            int garbInterval
+    ) {
+        int i = 0;
+        nCycles = iters;
+        /* Should have at least one of nCycles>0 */
+        if (nCycles <= 0) nCycles = Long.MAX_VALUE;
+        jniter = new JNIter005[nJNI];
+        interval = jniInterval;
+        irupt = new Interrupter[nInter];
+        garb = new GarbageGenerator[nGarb];
+        for (i = 0; i < nJNI; i++)
+            jniter[i] = new JNIter005(sync);
+        for (i = 0; i < nInter; i++) {
+            irupt[i] = new Interrupter(jniter, sync);
+            irupt[i].setInterval(iruptInterval);
+        }
+        for (i = 0; i < nGarb; i++) {
+            garb[i] = new GarbageGenerator();
+            garb[i].setInterval(garbInterval);
+        }
+    }
+
+    public void run() {
+        try {
+            int i = 0;
+            long iCycle = 0L;
+            //      JNIter005.clearCount();
+            JNIter005.clearInterruptCount();
+            for (i = 0; i < jniter.length; i++)
+                jniter[i].start();
+
+            while (JNIter005.getCount() < jniter.length) {
+                try {
+                    sleep(100);
+                } catch (InterruptedException e) {
+                }
+            }
+            //      JNIter005.clearCount();
+            // JNIter005.clearInterruptCount();
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+
+            for (i = 0; i < garb.length; i++)
+                garb[i].start();
+            for (i = 0; i < irupt.length; i++)
+                irupt[i].start();
+
+            if (DEBUG) System.out.println("Cycles=" + nCycles);
+            for (iCycle = 0; iCycle < nCycles && !done && JNIter005.passed(); iCycle++) {
+                System.out.print("Cycle: " + iCycle);
+                try {
+                    sleep(interval);
+                } catch (InterruptedException e) {
+                }
+                synchronized (sync[1]) {
+                    System.out.println(
+                            "  Interrupt count=" + JNIter005.getInterruptCount() +
+                                    " Native interrupt count=" + JNIter005.CountException);
+                }
+                //          JNIter005.clearCount();
+                synchronized (sync[0]) {
+                    sync[0].notifyAll();
+                }
+                int n = 0;
+                for (i = 0; i < jniter.length; i++)
+                    if (jniter[i].finished()) n++;
+                if (n == jniter.length) break;
+            }
+            if (JNIter005.passed())
+                System.out.println("JNI TEST PASSED");
+            else
+                System.out.println("JNI TEST FAILED");
+            for (i = 0; i < irupt.length; i++)
+                irupt[i].halt();
+            for (i = 0; i < garb.length; i++)
+                garb[i].halt();
+            for (i = 0; i < jniter.length; i++)
+                jniter[i].halt();
+                        /* Flush any waiters */
+            if (DEBUG) System.out.println("jnistress005::run(): before sync[0]");
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+            if (DEBUG) System.out.println("jnistress005::run(): after sync[0]");
+            for (i = 0; i < irupt.length; i++) {
+                try {
+                    irupt[i].join();
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress005::run(): X");
+            for (i = 0; i < garb.length; i++) {
+                try {
+                    garb[i].join();
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress005::run(): Y");
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+            for (i = 0; i < jniter.length; i++) {
+                try {
+                    if (jniter[i].isAlive()) {
+                        jniter[i].join();
+                    }
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress005::run(): Z");
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    public void halt() {
+        done = true;
+    }
+
+    public boolean finished() {
+        return done;
+    }
+
+    long nCycles = 0;
+    JNIter005[] jniter;
+    static Synchronizer[] sync;
+    private int interval = 100;
+    Interrupter[] irupt;
+    GarbageGenerator[] garb;
+    private boolean done = false;
+    final private static boolean DEBUG = false;
+}
+
+class JNIter005 extends Thread {
+
+    // The native methods for testing JNI exception calls
+    public native void except(Throwable tobj);
+
+    //    public native int count();
+    static {
+        System.loadLibrary("jnistress005");
+    }
+
+    Exception nobj = new Exception();
+    static int CountException = 0;
+    static int counts = 0;
+
+    public JNIter005(Synchronizer[] aSync) {
+        sync = aSync;
+    }
+
+    public void run() {
+        try {
+            char[] Sum;
+            int iter = 0;
+
+                        /* Synchronize start of work */
+            incCount();
+            synchronized (sync[0]) {
+                try {
+                    sync[0].wait();
+                } catch (InterruptedException e) {
+                }
+            }
+            while (!done && pass) {
+                try {
+                                /* Synchronized the JNI stressing */
+                    synchronized (sync[2]) {
+                        incCount();
+                    }
+                    synchronized (sync[0]) {
+                        try {
+                            sync[0].wait();
+                        } catch (InterruptedException e) {
+                            synchronized (sync[1]) {
+                                JNIter005.incInterruptCount();
+                            }
+                        }
+                    }
+                    synchronized (sync[0]) {
+                        if (CountException < jnistress005.jniStringAllocSize) {
+                            try {
+                                except(nobj);
+                            } catch (Exception e) {
+                                if ((CountException % 1000) == 0)
+                                    System.out.println("JAVA: " + e);
+                                System.out.println("Here");
+                                System.out.println("counts " + counts +
+                                        " CountException " + CountException);
+
+                                ++CountException;
+                            }
+                        } else
+                            //                      if (CountException==counts) halt();
+                            if (CountException == jnistress005.jniStringAllocSize) halt();
+                    }
+                    if (DEBUG)
+                        System.out.println("We have " + activeCount() + " threads now.");
+                    synchronized (this) {
+                        try {
+                            wait(1L);
+                        } catch (InterruptedException e) {
+                            throw new InterruptedException();
+                        }
+                    }
+                } catch (Exception e) {
+                    synchronized (sync[1]) {
+                        JNIter005.incInterruptCount();
+                    }
+                }
+                iter++;
+                iter = iter % CASECOUNT;
+            }
+            if (DEBUG) System.out.println("JNITer::run(): done=" + done);
+            done = true;
+            if (DEBUG) System.out.println("JNITer::run(): pass=" + JNIter005.pass);
+            if (DEBUG) System.out.println("JNIter005::run(): done");
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    public synchronized static void incCount() {
+        count++;
+    }
+
+    public static int getCount() {
+        return count;
+    }
+
+    public synchronized static void clearCount() {
+        count = 0;
+    }
+
+    private synchronized static void incInterruptCount() {
+        interruptCount++;
+    }
+
+    public static int getInterruptCount() {
+        return interruptCount;
+    }
+
+    public synchronized static void clearInterruptCount() {
+        interruptCount = 0;
+    }
+
+    public void halt() {
+        done = true;
+    }
+
+    public boolean finished() {
+        return done;
+    }
+
+    public static boolean passed() {
+        return pass;
+    }
+
+    public static void setpass(boolean value) {
+        pass = value;
+    }
+
+    Synchronizer[] sync;
+    private static int count = 0;
+    private static int interruptCount = 0;
+    private boolean done = false;
+    private static boolean pass = true;
+    final private static int CASECOUNT = 2;
+    final private static boolean DEBUG = false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnistress006.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,502 @@
+/*
+ * 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.
+ */
+
+/*
+ * jnistress006 is a class that sets up classes that do the work
+ * for the test.
+ *
+ * The Interrupter objects send interrupts to the JNIters.
+ * The GarbageGenerator objects generate garbage.
+ *
+ * sync[0] synchronizes the test cycles.
+ * sync[1] synchronizes access to exception counters.
+ * sync[2] synchronizes the cycle count update.  It also insures that
+ *         the interrupts do not interfere with the cycle count updates.
+ *         This is because cycle count updates are used to define cycles.
+ */
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/jni/jnistress006.
+ * VM testbase keywords: [stress, quick, feature_283, nonconcurrent]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.stress.jni.jnistress006
+ *      -numTHREADer 20
+ *      -threadInterval 200
+ *      -numInterrupter 2
+ *      -interruptInterval 500
+ *      -numGarbage 80
+ *      -garbageInterval 5
+ *      -numIteration 260
+ */
+
+package nsk.stress.jni;
+
+import nsk.share.Consts;
+import nsk.share.Debug;
+import nsk.share.test.StressOptions;
+
+public class jnistress006 extends Thread {
+
+    /* Maximum number of iterations.  Ignored if <= 0L */
+    static long numIteration = 0L;
+    /* Timeout */
+    static long timeOut;
+    /* Number of test class objects */
+    static int numJNIter = 1;
+    /* Time between JNI stressing by the threads under test */
+    /* (in milliseconds) */
+    static int jniInterval = 10000;
+    /* Number of interrupting threads */
+    static int numInterrupter = 1;
+    /* Time between interrupts in milliseconds */
+    static int interruptInterval = 100;
+    /* Number of garbage generating threads */
+    static int numGarbage = 1;
+    /* Time between garbage allocations in milliseconds */
+    static int garbageInterval = 100;
+    // The MAX quantity of creates global refs
+    static int jniStringAllocSize = 30000;
+
+    private static StressOptions stressOptions;
+
+    public static void main(String[] argv) {
+        try {
+            int i = 0;
+            int nJNISync = 10;
+            jnistress006 dm = null;
+            boolean errArg = false;
+
+            stressOptions = new StressOptions(argv);
+
+                        /* Process arguments */
+            while (!errArg && i < argv.length) {
+                            /* Number of iterations. Ignored if <= 0. */
+                if (i < argv.length && argv[i].equals("-numIteration")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numIteration = Long.parseLong(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numTHREADer")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numJNIter = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                        if (numJNIter <= 0) errArg = true;
+                    }
+                } else if (i < argv.length && argv[i].equals("-threadInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            jniInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numInterrupter")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numInterrupter = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-interruptInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            interruptInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numGarbage")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numGarbage = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-garbageInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            garbageInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-jniStringAllocSize")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            jniStringAllocSize = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].startsWith("-stress")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        ++i;
+                    }
+                } else System.out.println("Argument #" + i++ + " is incorrect");
+            }
+
+            numIteration *= stressOptions.getIterationsFactor();
+            numJNIter *= stressOptions.getThreadsFactor();
+            numInterrupter *= stressOptions.getThreadsFactor();
+            numGarbage *= stressOptions.getThreadsFactor();
+            timeOut = stressOptions.getTime() * 1000;
+
+            sync = new Synchronizer[10];
+            for (i = 0; i < nJNISync; i++)
+                sync[i] = new Synchronizer();
+            dm = new jnistress006(numIteration, numJNIter, jniInterval,
+                    numInterrupter, interruptInterval, numGarbage, garbageInterval);
+
+            dm.start();
+
+            try {
+                dm.join(timeOut);
+            } catch (InterruptedException e) {
+                System.out.println("TESTER THREAD WAS INTERRUPTED");
+                System.exit(Consts.TEST_FAILED);
+            }
+
+            if (DEBUG) System.out.println("jnistress006::main(): halt!");
+
+            if (dm.isAlive()) {
+                System.out.println("TIME LIMIT EXCEEDED");
+                dm.halt();
+                if (DEBUG) System.out.println("jnistress006::main(): join!");
+                try {
+                    dm.join(10000L);
+                } catch (InterruptedException e) {
+                    System.out.println("TESTER THREAD WAS INTERRUPTED");
+                    System.exit(Consts.TEST_FAILED);
+                }
+            } else {
+                System.out.println("TESTER THREAD FINISHED");
+            }
+
+            if (DEBUG) System.out.println("jnistress006::main(): zzzz...");
+
+            if (!JNIter006.passed())
+                System.exit(Consts.TEST_FAILED);
+
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    jnistress006(
+            long iters,
+            int nJNI,
+            int jniInterval,
+            int nInter,
+            int iruptInterval,
+            int nGarb,
+            int garbInterval
+    ) {
+        int i = 0;
+        nCycles = iters;
+        /* Should have at least one of nCycles>0 */
+        if (nCycles <= 0) nCycles = Long.MAX_VALUE;
+        jniter = new JNIter006[nJNI];
+        interval = jniInterval;
+        irupt = new Interrupter[nInter];
+        garb = new GarbageGenerator[nGarb];
+        for (i = 0; i < nJNI; i++)
+            jniter[i] = new JNIter006(sync);
+        for (i = 0; i < nInter; i++) {
+            irupt[i] = new Interrupter(jniter, sync);
+            irupt[i].setInterval(iruptInterval);
+        }
+        for (i = 0; i < nGarb; i++) {
+            garb[i] = new GarbageGenerator();
+            garb[i].setInterval(garbInterval);
+        }
+    }
+
+    public void run() {
+        try {
+            int i = 0;
+            long iCycle = 0L;
+            JNIter006.clearCount();
+            JNIter006.clearInterruptCount();
+            for (i = 0; i < jniter.length; i++)
+                jniter[i].start();
+
+            while (JNIter006.getCount() < jniter.length) {
+                try {
+                    sleep(100);
+                } catch (InterruptedException e) {
+                }
+            }
+            JNIter006.clearCount();
+            // JNIter006.clearInterruptCount();
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+
+            for (i = 0; i < garb.length; i++)
+                garb[i].start();
+            for (i = 0; i < irupt.length; i++)
+                irupt[i].start();
+
+            if (DEBUG) System.out.println("Cycles=" + nCycles);
+            for (iCycle = 0; iCycle < nCycles && !done && JNIter006.passed(); iCycle++) {
+                System.out.print("Cycle: " + iCycle);
+                try {
+                    sleep(interval);
+                } catch (InterruptedException e) {
+                }
+                synchronized (sync[1]) {
+                    System.out.println("  Interrupt count=" +
+                            JNIter006.getInterruptCount());
+                }
+                JNIter006.clearCount();
+                synchronized (sync[0]) {
+                    sync[0].notifyAll();
+                }
+                int n = 0;
+                for (i = 0; i < jniter.length; i++)
+                    if (jniter[i].finished()) n++;
+                if (n == jniter.length) break;
+            }
+            if (JNIter006.passed())
+                System.out.println("JNI TEST PASSED");
+            else
+                System.out.println("JNI TEST FAILED");
+            for (i = 0; i < irupt.length; i++)
+                irupt[i].halt();
+            for (i = 0; i < garb.length; i++)
+                garb[i].halt();
+            for (i = 0; i < jniter.length; i++)
+                jniter[i].halt();
+                        /* Flush any waiters */
+            if (DEBUG) System.out.println("jnistress006::run(): before sync[0]");
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+            if (DEBUG) System.out.println("jnistress006::run(): after sync[0]");
+            for (i = 0; i < irupt.length; i++) {
+                try {
+                    irupt[i].join();
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress006::run(): X");
+            for (i = 0; i < garb.length; i++) {
+                try {
+                    garb[i].join();
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress006::run(): Y");
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+            for (i = 0; i < jniter.length; i++) {
+                try {
+                    if (jniter[i].isAlive()) {
+                        jniter[i].join();
+                    }
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress006::run(): Z");
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    public void halt() {
+        done = true;
+    }
+
+    public boolean finished() {
+        return done;
+    }
+
+    long nCycles = 0;
+    JNIter006[] jniter;
+    static Synchronizer[] sync;
+    private int interval = 100;
+    Interrupter[] irupt;
+    GarbageGenerator[] garb;
+    private boolean done = false;
+    final private static boolean DEBUG = false;
+}
+
+class JNIter006 extends Thread {
+
+    // The native methods for testing JNI exception calls
+    public native boolean refs(Object tobj, int jniStringAllocSize);
+
+    static {
+        System.loadLibrary("jnistress006");
+    }
+
+    Referenced tobj = new Referenced();
+    static int CountRefs;
+
+    public JNIter006(Synchronizer[] aSync) {
+        sync = aSync;
+    }
+
+    public void run() {
+        try {
+            int iter = 0;
+
+                        /* Synchronize start of work */
+            incCount();
+            synchronized (sync[0]) {
+                try {
+                    sync[0].wait();
+                } catch (InterruptedException e) {
+                }
+            }
+            while (!done && pass) {
+                try {
+                                /* Synchronized the JNI stressing */
+                    synchronized (sync[2]) {
+                        incCount();
+                    }
+                    synchronized (sync[0]) {
+                        try {
+                            sync[0].wait();
+                        } catch (InterruptedException e) {
+                            synchronized (sync[1]) {
+                                JNIter006.incInterruptCount();
+                            }
+                        }
+                    }
+                    synchronized (sync[0]) {
+                        try {
+                            tobj.set_i(123456);
+                            pass = refs(tobj, jnistress006.jniStringAllocSize);
+                        } catch (Exception e) {
+                            System.out.println("Error: " + e);
+                        }
+                    }
+                    if (DEBUG)
+                        System.out.println("We have " + activeCount() + " threads now.");
+                    synchronized (this) {
+                        try {
+                            wait(1L);
+                        } catch (InterruptedException e) {
+                            throw new InterruptedException();
+                        }
+                    }
+                } catch (Exception e) {
+                    synchronized (sync[1]) {
+                        JNIter006.incInterruptCount();
+                    }
+                }
+                iter++;
+                iter = iter % CASECOUNT;
+            }
+            if (DEBUG) System.out.println("JNITer::run(): done=" + done);
+            done = true;
+            if (DEBUG) System.out.println("JNITer::run(): pass=" + JNIter006.pass);
+            if (DEBUG) System.out.println("JNIter006::run(): done");
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    private synchronized static void incCount() {
+        count++;
+    }
+
+    public static int getCount() {
+        return count;
+    }
+
+    public synchronized static void clearCount() {
+        count = 0;
+    }
+
+    private synchronized static void incInterruptCount() {
+        interruptCount++;
+    }
+
+    public static int getInterruptCount() {
+        return interruptCount;
+    }
+
+    public synchronized static void clearInterruptCount() {
+        interruptCount = 0;
+    }
+
+    public void halt() {
+        done = true;
+    }
+
+    public boolean finished() {
+        return done;
+    }
+
+    public static boolean passed() {
+        return pass;
+    }
+
+    Synchronizer[] sync;
+    private static int count = 0;
+    private static int interruptCount = 0;
+    private static boolean done = false;
+    private static boolean pass = true;
+    final private static int CASECOUNT = 2;
+    final private static boolean DEBUG = false;
+}
+
+class Referenced {
+    private static int i;
+
+    public static void set_i(int value) {
+        i = value;
+    }
+
+    public static int get_i() {
+        return i;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/jnistress007.java	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,499 @@
+/*
+ * 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.
+ */
+
+/*
+ * jnistress007 is a class that sets up classes that do the work
+ * for the test.
+ *
+ * The Interrupter objects send interrupts to the JNIters.
+ * The GarbageGenerator objects generate garbage.
+ *
+ * sync[0] synchronizes the test cycles.
+ * sync[1] synchronizes access to exception counters.
+ * sync[2] synchronizes the cycle count update.  It also insures that
+ *         the interrupts do not interfere with the cycle count updates.
+ *         This is because cycle count updates are used to define cycles.
+ */
+
+
+/*
+ * @test
+ * @key stress
+ *
+ * @summary converted from VM testbase nsk/stress/jni/jnistress007.
+ * VM testbase keywords: [stress, quick, feature_283, nonconcurrent]
+ *
+ * @library /vmTestbase
+ *          /test/lib
+ * @run driver jdk.test.lib.FileInstaller . .
+ * @run main/othervm/native
+ *      nsk.stress.jni.jnistress007
+ *      -numTHREADer 10
+ *      -threadInterval 20
+ *      -numInterrupter 2
+ *      -interruptInterval 50
+ *      -numGarbage 80
+ *      -garbageInterval 5
+ *      -numIteration 130
+ */
+
+package nsk.stress.jni;
+
+import nsk.share.Consts;
+import nsk.share.Debug;
+import nsk.share.test.StressOptions;
+
+public class jnistress007 extends Thread {
+
+    /* Maximum number of iterations.  Ignored if <= 0L */
+    static long numIteration = 0L;
+    /* Timeout */
+    static long timeOut;
+    /* Number of test class objects */
+    static int numJNIter = 1;
+    /* Time between JNI stressing by the threads under test */
+    /* (in milliseconds) */
+    static int jniInterval = 10000;
+    /* Number of interrupting threads */
+    static int numInterrupter = 1;
+    /* Time between interrupts in milliseconds */
+    static int interruptInterval = 1000;
+    /* Number of garbage generating threads */
+    static int numGarbage = 1;
+    /* Time between garbage allocations in milliseconds */
+    static int garbageInterval = 1000;
+    // The MAX quantity of monitor's call
+    static int jniStringAllocSize = 300;
+
+    private static StressOptions stressOptions;
+
+    public static void main(String[] argv) {
+        try {
+            int i = 0;
+            int nJNISync = 10;
+            jnistress007 dm = null;
+            boolean errArg = false;
+
+            stressOptions = new StressOptions(argv);
+
+                        /* Process arguments */
+            while (!errArg && i < argv.length) {
+                            /* Number of iterations. Ignored if <= 0. */
+                if (i < argv.length && argv[i].equals("-numIteration")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numIteration = Long.parseLong(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numTHREADer")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numJNIter = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                        if (numJNIter <= 0) errArg = true;
+                    }
+                } else if (i < argv.length && argv[i].equals("-threadInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            jniInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numInterrupter")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numInterrupter = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-interruptInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            interruptInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-numGarbage")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            numGarbage = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-garbageInterval")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            garbageInterval = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].equals("-jniStringAllocSize")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        try {
+                            jniStringAllocSize = Integer.parseInt(argv[i++]);
+                        } catch (NumberFormatException e) {
+                            errArg = true;
+                        }
+                    }
+                } else if (i < argv.length && argv[i].startsWith("-stress")) {
+                    ++i;
+                    if (i < argv.length && Character.isDigit(argv[i].charAt(0))) {
+                        ++i;
+                    }
+                } else System.out.println("Argument #" + i++ + " is incorrect");
+            }
+
+            numIteration *= stressOptions.getIterationsFactor();
+            numJNIter *= stressOptions.getThreadsFactor();
+            numInterrupter *= stressOptions.getThreadsFactor();
+            numGarbage *= stressOptions.getThreadsFactor();
+            timeOut = stressOptions.getTime() * 1000;
+
+            sync = new Synchronizer[10];
+            for (i = 0; i < nJNISync; i++)
+                sync[i] = new Synchronizer();
+            dm = new jnistress007(numIteration, numJNIter, jniInterval,
+                    numInterrupter, interruptInterval, numGarbage, garbageInterval);
+            dm.start();
+
+            try {
+                dm.join(timeOut);
+            } catch (InterruptedException e) {
+                System.out.println("TESTER THREAD WAS INTERRUPTED");
+                System.exit(Consts.TEST_FAILED);
+            }
+
+            if (DEBUG) System.out.println("jnistress007::main(): halt!");
+
+            if (dm.isAlive()) {
+                System.out.println("TIME LIMIT EXCEEDED");
+                dm.halt();
+                if (DEBUG) System.out.println("jnistress007::main(): join!");
+                try {
+                    dm.join(10000L);
+                } catch (InterruptedException e) {
+                    System.out.println("TESTER THREAD WAS INTERRUPTED");
+                    System.exit(Consts.TEST_FAILED);
+                }
+            } else {
+                System.out.println("TESTER THREAD FINISHED");
+            }
+
+            if (DEBUG) System.out.println("jnistress007::main(): zzzz...");
+
+            if (JNIter007.passed())
+                System.exit(Consts.TEST_FAILED);
+
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    jnistress007(
+            long iters,
+            int nJNI,
+            int jniInterval,
+            int nInter,
+            int iruptInterval,
+            int nGarb,
+            int garbInterval
+    ) {
+        int i = 0;
+        nCycles = iters;
+        /* Should have at least one of nCycles>0 */
+        if (nCycles <= 0) nCycles = Long.MAX_VALUE;
+        jniter = new JNIter007[nJNI];
+        interval = jniInterval;
+        irupt = new Interrupter[nInter];
+        garb = new GarbageGenerator[nGarb];
+        for (i = 0; i < nJNI; i++)
+            jniter[i] = new JNIter007(sync);
+        for (i = 0; i < nInter; i++) {
+            irupt[i] = new Interrupter(jniter, sync);
+            irupt[i].setInterval(iruptInterval);
+        }
+        for (i = 0; i < nGarb; i++) {
+            garb[i] = new GarbageGenerator();
+            garb[i].setInterval(garbInterval);
+        }
+    }
+
+    public void run() {
+        try {
+            int i = 0;
+            long iCycle = 0L;
+            JNIter007.clearCount();
+            JNIter007.clearInterruptCount();
+            for (i = 0; i < jniter.length; i++)
+                jniter[i].start();
+
+            while (JNIter007.getCount() < jniter.length) {
+                try {
+                    sleep(100);
+                } catch (InterruptedException e) {
+                }
+            }
+            JNIter007.clearCount();
+            // JNIter007.clearInterruptCount();
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+
+            for (i = 0; i < garb.length; i++)
+                garb[i].start();
+            for (i = 0; i < irupt.length; i++)
+                irupt[i].start();
+
+            if (DEBUG) System.out.println("Cycles=" + nCycles);
+            for (iCycle = 0; iCycle < nCycles && !done && !JNIter007.passed(); iCycle++) {
+                System.out.print("Cycle: " + iCycle);
+                try {
+                    sleep(interval);
+                } catch (InterruptedException e) {
+                }
+                synchronized (sync[1]) {
+                    System.out.println("\tInterrupt count=" +
+                            JNIter007.getInterruptCount());
+                }
+                JNIter007.clearCount();
+                synchronized (sync[0]) {
+                    sync[0].notifyAll();
+                }
+                int n = 0;
+                for (i = 0; i < jniter.length; i++)
+                    if (jniter[i].finished()) n++;
+                if (n == jniter.length) break;
+            }
+            for (i = 0; i < irupt.length; i++)
+                irupt[i].halt();
+            for (i = 0; i < garb.length; i++)
+                garb[i].halt();
+            for (i = 0; i < jniter.length; i++)
+                jniter[i].halt();
+                        /* Flush any waiters */
+            if (DEBUG) System.out.println("jnistress007::run(): before sync[0]");
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+            if (DEBUG) System.out.println("jnistress007::run(): after sync[0]");
+            for (i = 0; i < irupt.length; i++) {
+                try {
+                    irupt[i].join();
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress007::run(): X");
+            for (i = 0; i < garb.length; i++) {
+                try {
+                    garb[i].join();
+                } catch (InterruptedException e) {
+                }
+            }
+            if (DEBUG) System.out.println("jnistress007::run(): Y");
+            synchronized (sync[0]) {
+                sync[0].notifyAll();
+            }
+            for (i = 0; i < jniter.length; i++) {
+                try {
+                    jniter[i].join();
+                } catch (InterruptedException e) {
+                }
+            }
+            if (JNIter007.passed()) {
+                System.out.println("JNI TEST PASSED");
+            } else {
+                System.out.println("JNI TEST FAILED");
+            }
+            if (DEBUG) System.out.println("jnistress007::run(): Z");
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    public void halt() {
+        done = true;
+    }
+
+    public boolean finished() {
+        return done;
+    }
+
+    long nCycles = 0;
+    JNIter007[] jniter;
+    static Synchronizer[] sync;
+    private int interval = 100;
+    Interrupter[] irupt;
+    GarbageGenerator[] garb;
+    private boolean done = false;
+    final private static boolean DEBUG = false;
+}
+
+class JNIter007 extends Thread {
+
+    // The native methods for testing JNI monitors calls
+    public native void incCount(String name);
+
+    static {
+        System.loadLibrary("jnistress007");
+    }
+
+    public static int nativeCount, javaCount = 0;
+
+    public JNIter007(Synchronizer[] aSync) {
+        sync = aSync;
+    }
+
+    public void run() {
+        try {
+            int iter = 0;
+
+                        /* Synchronize start of work */
+            incCount();
+            synchronized (sync[0]) {
+                try {
+                    sync[0].wait();
+                } catch (InterruptedException e) {
+                }
+            }
+            while (!done && !pass) {
+                try {
+                                /* Synchronized the JNI stressing */
+                    synchronized (sync[2]) {
+                        incCount();
+                    }
+                    synchronized (sync[0]) {
+                        try {
+                            sync[0].wait();
+                        } catch (InterruptedException e) {
+                            synchronized (sync[1]) {
+                                JNIter007.incInterruptCount();
+                            }
+                        }
+                    }
+                    synchronized (sync[0]) {
+                        try {
+                            if ((javaCount < jnistress007.jniStringAllocSize) &&
+                                    (nativeCount < jnistress007.jniStringAllocSize)) {
+                                javaCount++;
+                                incCount(getName());
+                                if ((javaCount % 1000) == 0)
+                                    System.out.println("Count in java " +
+                                            getName() + " " + javaCount);
+                            } else if (javaCount == nativeCount) {
+                                done = true;
+                            } else {
+                                System.out.println("Native: " + nativeCount +
+                                        "\t" + "Java: " + javaCount);
+                                pass = true;
+                            }
+                        } catch (Exception e) {
+                            System.out.println("Error: " + e);
+                        }
+                    }
+                    if (DEBUG)
+                        System.out.println("We have " + activeCount() + " threads now.");
+                    synchronized (this) {
+                        try {
+                            wait(1L);
+                        } catch (InterruptedException e) {
+                            throw new InterruptedException();
+                        }
+                    }
+                } catch (Exception e) {
+                    synchronized (sync[1]) {
+                        JNIter007.incInterruptCount();
+                    }
+                }
+                iter++;
+                iter = iter % CASECOUNT;
+            }
+            if (DEBUG) System.out.println("JNITer::run(): done=" + done);
+            done = true;
+            if (DEBUG) System.out.println("JNITer::run(): pass=" + JNIter007.pass);
+            if (DEBUG) System.out.println("JNIter::run(): done");
+        } catch (Throwable e) {
+            Debug.Fail(e);
+        }
+    }
+
+    private synchronized static void incCount() {
+        count++;
+    }
+
+    public static int getCount() {
+        return count;
+    }
+
+    public synchronized static void clearCount() {
+        count = 0;
+    }
+
+    private synchronized static void incInterruptCount() {
+        interruptCount++;
+    }
+
+    public static int getInterruptCount() {
+        return interruptCount;
+    }
+
+    public synchronized static void clearInterruptCount() {
+        interruptCount = 0;
+    }
+
+    public void halt() {
+        done = true;
+    }
+
+    public boolean finished() {
+        return done;
+    }
+
+    public static boolean passed() {
+        return pass;
+    }
+
+    Synchronizer[] sync;
+    private static int count = 0;
+    private static int interruptCount = 0;
+    private boolean done = false;
+    private static boolean pass = false;
+    final private static int CASECOUNT = 2;
+    final private static boolean DEBUG = false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress001.c	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,239 @@
+/*
+ * 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 <jni.h>
+#include <stdio.h>
+/* Changed from strings.h to string.h for Windows. */
+#include <string.h>
+#include <stdlib.h>
+#include "jnihelper.h"
+
+#define DIGESTLENGTH 16
+
+typedef struct {
+    const char **str;
+    char **checkstr;
+} CHAR_ARRAY;
+
+typedef struct {
+    const jchar **str;
+    char **checkstr;
+    int *size;
+} JCHAR_ARRAY;
+
+JNIEXPORT jstring JNICALL
+Java_nsk_stress_jni_JNIter001_jnistress (JNIEnv *env, jobject jobj, jstring jstr,
+                    jint nstr, jint printperiod) {
+
+    int i,j;
+    size_t k;
+    static CHAR_ARRAY *element;
+    unsigned char digest[DIGESTLENGTH];
+    static int allocs=0;
+    static size_t strsize=0;
+    static unsigned int compared=1;
+
+    const char *clsName = "nsk/stress/jni/JNIter001";
+    const char *name="setpass";
+    const char *sig="(Z)V";
+    const char *halt="halt";
+    const char *haltSig="()V";
+    jstring tmpstr;
+    jclass clazz;
+    jmethodID methodID;
+
+    (*env)->MonitorEnter(env, jobj); CE
+    if (!allocs) {
+        element = (CHAR_ARRAY *)malloc(sizeof(CHAR_ARRAY));
+        element->str = (const char **)malloc(nstr*sizeof(const char *));
+        element->checkstr = (char **)malloc(nstr*sizeof(char *));
+        for (j=0;j<nstr;j++)
+            element->checkstr[j] = (char *)malloc(DIGESTLENGTH*sizeof(char));
+    }
+    for(j=0;j<DIGESTLENGTH;j++) {
+        digest[j]=0;
+    }
+    element->str[allocs] = (*env)->GetStringUTFChars(env,jstr,0); CE
+    if (strlen(element->str[allocs]) !=
+        (size_t) (*env)->GetStringUTFLength(env, jstr))
+        printf("Length is wrong in string No. %d\n",allocs);
+    else
+        strsize += strlen(element->str[allocs])+1;
+    for (k = 0; k < strlen(element->str[allocs]); k++) {
+       digest[k % DIGESTLENGTH] += element->str[allocs][k];
+    }
+    memcpy(element->checkstr[allocs],digest,DIGESTLENGTH);
+    allocs++;
+    if (allocs%printperiod==0) {
+        printf("Check string for thread %s is ", element->str[allocs-1]);
+        for (j=0;j<DIGESTLENGTH;j++)
+            printf("%02x", digest[j]);
+        printf("\n");
+    }
+    if (allocs==nstr) {
+        printf("JNI UTF8 strings memory=%zd\n", strsize);
+        tmpstr=(*env)->NewStringUTF(env,element->str[allocs-1]); CE
+        for (j=0; j<nstr; j++) {
+
+            for(i=0;i<DIGESTLENGTH;i++) {
+                digest[i]=0;
+            }
+            for (k=0; k < strlen(element->str[j]); k++) {
+                digest[k % DIGESTLENGTH] += element->str[j][k];
+            }
+            if (memcmp(digest,element->checkstr[j],DIGESTLENGTH)==0) {
+                (*env)->ReleaseStringUTFChars(env,jstr,element->str[j]); CE
+                element->str[j] = NULL;
+                element->checkstr[j] = NULL;
+            }
+            else {
+                compared=0;
+                printf("The element No. %d has been corrupted %s vs %s\n",j, element->str[j],element->checkstr[j]);
+                printf("Digest string  is %s [", element->str[j]);
+                for (i=0;i<DIGESTLENGTH;i++)
+                    printf("ch[%d]=%02x", i, digest[i]);
+                printf("Digest end\n");
+            }
+        }
+        allocs=0;
+        strsize = 0;
+        for (j=0;j<nstr;j++)
+            free(element->checkstr[j]);
+        free(element->checkstr);
+        free((void *)(element->str));
+        free(element);
+        clazz=(*env)->FindClass(env, clsName); CE
+        if (!compared) {
+            methodID=(*env)->GetStaticMethodID(env, clazz, name, sig); CE
+            (*env)->CallStaticVoidMethod(env, clazz, methodID, JNI_FALSE); CE
+        }
+        //methodID=(*env)->GetStaticMethodID(env, clazz, halt, haltSig); CE
+        //(*env)->CallStaticVoidMethod(env, clazz, methodID); CE
+        return(tmpstr);
+    }
+    (*env)->MonitorExit(env, jobj); CE
+    return ((*env)->NewStringUTF(env,element->str[allocs-1]));
+}
+
+JNIEXPORT jstring JNICALL
+Java_nsk_stress_jni_JNIter001_jnistress1(JNIEnv *env, jobject jobj, jstring jstr,
+                    jint nstr, jint printperiod) {
+
+    int i,j;
+    static JCHAR_ARRAY *javachars;
+    unsigned char digest[DIGESTLENGTH];
+    static int index=0;
+    static long len=0;
+    static unsigned int equal=1;
+    char *elem;
+
+    const char *clsName = "nsk/stress/jni/JNIter001";
+    const char *name="setpass";
+    const char *sig="(Z)V";
+    const char *halt="halt";
+    const char *haltSig="()V";
+    jstring tmpstr;
+    jclass clazz;
+    jmethodID methodID;
+
+    (*env)->MonitorEnter(env, jobj); CE
+    if (!index) {
+        javachars = (JCHAR_ARRAY *)malloc(sizeof(JCHAR_ARRAY));
+        javachars->str = (const jchar **)malloc(nstr*sizeof(const jchar *));
+        javachars->checkstr = (char **)malloc(nstr*sizeof(char *));
+        javachars->size = (int *)malloc(nstr*sizeof(int));
+        for (j=0;j<nstr;j++)
+            javachars->checkstr[j] = (char *)malloc(DIGESTLENGTH*sizeof(char));
+    }
+    for(j=0;j<DIGESTLENGTH;j++) {
+        digest[j]=0;
+    }
+    javachars->str[index] = (*env)->GetStringChars(env,jstr,0); CE
+    javachars->size[index] = (*env)->GetStringUTFLength(env, jstr); CE
+    len += javachars->size[index];
+    elem = (char*) malloc(javachars->size[index]*sizeof(char));
+    for (j=0; j < javachars->size[index]; j++) {
+        elem[j] = (char) javachars->str[index][j];
+    }
+    //memcpy(digest, elem, javachars->size[index]);
+    for(j=0;j<javachars->size[index]; j++) {
+        digest[j % DIGESTLENGTH]+=elem[j];
+    }
+    memcpy(javachars->checkstr[index++],digest,DIGESTLENGTH);
+    if (index%printperiod==0) {
+        printf("Check string sum for thread %s is ",elem);
+        for (j=0;j<DIGESTLENGTH;j++)
+            printf("%02x", digest[j]);
+        printf("\n");
+    }
+    free(elem);
+    if (index==nstr) {
+        printf("JNI Unicode strings memory=%ld\n",len);
+        tmpstr=(*env)->NewString(env,javachars->str[index-1],javachars->size[index-1]); CE
+        for (j=0; j<nstr; j++) {
+            elem = (char*) malloc(javachars->size[j]*sizeof(char));
+            for (i=0; i < javachars->size[j]; i++) {
+                elem[i] = (char) javachars->str[j][i];
+            }
+            //memcpy(digest, elem, javachars->size[j]);
+            for(i=0;i<DIGESTLENGTH;i++) {
+                digest[i]=0;
+            }
+            for(i=0;i<javachars->size[j]; i++) {
+                digest[i % DIGESTLENGTH]+=elem[i];
+            }
+            free(elem);
+            if (memcmp(digest,javachars->checkstr[j],javachars->size[j])==0) {
+                (*env)->ReleaseStringChars(env,jstr,javachars->str[j]); CE
+                javachars->str[j] = NULL;
+                javachars->checkstr[j] = NULL;
+                javachars->size[j] = 0;
+            }
+            else {
+                equal=0;
+                printf("The Unicode element No. %d has been corrupted\n",j);
+                for(i=0;i<DIGESTLENGTH;i++) {
+                    printf("digest[%d]=%02x checkstr[%d]=%02x\n",i,digest[i],i,javachars->checkstr[j][i]);
+                }
+            }
+        }
+        index=0;
+        len = 0;
+        for (j=0;j<nstr;j++)
+            free(javachars->checkstr[j]);
+        free(javachars->checkstr);
+        free((void *)(javachars->str));
+        free(javachars->size);
+        free(javachars);
+        clazz=(*env)->FindClass(env, clsName); CE
+        if (!equal) {
+            methodID=(*env)->GetStaticMethodID(env, clazz, name, sig); CE
+            (*env)->CallStaticVoidMethod(env, clazz, methodID, JNI_FALSE); CE
+        }
+        //methodID=(*env)->GetStaticMethodID(env, clazz, halt, haltSig); CE
+        //(*env)->CallStaticVoidMethod(env, clazz, methodID); CE
+        return(tmpstr);
+    }
+    (*env)->MonitorExit(env, jobj); CE
+    return((*env)->NewString(env,javachars->str[index-1],javachars->size[index-1]));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress002.c	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,102 @@
+/*
+ * 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 <jni.h>
+#include <stdio.h>
+#include "jnihelper.h"
+
+jobject NewObjectWrapper(JNIEnv *env, jclass clazz, jmethodID methodID, ...) {
+  va_list ap;
+  jobject tmp;
+
+  va_start(ap,methodID);
+  tmp=(*env)->NewObjectV(env, clazz, methodID, ap);
+  va_end(ap);
+  return(tmp);
+}
+
+JNIEXPORT jobjectArray JNICALL
+Java_nsk_stress_jni_JNIter002_jniobjects (JNIEnv *env, jobject jobj, jstring jstr, jint intgr,
+              jlong lng, jcharArray jChArr, jfloat flt, jdouble dbl) {
+
+  static int classCount = 0;
+  jobjectArray obj;
+  jobject element;
+  jclass clazz, clazzUp;
+  jmethodID methodID;
+  const char *classname="nsk/stress/jni/objectsJNI";
+  const char *name="<init>";
+  const char *sig="(Ljava/lang/String;IJ[CFD)V";
+  const char *upperClassName="nsk/stress/jni/jnistress002";
+  const char *fieldName="jniStringAllocSize";
+  const char *fieldSig="I";
+  const char *setpass="halt";
+  const char *setpassSig="()V";
+  jvalue paramArr [6];
+
+  (*env)->MonitorEnter(env, jobj); CE
+  ++classCount;
+  (*env)->MonitorExit(env, jobj); CE
+  paramArr[0].l=jstr;
+  paramArr[1].i=intgr;
+  paramArr[2].j=lng;
+  paramArr[3].l=jChArr;
+  paramArr[4].f=flt;
+  paramArr[5].d=dbl;
+
+  clazz=(*env)->FindClass(env,classname); CE
+  obj=(*env)->NewObjectArray(env,(jsize)3,clazz,
+                 (*env)->AllocObject(env, clazz)); CE
+  if (obj==NULL) {
+    fprintf(stderr,"Can not construct the object Array for  %s\n", classname);
+    return(NULL);
+  }
+
+  methodID=(*env)->GetMethodID(env,clazz,name,sig); CE
+  if (methodID==NULL) {
+    fprintf(stderr,"Can not get the ID of <init> for %s\n", classname);
+    return(NULL);
+  }
+
+  element=(*env)->NewObject(env,clazz,methodID,
+                jstr, intgr, lng, jChArr, flt, dbl); CE
+  (*env)->SetObjectArrayElement(env,obj,0,element); CE
+  element=(*env)->NewObjectA(env,clazz,methodID,paramArr); CE
+  (*env)->SetObjectArrayElement(env,obj,1,element); CE
+  element= NewObjectWrapper(env, clazz, methodID,
+                jstr, intgr, lng, jChArr, flt, dbl); CE
+  (*env)->SetObjectArrayElement(env,obj,2,element); CE
+
+  clazzUp=(*env)->FindClass(env, upperClassName); CE
+  if (classCount == (*env)->GetStaticIntField(env, clazzUp,
+      (*env)->GetStaticFieldID(env,clazzUp,fieldName,fieldSig))) {
+    classname="nsk/stress/jni/JNIter002";
+    clazz=(*env)->FindClass(env, classname); CE
+    methodID=(*env)->GetStaticMethodID(env,clazz, setpass, setpassSig); CE
+    (*env)->CallStaticVoidMethod(env, clazz, methodID); CE
+  }
+
+  CE
+
+  return obj;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress003.c	Thu May 17 16:21:27 2018 -0700
@@ -0,0 +1,260 @@
+/*
+ * 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 <jni.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "jnihelper.h"
+
+#define BOOL  0
+#define BYTE  1
+#define CHAR  2
+#define SHORT 3
+#define INT   4
+#define LONG  5
+#define FLOAT 6
+#define DOUBLE 7
+
+JNIEXPORT jobjectArray JNICALL
+Java_nsk_stress_jni_JNIter003_jniInitArrays (JNIEnv *env, jobject jobj, jint size) {
+
+    jobject *arrayArray;
+    jboolean *boolBuf;
+    jbyte *byteBuf;
+    jchar *charBuf;
+    jshort *shortBuf;
+    jint *intBuf;
+    jlong *longBuf;
+    jfloat *floatBuf;
+    jdouble *doubleBuf;
+    jobjectArray objectsArray;
+
+    int i;
+    int SIZE=size;
+    const char *classname="java/lang/Object";
+    jclass clazz = (*env)->FindClass(env,classname); CE
+    objectsArray = (*env)->NewObjectArray(env,8,clazz,(*env)->AllocObject(env,clazz));
+
+    arrayArray=(jobject *)malloc(8*sizeof(jobject)); CE
+    arrayArray[BOOL]=(*env)->NewBooleanArray(env,SIZE); CE
+    arrayArray[BYTE]=(*env)->NewByteArray(env, SIZE); CE
+    arrayArray[CHAR]=(*env)->NewCharArray(env, SIZE); CE
+    arrayArray[SHORT]=(*env)->NewShortArray(env, SIZE); CE
+    arrayArray[INT]=(*env)->NewIntArray(env, SIZE); CE
+    arrayArray[LONG]=(*env)->NewLongArray(env, SIZE); CE
+    arrayArray[FLOAT]=(*env)->NewFloatArray(env, SIZE); CE
+    arrayArray[DOUBLE]=(*env)->NewDoubleArray(env, SIZE); CE
+
+