Merge from default ihse-runtestprebuilt-branch
authorerikj
Fri, 07 Sep 2018 15:46:39 -0700
branchihse-runtestprebuilt-branch
changeset 56894 da01b7339c5e
parent 56875 395b1ac9cdda (current diff)
parent 51676 5a1be00ea4f6 (diff)
child 56895 3289d2b19b94
Merge from default
make/idea/template/build.xml
make/langtools/intellij/ant.xml
make/langtools/intellij/codeStyleSettings.xml
make/langtools/intellij/compiler.xml
make/langtools/intellij/copyright/langtools.xml
make/langtools/intellij/copyright/profiles_settings.xml
make/langtools/intellij/inspectionProfiles/langtools.xml
make/langtools/intellij/inspectionProfiles/profiles_settings.xml
make/langtools/intellij/langtools.iml
make/langtools/intellij/misc.xml
make/langtools/intellij/modules.xml
make/langtools/intellij/runConfigurations/javac.xml
make/langtools/intellij/runConfigurations/javadoc.xml
make/langtools/intellij/runConfigurations/javap.xml
make/langtools/intellij/runConfigurations/jshell.xml
make/langtools/intellij/runConfigurations/sjavac.xml
make/langtools/intellij/src/idea/LangtoolsIdeaAntLogger.java
make/langtools/intellij/vcs.xml
make/langtools/intellij/workspace.xml
src/hotspot/share/utilities/errorReporter.cpp
src/hotspot/share/utilities/errorReporter.hpp
src/hotspot/share/utilities/globalDefinitions_sparcWorks.hpp
test/jdk/com/sun/jdi/CatchAllTest.sh
test/jdk/com/sun/jdi/CatchCaughtTest.sh
test/jdk/com/sun/jdi/CommandCommentDelimiter.sh
test/jdk/com/sun/jdi/DeoptimizeWalk.sh
test/jdk/com/sun/jdi/EvalArgs.sh
test/jdk/com/sun/jdi/EvalArraysAsList.sh
test/jdk/com/sun/jdi/EvalInterfaceStatic.sh
test/jdk/com/sun/jdi/GetLocalVariables3Test.sh
test/jdk/com/sun/jdi/GetLocalVariables4Test.sh
test/jdk/com/sun/jdi/JdbArgTest.sh
test/jdk/com/sun/jdi/JdbLockTest.sh
test/jdk/com/sun/jdi/JdbMissStep.sh
test/jdk/com/sun/jdi/JdbVarargsTest.sh
test/jdk/com/sun/jdi/MixedSuspendTest.sh
test/jdk/com/sun/jdi/NotAField.sh
test/jdk/com/sun/jdi/NullLocalVariable.sh
test/jdk/jdk/internal/reflect/Reflection/GetCallerClassTest.sh
test/jdk/lib/testlibrary/jdk/testlibrary/OSInfo.java
test/jdk/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java
test/jdk/lib/testlibrary/jdk/testlibrary/OutputBuffer.java
test/jdk/lib/testlibrary/jdk/testlibrary/ProcessTools.java
test/jdk/lib/testlibrary/jdk/testlibrary/StreamPumper.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,15 @@
+/build/
+/dist/
+/.idea/
+nbproject/private/
+/webrev
+/.src-rev
+/.jib/
+.DS_Store
+.metadata/
+.recommenders/
+test/nashorn/script/external
+test/nashorn/lib
+NashornProfile.txt
+**/JTreport/**
+**/JTwork/**
--- a/.hgtags	Wed Aug 29 09:45:58 2018 +0200
+++ b/.hgtags	Fri Sep 07 15:46:39 2018 -0700
@@ -496,15 +496,18 @@
 14708e1acdc3974f4539027cbbcfa6d69f83cf51 jdk-11+21
 00b16d0457e43d23f6ca5ade6b243edce62750a0 jdk-12+1
 9937ef7499dcd7673714517fd5e450410c14ba4e jdk-11+22
+69b438908512d3dfef5852c6a843a5778333a309 jdk-12+2
 1edcf36fe15f79d6228d1a63eb680878e2386480 jdk-11+23
+990db216e7199b2ba9989d8fa20b657e0ca7d969 jdk-12+3
 ea900a7dc7d77dee30865c60eabd87fc24b1037c jdk-11+24
+499b873761d8e8a1cc4aa649daf04cbe98cbce77 jdk-12+4
 331888ea4a788df801b1edf8836646cd25fc758b jdk-11+25
+f8696e0ab9b795030429fc3374ec03e378fd9ed7 jdk-12+5
 945ba9278a272a5477ffb1b3ea1b04174fed8036 jdk-11+26
+7939b3c4e4088bf4f70ec5bbd8030393b653372f jdk-12+6
 9d7d74c6f2cbe522e39fa22dc557fdd3f79b32ad jdk-11+27
-69b438908512d3dfef5852c6a843a5778333a309 jdk-12+2
-990db216e7199b2ba9989d8fa20b657e0ca7d969 jdk-12+3
-499b873761d8e8a1cc4aa649daf04cbe98cbce77 jdk-12+4
-f8696e0ab9b795030429fc3374ec03e378fd9ed7 jdk-12+5
-7939b3c4e4088bf4f70ec5bbd8030393b653372f jdk-12+6
 ef57958c7c511162da8d9a75f0b977f0f7ac464e jdk-12+7
+76072a077ee1d815152d45d1692c4b36c53c5c49 jdk-11+28
 492b366f8e5784cc4927c2c98f9b8a3f16c067eb jdk-12+8
+31b159f30fb281016c5f0c103552809aeda84063 jdk-12+9
+8f594f75e0547d4ca16649cb3501659e3155e81b jdk-12+10
--- a/bin/idea.sh	Wed Aug 29 09:45:58 2018 +0200
+++ b/bin/idea.sh	Fri Sep 07 15:46:39 2018 -0700
@@ -49,7 +49,7 @@
       ;;
 
     -o | --output )
-      IDEA_OUTPUT=$2
+      IDEA_OUTPUT=$2/.idea
       shift
       ;;
 
@@ -64,31 +64,25 @@
   shift
 done
 
-mkdir $IDEA_OUTPUT || exit 1
+mkdir -p $IDEA_OUTPUT || exit 1
 cd $IDEA_OUTPUT; IDEA_OUTPUT=`pwd`
 
+if [ "x$TOPLEVEL_DIR" = "x" ] ; then
+    cd $SCRIPT_DIR/..
+    TOPLEVEL_DIR=`pwd`
+    cd $IDEA_OUTPUT
+fi
+
 MAKE_DIR="$SCRIPT_DIR/../make"
-SUPPORT_DIR="$SCRIPT_DIR/../build/.idea-support"
 IDEA_MAKE="$MAKE_DIR/idea"
 IDEA_TEMPLATE="$IDEA_MAKE/template"
 
-mkdir -p $SUPPORT_DIR
-
 cp -r "$IDEA_TEMPLATE"/* "$IDEA_OUTPUT"
 
-#init template variables
-for file in `ls -p $IDEA_TEMPLATE | grep -v /`; do
-	VAR_SUFFIX=`echo $file | cut -d'.' -f1 | tr [:lower:] [:upper:]`
-    eval "$VAR_SUFFIX"_TEMPLATE="$IDEA_TEMPLATE"/$file
-	eval IDEA_"$VAR_SUFFIX"="$IDEA_OUTPUT"/$file
-done
-
-#override template variables
+#override template
 if [ -d "$TEMPLATES_OVERRIDE" ] ; then
     for file in `ls -p "$TEMPLATES_OVERRIDE" | grep -v /`; do
         cp "$TEMPLATES_OVERRIDE"/$file "$IDEA_OUTPUT"/
-    	VAR_SUFFIX=`echo $file | cut -d'.' -f1 | tr [:lower:] [:upper:]`
-        eval "$VAR_SUFFIX"_TEMPLATE="$TEMPLATES_OVERRIDE"/$file
     done
 fi
 
@@ -97,14 +91,6 @@
   echo "idea template dir: $IDEA_TEMPLATE"
 fi
 
-if [ ! -f "$JDK_TEMPLATE" ] ; then
-  echo "FATAL: cannot find $JDK_TEMPLATE" >&2; exit 1
-fi
-
-if [ ! -f "$ANT_TEMPLATE" ] ; then
-  echo "FATAL: cannot find $ANT_TEMPLATE" >&2; exit 1
-fi
-
 cd $TOP ; make -f "$IDEA_MAKE/idea.gmk" -I $MAKE_DIR/.. idea MAKEOVERRIDES= OUT=$IDEA_OUTPUT/env.cfg MODULES="$*" || exit 1
 cd $SCRIPT_DIR
 
@@ -127,99 +113,46 @@
   echo "FATAL: SPEC is empty" >&2; exit 1
 fi
 
-# move build.xml out of .idea, see IDEA-189915
-IDEA_BUILD_OLD=$IDEA_BUILD
-IDEA_BUILD=$SUPPORT_DIR/build.xml
-mv $IDEA_BUILD_OLD $IDEA_BUILD
+### Replace template variables
+
+NUM_REPLACEMENTS=0
 
-SOURCE_FOLDER="      <sourceFolder url=\"file://\$MODULE_DIR\$/####\" isTestSource=\"false\" />"
-SOURCE_FOLDERS_DONE="false"
-
-addSourceFolder() {
-  root=$@
-  relativePath="`echo "$root" | sed -e s@"$TOP/\(.*$\)"@"\1"@`"
-  folder="`echo "$SOURCE_FOLDER" | sed -e s@"\(.*/\)####\(.*\)"@"\1$relativePath\2"@`"
-  printf "%s\n" "$folder" >> $IDEA_JDK
+replace_template_file() {
+    for i in $(seq 1 $NUM_REPLACEMENTS); do
+      eval "sed \"s|\${FROM${i}}|\${TO${i}}|g\" $1 > $1.tmp"
+      mv $1.tmp $1
+    done
 }
 
-### Generate project iml
-
-rm -f $IDEA_JDK
-while IFS= read -r line
-do
-  if echo "$line" | egrep "^ .* <sourceFolder.*####" > /dev/null ; then
-    if [ "$SOURCE_FOLDERS_DONE" = "false" ] ; then
-      SOURCE_FOLDERS_DONE="true"
-      for root in $MODULE_ROOTS; do
-         addSourceFolder $root
-      done
-    fi
-  else
-    printf "%s\n" "$line" >> $IDEA_JDK
-  fi
-done < "$JDK_TEMPLATE"
-
-
-MODULE_NAME="        <property name=\"module.name\" value=\"####\" />"
-
-addModuleName() {
-  mn="`echo "$MODULE_NAME" | sed -e s@"\(.*\)####\(.*\)"@"\1$MODULE_NAMES\2"@`"
-  printf "%s\n" "$mn" >> $IDEA_ANT
+replace_template_dir() {
+    for f in `find $1 -type f` ; do
+        replace_template_file $f
+    done
 }
 
-BUILD_DIR="        <property name=\"build.target.dir\" value=\"####\" />"
-
-addBuildDir() {
-  DIR=`dirname $SPEC`
-  mn="`echo "$BUILD_DIR" | sed -e s@"\(.*\)####\(.*\)"@"\1$DIR\2"@`"
-  printf "%s\n" "$mn" >> $IDEA_ANT
+add_replacement() {
+    NUM_REPLACEMENTS=`expr $NUM_REPLACEMENTS + 1`
+    eval FROM$NUM_REPLACEMENTS='$1'
+    eval TO$NUM_REPLACEMENTS='$2'
 }
 
-### Generate ant.xml
-
-rm -f $IDEA_ANT
-while IFS= read -r line
-do
-  if echo "$line" | egrep "^ .* <property name=\"module.name\"" > /dev/null ; then
-    addModuleName
-  elif echo "$line" | egrep "^ .* <property name=\"build.target.dir\"" > /dev/null ; then
-    addBuildDir
-  else
-    printf "%s\n" "$line" >> $IDEA_ANT
-  fi
-done < "$ANT_TEMPLATE"
-
-### Generate misc.xml
-
-rm -f $IDEA_MISC
-
-JTREG_HOME="    <path>####</path>"
-
-IMAGES_DIR="    <jre alt=\"true\" value=\"####\" />"
+add_replacement "###BUILD_DIR###" "`dirname $SPEC`"
+add_replacement "###MODULE_NAMES###" "$MODULE_NAMES"
+add_replacement "###JTREG_HOME###" "$JT_HOME"
+add_replacement "###IMAGES_DIR###" "`dirname $SPEC`/images/jdk"
+add_replacement "###ROOT_DIR###" "$TOPLEVEL_DIR"
+add_replacement "###IDEA_DIR###" "$IDEA_OUTPUT"
 
-addImagesDir() {
-  DIR=`dirname $SPEC`/images/jdk
-  mn="`echo "$IMAGES_DIR" | sed -e s@"\(.*\)####\(.*\)"@"\1$DIR\2"@`"
-  printf "%s\n" "$mn" >> $IDEA_MISC
-}
-
-addJtregHome() {
-  DIR=`dirname $SPEC`
-  mn="`echo "$JTREG_HOME" | sed -e s@"\(.*\)####\(.*\)"@"\1$JT_HOME\2"@`"
-  printf "%s\n" "$mn" >> $IDEA_MISC
-}
+SOURCE_PREFIX="<sourceFolder url=\"file://"
+SOURCE_POSTFIX="\" isTestSource=\"false\" />"
 
-rm -f $MISC_ANT
-while IFS= read -r line
-do
-  if echo "$line" | egrep "^ .*<path>jtreg_home</path>" > /dev/null ; then
-	addJtregHome
-  elif echo "$line" | egrep "^ .*<jre alt=\"true\" value=\"images_jdk\"" > /dev/null ; then
-    addImagesDir
-  else
-    printf "%s\n" "$line" >> $IDEA_MISC
-  fi
-done < "$MISC_TEMPLATE"
+for root in $MODULE_ROOTS; do
+    SOURCES=$SOURCES" $SOURCE_PREFIX""$root""$SOURCE_POSTFIX"
+done
+
+add_replacement "###SOURCE_ROOTS###" "$SOURCES"
+
+replace_template_dir "$IDEA_OUTPUT"
 
 ### Compile the custom Logger
 
--- a/doc/building.html	Wed Aug 29 09:45:58 2018 +0200
+++ b/doc/building.html	Fri Sep 07 15:46:39 2018 -0700
@@ -26,7 +26,8 @@
 <li><a href="#build-hardware-requirements">Build Hardware Requirements</a><ul>
 <li><a href="#building-on-x86">Building on x86</a></li>
 <li><a href="#building-on-sparc">Building on sparc</a></li>
-<li><a href="#building-on-armaarch64">Building on arm/aarch64</a></li>
+<li><a href="#building-on-aarch64">Building on aarch64</a></li>
+<li><a href="#building-on-32-bit-arm">Building on 32-bit arm</a></li>
 </ul></li>
 <li><a href="#operating-system-requirements">Operating System Requirements</a><ul>
 <li><a href="#windows">Windows</a></li>
@@ -154,7 +155,10 @@
 <p>Even for 32-bit builds, it is recommended to use a 64-bit build machine, and instead create a 32-bit target using <code>--with-target-bits=32</code>.</p>
 <h3 id="building-on-sparc">Building on sparc</h3>
 <p>At a minimum, a machine with 4 cores is advisable, as well as 4 GB of RAM. (The more cores to use, the more memory you need.) At least 8 GB of free disk space is required.</p>
-<h3 id="building-on-armaarch64">Building on arm/aarch64</h3>
+<h3 id="building-on-aarch64">Building on aarch64</h3>
+<p>At a minimum, a machine with 8 cores is advisable, as well as 8 GB of RAM. (The more cores to use, the more memory you need.) At least 6 GB of free disk space is required.</p>
+<p>If you do not have access to sufficiently powerful hardware, it is also possible to use <a href="#cross-compiling">cross-compiling</a>.</p>
+<h3 id="building-on-32-bit-arm">Building on 32-bit arm</h3>
 <p>This is not recommended. Instead, see the section on <a href="#cross-compiling">Cross-compiling</a>.</p>
 <h2 id="operating-system-requirements">Operating System Requirements</h2>
 <p>The mainline JDK project supports Linux, Solaris, macOS, AIX and Windows. Support for other operating system, e.g. BSD, exists in separate &quot;port&quot; projects.</p>
--- a/doc/building.md	Wed Aug 29 09:45:58 2018 +0200
+++ b/doc/building.md	Fri Sep 07 15:46:39 2018 -0700
@@ -120,7 +120,16 @@
 more cores to use, the more memory you need.) At least 8 GB of free disk space
 is required.
 
-### Building on arm/aarch64
+### Building on aarch64
+
+At a minimum, a machine with 8 cores is advisable, as well as 8 GB of RAM.
+(The more cores to use, the more memory you need.) At least 6 GB of free disk
+space is required.
+
+If you do not have access to sufficiently powerful hardware, it is also
+possible to use [cross-compiling](#cross-compiling).
+
+### Building on 32-bit arm
 
 This is not recommended. Instead, see the section on [Cross-compiling](
 #cross-compiling).
--- a/doc/testing.html	Wed Aug 29 09:45:58 2018 +0200
+++ b/doc/testing.html	Fri Sep 07 15:46:39 2018 -0700
@@ -1,16 +1,11 @@
 <!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
+<html>
 <head>
-  <meta charset="utf-8" />
-  <meta name="generator" content="pandoc" />
-  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
+  <meta charset="utf-8">
+  <meta name="generator" content="pandoc">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
   <title>Testing the JDK</title>
-  <style type="text/css">
-      code{white-space: pre-wrap;}
-      span.smallcaps{font-variant: small-caps;}
-      span.underline{text-decoration: underline;}
-      div.column{display: inline-block; vertical-align: top; width: 50%;}
-  </style>
+  <style type="text/css">code{white-space: pre;}</style>
   <link rel="stylesheet" href="../make/data/docs-resources/resources/jdk-default.css">
   <!--[if lt IE 9]>
     <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
@@ -39,7 +34,7 @@
 </nav>
 <h2 id="using-the-run-test-framework">Using the run-test framework</h2>
 <p>This new way of running tests is developer-centric. It assumes that you have built a JDK locally and want to test it. Running common test targets is simple, and more complex ad-hoc combination of tests is possible. The user interface is forgiving, and clearly report errors it cannot resolve.</p>
-<p>The main target “run-test” uses the jdk-image as the tested product. There is also an alternate target “exploded-run-test” that uses the exploded image instead. Not all tests will run successfully on the exploded image, but using this target can greatly improve rebuild times for certain workflows.</p>
+<p>The main target &quot;run-test&quot; uses the jdk-image as the tested product. There is also an alternate target &quot;exploded-run-test&quot; that uses the exploded image instead. Not all tests will run successfully on the exploded image, but using this target can greatly improve rebuild times for certain workflows.</p>
 <p>Some example command-lines:</p>
 <pre><code>$ make run-test-tier1
 $ make run-test-jdk_lang JTREG=&quot;JOBS=8&quot;
@@ -49,7 +44,7 @@
 $ make run-test TEST=&quot;jtreg:test/hotspot:hotspot_gc test/hotspot/jtreg/native_sanity/JniVersion.java&quot;
 $ make exploded-run-test TEST=tier2</code></pre>
 <h3 id="configuration">Configuration</h3>
-<p>To be able to run JTReg tests, <code>configure</code> needs to know where to find the JTReg test framework. If it is not picked up automatically by configure, use the <code>--with-jtreg=&lt;path to jtreg home&gt;</code> option to point to the JTReg framework. Note that this option should point to the JTReg home, i.e. the top directory, containing <code>lib/jtreg.jar</code> etc. (An alternative is to set the <code>JT_HOME</code> environment variable to point to the JTReg home before running <code>configure</code>.)</p>
+<p>To be able to run JTReg tests, <code>configure</code> needs to know where to find the JTReg test framework. If it is not picked up automatically by configure, use the <code>--with-jtreg=&lt;path to jtreg home&gt;</code> option to point to the JTReg framework. Note that this option should point to the JTReg home, i.e. the top directory, containing <code>lib/jtreg.jar</code> etc. (An alternative is to set the <code>JT_HOME</code> environment variable to point to the JTReg home before running <code>configure</code>.)</p>
 <h2 id="test-selection">Test selection</h2>
 <p>All functionality is available using the run-test make target. In this use case, the test or tests to be executed is controlled using the <code>TEST</code> variable. To speed up subsequent test runs with no source code changes, run-test-only can be used instead, which do not depend on the source and test image build.</p>
 <p>For some common top-level tests, direct make targets have been generated. This includes all JTReg test groups, the hotspot gtest, and custom tests (if present). This means that <code>make run-test-tier1</code> is equivalent to <code>make run-test TEST=&quot;tier1&quot;</code>, but the latter is more tab-completion friendly. For more complex test runs, the <code>run-test TEST=&quot;x&quot;</code> solution needs to be used.</p>
@@ -63,7 +58,7 @@
 <h3 id="gtest">Gtest</h3>
 <p>Since the Hotspot Gtest suite is so quick, the default is to run all tests. This is specified by just <code>gtest</code>, or as a fully qualified test descriptor <code>gtest:all</code>.</p>
 <p>If you want, you can single out an individual test or a group of tests, for instance <code>gtest:LogDecorations</code> or <code>gtest:LogDecorations.level_test_vm</code>. This can be particularly useful if you want to run a shaky test repeatedly.</p>
-<p>For Gtest, there is a separate test suite for each JVM variant. The JVM variant is defined by adding <code>/&lt;variant&gt;</code> to the test descriptor, e.g. <code>gtest:Log/client</code>. If you specify no variant, gtest will run once for each JVM variant present (e.g. server, client). So if you only have the server JVM present, then <code>gtest:all</code> will be equivalent to <code>gtest:all/server</code>.</p>
+<p>For Gtest, there is a separate test suite for each JVM variant. The JVM variant is defined by adding <code>/&lt;variant&gt;</code> to the test descriptor, e.g. <code>gtest:Log/client</code>. If you specify no variant, gtest will run once for each JVM variant present (e.g. server, client). So if you only have the server JVM present, then <code>gtest:all</code> will be equivalent to <code>gtest:all/server</code>.</p>
 <h2 id="test-results-and-summary">Test results and summary</h2>
 <p>At the end of the test run, a summary of all tests run will be presented. This will have a consistent look, regardless of what test suites were used. This is a sample summary:</p>
 <pre><code>==============================
@@ -78,13 +73,13 @@
 <p>Tests where the number of TOTAL tests does not equal the number of PASSed tests will be considered a test failure. These are marked with the <code>&gt;&gt; ... &lt;&lt;</code> marker for easy identification.</p>
 <p>The classification of non-passed tests differs a bit between test suites. In the summary, ERROR is used as a catch-all for tests that neither passed nor are classified as failed by the framework. This might indicate test framework error, timeout or other problems.</p>
 <p>In case of test failures, <code>make run-test</code> will exit with a non-zero exit value.</p>
-<p>All tests have their result stored in <code>build/$BUILD/test-results/$TEST_ID</code>, where TEST_ID is a path-safe conversion from the fully qualified test descriptor, e.g. for <code>jtreg:jdk/test:tier1</code> the TEST_ID is <code>jtreg_jdk_test_tier1</code>. This path is also printed in the log at the end of the test run.</p>
+<p>All tests have their result stored in <code>build/$BUILD/test-results/$TEST_ID</code>, where TEST_ID is a path-safe conversion from the fully qualified test descriptor, e.g. for <code>jtreg:jdk/test:tier1</code> the TEST_ID is <code>jtreg_jdk_test_tier1</code>. This path is also printed in the log at the end of the test run.</p>
 <p>Additional work data is stored in <code>build/$BUILD/test-support/$TEST_ID</code>. For some frameworks, this directory might contain information that is useful in determining the cause of a failed test.</p>
 <h2 id="test-suite-control">Test suite control</h2>
 <p>It is possible to control various aspects of the test suites using make control variables.</p>
 <p>These variables use a keyword=value approach to allow multiple values to be set. So, for instance, <code>JTREG=&quot;JOBS=1;TIMEOUT=8&quot;</code> will set the JTReg concurrency level to 1 and the timeout factor to 8. This is equivalent to setting <code>JTREG_JOBS=1 JTREG_TIMEOUT=8</code>, but using the keyword format means that the <code>JTREG</code> variable is parsed and verified for correctness, so <code>JTREG=&quot;TMIEOUT=8&quot;</code> would give an error, while <code>JTREG_TMIEOUT=8</code> would just pass unnoticed.</p>
 <p>To separate multiple keyword=value pairs, use <code>;</code> (semicolon). Since the shell normally eats <code>;</code>, the recommended usage is to write the assignment inside qoutes, e.g. <code>JTREG=&quot;...;...&quot;</code>. This will also make sure spaces are preserved, as in <code>JTREG=&quot;VM_OPTIONS=-XshowSettings -Xlog:gc+ref=debug&quot;</code>.</p>
-<p>(Other ways are possible, e.g. using backslash: <code>JTREG=JOBS=1\;TIMEOUT=8</code>. Also, as a special technique, the string <code>%20</code> will be replaced with space for certain options, e.g. <code>JTREG=VM_OPTIONS=-XshowSettings%20-Xlog:gc+ref=debug</code>. This can be useful if you have layers of scripts and have trouble getting proper quoting of command line arguments through.)</p>
+<p>(Other ways are possible, e.g. using backslash: <code>JTREG=JOBS=1\;TIMEOUT=8</code>. Also, as a special technique, the string <code>%20</code> will be replaced with space for certain options, e.g. <code>JTREG=VM_OPTIONS=-XshowSettings%20-Xlog:gc+ref=debug</code>. This can be useful if you have layers of scripts and have trouble getting proper quoting of command line arguments through.)</p>
 <p>As far as possible, the names of the keywords have been standardized between test suites.</p>
 <h3 id="jtreg-keywords">JTReg keywords</h3>
 <h4 id="jobs">JOBS</h4>
--- a/make/Docs.gmk	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/Docs.gmk	Fri Sep 07 15:46:39 2018 -0700
@@ -61,7 +61,7 @@
     $(SUPPORT_OUTPUTDIR)/rmic/* $(TOPDIR)/src/*/share/doc/stub)
 
 # URLs
-JAVADOC_BASE_URL := http://www.oracle.com/pls/topic/lookup?ctx=javase10&amp;id=homepage
+JAVADOC_BASE_URL := http://www.oracle.com/pls/topic/lookup?ctx=javase$(VERSION_NUMBER)&amp;id=homepage
 BUG_SUBMIT_URL := http://bugreport.java.com/bugreport/
 COPYRIGHT_URL := {@docroot}/../legal/copyright.html
 LICENSE_URL := http://www.oracle.com/technetwork/java/javase/terms/license/java$(VERSION_NUMBER)speclicense.html
--- a/make/SourceRevision.gmk	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/SourceRevision.gmk	Fri Sep 07 15:46:39 2018 -0700
@@ -31,23 +31,35 @@
 ################################################################################
 # Keep track of what source revision is used to create the build, by creating
 # a tracker file in the output directory. This tracker file is included in the
-# image, and can be used to recreate the source revision used.
+# source image, and can be used to recreate the source revision used.
 #
-# We're either building directly from a mercurial forest, and if so, use the
-# current revision from mercurial. Otherwise, we are building from a source
-# bundle. As a part of creating this source bundle, the current mercurial
-# revisions of all repos will be stored in a file in the top dir, which is then
-# used when creating the tracker file.
+# We're either building directly from an SCM repository, and if so, use the
+# current revision from that SCM. Otherwise, we are building from a source
+# bundle. As a part of creating this source bundle, the current SCM revisions of
+# all repos will be stored in a file in the top dir, which is then used when
+# creating the tracker file.
 
 STORED_SOURCE_REVISION := $(TOPDIR)/.src-rev
 
-# Are we using mercurial?
+USE_SCM := false
 ifneq ($(and $(HG), $(wildcard $(TOPDIR)/.hg)), )
+  USE_SCM := true
+  SCM_DIR := .hg
+  ID_COMMAND := $(PRINTF) "hg:%s" "$$($(HG) id -i)"
+else ifneq ($(and $(GIT), $(wildcard $(TOPDIR)/.git)), )
+  USE_SCM := true
+  SCM_DIR := .git
+  ID_COMMAND := $(PRINTF) "git:%s%s\n" \
+      "$$(git log -n1 --format=%H | cut -c1-12)" \
+      "$$(if test -n "$$(git status --porcelain)"; then printf '+'; fi)"
+endif
+
+ifeq ($(USE_SCM), true)
 
   # Verify that the entire forest is consistent
   $(foreach repo, $(call FindAllReposRel), \
-    $(if $(wildcard $(TOPDIR)/$(repo)/.hg),, \
-        $(error Inconsistent revision control: $(repo) is missing .hg directory)) \
+    $(if $(wildcard $(TOPDIR)/$(repo)/$(SCM_DIR)),, \
+        $(error Inconsistent revision control: $(repo) is missing $(SCM_DIR) directory)) \
   )
 
   # Replace "." with "_top" and "/" with "-"
@@ -56,7 +68,9 @@
 
   ################################################################################
   # SetupGetRevisionForRepo defines a make rule for creating a file containing
-  # the name of the repository and the output of "hg id" for that repository.
+  # the name of the repository and the output of the scm command for that
+  # repository.
+  #
   # Argument 1 is the relative path to the repository from the top dir.
   #
   SetupGetRevisionForRepo = $(NamedParamsMacroTemplate)
@@ -66,7 +80,7 @@
 
     $$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME): FRC
 	$$(call MakeDir, $$(@D))
-	$$(ECHO) $$(strip $1):`$$(HG) id -i --repository $$($1_REPO_PATH)` > $$@
+	$$(ECHO) $$(strip $1):`$$(CD) $$($1_REPO_PATH) && $$(ID_COMMAND)` > $$@
 
     REPO_REVISIONS += $$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME)
   endef
@@ -92,23 +106,25 @@
 
   $(eval $(call CreateSourceRevisionFile, $(STORED_SOURCE_REVISION)))
 
-  hg-store-source-revision: $(STORED_SOURCE_REVISION)
+  scm-store-source-revision: $(STORED_SOURCE_REVISION)
 
   $(eval $(call CreateSourceRevisionFile, $(SOURCE_REVISION_TRACKER)))
 
-  hg-create-source-revision-tracker: $(SOURCE_REVISION_TRACKER)
+  scm-create-source-revision-tracker: $(SOURCE_REVISION_TRACKER)
 
-  STORE_SOURCE_REVISION_TARGET := hg-store-source-revision
-  CREATE_SOURCE_REVISION_TRACKER_TARGET := hg-create-source-revision-tracker
+  STORE_SOURCE_REVISION_TARGET := scm-store-source-revision
+  CREATE_SOURCE_REVISION_TRACKER_TARGET := scm-create-source-revision-tracker
+
+  .PHONY: scm-store-source-revision scm-create-source-revision-tracker
 
 else
-  # Not using HG
+  # Not using any SCM
 
   ifneq ($(wildcard $(STORED_SOURCE_REVISION)), )
     # We have a stored source revision (.src-rev)
 
     src-store-source-revision:
-	$(call LogInfo, No mercurial configuration present$(COMMA) not updating .src-rev)
+	$(call LogInfo, No SCM configuration present$(COMMA) not updating .src-rev)
 
     $(SOURCE_REVISION_TRACKER): $(STORED_SOURCE_REVISION)
 	$(install-file)
@@ -118,16 +134,18 @@
     # We don't have a stored source revision. Can't do anything, really.
 
     src-store-source-revision:
-	$(call LogWarn, Error: No mercurial configuration present$(COMMA) cannot create .src-rev)
+	$(call LogWarn, Error: No SCM configuration present$(COMMA) cannot create .src-rev)
 	exit 2
 
     src-create-source-revision-tracker:
-	$(call LogWarn, Warning: No mercurial configuration present and no .src-rev)
+	$(call LogWarn, Warning: No SCM configuration present and no .src-rev)
   endif
 
   STORE_SOURCE_REVISION_TARGET := src-store-source-revision
   CREATE_SOURCE_REVISION_TRACKER_TARGET := src-create-source-revision-tracker
 
+  .PHONY: src-store-source-revision src-create-source-revision-tracker
+
 endif
 
 ################################################################################
--- a/make/autoconf/basics.m4	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/autoconf/basics.m4	Fri Sep 07 15:46:39 2018 -0700
@@ -1190,6 +1190,7 @@
   BASIC_PATH_PROGS(READELF, [greadelf readelf])
   BASIC_PATH_PROGS(DOT, dot)
   BASIC_PATH_PROGS(HG, hg)
+  BASIC_PATH_PROGS(GIT, git)
   BASIC_PATH_PROGS(STAT, stat)
   BASIC_PATH_PROGS(TIME, time)
   BASIC_PATH_PROGS(FLOCK, flock)
--- a/make/autoconf/configure	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/autoconf/configure	Fri Sep 07 15:46:39 2018 -0700
@@ -122,14 +122,18 @@
   if test "x$CUSTOM_CONFIG_DIR" != x; then
     # Generate configure script with custom hooks compiled in.
     custom_patcher='sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|"'
+    custom_script_dir_include="-I$CUSTOM_CONFIG_DIR"
   else
     custom_patcher='cat'
+    custom_script_dir_include=""
   fi
 
   mkdir -p $build_support_dir
   # Call autoconf but replace the "magic" variable in configure.ac if requested.
+
   cat $conf_script_dir/configure.ac | eval $custom_patcher | \
-      ${AUTOCONF} -W all -I$conf_script_dir - > $generated_script
+      ${AUTOCONF} -W all $custom_script_dir_include -I$conf_script_dir - \
+      > $generated_script
   rm -rf autom4te.cache
 
   # Sanity check
--- a/make/autoconf/flags.m4	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/autoconf/flags.m4	Fri Sep 07 15:46:39 2018 -0700
@@ -241,7 +241,8 @@
   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
     MACHINE_FLAG="-m${OPENJDK_TARGET_CPU_BITS}"
   elif test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
-    if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86 ||
+    if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86 &&
+        test "x$OPENJDK_TARGET_CPU" != xx32 ||
         test "x$OPENJDK_TARGET_CPU_ARCH" = xsparc ||
         test "x$OPENJDK_TARGET_CPU_ARCH" = xppc; then
       MACHINE_FLAG="-m${OPENJDK_TARGET_CPU_BITS}"
--- a/make/autoconf/hotspot.m4	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/autoconf/hotspot.m4	Fri Sep 07 15:46:39 2018 -0700
@@ -517,9 +517,6 @@
 
   # Used for verification of Makefiles by check-jvm-feature
   AC_SUBST(VALID_JVM_FEATURES)
-
-  # We don't support --with-jvm-interpreter anymore, use zero instead.
-  BASIC_DEPRECATED_ARG_WITH(jvm-interpreter)
 ])
 
 ###############################################################################
--- a/make/autoconf/jdk-options.m4	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/autoconf/jdk-options.m4	Fri Sep 07 15:46:39 2018 -0700
@@ -126,10 +126,6 @@
   else
     AC_MSG_ERROR([Invalid value for --enable-openjdk-only: $enable_openjdk_only])
   fi
-
-  # custom-make-dir is deprecated. Please use your custom-hook.m4 to override
-  # the IncludeCustomExtension macro.
-  BASIC_DEPRECATED_ARG_WITH(custom-make-dir)
 ])
 
 AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS],
@@ -350,16 +346,6 @@
     AC_MSG_ERROR([Allowed native debug symbols are: none, internal, external, zipped])
   fi
 
-  # --enable-debug-symbols is deprecated.
-  # Please use --with-native-debug-symbols=[internal,external,zipped] .
-  BASIC_DEPRECATED_ARG_ENABLE(debug-symbols, debug_symbols,
-        [Please use --with-native-debug-symbols=[[internal,external,zipped]] .])
-
-  # --enable-zip-debug-info is deprecated.
-  # Please use --with-native-debug-symbols=zipped .
-  BASIC_DEPRECATED_ARG_ENABLE(zip-debug-info, zip_debug_info,
-                              [Please use --with-native-debug-symbols=zipped .])
-
   AC_SUBST(COMPILE_WITH_DEBUG_SYMBOLS)
   AC_SUBST(COPY_DEBUG_SYMBOLS)
   AC_SUBST(ZIP_EXTERNAL_DEBUG_SYMBOLS)
--- a/make/autoconf/jdk-version.m4	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/autoconf/jdk-version.m4	Fri Sep 07 15:46:39 2018 -0700
@@ -57,15 +57,6 @@
 
 AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS],
 [
-  # Warn user that old version arguments are deprecated.
-  BASIC_DEPRECATED_ARG_WITH([milestone])
-  BASIC_DEPRECATED_ARG_WITH([update-version])
-  BASIC_DEPRECATED_ARG_WITH([user-release-suffix])
-  BASIC_DEPRECATED_ARG_WITH([build-number])
-  BASIC_DEPRECATED_ARG_WITH([version-major])
-  BASIC_DEPRECATED_ARG_WITH([version-minor])
-  BASIC_DEPRECATED_ARG_WITH([version-security])
-
   # Source the version numbers file
   . $AUTOCONF_DIR/version-numbers
 
@@ -443,7 +434,7 @@
     AC_MSG_ERROR([--with-version-date must have a value])
   elif test "x$with_version_date" != x; then
     if [ ! [[ $with_version_date =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] ]; then
-      AC_MSG_ERROR(["$with_version_date" is not a valid version date]) 
+      AC_MSG_ERROR(["$with_version_date" is not a valid version date])
     else
       VERSION_DATE="$with_version_date"
     fi
--- a/make/autoconf/libraries.m4	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/autoconf/libraries.m4	Fri Sep 07 15:46:39 2018 -0700
@@ -180,13 +180,6 @@
   AC_SUBST(LIBDL)
   LIBS="$save_LIBS"
 
-  # Deprecated libraries, keep the flags for backwards compatibility
-  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
-    BASIC_DEPRECATED_ARG_WITH([dxsdk])
-    BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
-    BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
-  fi
-
   # Control if libzip can use mmap. Available for purposes of overriding.
   LIBZIP_CAN_USE_MMAP=true
   AC_SUBST(LIBZIP_CAN_USE_MMAP)
@@ -217,4 +210,3 @@
     AC_SUBST(STLPORT_LIB)
   fi
 ])
-
--- a/make/autoconf/platform.m4	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/autoconf/platform.m4	Fri Sep 07 15:46:39 2018 -0700
@@ -30,6 +30,12 @@
 [
   # First argument is the cpu name from the trip/quad
   case "$1" in
+    x86_64*x32)
+      VAR_CPU=x32
+      VAR_CPU_ARCH=x86
+      VAR_CPU_BITS=32
+      VAR_CPU_ENDIAN=little
+      ;;
     x86_64)
       VAR_CPU=x86_64
       VAR_CPU_ARCH=x86
@@ -455,6 +461,8 @@
     HOTSPOT_$1_CPU_DEFINE=IA32
   elif test "x$OPENJDK_$1_CPU" = xx86_64; then
     HOTSPOT_$1_CPU_DEFINE=AMD64
+  elif test "x$OPENJDK_$1_CPU" = xx32; then
+    HOTSPOT_$1_CPU_DEFINE=X32
   elif test "x$OPENJDK_$1_CPU" = xsparcv9; then
     HOTSPOT_$1_CPU_DEFINE=SPARC
   elif test "x$OPENJDK_$1_CPU" = xaarch64; then
--- a/make/autoconf/spec.gmk.in	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/autoconf/spec.gmk.in	Fri Sep 07 15:46:39 2018 -0700
@@ -723,6 +723,7 @@
 FILE:=@FILE@
 DOT:=@DOT@
 HG:=@HG@
+GIT:=@GIT@
 OBJCOPY:=@OBJCOPY@
 SETFILE:=@SETFILE@
 XATTR:=@XATTR@
--- a/make/autoconf/toolchain.m4	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/autoconf/toolchain.m4	Fri Sep 07 15:46:39 2018 -0700
@@ -1026,8 +1026,6 @@
   HOTSPOT_TOOLCHAIN_TYPE=$TOOLCHAIN_TYPE
   if test "x$TOOLCHAIN_TYPE" = xclang; then
     HOTSPOT_TOOLCHAIN_TYPE=gcc
-  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
-    HOTSPOT_TOOLCHAIN_TYPE=sparcWorks
   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
     HOTSPOT_TOOLCHAIN_TYPE=visCPP
   fi
--- a/make/common/MakeBase.gmk	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/common/MakeBase.gmk	Fri Sep 07 15:46:39 2018 -0700
@@ -347,6 +347,7 @@
 FindAllReposAbs = \
     $(strip $(sort $(dir $(filter-out $(TOPDIR)/build/%, $(wildcard \
         $(addprefix $(TOPDIR)/, .hg */.hg */*/.hg */*/*/.hg */*/*/*/.hg) \
+        $(addprefix $(TOPDIR)/, .git */.git */*/.git */*/*/.git */*/*/*/.git) \
     )))))
 
 # Locate all hg repositories included in the forest, as relative paths
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/idea/build.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,43 @@
+<!-- importing.xml -->
+<project name="jdk">
+
+    <script language="javascript" classpath="${idea.dir}/classes">
+        var JdkLogger = Java.type("idea.JdkIdeaAntLogger");
+        new JdkLogger(project)
+    </script>
+
+    <macrodef name="call-make">
+        <attribute name="dir"/>
+        <attribute name="args"/>
+        <sequential>
+            <exec executable="make" dir="@{dir}" failonerror="true">
+                <arg line="@{args}"/>
+                <env key="CLASSPATH" value = ""/>
+            </exec>
+        </sequential>
+    </macrodef>
+
+    <target name="cond-clean" unless="${intellij.ismake}">
+        <antcall target="clean"/>
+    </target>
+
+    <target name="post-make" depends="cond-clean, build-module"/>
+
+    <!--
+        **** Global JDK Build Targets
+    -->
+
+    <target name="clean">
+        <echo message="base = ${basedir}"/>
+        <call-make dir = "${build.target.dir}" args = "reconfigure"/>
+        <call-make dir = "${build.target.dir}" args = "clean"/>
+    </target>
+
+    <target name="images">
+        <call-make dir = "${build.target.dir}" args = "images"/>
+    </target>
+
+    <target name="build-module">
+        <call-make dir = "${build.target.dir}" args = "${module.name}"/>
+    </target>
+</project>
--- a/make/idea/template/ant.xml	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/idea/template/ant.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="AntConfiguration">
-    <buildFile url="file://$PROJECT_DIR$/build/.idea-support/build.xml">
+    <buildFile url="file://###ROOT_DIR###/make/idea/build.xml">
       <properties>
         <property name="intellij.ismake" value="$IsMake$" />
-        <property name="build.target.dir" value="specDir" /> <!-- this will be replaced -->
-        <property name="module.name" value="java.base" /> <!-- this will be replaced -->
+        <property name="build.target.dir" value="###BUILD_DIR###" />
+        <property name="module.name" value="###MODULE_NAMES###" />
+        <property name="idea.dir" value="###IDEA_DIR###" />
       </properties>
       <executeOn event="afterCompilation" target="post-make" />
     </buildFile>
--- a/make/idea/template/build.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-<!-- importing.xml -->
-<project name="jdk" basedir="../..">
-
-    <script language="javascript" classpath=".idea/classes">
-        var JdkLogger = Java.type("idea.JdkIdeaAntLogger");
-        new JdkLogger(project)
-    </script>
-
-    <macrodef name="call-make">
-        <attribute name="dir"/>
-        <attribute name="args"/>
-        <sequential>
-            <exec executable="make" dir="@{dir}" failonerror="true">
-                <arg line="@{args}"/>
-                <env key="CLASSPATH" value = ""/>
-            </exec>
-        </sequential>
-    </macrodef>
-
-    <target name="cond-clean" unless="${intellij.ismake}">
-        <antcall target="clean"/>
-    </target>
-
-    <target name="post-make" depends="cond-clean, build-module"/>
-
-    <!--
-        **** Global JDK Build Targets
-    -->
-
-    <target name="clean">
-        <echo message="base = ${basedir}"/>
-        <call-make dir = "${build.target.dir}" args = "reconfigure"/>
-        <call-make dir = "${build.target.dir}" args = "clean"/>
-    </target>
-
-    <target name="images">
-        <call-make dir = "${build.target.dir}" args = "images"/>
-    </target>
-
-    <target name="build-module">
-        <call-make dir = "${build.target.dir}" args = "${module.name}"/>
-    </target>
-</project>
--- a/make/idea/template/compiler.xml	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/idea/template/compiler.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -3,10 +3,10 @@
   <component name="CompilerConfiguration">
     <option name="DEFAULT_COMPILER" value="Javac" />
     <excludeFromCompile>
-      <directory url="file://$PROJECT_DIR$/src" includeSubdirectories="true" />
-      <directory url="file://$PROJECT_DIR$/build" includeSubdirectories="true" />
-      <directory url="file://$PROJECT_DIR$/make" includeSubdirectories="true" />
-      <directory url="file://$PROJECT_DIR$/test" includeSubdirectories="true" />
+      <directory url="file://###ROOT_DIR###/src" includeSubdirectories="true" />
+      <directory url="file://###ROOT_DIR###/build" includeSubdirectories="true" />
+      <directory url="file://###ROOT_DIR###/make" includeSubdirectories="true" />
+      <directory url="file://###ROOT_DIR###/test" includeSubdirectories="true" />
     </excludeFromCompile>
     <resourceExtensions />
     <wildcardResourcePatterns>
@@ -25,4 +25,5 @@
       </profile>
     </annotationProcessing>
   </component>
-</project>
\ No newline at end of file
+</project>
+
--- a/make/idea/template/jdk.iml	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/idea/template/jdk.iml	Fri Sep 07 15:46:39 2018 -0700
@@ -2,10 +2,10 @@
 <module type="JAVA_MODULE" version="4">
   <component name="NewModuleRootManager" inherit-compiler-output="true">
     <exclude-output />
-    <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/####" isTestSource="false" />
-      <excludeFolder url="file://$MODULE_DIR$/build" />
-      <excludeFolder url="file://$MODULE_DIR$/make" />
+    <content url="file://###ROOT_DIR###">
+      ###SOURCE_ROOTS###
+      <excludeFolder url="file://###ROOT_DIR###/build" />
+      <excludeFolder url="file://###ROOT_DIR###/make" />
     </content>
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="inheritedJdk" />
--- a/make/idea/template/misc.xml	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/idea/template/misc.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -4,15 +4,15 @@
     <entry_points version="2.0" />
   </component>
   <component name="JTRegService">
-    <path>jtreg_home</path> <!-- this will be replaced -->
-    <workDir>build</workDir>
-    <jre alt="true" value="images_jdk" /> <!-- this will be replaced -->
+    <path>###JTREG_HOME###</path>
+    <workDir>###BUILD_DIR###</workDir>
+    <jre alt="true" value="###IMAGES_DIR###" />
     <options></options>
     <ant>
-      <target file="file://$PROJECT_DIR$/build/.idea-support/build.xml" name="images" />
+      <target file="file://###ROOT_DIR###/make/idea/build.xml" name="images" />
     </ant>
   </component>
   <component name="ProjectRootManager" version="2" languageLevel="JDK_1_9" assert-keyword="true" jdk-15="true">
-    <output url="file://$PROJECT_DIR$/build/.idea-support/out" />
+    <output url="file://###BUILD_DIR###" />
   </component>
 </project>
--- a/make/idea/template/vcs.xml	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/idea/template/vcs.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="VcsDirectoryMappings">
-    <mapping directory="$PROJECT_DIR$" vcs="hg4idea" />
+    <mapping directory="###ROOT_DIR###" vcs="hg4idea" />
   </component>
 </project>
-
--- a/make/idea/template/workspace.xml	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/idea/template/workspace.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -2,7 +2,7 @@
 <project version="4">
   <component name="ChangeListManager">
     <ignored path="jdk.iws" />
-    <ignored path="$PROJECT_DIR$/build/idea/out/" />
+    <ignored path="###ROOT_DIR###/build/idea/out/" />
     <ignored path=".idea/" />
   </component>
   <component name="StructureViewFactory">
@@ -11,24 +11,11 @@
   <component name="antWorkspaceConfiguration">
     <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
     <option name="FILTER_TARGETS" value="false" />
-    <buildFile url="file://$PROJECT_DIR$/.idea/build.xml">
+    <buildFile url="file://###ROOT_DIR###/make/idea/build.xml">
       <runInBackground value="false" />
       <targetFilters>
-        <filter targetName="post-make" isVisible="false" />
         <filter targetName="clean" isVisible="true" />
-        <filter targetName="-do-configure" isVisible="false" />
         <filter targetName="images" isVisible="true" />
-        <filter targetName="build-module" isVisible="true" />
-        <filter targetName="jtreg-debug" isVisible="false" />
-        <filter targetName="jtreg-debug-internal" isVisible="false" />
-        <filter targetName="jtreg" isVisible="false" />
-        <filter targetName="-check-jtreg.home" isVisible="false" />
-        <filter targetName="-def-check" isVisible="false" />
-        <filter targetName="-def-jtreg" isVisible="false" />
-        <filter targetName="-check-boot.java.home" isVisible="false" />
-        <filter targetName="-check-target.java.home" isVisible="false" />
-        <filter targetName="find-jdk-build-dir" isVisible="false" />
-        <filter targetName="check-env" isVisible="false" />
       </targetFilters>
       <treeView value="false" />
       <expanded value="true" />
--- a/make/langtools/build.xml	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/langtools/build.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -76,7 +76,6 @@
     <property name="make.conf.dir" location="${make.dir}/conf"/>
     <property name="make.tools.dir" location="${make.dir}/tools"/>
     <property name="build.dir" location="build/langtools"/>
-    <property name="idea.support.dir" location="build/.idea-support"/>
     <property name="build.modules" location="${build.dir}/modules"/>
     <property name="build.gensrc" location="${build.dir}/gensrc"/>
     <property name="build.tools" location="${build.dir}/toolclasses"/>
@@ -270,14 +269,11 @@
     <target name="idea" depends="-check-langtools.jdk.home">
         <mkdir dir=".idea"/>
         <copy todir=".idea" >
-            <fileset dir="${make.dir}/intellij">
+            <fileset dir="${make.dir}/intellij/template">
                <exclude name="**/src/**"/>
                <exclude name="**/utils/**"/>
             </fileset>
         </copy>
-        <!-- move build.xml out of .idea, see IDEA-189915 -->
-        <mkdir dir="${idea.support.dir}"/>
-        <move todir="${idea.support.dir}" file=".idea/build.xml"/>
         <condition property="idea.jtreg.home" value="${jtreg.home}" else = "[jtreg.home]">
             <isset property="jtreg.home"/>
         </condition>
@@ -293,7 +289,7 @@
         <mkdir dir=".idea/classes"/>
         <javac source="${javac.build.source}"
                target="${javac.build.target}"
-               srcdir="${make.dir}/intellij/src"
+               srcdir="${make.dir}/intellij/template/src"
                destdir=".idea/classes"/>
     </target>
 
--- a/make/langtools/intellij/ant.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="AntConfiguration">
-    <buildFile url="file://$PROJECT_DIR$/build/.idea-support/build.xml">
-      <properties>
-	    <property name="langtools.jdk.home" value="@IDEA_TARGET_JDK@" />
-        <property name="intellij.ismake" value="$IsMake$" />
-      </properties>
-      <executeOn event="afterCompilation" target="post-make" />
-    </buildFile>
-  </component>
-</project>
--- a/make/langtools/intellij/build.xml	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/langtools/intellij/build.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -1,12 +1,12 @@
 <!-- importing.xml -->
-<project name="langtools" basedir="../..">
+<project name="langtools" basedir = "../../..">
 
     <script language="javascript" classpath=".idea/classes">
         var LangtoolsLogger = Java.type("idea.LangtoolsIdeaAntLogger");
         new LangtoolsLogger(project)
     </script>
 
-    <import file="../../make/langtools/build.xml"/>
+    <import file="../build.xml"/>
 
     <target name="cond-clean" unless="${intellij.ismake}">
         <antcall target="clean"/>
--- a/make/langtools/intellij/codeStyleSettings.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="ProjectCodeStyleSettingsManager">
-    <option name="PER_PROJECT_SETTINGS">
-      <value>
-        <option name="INSERT_INNER_CLASS_IMPORTS" value="true" />
-        <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
-        <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
-        <option name="RIGHT_MARGIN" value="100" />
-        <option name="JD_DO_NOT_WRAP_ONE_LINE_COMMENTS" value="true" />
-        <XML>
-          <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
-        </XML>
-        <codeStyleSettings language="JAVA">
-          <option name="SPACE_AFTER_TYPE_CAST" value="false" />
-        </codeStyleSettings>
-      </value>
-    </option>
-    <option name="USE_PER_PROJECT_SETTINGS" value="true" />
-  </component>
-</project>
-
--- a/make/langtools/intellij/compiler.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="CompilerConfiguration">
-    <option name="DEFAULT_COMPILER" value="Javac" />
-    <excludeFromCompile>
-      <directory url="file://$PROJECT_DIR$/src" includeSubdirectories="true" />
-      <directory url="file://$PROJECT_DIR$/test" includeSubdirectories="true" />
-      <directory url="file://$PROJECT_DIR$/build" includeSubdirectories="true" />
-      <directory url="file://$PROJECT_DIR$/make" includeSubdirectories="true" />
-    </excludeFromCompile>
-    <resourceExtensions />
-    <wildcardResourcePatterns />
-    <annotationProcessing>
-      <profile default="true" name="Default" enabled="false">
-        <processorPath useClasspath="true" />
-      </profile>
-    </annotationProcessing>
-  </component>
-</project>
-
--- a/make/langtools/intellij/copyright/langtools.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-<component name="CopyrightManager">
-  <copyright>
-    <option name="notice" value="Copyright (c) &amp;#36;today.year, Oracle and/or its affiliates. All rights reserved.&#10;DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.&#10;&#10;This code is free software; you can redistribute it and/or modify it&#10;under the terms of the GNU General Public License version 2 only, as&#10;published by the Free Software Foundation.  Oracle designates this&#10;particular file as subject to the &quot;Classpath&quot; exception as provided&#10;by Oracle in the LICENSE file that accompanied this code.&#10;&#10;This code is distributed in the hope that it will be useful, but WITHOUT&#10;ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or&#10;FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License&#10;version 2 for more details (a copy is included in the LICENSE file that&#10;accompanied this code).&#10;&#10;You should have received a copy of the GNU General Public License version&#10;2 along with this work; if not, write to the Free Software Foundation,&#10;Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.&#10;&#10;Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA&#10;or visit www.oracle.com if you need additional information or have any&#10;questions." />
-    <option name="keyword" value="Copyright" />
-    <option name="allowReplaceKeyword" value="" />
-    <option name="myName" value="langtools" />
-    <option name="myLocal" value="true" />
-  </copyright>
-</component>
--- a/make/langtools/intellij/copyright/profiles_settings.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-<component name="CopyrightManager">
-  <settings default="langtools">
-    <LanguageOptions name="JAVA">
-      <option name="fileLocation" value="1" />
-    </LanguageOptions>
-  </settings>
-</component>
--- a/make/langtools/intellij/inspectionProfiles/langtools.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-<component name="InspectionProjectProfileManager">
-  <profile version="1.0" is_locked="false">
-    <option name="myName" value="langtools" />
-    <option name="myLocal" value="false" />
-    <inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
-      <option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
-      <option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
-    </inspection_tool>
-    <inspection_tool class="MismatchedCollectionQueryUpdate" enabled="false" level="WARNING" enabled_by_default="false">
-      <option name="queryNames">
-        <value />
-      </option>
-      <option name="updateNames">
-        <value />
-      </option>
-    </inspection_tool>
-    <inspection_tool class="RawUseOfParameterizedType" enabled="true" level="WARNING" enabled_by_default="true">
-      <option name="ignoreObjectConstruction" value="false" />
-      <option name="ignoreUncompilable" value="true" />
-    </inspection_tool>
-    <inspection_tool class="SpellCheckingInspection" enabled="true" level="TYPO" enabled_by_default="true">
-      <option name="processCode" value="false" />
-      <option name="processLiterals" value="false" />
-      <option name="processComments" value="false" />
-    </inspection_tool>
-    <inspection_tool class="SuspiciousMethodCalls" enabled="true" level="WARNING" enabled_by_default="true">
-      <option name="REPORT_CONVERTIBLE_METHOD_CALLS" value="false" />
-    </inspection_tool>
-  </profile>
-</component>
--- a/make/langtools/intellij/inspectionProfiles/profiles_settings.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-<component name="InspectionProjectProfileManager">
-  <settings>
-    <option name="PROJECT_PROFILE" value="langtools" />
-    <option name="USE_PROJECT_PROFILE" value="true" />
-    <version value="1.0" />
-  </settings>
-</component>
--- a/make/langtools/intellij/langtools.iml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="true">
-    <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/src/java.compiler/share/classes" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/jdk.compiler/share/classes" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/jdk.javadoc/share/classes" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/jdk.jdeps/share/classes" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/jdk.jshell/share/classes" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/build/langtools/gensrc/jdk.compiler" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/build/langtools/gensrc/jdk.javadoc" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/build/langtools/gensrc/jdk.jdeps" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/make/langtools/tools" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/make/langtools/src/classes" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/build/langtools/gensrc/jdk.compiler" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/build/langtools/gensrc/jdk.javadoc" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/build/langtools/gensrc/jdk.jdeps" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/build/langtools/gensrc/jdk.jshell" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/jdk.compiler" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/java.compiler" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/jdk.jdeps" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/jdk.jshell" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/jdk.javadoc" isTestSource="false" />
-      <excludeFolder url="file://$MODULE_DIR$/build" />
-    </content>
-    <orderEntry type="sourceFolder" forTests="false" />
-    <orderEntry type="inheritedJdk" />
-  </component>
-</module>
--- a/make/langtools/intellij/misc.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="EntryPointsManager">
-    <entry_points version="2.0" />
-  </component>
-  <component name="JTRegService">
-    <path>@IDEA_JTREG_HOME@</path>
-    <workDir>build</workDir>
-    <jre alt="true" value="@IDEA_TARGET_JDK@" />
-    <options>@XPATCH@</options>
-    <ant>
-      <target file="file://$PROJECT_DIR$/build/.idea-support/build.xml" name="build-all-classes" />
-    </ant>
-  </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
-    <output url="file://$PROJECT_DIR$/build/.idea-support/out" />
-  </component>
-</project>
--- a/make/langtools/intellij/modules.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="ProjectModuleManager">
-    <modules>
-      <module fileurl="file://$PROJECT_DIR$/.idea/langtools.iml" filepath="$PROJECT_DIR$/.idea/langtools.iml" />
-    </modules>
-  </component>
-</project>
-
--- a/make/langtools/intellij/runConfigurations/javac.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-<component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="javac" type="Application" factoryName="Application">
-    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
-    <option name="MAIN_CLASS_NAME" value="com.sun.tools.javac.Main" />
-    <option name="VM_PARAMETERS" value='@XPATCH@' />
-    <option name="PROGRAM_PARAMETERS" value="" />
-    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
-    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
-    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
-    <option name="ENABLE_SWING_INSPECTOR" value="false" />
-    <option name="ENV_VARIABLES" />
-    <option name="PASS_PARENT_ENVS" value="true" />
-    <module name="langtools" />
-    <envs />
-    <RunnerSettings RunnerId="Run" />
-    <ConfigurationWrapper RunnerId="Run" />
-    <method>
-      <option name="Make" enabled="false" />
-      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
-    </method>
-  </configuration>
-</component>
--- a/make/langtools/intellij/runConfigurations/javadoc.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-<component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="javadoc" type="Application" factoryName="Application">
-    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
-    <option name="MAIN_CLASS_NAME" value="jdk.javadoc.internal.tool.Main" />
-    <option name="VM_PARAMETERS" value='@XPATCH@ --add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED' />
-    <option name="PROGRAM_PARAMETERS" value="" />
-    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
-    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
-    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
-    <option name="ENABLE_SWING_INSPECTOR" value="false" />
-    <option name="ENV_VARIABLES" />
-    <option name="PASS_PARENT_ENVS" value="true" />
-    <module name="langtools" />
-    <envs />
-    <RunnerSettings RunnerId="Run" />
-    <ConfigurationWrapper RunnerId="Run" />
-    <method>
-      <option name="Make" enabled="false" />
-      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
-    </method>
-  </configuration>
-</component>
--- a/make/langtools/intellij/runConfigurations/javap.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-<component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="javap" type="Application" factoryName="Application">
-    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
-    <option name="MAIN_CLASS_NAME" value="com.sun.tools.javap.Main" />
-    <option name="VM_PARAMETERS" value='@XPATCH@ --add-exports=jdk.jdeps/com.sun.tools.javap=ALL-UNNAMED' />
-    <option name="PROGRAM_PARAMETERS" value="" />
-    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
-    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
-    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
-    <option name="ENABLE_SWING_INSPECTOR" value="false" />
-    <option name="ENV_VARIABLES" />
-    <option name="PASS_PARENT_ENVS" value="true" />
-    <module name="langtools" />
-    <envs />
-    <RunnerSettings RunnerId="Run" />
-    <ConfigurationWrapper RunnerId="Run" />
-    <method>
-      <option name="Make" enabled="false" />
-      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
-    </method>
-  </configuration>
-</component>
--- a/make/langtools/intellij/runConfigurations/jshell.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-<component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="jshell" type="Application" factoryName="Application">
-    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
-    <option name="MAIN_CLASS_NAME" value="jdk.internal.jshell.tool.JShellToolProvider" />
-    <option name="VM_PARAMETERS" value='@XPATCH@ --add-exports=jdk.jshell/jdk.internal.jshell.tool=ALL-UNNAMED' />
-    <option name="PROGRAM_PARAMETERS" value="" />
-    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
-    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
-    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
-    <option name="ENABLE_SWING_INSPECTOR" value="false" />
-    <option name="ENV_VARIABLES" />
-    <option name="PASS_PARENT_ENVS" value="true" />
-    <module name="langtools" />
-    <envs />
-    <method>
-      <option name="Make" enabled="false" />
-      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
-    </method>
-  </configuration>
-</component>
--- a/make/langtools/intellij/runConfigurations/sjavac.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-<component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="sjavac" type="Application" factoryName="Application">
-    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
-    <option name="MAIN_CLASS_NAME" value="com.sun.tools.sjavac.Main" />
-    <option name="VM_PARAMETERS" value='@XPATCH@ --add-exports=jdk.compiler/com.sun.tools.sjavac=ALL-UNNAMED' />
-    <option name="PROGRAM_PARAMETERS" value="" />
-    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
-    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
-    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
-    <option name="ENABLE_SWING_INSPECTOR" value="false" />
-    <option name="ENV_VARIABLES" />
-    <option name="PASS_PARENT_ENVS" value="true" />
-    <module name="langtools" />
-    <envs />
-    <RunnerSettings RunnerId="Run" />
-    <ConfigurationWrapper RunnerId="Run" />
-    <method>
-      <option name="Make" enabled="false" />
-      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
-    </method>
-  </configuration>
-</component>
--- a/make/langtools/intellij/src/idea/LangtoolsIdeaAntLogger.java	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,364 +0,0 @@
-/*
- * Copyright (c) 2014, 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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 idea;
-
-import org.apache.tools.ant.BuildEvent;
-import org.apache.tools.ant.BuildListener;
-import org.apache.tools.ant.DefaultLogger;
-import org.apache.tools.ant.Project;
-
-import java.util.EnumSet;
-import java.util.Stack;
-
-import static org.apache.tools.ant.Project.*;
-
-/**
- * This class is used to wrap the IntelliJ ant logger in order to provide more meaningful
- * output when building langtools. The basic ant output in IntelliJ can be quite cumbersome to
- * work with, as it provides two separate views: (i) a tree view, which is good to display build task
- * in a hierarchical fashion as they are processed; and a (ii) plain text view, which gives you
- * the full ant output. The main problem is that javac-related messages are buried into the
- * ant output (which is made very verbose by IntelliJ in order to support the tree view). It is
- * not easy to figure out which node to expand in order to see the error message; switching
- * to plain text doesn't help either, as now the output is totally flat.
- *
- * This logger class removes a lot of verbosity from the IntelliJ ant logger by not propagating
- * all the events to the IntelliJ's logger. In addition, certain events are handled in a custom
- * fashion, to generate better output during the build.
- */
-public final class LangtoolsIdeaAntLogger extends DefaultLogger {
-
-    /**
-     * This is just a way to pass in customized binary string predicates;
-     *
-     * TODO: replace with @code{BiPredicate<String, String>} and method reference when moving to 8
-     */
-    enum StringBinaryPredicate {
-        CONTAINS() {
-            @Override
-            boolean apply(String s1, String s2) {
-                return s1.contains(s2);
-            }
-        },
-        STARTS_WITH {
-            @Override
-            boolean apply(String s1, String s2) {
-                return s1.startsWith(s2);
-            }
-        };
-
-        abstract boolean apply(String s1, String s2);
-    }
-
-    /**
-     * Various kinds of ant messages that we shall intercept
-     */
-    enum MessageKind {
-
-        /** a javac error */
-        JAVAC_ERROR(StringBinaryPredicate.CONTAINS, MSG_ERR, "error:", "compiler.err"),
-        /** a javac warning */
-        JAVAC_WARNING(StringBinaryPredicate.CONTAINS, MSG_WARN, "warning:", "compiler.warn"),
-        /** a javac note */
-        JAVAC_NOTE(StringBinaryPredicate.CONTAINS, MSG_INFO, "note:", "compiler.note"),
-        /** a javac raw error (these typically come from a build misconfiguration - such as a bad javac flag) */
-        JAVAC_RAW_ERROR(StringBinaryPredicate.STARTS_WITH, MSG_INFO, "javac: "),
-        /** continuation of some javac error message */
-        JAVAC_NESTED_DIAG(StringBinaryPredicate.STARTS_WITH, MSG_INFO, "  "),
-        /** a javac crash */
-        JAVAC_CRASH(StringBinaryPredicate.STARTS_WITH, MSG_ERR, "An exception has occurred in the compiler"),
-        /** jtreg test success */
-        JTREG_TEST_PASSED(StringBinaryPredicate.STARTS_WITH, MSG_INFO, "Passed: "),
-        /** jtreg test failure */
-        JTREG_TEST_FAILED(StringBinaryPredicate.STARTS_WITH, MSG_ERR, "FAILED: "),
-        /** jtreg test error */
-        JTREG_TEST_ERROR(StringBinaryPredicate.STARTS_WITH, MSG_ERR, "Error: "),
-        /** jtreg report */
-        JTREG_TEST_REPORT(StringBinaryPredicate.STARTS_WITH, MSG_INFO, "Report written");
-
-        StringBinaryPredicate sbp;
-        int priority;
-        String[] keys;
-
-        MessageKind(StringBinaryPredicate sbp, int priority, String... keys) {
-            this.sbp = sbp;
-            this.priority = priority;
-            this.keys = keys;
-        }
-
-        /**
-         * Does a given message string matches this kind?
-         */
-        boolean matches(String s) {
-            for (String key : keys) {
-                if (sbp.apply(s, key)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-    }
-
-    /**
-     * This enum is used to represent the list of tasks we need to keep track of during logging.
-     */
-    enum Task {
-        /** exec task - invoked during compilation */
-        JAVAC("exec", MessageKind.JAVAC_ERROR, MessageKind.JAVAC_WARNING, MessageKind.JAVAC_NOTE,
-                       MessageKind.JAVAC_RAW_ERROR, MessageKind.JAVAC_NESTED_DIAG, MessageKind.JAVAC_CRASH),
-        /** jtreg task - invoked during test execution */
-        JTREG("jtreg", MessageKind.JTREG_TEST_PASSED, MessageKind.JTREG_TEST_FAILED, MessageKind.JTREG_TEST_ERROR, MessageKind.JTREG_TEST_REPORT),
-        /** initial synthetic task when the logger is created */
-        ROOT("") {
-            @Override
-            boolean matches(String s) {
-                return false;
-            }
-        },
-        /** synthetic task catching any other tasks not in this list */
-        ANY("") {
-            @Override
-            boolean matches(String s) {
-                return true;
-            }
-        };
-
-        String taskName;
-        MessageKind[] msgs;
-
-        Task(String taskName, MessageKind... msgs) {
-            this.taskName = taskName;
-            this.msgs = msgs;
-        }
-
-        boolean matches(String s) {
-            return s.equals(taskName);
-        }
-    }
-
-    /**
-     * This enum is used to represent the list of targets we need to keep track of during logging.
-     * A regular expression is used to match a given target name.
-     */
-    enum Target {
-        /** jtreg target - executed when launching tests */
-        JTREG("jtreg") {
-            @Override
-            String getDisplayMessage(BuildEvent e) {
-                return "Running jtreg tests: " + e.getProject().getProperty("jtreg.tests");
-            }
-        },
-        /** build bootstrap tool target - executed when bootstrapping javac */
-        BUILD_BOOTSTRAP_JAVAC("build-bootstrap-javac-classes") {
-            @Override
-            String getDisplayMessage(BuildEvent e) {
-                return "Building bootstrap javac...";
-            }
-        },
-        /** build classes target - executed when building classes of given tool */
-        BUILD_ALL_CLASSES("build-all-classes") {
-            @Override
-            String getDisplayMessage(BuildEvent e) {
-                return "Building all classes...";
-            }
-        },
-        /** synthetic target catching any other target not in this list */
-        ANY("") {
-            @Override
-            String getDisplayMessage(BuildEvent e) {
-                return "Executing Ant target(s): " + e.getProject().getProperty("ant.project.invoked-targets");
-            }
-            @Override
-            boolean matches(String msg) {
-                return true;
-            }
-        };
-
-        String targetName;
-
-        Target(String targetName) {
-            this.targetName = targetName;
-        }
-
-        boolean matches(String msg) {
-            return msg.equals(targetName);
-        }
-
-        abstract String getDisplayMessage(BuildEvent e);
-    }
-
-    /**
-     * A custom build event used to represent status changes which should be notified inside
-     * Intellij
-     */
-    static class StatusEvent extends BuildEvent {
-
-        /** the target to which the status update refers */
-        Target target;
-
-        StatusEvent(BuildEvent e, Target target) {
-            super(new StatusTask(e, target.getDisplayMessage(e)));
-            this.target = target;
-            setMessage(getTask().getTaskName(), 2);
-        }
-
-        /**
-         * A custom task used to channel info regarding a status change
-         */
-        static class StatusTask extends org.apache.tools.ant.Task {
-            StatusTask(BuildEvent event, String msg) {
-                setProject(event.getProject());
-                setOwningTarget(event.getTarget());
-                setTaskName(msg);
-            }
-        }
-    }
-
-    /** wrapped ant logger (IntelliJ's own logger) */
-    DefaultLogger logger;
-
-    /** flag - is this the first target we encounter? */
-    boolean firstTarget = true;
-
-    /** flag - should subsequenet failures be suppressed ? */
-    boolean suppressTaskFailures = false;
-
-    /** flag - have we ran into a javac crash ? */
-    boolean crashFound = false;
-
-    /** stack of status changes associated with pending targets */
-    Stack<StatusEvent> statusEvents = new Stack<>();
-
-    /** stack of pending tasks */
-    Stack<Task> tasks = new Stack<>();
-
-    public LangtoolsIdeaAntLogger(Project project) {
-        for (Object o : project.getBuildListeners()) {
-            if (o instanceof DefaultLogger) {
-                this.logger = (DefaultLogger)o;
-                project.removeBuildListener((BuildListener)o);
-                project.addBuildListener(this);
-            }
-        }
-        logger.setMessageOutputLevel(3);
-        tasks.push(Task.ROOT);
-    }
-
-    @Override
-    public void buildStarted(BuildEvent event) {
-        //do nothing
-    }
-
-    @Override
-    public void buildFinished(BuildEvent event) {
-        //do nothing
-    }
-
-    @Override
-    public void targetStarted(BuildEvent event) {
-        EnumSet<Target> statusKinds = firstTarget ?
-                EnumSet.allOf(Target.class) :
-                EnumSet.complementOf(EnumSet.of(Target.ANY));
-
-        String targetName = event.getTarget().getName();
-
-        for (Target statusKind : statusKinds) {
-            if (statusKind.matches(targetName)) {
-                StatusEvent statusEvent = new StatusEvent(event, statusKind);
-                statusEvents.push(statusEvent);
-                logger.taskStarted(statusEvent);
-                firstTarget = false;
-                return;
-            }
-        }
-    }
-
-    @Override
-    public void targetFinished(BuildEvent event) {
-        if (!statusEvents.isEmpty()) {
-            StatusEvent lastEvent = statusEvents.pop();
-            if (lastEvent.target.matches(event.getTarget().getName())) {
-                logger.taskFinished(lastEvent);
-            }
-        }
-    }
-
-    @Override
-    public void taskStarted(BuildEvent event) {
-        String taskName = event.getTask().getTaskName();
-        for (Task task : Task.values()) {
-            if (task.matches(taskName)) {
-                tasks.push(task);
-                return;
-            }
-        }
-    }
-
-    @Override
-    public void taskFinished(BuildEvent event) {
-        if (tasks.peek() == Task.ROOT) {
-            //we need to 'close' the root task to get nicer output
-            logger.taskFinished(event);
-        } else if (!suppressTaskFailures && event.getException() != null) {
-            //the first (innermost) task failure should always be logged
-            event.setMessage(event.getException().toString(), 0);
-            event.setException(null);
-            //note: we turn this into a plain message to avoid stack trace being logged by Idea
-            logger.messageLogged(event);
-            suppressTaskFailures = true;
-        }
-        tasks.pop();
-    }
-
-    @Override
-    public void messageLogged(BuildEvent event) {
-        String msg = event.getMessage();
-
-        boolean processed = false;
-
-        if (!tasks.isEmpty()) {
-            Task task = tasks.peek();
-            for (MessageKind messageKind : task.msgs) {
-                if (messageKind.matches(msg)) {
-                    event.setMessage(msg, messageKind.priority);
-                    processed = true;
-                    if (messageKind == MessageKind.JAVAC_CRASH) {
-                        crashFound = true;
-                    }
-                    break;
-                }
-            }
-        }
-
-        if (event.getPriority() == MSG_ERR || crashFound) {
-            //we log errors regardless of owning task
-            logger.messageLogged(event);
-            suppressTaskFailures = true;
-        } else if (processed) {
-            logger.messageLogged(event);
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/ant.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="AntConfiguration">
+    <buildFile url="file://$PROJECT_DIR$/make/langtools/intellij/build.xml">
+      <properties>
+	    <property name="langtools.jdk.home" value="@IDEA_TARGET_JDK@" />
+        <property name="intellij.ismake" value="$IsMake$" />
+      </properties>
+      <executeOn event="afterCompilation" target="post-make" />
+    </buildFile>
+  </component>
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/codeStyleSettings.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectCodeStyleSettingsManager">
+    <option name="PER_PROJECT_SETTINGS">
+      <value>
+        <option name="INSERT_INNER_CLASS_IMPORTS" value="true" />
+        <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
+        <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
+        <option name="RIGHT_MARGIN" value="100" />
+        <option name="JD_DO_NOT_WRAP_ONE_LINE_COMMENTS" value="true" />
+        <XML>
+          <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
+        </XML>
+        <codeStyleSettings language="JAVA">
+          <option name="SPACE_AFTER_TYPE_CAST" value="false" />
+        </codeStyleSettings>
+      </value>
+    </option>
+    <option name="USE_PER_PROJECT_SETTINGS" value="true" />
+  </component>
+</project>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/compiler.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <option name="DEFAULT_COMPILER" value="Javac" />
+    <excludeFromCompile>
+      <directory url="file://$PROJECT_DIR$/src" includeSubdirectories="true" />
+      <directory url="file://$PROJECT_DIR$/test" includeSubdirectories="true" />
+      <directory url="file://$PROJECT_DIR$/build" includeSubdirectories="true" />
+      <directory url="file://$PROJECT_DIR$/make" includeSubdirectories="true" />
+    </excludeFromCompile>
+    <resourceExtensions />
+    <wildcardResourcePatterns />
+    <annotationProcessing>
+      <profile default="true" name="Default" enabled="false">
+        <processorPath useClasspath="true" />
+      </profile>
+    </annotationProcessing>
+  </component>
+</project>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/copyright/langtools.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,9 @@
+<component name="CopyrightManager">
+  <copyright>
+    <option name="notice" value="Copyright (c) &amp;#36;today.year, Oracle and/or its affiliates. All rights reserved.&#10;DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.&#10;&#10;This code is free software; you can redistribute it and/or modify it&#10;under the terms of the GNU General Public License version 2 only, as&#10;published by the Free Software Foundation.  Oracle designates this&#10;particular file as subject to the &quot;Classpath&quot; exception as provided&#10;by Oracle in the LICENSE file that accompanied this code.&#10;&#10;This code is distributed in the hope that it will be useful, but WITHOUT&#10;ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or&#10;FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License&#10;version 2 for more details (a copy is included in the LICENSE file that&#10;accompanied this code).&#10;&#10;You should have received a copy of the GNU General Public License version&#10;2 along with this work; if not, write to the Free Software Foundation,&#10;Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.&#10;&#10;Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA&#10;or visit www.oracle.com if you need additional information or have any&#10;questions." />
+    <option name="keyword" value="Copyright" />
+    <option name="allowReplaceKeyword" value="" />
+    <option name="myName" value="langtools" />
+    <option name="myLocal" value="true" />
+  </copyright>
+</component>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/copyright/profiles_settings.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,7 @@
+<component name="CopyrightManager">
+  <settings default="langtools">
+    <LanguageOptions name="JAVA">
+      <option name="fileLocation" value="1" />
+    </LanguageOptions>
+  </settings>
+</component>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/inspectionProfiles/langtools.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,30 @@
+<component name="InspectionProjectProfileManager">
+  <profile version="1.0" is_locked="false">
+    <option name="myName" value="langtools" />
+    <option name="myLocal" value="false" />
+    <inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
+      <option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
+      <option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
+    </inspection_tool>
+    <inspection_tool class="MismatchedCollectionQueryUpdate" enabled="false" level="WARNING" enabled_by_default="false">
+      <option name="queryNames">
+        <value />
+      </option>
+      <option name="updateNames">
+        <value />
+      </option>
+    </inspection_tool>
+    <inspection_tool class="RawUseOfParameterizedType" enabled="true" level="WARNING" enabled_by_default="true">
+      <option name="ignoreObjectConstruction" value="false" />
+      <option name="ignoreUncompilable" value="true" />
+    </inspection_tool>
+    <inspection_tool class="SpellCheckingInspection" enabled="true" level="TYPO" enabled_by_default="true">
+      <option name="processCode" value="false" />
+      <option name="processLiterals" value="false" />
+      <option name="processComments" value="false" />
+    </inspection_tool>
+    <inspection_tool class="SuspiciousMethodCalls" enabled="true" level="WARNING" enabled_by_default="true">
+      <option name="REPORT_CONVERTIBLE_METHOD_CALLS" value="false" />
+    </inspection_tool>
+  </profile>
+</component>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/inspectionProfiles/profiles_settings.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,7 @@
+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="PROJECT_PROFILE" value="langtools" />
+    <option name="USE_PROJECT_PROFILE" value="true" />
+    <version value="1.0" />
+  </settings>
+</component>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/langtools.iml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/java.compiler/share/classes" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/jdk.compiler/share/classes" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/jdk.javadoc/share/classes" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/jdk.jdeps/share/classes" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/jdk.jshell/share/classes" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/build/langtools/gensrc/jdk.compiler" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/build/langtools/gensrc/jdk.javadoc" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/build/langtools/gensrc/jdk.jdeps" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/make/langtools/tools" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/make/langtools/src/classes" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/build/langtools/gensrc/jdk.compiler" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/build/langtools/gensrc/jdk.javadoc" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/build/langtools/gensrc/jdk.jdeps" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/build/langtools/gensrc/jdk.jshell" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/jdk.compiler" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/java.compiler" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/jdk.jdeps" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/jdk.jshell" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/jdk.javadoc" isTestSource="false" />
+      <excludeFolder url="file://$MODULE_DIR$/build" />
+    </content>
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="inheritedJdk" />
+  </component>
+</module>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/misc.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="EntryPointsManager">
+    <entry_points version="2.0" />
+  </component>
+  <component name="JTRegService">
+    <path>@IDEA_JTREG_HOME@</path>
+    <workDir>build</workDir>
+    <jre alt="true" value="@IDEA_TARGET_JDK@" />
+    <options>@XPATCH@</options>
+    <ant>
+      <target file="file://$PROJECT_DIR$/make/langtools/intellij/build.xml" name="build-all-classes" />
+    </ant>
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/build" />
+  </component>
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/modules.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/langtools.iml" filepath="$PROJECT_DIR$/.idea/langtools.iml" />
+    </modules>
+  </component>
+</project>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/runConfigurations/javac.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,22 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="javac" type="Application" factoryName="Application">
+    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+    <option name="MAIN_CLASS_NAME" value="com.sun.tools.javac.Main" />
+    <option name="VM_PARAMETERS" value='@XPATCH@' />
+    <option name="PROGRAM_PARAMETERS" value="" />
+    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
+    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
+    <option name="ENABLE_SWING_INSPECTOR" value="false" />
+    <option name="ENV_VARIABLES" />
+    <option name="PASS_PARENT_ENVS" value="true" />
+    <module name="langtools" />
+    <envs />
+    <RunnerSettings RunnerId="Run" />
+    <ConfigurationWrapper RunnerId="Run" />
+    <method>
+      <option name="Make" enabled="false" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/make/langtools/intellij/build.xml" target="build-all-classes" />
+    </method>
+  </configuration>
+</component>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/runConfigurations/javadoc.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,22 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="javadoc" type="Application" factoryName="Application">
+    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+    <option name="MAIN_CLASS_NAME" value="jdk.javadoc.internal.tool.Main" />
+    <option name="VM_PARAMETERS" value='@XPATCH@ --add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED' />
+    <option name="PROGRAM_PARAMETERS" value="" />
+    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
+    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
+    <option name="ENABLE_SWING_INSPECTOR" value="false" />
+    <option name="ENV_VARIABLES" />
+    <option name="PASS_PARENT_ENVS" value="true" />
+    <module name="langtools" />
+    <envs />
+    <RunnerSettings RunnerId="Run" />
+    <ConfigurationWrapper RunnerId="Run" />
+    <method>
+      <option name="Make" enabled="false" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/make/langtools/intellij/build.xml" target="build-all-classes" />
+    </method>
+  </configuration>
+</component>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/runConfigurations/javap.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,22 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="javap" type="Application" factoryName="Application">
+    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+    <option name="MAIN_CLASS_NAME" value="com.sun.tools.javap.Main" />
+    <option name="VM_PARAMETERS" value='@XPATCH@ --add-exports=jdk.jdeps/com.sun.tools.javap=ALL-UNNAMED' />
+    <option name="PROGRAM_PARAMETERS" value="" />
+    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
+    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
+    <option name="ENABLE_SWING_INSPECTOR" value="false" />
+    <option name="ENV_VARIABLES" />
+    <option name="PASS_PARENT_ENVS" value="true" />
+    <module name="langtools" />
+    <envs />
+    <RunnerSettings RunnerId="Run" />
+    <ConfigurationWrapper RunnerId="Run" />
+    <method>
+      <option name="Make" enabled="false" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/make/langtools/intellij/build.xml" target="build-all-classes" />
+    </method>
+  </configuration>
+</component>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/runConfigurations/jshell.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,20 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="jshell" type="Application" factoryName="Application">
+    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+    <option name="MAIN_CLASS_NAME" value="jdk.internal.jshell.tool.JShellToolProvider" />
+    <option name="VM_PARAMETERS" value='@XPATCH@ --add-exports=jdk.jshell/jdk.internal.jshell.tool=ALL-UNNAMED' />
+    <option name="PROGRAM_PARAMETERS" value="" />
+    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
+    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
+    <option name="ENABLE_SWING_INSPECTOR" value="false" />
+    <option name="ENV_VARIABLES" />
+    <option name="PASS_PARENT_ENVS" value="true" />
+    <module name="langtools" />
+    <envs />
+    <method>
+      <option name="Make" enabled="false" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/make/langtools/intellij/build.xml" target="build-all-classes" />
+    </method>
+  </configuration>
+</component>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/runConfigurations/sjavac.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,22 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="sjavac" type="Application" factoryName="Application">
+    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+    <option name="MAIN_CLASS_NAME" value="com.sun.tools.sjavac.Main" />
+    <option name="VM_PARAMETERS" value='@XPATCH@ --add-exports=jdk.compiler/com.sun.tools.sjavac=ALL-UNNAMED' />
+    <option name="PROGRAM_PARAMETERS" value="" />
+    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
+    <option name="ALTERNATIVE_JRE_PATH" value="@IDEA_TARGET_JDK@" />
+    <option name="ENABLE_SWING_INSPECTOR" value="false" />
+    <option name="ENV_VARIABLES" />
+    <option name="PASS_PARENT_ENVS" value="true" />
+    <module name="langtools" />
+    <envs />
+    <RunnerSettings RunnerId="Run" />
+    <ConfigurationWrapper RunnerId="Run" />
+    <method>
+      <option name="Make" enabled="false" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/make/langtools/intellij/build.xml" target="build-all-classes" />
+    </method>
+  </configuration>
+</component>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/src/idea/LangtoolsIdeaAntLogger.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,364 @@
+/*
+ * Copyright (c) 2014, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 idea;
+
+import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.DefaultLogger;
+import org.apache.tools.ant.Project;
+
+import java.util.EnumSet;
+import java.util.Stack;
+
+import static org.apache.tools.ant.Project.*;
+
+/**
+ * This class is used to wrap the IntelliJ ant logger in order to provide more meaningful
+ * output when building langtools. The basic ant output in IntelliJ can be quite cumbersome to
+ * work with, as it provides two separate views: (i) a tree view, which is good to display build task
+ * in a hierarchical fashion as they are processed; and a (ii) plain text view, which gives you
+ * the full ant output. The main problem is that javac-related messages are buried into the
+ * ant output (which is made very verbose by IntelliJ in order to support the tree view). It is
+ * not easy to figure out which node to expand in order to see the error message; switching
+ * to plain text doesn't help either, as now the output is totally flat.
+ *
+ * This logger class removes a lot of verbosity from the IntelliJ ant logger by not propagating
+ * all the events to the IntelliJ's logger. In addition, certain events are handled in a custom
+ * fashion, to generate better output during the build.
+ */
+public final class LangtoolsIdeaAntLogger extends DefaultLogger {
+
+    /**
+     * This is just a way to pass in customized binary string predicates;
+     *
+     * TODO: replace with @code{BiPredicate<String, String>} and method reference when moving to 8
+     */
+    enum StringBinaryPredicate {
+        CONTAINS() {
+            @Override
+            boolean apply(String s1, String s2) {
+                return s1.contains(s2);
+            }
+        },
+        STARTS_WITH {
+            @Override
+            boolean apply(String s1, String s2) {
+                return s1.startsWith(s2);
+            }
+        };
+
+        abstract boolean apply(String s1, String s2);
+    }
+
+    /**
+     * Various kinds of ant messages that we shall intercept
+     */
+    enum MessageKind {
+
+        /** a javac error */
+        JAVAC_ERROR(StringBinaryPredicate.CONTAINS, MSG_ERR, "error:", "compiler.err"),
+        /** a javac warning */
+        JAVAC_WARNING(StringBinaryPredicate.CONTAINS, MSG_WARN, "warning:", "compiler.warn"),
+        /** a javac note */
+        JAVAC_NOTE(StringBinaryPredicate.CONTAINS, MSG_INFO, "note:", "compiler.note"),
+        /** a javac raw error (these typically come from a build misconfiguration - such as a bad javac flag) */
+        JAVAC_RAW_ERROR(StringBinaryPredicate.STARTS_WITH, MSG_INFO, "javac: "),
+        /** continuation of some javac error message */
+        JAVAC_NESTED_DIAG(StringBinaryPredicate.STARTS_WITH, MSG_INFO, "  "),
+        /** a javac crash */
+        JAVAC_CRASH(StringBinaryPredicate.STARTS_WITH, MSG_ERR, "An exception has occurred in the compiler"),
+        /** jtreg test success */
+        JTREG_TEST_PASSED(StringBinaryPredicate.STARTS_WITH, MSG_INFO, "Passed: "),
+        /** jtreg test failure */
+        JTREG_TEST_FAILED(StringBinaryPredicate.STARTS_WITH, MSG_ERR, "FAILED: "),
+        /** jtreg test error */
+        JTREG_TEST_ERROR(StringBinaryPredicate.STARTS_WITH, MSG_ERR, "Error: "),
+        /** jtreg report */
+        JTREG_TEST_REPORT(StringBinaryPredicate.STARTS_WITH, MSG_INFO, "Report written");
+
+        StringBinaryPredicate sbp;
+        int priority;
+        String[] keys;
+
+        MessageKind(StringBinaryPredicate sbp, int priority, String... keys) {
+            this.sbp = sbp;
+            this.priority = priority;
+            this.keys = keys;
+        }
+
+        /**
+         * Does a given message string matches this kind?
+         */
+        boolean matches(String s) {
+            for (String key : keys) {
+                if (sbp.apply(s, key)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+
+    /**
+     * This enum is used to represent the list of tasks we need to keep track of during logging.
+     */
+    enum Task {
+        /** exec task - invoked during compilation */
+        JAVAC("exec", MessageKind.JAVAC_ERROR, MessageKind.JAVAC_WARNING, MessageKind.JAVAC_NOTE,
+                       MessageKind.JAVAC_RAW_ERROR, MessageKind.JAVAC_NESTED_DIAG, MessageKind.JAVAC_CRASH),
+        /** jtreg task - invoked during test execution */
+        JTREG("jtreg", MessageKind.JTREG_TEST_PASSED, MessageKind.JTREG_TEST_FAILED, MessageKind.JTREG_TEST_ERROR, MessageKind.JTREG_TEST_REPORT),
+        /** initial synthetic task when the logger is created */
+        ROOT("") {
+            @Override
+            boolean matches(String s) {
+                return false;
+            }
+        },
+        /** synthetic task catching any other tasks not in this list */
+        ANY("") {
+            @Override
+            boolean matches(String s) {
+                return true;
+            }
+        };
+
+        String taskName;
+        MessageKind[] msgs;
+
+        Task(String taskName, MessageKind... msgs) {
+            this.taskName = taskName;
+            this.msgs = msgs;
+        }
+
+        boolean matches(String s) {
+            return s.equals(taskName);
+        }
+    }
+
+    /**
+     * This enum is used to represent the list of targets we need to keep track of during logging.
+     * A regular expression is used to match a given target name.
+     */
+    enum Target {
+        /** jtreg target - executed when launching tests */
+        JTREG("jtreg") {
+            @Override
+            String getDisplayMessage(BuildEvent e) {
+                return "Running jtreg tests: " + e.getProject().getProperty("jtreg.tests");
+            }
+        },
+        /** build bootstrap tool target - executed when bootstrapping javac */
+        BUILD_BOOTSTRAP_JAVAC("build-bootstrap-javac-classes") {
+            @Override
+            String getDisplayMessage(BuildEvent e) {
+                return "Building bootstrap javac...";
+            }
+        },
+        /** build classes target - executed when building classes of given tool */
+        BUILD_ALL_CLASSES("build-all-classes") {
+            @Override
+            String getDisplayMessage(BuildEvent e) {
+                return "Building all classes...";
+            }
+        },
+        /** synthetic target catching any other target not in this list */
+        ANY("") {
+            @Override
+            String getDisplayMessage(BuildEvent e) {
+                return "Executing Ant target(s): " + e.getProject().getProperty("ant.project.invoked-targets");
+            }
+            @Override
+            boolean matches(String msg) {
+                return true;
+            }
+        };
+
+        String targetName;
+
+        Target(String targetName) {
+            this.targetName = targetName;
+        }
+
+        boolean matches(String msg) {
+            return msg.equals(targetName);
+        }
+
+        abstract String getDisplayMessage(BuildEvent e);
+    }
+
+    /**
+     * A custom build event used to represent status changes which should be notified inside
+     * Intellij
+     */
+    static class StatusEvent extends BuildEvent {
+
+        /** the target to which the status update refers */
+        Target target;
+
+        StatusEvent(BuildEvent e, Target target) {
+            super(new StatusTask(e, target.getDisplayMessage(e)));
+            this.target = target;
+            setMessage(getTask().getTaskName(), 2);
+        }
+
+        /**
+         * A custom task used to channel info regarding a status change
+         */
+        static class StatusTask extends org.apache.tools.ant.Task {
+            StatusTask(BuildEvent event, String msg) {
+                setProject(event.getProject());
+                setOwningTarget(event.getTarget());
+                setTaskName(msg);
+            }
+        }
+    }
+
+    /** wrapped ant logger (IntelliJ's own logger) */
+    DefaultLogger logger;
+
+    /** flag - is this the first target we encounter? */
+    boolean firstTarget = true;
+
+    /** flag - should subsequenet failures be suppressed ? */
+    boolean suppressTaskFailures = false;
+
+    /** flag - have we ran into a javac crash ? */
+    boolean crashFound = false;
+
+    /** stack of status changes associated with pending targets */
+    Stack<StatusEvent> statusEvents = new Stack<>();
+
+    /** stack of pending tasks */
+    Stack<Task> tasks = new Stack<>();
+
+    public LangtoolsIdeaAntLogger(Project project) {
+        for (Object o : project.getBuildListeners()) {
+            if (o instanceof DefaultLogger) {
+                this.logger = (DefaultLogger)o;
+                project.removeBuildListener((BuildListener)o);
+                project.addBuildListener(this);
+            }
+        }
+        logger.setMessageOutputLevel(3);
+        tasks.push(Task.ROOT);
+    }
+
+    @Override
+    public void buildStarted(BuildEvent event) {
+        //do nothing
+    }
+
+    @Override
+    public void buildFinished(BuildEvent event) {
+        //do nothing
+    }
+
+    @Override
+    public void targetStarted(BuildEvent event) {
+        EnumSet<Target> statusKinds = firstTarget ?
+                EnumSet.allOf(Target.class) :
+                EnumSet.complementOf(EnumSet.of(Target.ANY));
+
+        String targetName = event.getTarget().getName();
+
+        for (Target statusKind : statusKinds) {
+            if (statusKind.matches(targetName)) {
+                StatusEvent statusEvent = new StatusEvent(event, statusKind);
+                statusEvents.push(statusEvent);
+                logger.taskStarted(statusEvent);
+                firstTarget = false;
+                return;
+            }
+        }
+    }
+
+    @Override
+    public void targetFinished(BuildEvent event) {
+        if (!statusEvents.isEmpty()) {
+            StatusEvent lastEvent = statusEvents.pop();
+            if (lastEvent.target.matches(event.getTarget().getName())) {
+                logger.taskFinished(lastEvent);
+            }
+        }
+    }
+
+    @Override
+    public void taskStarted(BuildEvent event) {
+        String taskName = event.getTask().getTaskName();
+        for (Task task : Task.values()) {
+            if (task.matches(taskName)) {
+                tasks.push(task);
+                return;
+            }
+        }
+    }
+
+    @Override
+    public void taskFinished(BuildEvent event) {
+        if (tasks.peek() == Task.ROOT) {
+            //we need to 'close' the root task to get nicer output
+            logger.taskFinished(event);
+        } else if (!suppressTaskFailures && event.getException() != null) {
+            //the first (innermost) task failure should always be logged
+            event.setMessage(event.getException().toString(), 0);
+            event.setException(null);
+            //note: we turn this into a plain message to avoid stack trace being logged by Idea
+            logger.messageLogged(event);
+            suppressTaskFailures = true;
+        }
+        tasks.pop();
+    }
+
+    @Override
+    public void messageLogged(BuildEvent event) {
+        String msg = event.getMessage();
+
+        boolean processed = false;
+
+        if (!tasks.isEmpty()) {
+            Task task = tasks.peek();
+            for (MessageKind messageKind : task.msgs) {
+                if (messageKind.matches(msg)) {
+                    event.setMessage(msg, messageKind.priority);
+                    processed = true;
+                    if (messageKind == MessageKind.JAVAC_CRASH) {
+                        crashFound = true;
+                    }
+                    break;
+                }
+            }
+        }
+
+        if (event.getPriority() == MSG_ERR || crashFound) {
+            //we log errors regardless of owning task
+            logger.messageLogged(event);
+            suppressTaskFailures = true;
+        } else if (processed) {
+            logger.messageLogged(event);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/vcs.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="hg4idea" />
+  </component>
+</project>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/langtools/intellij/template/workspace.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="StructureViewFactory">
+    <option name="ACTIVE_ACTIONS" value=",ALPHA_COMPARATOR" />
+  </component>
+  <component name="antWorkspaceConfiguration">
+    <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
+    <option name="FILTER_TARGETS" value="false" />
+    <buildFile url="file://$PROJECT_DIR$/make/langtools/intellij/build.xml">
+      <runInBackground value="false" />
+      <targetFilters>
+        <filter targetName="build-all-tools" isVisible="true" />
+        <filter targetName="build-all-classes" isVisible="true" />
+        <filter targetName="clean" isVisible="true" />
+        <filter targetName="crules" isVisible="true" />
+      </targetFilters>
+      <viewClosedWhenNoErrors value="true" />
+      <expanded value="false" />
+      <treeView value="false" />
+    </buildFile>
+  </component>
+</project>
--- a/make/langtools/intellij/vcs.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="VcsDirectoryMappings">
-    <mapping directory="$PROJECT_DIR$" vcs="hg4idea" />
-  </component>
-</project>
-
--- a/make/langtools/intellij/workspace.xml	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="StructureViewFactory">
-    <option name="ACTIVE_ACTIONS" value=",ALPHA_COMPARATOR" />
-  </component>
-  <component name="antWorkspaceConfiguration">
-    <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
-    <option name="FILTER_TARGETS" value="false" />
-    <buildFile url="file://$PROJECT_DIR$/.idea/build.xml">
-      <runInBackground value="false" />
-      <targetFilters>
-        <filter targetName="build-all-tools" isVisible="true" />
-        <filter targetName="build-all-classes" isVisible="true" />
-        <filter targetName="clean" isVisible="true" />
-        <filter targetName="crules" isVisible="true" />
-      </targetFilters>
-      <viewClosedWhenNoErrors value="true" />
-      <expanded value="false" />
-      <treeView value="false" />
-    </buildFile>
-  </component>
-</project>
--- a/make/launcher/Launcher-jdk.jconsole.gmk	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/launcher/Launcher-jdk.jconsole.gmk	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
 $(eval $(call SetupBuildLauncher, jconsole, \
     MAIN_CLASS := sun.tools.jconsole.JConsole, \
     JAVA_ARGS := --add-opens java.base/java.io=jdk.jconsole \
+                 --add-modules ALL-DEFAULT \
 		 -Djconsole.showOutputViewer, \
     CFLAGS_windows := -DJAVAW, \
     LIBS_windows := user32.lib, \
--- a/make/lib/CoreLibraries.gmk	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/lib/CoreLibraries.gmk	Fri Sep 07 15:46:39 2018 -0700
@@ -68,7 +68,7 @@
       CFLAGS_linux_ppc64le := -ffp-contract=off, \
       CFLAGS_linux_s390x := -ffp-contract=off, \
       CFLAGS_linux_aarch64 := -ffp-contract=off, \
-      DISABLED_WARNINGS_gcc := sign-compare misleading-indentation, \
+      DISABLED_WARNINGS_gcc := sign-compare misleading-indentation array-bounds, \
       DISABLED_WARNINGS_microsoft := 4146 4244 4018, \
       ARFLAGS := $(ARFLAGS), \
       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \
--- a/make/nb_native/nbproject/configurations.xml	Wed Aug 29 09:45:58 2018 +0200
+++ b/make/nb_native/nbproject/configurations.xml	Fri Sep 07 15:46:39 2018 -0700
@@ -2843,8 +2843,6 @@
               <in>elfStringTable.hpp</in>
               <in>elfSymbolTable.cpp</in>
               <in>elfSymbolTable.hpp</in>
-              <in>errorReporter.cpp</in>
-              <in>errorReporter.hpp</in>
               <in>events.cpp</in>
               <in>events.hpp</in>
               <in>exceptions.cpp</in>
@@ -2855,7 +2853,7 @@
               <in>globalDefinitions.cpp</in>
               <in>globalDefinitions.hpp</in>
               <in>globalDefinitions_gcc.hpp</in>
-              <in>globalDefinitions_sparcWorks.hpp</in>
+              <in>globalDefinitions_solstudio.hpp</in>
               <in>globalDefinitions_visCPP.hpp</in>
               <in>globalDefinitions_xlc.hpp</in>
               <in>growableArray.cpp</in>
@@ -6157,6 +6155,9 @@
                 <df name="HeapMonitorModule">
                   <in>libHeapMonitorTest.c</in>
                 </df>
+                <df name="VMEvent">
+                  <in>libVMEventTest.c</in>
+                </df>
                 <df name="ModuleAwareAgents">
                   <df name="ClassFileLoadHook">
                     <in>libMAAClassFileLoadHook.c</in>
@@ -15166,16 +15167,6 @@
             tool="3"
             flavor2="0">
       </item>
-      <item path="../../src/hotspot/share/utilities/errorReporter.cpp"
-            ex="false"
-            tool="1"
-            flavor2="0">
-      </item>
-      <item path="../../src/hotspot/share/utilities/errorReporter.hpp"
-            ex="false"
-            tool="3"
-            flavor2="0">
-      </item>
       <item path="../../src/hotspot/share/utilities/events.cpp"
             ex="false"
             tool="1"
@@ -15226,7 +15217,7 @@
             tool="3"
             flavor2="0">
       </item>
-      <item path="../../src/hotspot/share/utilities/globalDefinitions_sparcWorks.hpp"
+      <item path="../../src/hotspot/share/utilities/globalDefinitions_solstudio.hpp"
             ex="false"
             tool="3"
             flavor2="0">
@@ -15878,7 +15869,7 @@
             <Elem>SPARC_WORKS</Elem>
             <Elem>TARGET_ARCH_MODEL_x86_64</Elem>
             <Elem>TARGET_ARCH_x86</Elem>
-            <Elem>TARGET_COMPILER_sparcWorks</Elem>
+            <Elem>TARGET_COMPILER_solstudio</Elem>
             <Elem>TARGET_OS_ARCH_MODEL_solaris_x86_64</Elem>
             <Elem>TARGET_OS_ARCH_solaris_x86</Elem>
             <Elem>TARGET_OS_FAMILY_solaris</Elem>
@@ -15931,7 +15922,7 @@
             <Elem>SPARC_WORKS</Elem>
             <Elem>TARGET_ARCH_MODEL_x86_64</Elem>
             <Elem>TARGET_ARCH_x86</Elem>
-            <Elem>TARGET_COMPILER_sparcWorks</Elem>
+            <Elem>TARGET_COMPILER_solstudio</Elem>
             <Elem>TARGET_OS_ARCH_MODEL_solaris_x86_64</Elem>
             <Elem>TARGET_OS_ARCH_solaris_x86</Elem>
             <Elem>TARGET_OS_FAMILY_solaris</Elem>
@@ -28948,16 +28939,6 @@
             tool="3"
             flavor2="0">
       </item>
-      <item path="../../src/hotspot/share/utilities/errorReporter.cpp"
-            ex="false"
-            tool="1"
-            flavor2="0">
-      </item>
-      <item path="../../src/hotspot/share/utilities/errorReporter.hpp"
-            ex="false"
-            tool="3"
-            flavor2="0">
-      </item>
       <item path="../../src/hotspot/share/utilities/events.cpp"
             ex="false"
             tool="1"
@@ -29008,7 +28989,7 @@
             tool="3"
             flavor2="0">
       </item>
-      <item path="../../src/hotspot/share/utilities/globalDefinitions_sparcWorks.hpp"
+      <item path="../../src/hotspot/share/utilities/globalDefinitions_solstudio.hpp"
             ex="false"
             tool="3"
             flavor2="0">
@@ -40168,6 +40149,11 @@
             tool="0"
             flavor2="0">
       </item>
+      <item path="../../test/hotspot/jtreg/serviceability/jvmti/VMEvent/libVMEventTest.c"
+            ex="false"
+            tool="0"
+            flavor2="0">
+      </item>
       <item path="../../test/hotspot/jtreg/serviceability/jvmti/ModuleAwareAgents/ClassFileLoadHook/libMAAClassFileLoadHook.c"
             ex="false"
             tool="0"
--- a/src/hotspot/cpu/aarch64/aarch64.ad	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/aarch64/aarch64.ad	Fri Sep 07 15:46:39 2018 -0700
@@ -3378,26 +3378,18 @@
     // Load markOop from object into displaced_header.
     __ ldr(disp_hdr, Address(oop, oopDesc::mark_offset_in_bytes()));
 
-    // Always do locking in runtime.
-    if (EmitSync & 0x01) {
-      __ cmp(oop, zr);
-      return;
-    }
-
     if (UseBiasedLocking && !UseOptoBiasInlining) {
       __ biased_locking_enter(box, oop, disp_hdr, tmp, true, cont);
     }
 
     // Handle existing monitor
-    if ((EmitSync & 0x02) == 0) {
-      // we can use AArch64's bit test and branch here but
-      // markoopDesc does not define a bit index just the bit value
-      // so assert in case the bit pos changes
-#     define __monitor_value_log2 1
-      assert(markOopDesc::monitor_value == (1 << __monitor_value_log2), "incorrect bit position");
-      __ tbnz(disp_hdr, __monitor_value_log2, object_has_monitor);
-#     undef __monitor_value_log2
-    }
+    // we can use AArch64's bit test and branch here but
+    // markoopDesc does not define a bit index just the bit value
+    // so assert in case the bit pos changes
+#   define __monitor_value_log2 1
+    assert(markOopDesc::monitor_value == (1 << __monitor_value_log2), "incorrect bit position");
+    __ tbnz(disp_hdr, __monitor_value_log2, object_has_monitor);
+#   undef __monitor_value_log2
 
     // Set displaced_header to be (markOop of object | UNLOCK_VALUE).
     __ orr(disp_hdr, disp_hdr, markOopDesc::unlocked_value);
@@ -3455,63 +3447,62 @@
     __ str(tmp/*==0, perhaps*/, Address(box, BasicLock::displaced_header_offset_in_bytes()));
 
     // Handle existing monitor.
-    if ((EmitSync & 0x02) == 0) {
-      __ b(cont);
-
-      __ bind(object_has_monitor);
-      // The object's monitor m is unlocked iff m->owner == NULL,
-      // otherwise m->owner may contain a thread or a stack address.
-      //
-      // Try to CAS m->owner from NULL to current thread.
-      __ add(tmp, disp_hdr, (ObjectMonitor::owner_offset_in_bytes()-markOopDesc::monitor_value));
-      __ mov(disp_hdr, zr);
-
-      if (UseLSE) {
-        __ mov(rscratch1, disp_hdr);
-        __ casal(Assembler::xword, rscratch1, rthread, tmp);
-        __ cmp(rscratch1, disp_hdr);
-      } else {
-        Label retry_load, fail;
-        if ((VM_Version::features() & VM_Version::CPU_STXR_PREFETCH))
-          __ prfm(Address(tmp), PSTL1STRM);
-        __ bind(retry_load);
-        __ ldaxr(rscratch1, tmp);
-        __ cmp(disp_hdr, rscratch1);
-        __ br(Assembler::NE, fail);
-        // use stlxr to ensure update is immediately visible
-        __ stlxr(rscratch1, rthread, tmp);
-        __ cbnzw(rscratch1, retry_load);
-        __ bind(fail);
+    __ b(cont);
+
+    __ bind(object_has_monitor);
+    // The object's monitor m is unlocked iff m->owner == NULL,
+    // otherwise m->owner may contain a thread or a stack address.
+    //
+    // Try to CAS m->owner from NULL to current thread.
+    __ add(tmp, disp_hdr, (ObjectMonitor::owner_offset_in_bytes()-markOopDesc::monitor_value));
+    __ mov(disp_hdr, zr);
+
+    if (UseLSE) {
+      __ mov(rscratch1, disp_hdr);
+      __ casal(Assembler::xword, rscratch1, rthread, tmp);
+      __ cmp(rscratch1, disp_hdr);
+    } else {
+      Label retry_load, fail;
+      if ((VM_Version::features() & VM_Version::CPU_STXR_PREFETCH)) {
+        __ prfm(Address(tmp), PSTL1STRM);
       }
-
-      // Label next;
-      // __ cmpxchgptr(/*oldv=*/disp_hdr,
-      //               /*newv=*/rthread,
-      //               /*addr=*/tmp,
-      //               /*tmp=*/rscratch1,
-      //               /*succeed*/next,
-      //               /*fail*/NULL);
-      // __ bind(next);
-
-      // store a non-null value into the box.
-      __ str(box, Address(box, BasicLock::displaced_header_offset_in_bytes()));
-
-      // PPC port checks the following invariants
-      // #ifdef ASSERT
-      // bne(flag, cont);
-      // We have acquired the monitor, check some invariants.
-      // addw(/*monitor=*/tmp, tmp, -ObjectMonitor::owner_offset_in_bytes());
-      // Invariant 1: _recursions should be 0.
-      // assert(ObjectMonitor::recursions_size_in_bytes() == 8, "unexpected size");
-      // assert_mem8_is_zero(ObjectMonitor::recursions_offset_in_bytes(), tmp,
-      //                        "monitor->_recursions should be 0", -1);
-      // Invariant 2: OwnerIsThread shouldn't be 0.
-      // assert(ObjectMonitor::OwnerIsThread_size_in_bytes() == 4, "unexpected size");
-      //assert_mem4_isnot_zero(ObjectMonitor::OwnerIsThread_offset_in_bytes(), tmp,
-      //                           "monitor->OwnerIsThread shouldn't be 0", -1);
-      // #endif
+      __ bind(retry_load);
+      __ ldaxr(rscratch1, tmp);
+      __ cmp(disp_hdr, rscratch1);
+      __ br(Assembler::NE, fail);
+      // use stlxr to ensure update is immediately visible
+      __ stlxr(rscratch1, rthread, tmp);
+      __ cbnzw(rscratch1, retry_load);
+      __ bind(fail);
     }
 
+    // Label next;
+    // __ cmpxchgptr(/*oldv=*/disp_hdr,
+    //               /*newv=*/rthread,
+    //               /*addr=*/tmp,
+    //               /*tmp=*/rscratch1,
+    //               /*succeed*/next,
+    //               /*fail*/NULL);
+    // __ bind(next);
+
+    // store a non-null value into the box.
+    __ str(box, Address(box, BasicLock::displaced_header_offset_in_bytes()));
+
+    // PPC port checks the following invariants
+    // #ifdef ASSERT
+    // bne(flag, cont);
+    // We have acquired the monitor, check some invariants.
+    // addw(/*monitor=*/tmp, tmp, -ObjectMonitor::owner_offset_in_bytes());
+    // Invariant 1: _recursions should be 0.
+    // assert(ObjectMonitor::recursions_size_in_bytes() == 8, "unexpected size");
+    // assert_mem8_is_zero(ObjectMonitor::recursions_offset_in_bytes(), tmp,
+    //                        "monitor->_recursions should be 0", -1);
+    // Invariant 2: OwnerIsThread shouldn't be 0.
+    // assert(ObjectMonitor::OwnerIsThread_size_in_bytes() == 4, "unexpected size");
+    //assert_mem4_isnot_zero(ObjectMonitor::OwnerIsThread_offset_in_bytes(), tmp,
+    //                           "monitor->OwnerIsThread shouldn't be 0", -1);
+    // #endif
+
     __ bind(cont);
     // flag == EQ indicates success
     // flag == NE indicates failure
@@ -3533,12 +3524,6 @@
 
     assert_different_registers(oop, box, tmp, disp_hdr);
 
-    // Always do locking in runtime.
-    if (EmitSync & 0x01) {
-      __ cmp(oop, zr); // Oop can't be 0 here => always false.
-      return;
-    }
-
     if (UseBiasedLocking && !UseOptoBiasInlining) {
       __ biased_locking_exit(oop, tmp, cont);
     }
@@ -3552,10 +3537,8 @@
 
 
     // Handle existing monitor.
-    if ((EmitSync & 0x02) == 0) {
-      __ ldr(tmp, Address(oop, oopDesc::mark_offset_in_bytes()));
-      __ tbnz(disp_hdr, exact_log2(markOopDesc::monitor_value), object_has_monitor);
-    }
+    __ ldr(tmp, Address(oop, oopDesc::mark_offset_in_bytes()));
+    __ tbnz(disp_hdr, exact_log2(markOopDesc::monitor_value), object_has_monitor);
 
     // Check if it is still a light weight lock, this is is true if we
     // see the stack address of the basicLock in the markOop of the
@@ -3590,27 +3573,25 @@
     __ bind(cas_failed);
 
     // Handle existing monitor.
-    if ((EmitSync & 0x02) == 0) {
-      __ b(cont);
-
-      __ bind(object_has_monitor);
-      __ add(tmp, tmp, -markOopDesc::monitor_value); // monitor
-      __ ldr(rscratch1, Address(tmp, ObjectMonitor::owner_offset_in_bytes()));
-      __ ldr(disp_hdr, Address(tmp, ObjectMonitor::recursions_offset_in_bytes()));
-      __ eor(rscratch1, rscratch1, rthread); // Will be 0 if we are the owner.
-      __ orr(rscratch1, rscratch1, disp_hdr); // Will be 0 if there are 0 recursions
-      __ cmp(rscratch1, zr);
-      __ br(Assembler::NE, cont);
-
-      __ ldr(rscratch1, Address(tmp, ObjectMonitor::EntryList_offset_in_bytes()));
-      __ ldr(disp_hdr, Address(tmp, ObjectMonitor::cxq_offset_in_bytes()));
-      __ orr(rscratch1, rscratch1, disp_hdr); // Will be 0 if both are 0.
-      __ cmp(rscratch1, zr);
-      __ cbnz(rscratch1, cont);
-      // need a release store here
-      __ lea(tmp, Address(tmp, ObjectMonitor::owner_offset_in_bytes()));
-      __ stlr(rscratch1, tmp); // rscratch1 is zero
-    }
+    __ b(cont);
+
+    __ bind(object_has_monitor);
+    __ add(tmp, tmp, -markOopDesc::monitor_value); // monitor
+    __ ldr(rscratch1, Address(tmp, ObjectMonitor::owner_offset_in_bytes()));
+    __ ldr(disp_hdr, Address(tmp, ObjectMonitor::recursions_offset_in_bytes()));
+    __ eor(rscratch1, rscratch1, rthread); // Will be 0 if we are the owner.
+    __ orr(rscratch1, rscratch1, disp_hdr); // Will be 0 if there are 0 recursions
+    __ cmp(rscratch1, zr);
+    __ br(Assembler::NE, cont);
+
+    __ ldr(rscratch1, Address(tmp, ObjectMonitor::EntryList_offset_in_bytes()));
+    __ ldr(disp_hdr, Address(tmp, ObjectMonitor::cxq_offset_in_bytes()));
+    __ orr(rscratch1, rscratch1, disp_hdr); // Will be 0 if both are 0.
+    __ cmp(rscratch1, zr);
+    __ cbnz(rscratch1, cont);
+    // need a release store here
+    __ lea(tmp, Address(tmp, ObjectMonitor::owner_offset_in_bytes()));
+    __ stlr(rscratch1, tmp); // rscratch1 is zero
 
     __ bind(cont);
     // flag == EQ indicates success
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -40,16 +40,21 @@
 #include "oops/accessDecorators.hpp"
 #include "oops/compressedOops.inline.hpp"
 #include "oops/klass.inline.hpp"
-#include "oops/oop.hpp"
-#include "opto/compile.hpp"
-#include "opto/intrinsicnode.hpp"
-#include "opto/node.hpp"
 #include "runtime/biasedLocking.hpp"
 #include "runtime/icache.hpp"
 #include "runtime/interfaceSupport.inline.hpp"
 #include "runtime/jniHandles.inline.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/thread.hpp"
+#ifdef COMPILER1
+#include "c1/c1_LIRAssembler.hpp"
+#endif
+#ifdef COMPILER2
+#include "oops/oop.hpp"
+#include "opto/compile.hpp"
+#include "opto/intrinsicnode.hpp"
+#include "opto/node.hpp"
+#endif
 
 #ifdef PRODUCT
 #define BLOCK_COMMENT(str) /* nothing */
@@ -741,12 +746,15 @@
 
   // We need a trampoline if branches are far.
   if (far_branches()) {
+    bool in_scratch_emit_size = false;
+#ifdef COMPILER2
     // We don't want to emit a trampoline if C2 is generating dummy
     // code during its branch shortening phase.
     CompileTask* task = ciEnv::current()->task();
-    bool in_scratch_emit_size =
+    in_scratch_emit_size =
       (task != NULL && is_c2_compile(task->comp_level()) &&
        Compile::current()->in_scratch_emit_size());
+#endif
     if (!in_scratch_emit_size) {
       address stub = emit_trampoline_stub(offset(), entry.target());
       if (stub == NULL) {
@@ -780,7 +788,9 @@
 
 address MacroAssembler::emit_trampoline_stub(int insts_call_instruction_offset,
                                              address dest) {
-  address stub = start_a_stub(Compile::MAX_stubs_size/2);
+  // Max stub size: alignment nop, TrampolineStub.
+  address stub = start_a_stub(NativeInstruction::instruction_size
+                   + NativeCallTrampolineStub::instruction_size);
   if (stub == NULL) {
     return NULL;  // CodeBuffer::expand failed
   }
@@ -4324,6 +4334,7 @@
   }
 }
 
+#ifdef COMPILER2
 typedef void (MacroAssembler::* chr_insn)(Register Rt, const Address &adr);
 
 // Search for str1 in str2 and return index or -1
@@ -5053,6 +5064,7 @@
 
   BLOCK_COMMENT("} string_compare");
 }
+#endif // COMPILER2
 
 // This method checks if provided byte array contains byte with highest bit set.
 void MacroAssembler::has_negatives(Register ary1, Register len, Register result) {
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -592,7 +592,7 @@
   // Required platform-specific helpers for Label::patch_instructions.
   // They _shadow_ the declarations in AbstractAssembler, which are undefined.
   static int pd_patch_instruction_size(address branch, address target);
-  static void pd_patch_instruction(address branch, address target) {
+  static void pd_patch_instruction(address branch, address target, const char* file = NULL, int line = 0) {
     pd_patch_instruction_size(branch, target);
   }
   static address pd_call_destination(address branch) {
--- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1107,7 +1107,7 @@
     }
   }
   __ pop(x, sp);
-  for ( int i = first_arg ; i < arg_count ; i++ ) {
+  for ( int i = arg_count - 1 ; i >= first_arg ; i-- ) {
     if (args[i].first()->is_Register()) {
       ;
     } else if (args[i].first()->is_FloatRegister()) {
--- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -5792,6 +5792,7 @@
     // byte_array_inflate stub for large arrays.
     StubRoutines::aarch64::_large_byte_array_inflate = generate_large_byte_array_inflate();
 
+#ifdef COMPILER2
     if (UseMultiplyToLenIntrinsic) {
       StubRoutines::_multiplyToLen = generate_multiplyToLen();
     }
@@ -5817,6 +5818,7 @@
       // because it's faster for the sizes of modulus we care about.
       StubRoutines::_montgomerySquare = g.generate_multiply();
     }
+#endif // COMPILER2
 
 #ifndef BUILTIN_SIM
     // generate GHASH intrinsics code
--- a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -217,9 +217,11 @@
     if (FLAG_IS_DEFAULT(UseSIMDForMemoryOps)) {
       FLAG_SET_DEFAULT(UseSIMDForMemoryOps, true);
     }
+#ifdef COMPILER2
     if (FLAG_IS_DEFAULT(UseFPUForSpilling)) {
       FLAG_SET_DEFAULT(UseFPUForSpilling, true);
     }
+#endif
   }
 
   // Cortex A53
@@ -384,6 +386,15 @@
     FLAG_SET_DEFAULT(UseUnalignedAccesses, true);
   }
 
+  if (FLAG_IS_DEFAULT(UseBarriersForVolatile)) {
+    UseBarriersForVolatile = (_features & CPU_DMB_ATOMICS) != 0;
+  }
+
+  if (FLAG_IS_DEFAULT(UsePopCountInstruction)) {
+    UsePopCountInstruction = true;
+  }
+
+#ifdef COMPILER2
   if (FLAG_IS_DEFAULT(UseMultiplyToLenIntrinsic)) {
     UseMultiplyToLenIntrinsic = true;
   }
@@ -396,14 +407,6 @@
     UseMulAddIntrinsic = true;
   }
 
-  if (FLAG_IS_DEFAULT(UseBarriersForVolatile)) {
-    UseBarriersForVolatile = (_features & CPU_DMB_ATOMICS) != 0;
-  }
-
-  if (FLAG_IS_DEFAULT(UsePopCountInstruction)) {
-    UsePopCountInstruction = true;
-  }
-
   if (FLAG_IS_DEFAULT(UseMontgomeryMultiplyIntrinsic)) {
     UseMontgomeryMultiplyIntrinsic = true;
   }
@@ -411,7 +414,6 @@
     UseMontgomerySquareIntrinsic = true;
   }
 
-#ifdef COMPILER2
   if (FLAG_IS_DEFAULT(OptoScheduling)) {
     OptoScheduling = true;
   }
--- a/src/hotspot/cpu/aarch64/vtableStubs_aarch64.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/aarch64/vtableStubs_aarch64.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -44,24 +44,30 @@
 #define __ masm->
 
 #ifndef PRODUCT
-extern "C" void bad_compiled_vtable_index(JavaThread* thread,
-                                          oop receiver,
-                                          int index);
+extern "C" void bad_compiled_vtable_index(JavaThread* thread, oop receiver, int index);
 #endif
 
 VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
-  const int aarch64_code_length = VtableStub::pd_code_size_limit(true);
-  VtableStub* s = new(aarch64_code_length) VtableStub(true, vtable_index);
+  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
+  const int stub_code_length = code_size_limit(true);
+  VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index);
   // Can be NULL if there is no free space in the code cache.
   if (s == NULL) {
     return NULL;
   }
 
-  ResourceMark rm;
-  CodeBuffer cb(s->entry_point(), aarch64_code_length);
+  // Count unused bytes in instruction sequences of variable size.
+  // We add them to the computed buffer size in order to avoid
+  // overflow in subsequently generated stubs.
+  address   start_pc;
+  int       slop_bytes = 0;
+  int       slop_delta = 0;
+
+  ResourceMark    rm;
+  CodeBuffer      cb(s->entry_point(), stub_code_length);
   MacroAssembler* masm = new MacroAssembler(&cb);
 
-#ifndef PRODUCT
+#if (!defined(PRODUCT) && defined(COMPILER2))
   if (CountCompiledCalls) {
     __ lea(r16, ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
     __ incrementw(Address(r16));
@@ -78,21 +84,35 @@
 #ifndef PRODUCT
   if (DebugVtables) {
     Label L;
+    // TODO: find upper bound for this debug code.
+    start_pc = __ pc();
+
     // check offset vs vtable length
     __ ldrw(rscratch1, Address(r16, Klass::vtable_length_offset()));
     __ cmpw(rscratch1, vtable_index * vtableEntry::size());
     __ br(Assembler::GT, L);
     __ enter();
     __ mov(r2, vtable_index);
-    __ call_VM(noreg,
-               CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), j_rarg0, r2);
+
+    __ call_VM(noreg, CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), j_rarg0, r2);
+    const ptrdiff_t estimate = 256;
+    const ptrdiff_t codesize = __ pc() - start_pc;
+    slop_delta  = estimate - codesize;  // call_VM varies in length, depending on data
+    slop_bytes += slop_delta;
+    assert(slop_delta >= 0, "vtable #%d: Code size estimate (%d) for DebugVtables too small, required: %d", vtable_index, (int)estimate, (int)codesize);
+
     __ leave();
     __ bind(L);
   }
 #endif // PRODUCT
 
+  start_pc = __ pc();
   __ lookup_virtual_method(r16, vtable_index, rmethod);
+  slop_delta  = 8 - (int)(__ pc() - start_pc);
+  slop_bytes += slop_delta;
+  assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
 
+#ifndef PRODUCT
   if (DebugVtables) {
     Label L;
     __ cbz(rmethod, L);
@@ -101,6 +121,8 @@
     __ stop("Vtable entry is NULL");
     __ bind(L);
   }
+#endif // PRODUCT
+
   // r0: receiver klass
   // rmethod: Method*
   // r2: receiver
@@ -108,43 +130,46 @@
   __ ldr(rscratch1, Address(rmethod, Method::from_compiled_offset()));
   __ br(rscratch1);
 
-  __ flush();
+  masm->flush();
+  bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0);
 
-  if (PrintMiscellaneous && (WizardMode || Verbose)) {
-    tty->print_cr("vtable #%d at " PTR_FORMAT "[%d] left over: %d",
-                  vtable_index, p2i(s->entry_point()),
-                  (int)(s->code_end() - s->entry_point()),
-                  (int)(s->code_end() - __ pc()));
-  }
-  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
-
-  s->set_exception_points(npe_addr, ame_addr);
   return s;
 }
 
 
 VtableStub* VtableStubs::create_itable_stub(int itable_index) {
-  // Note well: pd_code_size_limit is the absolute minimum we can get
-  // away with.  If you add code here, bump the code stub size
-  // returned by pd_code_size_limit!
-  const int code_length = VtableStub::pd_code_size_limit(false);
-  VtableStub* s = new(code_length) VtableStub(false, itable_index);
-  ResourceMark rm;
-  CodeBuffer cb(s->entry_point(), code_length);
+  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
+  const int stub_code_length = code_size_limit(false);
+  VtableStub* s = new(stub_code_length) VtableStub(false, itable_index);
+  // Can be NULL if there is no free space in the code cache.
+  if (s == NULL) {
+    return NULL;
+  }
+  // Count unused bytes in instruction sequences of variable size.
+  // We add them to the computed buffer size in order to avoid
+  // overflow in subsequently generated stubs.
+  address   start_pc;
+  int       slop_bytes = 0;
+  int       slop_delta = 0;
+
+  ResourceMark    rm;
+  CodeBuffer      cb(s->entry_point(), stub_code_length);
   MacroAssembler* masm = new MacroAssembler(&cb);
 
-#ifndef PRODUCT
+#if (!defined(PRODUCT) && defined(COMPILER2))
   if (CountCompiledCalls) {
     __ lea(r10, ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
     __ incrementw(Address(r10));
   }
 #endif
 
+  // get receiver (need to skip return address on top of stack)
+  assert(VtableStub::receiver_location() == j_rarg0->as_VMReg(), "receiver expected in j_rarg0");
+
   // Entry arguments:
   //  rscratch2: CompiledICHolder
   //  j_rarg0: Receiver
 
-
   // Most registers are in use; we'll use r16, rmethod, r10, r11
   const Register recv_klass_reg     = r10;
   const Register holder_klass_reg   = r16; // declaring interface klass (DECC)
@@ -157,8 +182,8 @@
   __ ldr(resolved_klass_reg, Address(icholder_reg, CompiledICHolder::holder_klass_offset()));
   __ ldr(holder_klass_reg,   Address(icholder_reg, CompiledICHolder::holder_metadata_offset()));
 
-  // get receiver (need to skip return address on top of stack)
-  assert(VtableStub::receiver_location() == j_rarg0->as_VMReg(), "receiver expected in j_rarg0");
+  start_pc = __ pc();
+
   // get receiver klass (also an implicit null-check)
   address npe_addr = __ pc();
   __ load_klass(recv_klass_reg, j_rarg0);
@@ -172,16 +197,25 @@
                              L_no_such_interface,
                              /*return_method=*/false);
 
+  const ptrdiff_t  typecheckSize = __ pc() - start_pc;
+  start_pc = __ pc();
+
   // Get selected method from declaring class and itable index
   __ load_klass(recv_klass_reg, j_rarg0);   // restore recv_klass_reg
   __ lookup_interface_method(// inputs: rec. class, interface, itable index
-                       recv_klass_reg, holder_klass_reg, itable_index,
-                       // outputs: method, scan temp. reg
-                       rmethod, temp_reg,
-                       L_no_such_interface);
+                             recv_klass_reg, holder_klass_reg, itable_index,
+                             // outputs: method, scan temp. reg
+                             rmethod, temp_reg,
+                             L_no_such_interface);
+
+  const ptrdiff_t lookupSize = __ pc() - start_pc;
 
-  // method (rmethod): Method*
-  // j_rarg0: receiver
+  // Reduce "estimate" such that "padding" does not drop below 8.
+  const ptrdiff_t estimate = 152;
+  const ptrdiff_t codesize = typecheckSize + lookupSize;
+  slop_delta  = (int)(estimate - codesize);
+  slop_bytes += slop_delta;
+  assert(slop_delta >= 0, "itable #%d: Code size estimate (%d) for lookup_interface_method too small, required: %d", itable_index, (int)estimate, (int)codesize);
 
 #ifdef ASSERT
   if (DebugVtables) {
@@ -206,92 +240,17 @@
   // We force resolving of the call site by jumping to the "handle
   // wrong method" stub, and so let the interpreter runtime do all the
   // dirty work.
+  assert(SharedRuntime::get_handle_wrong_method_stub() != NULL, "check initialization order");
   __ far_jump(RuntimeAddress(SharedRuntime::get_handle_wrong_method_stub()));
 
-  __ flush();
+  masm->flush();
+  bookkeeping(masm, tty, s, npe_addr, ame_addr, false, itable_index, slop_bytes, 0);
 
-  if (PrintMiscellaneous && (WizardMode || Verbose)) {
-    tty->print_cr("itable #%d at " PTR_FORMAT "[%d] left over: %d",
-                  itable_index, p2i(s->entry_point()),
-                  (int)(s->code_end() - s->entry_point()),
-                  (int)(s->code_end() - __ pc()));
-  }
-  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
-
-  s->set_exception_points(npe_addr, ame_addr);
   return s;
 }
 
-
-int VtableStub::pd_code_size_limit(bool is_vtable_stub) {
-  int size = DebugVtables ? 216 : 0;
-  if (CountCompiledCalls)
-    size += 6 * 4;
-  // FIXME: vtable stubs only need 36 bytes
-  if (is_vtable_stub)
-    size += 52;
-  else
-    size += 176;
-  return size;
-
-  // In order to tune these parameters, run the JVM with VM options
-  // +PrintMiscellaneous and +WizardMode to see information about
-  // actual itable stubs.  Run it with -Xmx31G -XX:+UseCompressedOops.
-  //
-  // If Universe::narrow_klass_base is nonzero, decoding a compressed
-  // class can take zeveral instructions.
-  //
-  // The JVM98 app. _202_jess has a megamorphic interface call.
-  // The itable code looks like this:
-
-  //    ldr    xmethod, [xscratch2,#CompiledICHolder::holder_klass_offset]
-  //    ldr    x0, [xscratch2]
-  //    ldr    w10, [x1,#oopDesc::klass_offset_in_bytes]
-  //    mov    xheapbase, #0x3c000000                //   #narrow_klass_base
-  //    movk    xheapbase, #0x3f7, lsl #32
-  //    add    x10, xheapbase, x10
-  //    mov    xheapbase, #0xe7ff0000                //   #heapbase
-  //    movk    xheapbase, #0x3f7, lsl #32
-  //    ldr    w11, [x10,#vtable_length_offset]
-  //    add    x11, x10, x11, uxtx #3
-  //    add    x11, x11, #itableMethodEntry::method_offset_in_bytes
-  //    ldr    x10, [x11]
-  //    cmp    xmethod, x10
-  //    b.eq    found_method
-  // search:
-  //    cbz    x10, no_such_interface
-  //    add    x11, x11, #0x10
-  //    ldr    x10, [x11]
-  //    cmp    xmethod, x10
-  //    b.ne    search
-  // found_method:
-  //    ldr    w10, [x1,#oopDesc::klass_offset_in_bytes]
-  //    mov    xheapbase, #0x3c000000                //   #narrow_klass_base
-  //    movk    xheapbase, #0x3f7, lsl #32
-  //    add    x10, xheapbase, x10
-  //    mov    xheapbase, #0xe7ff0000                //   #heapbase
-  //    movk    xheapbase, #0x3f7, lsl #32
-  //    ldr    w11, [x10,#vtable_length_offset]
-  //    add    x11, x10, x11, uxtx #3
-  //    add    x11, x11, #itableMethodEntry::method_offset_in_bytes
-  //    add    x10, x10, #itentry_off
-  //    ldr    xmethod, [x11]
-  //    cmp    x0, xmethod
-  //    b.eq    found_method2
-  // search2:
-  //    cbz    xmethod, 0x000003ffa872e6cc
-  //    add    x11, x11, #0x10
-  //    ldr    xmethod, [x11]
-  //    cmp    x0, xmethod
-  //    b.ne    search2
-  // found_method2:
-  //    ldr    w11, [x11,#itableOffsetEntry::offset_offset_in_bytes]
-  //    ldr    xmethod, [x10,w11,uxtw]
-  //    ldr    xscratch1, [xmethod,#Method::from_compiled_offset]
-  //    br    xscratch1
-  // no_such_interface:
-  //    b      throw_ICCE_entry
-
+int VtableStub::pd_code_alignment() {
+  // aarch64 cache line size is not an architected constant. We just align on 4 bytes (instruction size).
+  const unsigned int icache_line_size = 4;
+  return icache_line_size;
 }
-
-int VtableStub::pd_code_alignment() { return 4; }
--- a/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -50,6 +50,43 @@
     }
     break;
   }
+  case T_BOOLEAN: __ ldrb      (dst, src); break;
+  case T_BYTE:    __ ldrsb     (dst, src); break;
+  case T_CHAR:    __ ldrh      (dst, src); break;
+  case T_SHORT:   __ ldrsh     (dst, src); break;
+  case T_INT:     __ ldr_s32   (dst, src); break;
+  case T_ADDRESS: __ ldr       (dst, src); break;
+  case T_LONG:
+#ifdef AARCH64
+    __ ldr                     (dst, src); break;
+#else
+    assert(dst == noreg, "only to ltos");
+    __ add                     (src.index(), src.index(), src.base());
+    __ ldmia                   (src.index(), RegisterSet(R0_tos_lo) | RegisterSet(R1_tos_hi));
+#endif // AARCH64
+    break;
+#ifdef __SOFTFP__
+  case T_FLOAT:
+    assert(dst == noreg, "only to ftos");
+    __ ldr                     (R0_tos, src);
+    break;
+  case T_DOUBLE:
+    assert(dst == noreg, "only to dtos");
+    __ add                     (src.index(), src.index(), src.base());
+    __ ldmia                   (src.index(), RegisterSet(R0_tos_lo) | RegisterSet(R1_tos_hi));
+    break;
+#else
+  case T_FLOAT:
+    assert(dst == noreg, "only to ftos");
+    __ add(src.index(), src.index(), src.base());
+    __ ldr_float               (S0_tos, src.index());
+    break;
+  case T_DOUBLE:
+    assert(dst == noreg, "only to dtos");
+    __ add                     (src.index(), src.index(), src.base());
+    __ ldr_double              (D0_tos, src.index());
+    break;
+#endif
   default: Unimplemented();
   }
 
@@ -73,7 +110,7 @@
       } else
 #endif // AARCH64
       {
-        __ str(val, obj);
+      __ str(val, obj);
       }
     } else {
       assert(in_native, "why else?");
@@ -81,6 +118,46 @@
     }
     break;
   }
+  case T_BOOLEAN:
+    __ and_32(val, val, 1);
+    __ strb(val, obj);
+    break;
+  case T_BYTE:    __ strb      (val, obj); break;
+  case T_CHAR:    __ strh      (val, obj); break;
+  case T_SHORT:   __ strh      (val, obj); break;
+  case T_INT:     __ str       (val, obj); break;
+  case T_ADDRESS: __ str       (val, obj); break;
+  case T_LONG:
+#ifdef AARCH64
+    __ str                     (val, obj); break;
+#else // AARCH64
+    assert(val == noreg, "only tos");
+    __ add                     (obj.index(), obj.index(), obj.base());
+    __ stmia                   (obj.index(), RegisterSet(R0_tos_lo) | RegisterSet(R1_tos_hi));
+#endif // AARCH64
+    break;
+#ifdef __SOFTFP__
+  case T_FLOAT:
+    assert(val == noreg, "only tos");
+    __ str (R0_tos,  obj);
+    break;
+  case T_DOUBLE:
+    assert(val == noreg, "only tos");
+    __ add                     (obj.index(), obj.index(), obj.base());
+    __ stmia                   (obj.index(), RegisterSet(R0_tos_lo) | RegisterSet(R1_tos_hi));
+    break;
+#else
+  case T_FLOAT:
+    assert(val == noreg, "only tos");
+    __ add                     (obj.index(), obj.index(), obj.base());
+    __ str_float               (S0_tos,  obj.index());
+    break;
+  case T_DOUBLE:
+    assert(val == noreg, "only tos");
+    __ add                     (obj.index(), obj.index(), obj.base());
+    __ str_double              (D0_tos,  obj.index());
+    break;
+#endif
   default: Unimplemented();
   }
 }
--- a/src/hotspot/cpu/arm/interp_masm_arm.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/arm/interp_masm_arm.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -302,8 +302,9 @@
   // Add in the index
   // convert from field index to resolved_references() index and from
   // word index to byte offset. Since this is a java object, it can be compressed
-  add(cache, cache, AsmOperand(index, lsl, LogBytesPerHeapOop));
-  load_heap_oop(result, Address(cache, arrayOopDesc::base_offset_in_bytes(T_OBJECT)));
+  logical_shift_left(index, index, LogBytesPerHeapOop);
+  add(index, index, arrayOopDesc::base_offset_in_bytes(T_OBJECT));
+  load_heap_oop(result, Address(cache, index));
 }
 
 void InterpreterMacroAssembler::load_resolved_klass_at_offset(
--- a/src/hotspot/cpu/arm/macroAssembler_arm.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/arm/macroAssembler_arm.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1276,7 +1276,7 @@
     inc_counter((address) counter_addr, tmpreg1, tmpreg2);
   }
 
-  void pd_patch_instruction(address branch, address target);
+  void pd_patch_instruction(address branch, address target, const char* file, int line);
 
   // Loading and storing values by size and signed-ness;
   // size must not exceed wordSize (i.e. 8-byte values are not supported on 32-bit ARM);
--- a/src/hotspot/cpu/arm/macroAssembler_arm.inline.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/arm/macroAssembler_arm.inline.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -30,7 +30,7 @@
 #include "code/codeCache.hpp"
 #include "runtime/handles.inline.hpp"
 
-inline void MacroAssembler::pd_patch_instruction(address branch, address target) {
+inline void MacroAssembler::pd_patch_instruction(address branch, address target, const char* file, int line) {
   int instr = *(int*)branch;
   int new_offset = (int)(target - branch NOT_AARCH64(- 8));
   assert((new_offset & 3) == 0, "bad alignment");
--- a/src/hotspot/cpu/arm/methodHandles_arm.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/arm/methodHandles_arm.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -162,7 +162,7 @@
 
   __ load_heap_oop(Rmethod, Address(tmp, NONZERO(java_lang_invoke_MemberName::method_offset_in_bytes())));
   __ verify_oop(Rmethod);
-  __ ldr(Rmethod, Address(Rmethod, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset_in_bytes())));
+  __ access_load_at(T_ADDRESS, IN_HEAP, Address(Rmethod, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset_in_bytes())), Rmethod, noreg, noreg, noreg);
 
   if (VerifyMethodHandles && !for_compiler_entry) {
     // make sure recv is already on stack
@@ -381,7 +381,7 @@
         verify_ref_kind(_masm, JVM_REF_invokeSpecial, member_reg, temp3);
       }
       __ load_heap_oop(Rmethod, member_vmtarget);
-      __ ldr(Rmethod, vmtarget_method);
+      __ access_load_at(T_ADDRESS, IN_HEAP, vmtarget_method, Rmethod, noreg, noreg, noreg);
       break;
 
     case vmIntrinsics::_linkToStatic:
@@ -389,7 +389,7 @@
         verify_ref_kind(_masm, JVM_REF_invokeStatic, member_reg, temp3);
       }
       __ load_heap_oop(Rmethod, member_vmtarget);
-      __ ldr(Rmethod, vmtarget_method);
+      __ access_load_at(T_ADDRESS, IN_HEAP, vmtarget_method, Rmethod, noreg, noreg, noreg);
       break;
       break;
 
@@ -404,7 +404,7 @@
 
       // pick out the vtable index from the MemberName, and then we can discard it:
       Register temp2_index = temp2;
-      __ ldr(temp2_index, member_vmindex);
+      __ access_load_at(T_ADDRESS, IN_HEAP, member_vmindex, temp2_index, noreg, noreg, noreg);
 
       if (VerifyMethodHandles) {
         Label L_index_ok;
@@ -436,7 +436,7 @@
       __ verify_klass_ptr(temp3_intf);
 
       Register rbx_index = rbx_method;
-      __ ldr(rbx_index, member_vmindex);
+      __ access_load_at(T_ADDRESS, IN_HEAP, member_vmindex, rbx_index, noreg, noreg, noreg);
       if (VerifyMethodHandles) {
         Label L;
         __ cmp(rbx_index, 0);
--- a/src/hotspot/cpu/arm/templateTable_arm.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/arm/templateTable_arm.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -161,6 +161,18 @@
   return Address(temp, arrayOopDesc::base_offset_in_bytes(elemType));
 }
 
+// Returns address of Java array element using temp register as offset from array base
+Address TemplateTable::get_array_elem_addr_same_base(BasicType elemType, Register array, Register index, Register temp) {
+  int logElemSize = exact_log2(type2aelembytes(elemType));
+  if (logElemSize == 0) {
+    __ add(temp, index, arrayOopDesc::base_offset_in_bytes(elemType));
+  } else {
+    __ mov(temp, arrayOopDesc::base_offset_in_bytes(elemType));
+    __ add_ptr_scaled_int32(temp, temp, index, logElemSize);
+  }
+  return Address(array, temp);
+}
+
 //----------------------------------------------------------------------------------------------------
 // Condition conversion
 AsmCondition convNegCond(TemplateTable::Condition cc) {
@@ -883,7 +895,8 @@
   const Register Rindex = R0_tos;
 
   index_check(Rarray, Rindex);
-  __ ldr_s32(R0_tos, get_array_elem_addr(T_INT, Rarray, Rindex, Rtemp));
+  Address addr = get_array_elem_addr_same_base(T_INT, Rarray, Rindex, Rtemp);
+  __ access_load_at(T_INT, IN_HEAP | IS_ARRAY, addr, R0_tos, noreg, noreg, noreg);
 }
 
 
@@ -897,9 +910,8 @@
 #ifdef AARCH64
   __ ldr(R0_tos, get_array_elem_addr(T_LONG, Rarray, Rindex, Rtemp));
 #else
-  __ add(Rtemp, Rarray, AsmOperand(Rindex, lsl, LogBytesPerLong));
-  __ add(Rtemp, Rtemp, arrayOopDesc::base_offset_in_bytes(T_LONG));
-  __ ldmia(Rtemp, RegisterSet(R0_tos_lo, R1_tos_hi));
+  Address addr = get_array_elem_addr_same_base(T_LONG, Rarray, Rindex, Rtemp);
+  __ access_load_at(T_LONG, IN_HEAP | IS_ARRAY, addr, noreg /* ltos */, noreg, noreg, noreg);
 #endif // AARCH64
 }
 
@@ -911,12 +923,8 @@
 
   index_check(Rarray, Rindex);
 
-  Address addr = get_array_elem_addr(T_FLOAT, Rarray, Rindex, Rtemp);
-#ifdef __SOFTFP__
-  __ ldr(R0_tos, addr);
-#else
-  __ ldr_float(S0_tos, addr);
-#endif // __SOFTFP__
+  Address addr = get_array_elem_addr_same_base(T_FLOAT, Rarray, Rindex, Rtemp);
+  __ access_load_at(T_FLOAT, IN_HEAP | IS_ARRAY, addr, noreg /* ftos */, noreg, noreg, noreg);
 }
 
 
@@ -927,13 +935,8 @@
 
   index_check(Rarray, Rindex);
 
-#ifdef __SOFTFP__
-  __ add(Rtemp, Rarray, AsmOperand(Rindex, lsl, LogBytesPerLong));
-  __ add(Rtemp, Rtemp, arrayOopDesc::base_offset_in_bytes(T_DOUBLE));
-  __ ldmia(Rtemp, RegisterSet(R0_tos_lo, R1_tos_hi));
-#else
-  __ ldr_double(D0_tos, get_array_elem_addr(T_DOUBLE, Rarray, Rindex, Rtemp));
-#endif // __SOFTFP__
+  Address addr = get_array_elem_addr_same_base(T_DOUBLE, Rarray, Rindex, Rtemp);
+  __ access_load_at(T_DOUBLE, IN_HEAP | IS_ARRAY, addr, noreg /* dtos */, noreg, noreg, noreg);
 }
 
 
@@ -943,7 +946,7 @@
   const Register Rindex = R0_tos;
 
   index_check(Rarray, Rindex);
-  do_oop_load(_masm, R0_tos, get_array_elem_addr(T_OBJECT, Rarray, Rindex, Rtemp), IS_ARRAY);
+  do_oop_load(_masm, R0_tos, get_array_elem_addr_same_base(T_OBJECT, Rarray, Rindex, Rtemp), IS_ARRAY);
 }
 
 
@@ -953,7 +956,8 @@
   const Register Rindex = R0_tos;
 
   index_check(Rarray, Rindex);
-  __ ldrsb(R0_tos, get_array_elem_addr(T_BYTE, Rarray, Rindex, Rtemp));
+  Address addr = get_array_elem_addr_same_base(T_BYTE, Rarray, Rindex, Rtemp);
+  __ access_load_at(T_BYTE, IN_HEAP | IS_ARRAY, addr, R0_tos, noreg, noreg, noreg);
 }
 
 
@@ -963,7 +967,8 @@
   const Register Rindex = R0_tos;
 
   index_check(Rarray, Rindex);
-  __ ldrh(R0_tos, get_array_elem_addr(T_CHAR, Rarray, Rindex, Rtemp));
+  Address addr = get_array_elem_addr_same_base(T_CHAR, Rarray, Rindex, Rtemp);
+  __ access_load_at(T_CHAR, IN_HEAP | IS_ARRAY, addr, R0_tos, noreg, noreg, noreg);
 }
 
 
@@ -983,7 +988,8 @@
 
   // get array element
   index_check(Rarray, Rindex);
-  __ ldrh(R0_tos, get_array_elem_addr(T_CHAR, Rarray, Rindex, Rtemp));
+  Address addr = get_array_elem_addr_same_base(T_CHAR, Rarray, Rindex, Rtemp);
+  __ access_load_at(T_CHAR, IN_HEAP | IS_ARRAY, addr, R0_tos, noreg, noreg, noreg);
 }
 
 
@@ -993,7 +999,8 @@
   const Register Rindex = R0_tos;
 
   index_check(Rarray, Rindex);
-  __ ldrsh(R0_tos, get_array_elem_addr(T_SHORT, Rarray, Rindex, Rtemp));
+  Address addr = get_array_elem_addr_same_base(T_SHORT, Rarray, Rindex, Rtemp);
+  __ access_load_at(T_SHORT, IN_HEAP | IS_ARRAY, addr, R0_tos, noreg, noreg, noreg);
 }
 
 
@@ -1231,7 +1238,8 @@
 
   __ pop_i(Rindex);
   index_check(Rarray, Rindex);
-  __ str_32(R0_tos, get_array_elem_addr(T_INT, Rarray, Rindex, Rtemp));
+  Address addr = get_array_elem_addr_same_base(T_INT, Rarray, Rindex, Rtemp);
+  __ access_store_at(T_INT, IN_HEAP | IS_ARRAY, addr, R0_tos, noreg, noreg, noreg, false);
 }
 
 
@@ -1247,9 +1255,8 @@
 #ifdef AARCH64
   __ str(R0_tos, get_array_elem_addr(T_LONG, Rarray, Rindex, Rtemp));
 #else
-  __ add(Rtemp, Rarray, AsmOperand(Rindex, lsl, LogBytesPerLong));
-  __ add(Rtemp, Rtemp, arrayOopDesc::base_offset_in_bytes(T_LONG));
-  __ stmia(Rtemp, RegisterSet(R0_tos_lo, R1_tos_hi));
+  Address addr = get_array_elem_addr_same_base(T_LONG, Rarray, Rindex, Rtemp);
+  __ access_store_at(T_LONG, IN_HEAP | IS_ARRAY, addr, noreg /* ltos */, noreg, noreg, noreg, false);
 #endif // AARCH64
 }
 
@@ -1262,13 +1269,8 @@
 
   __ pop_i(Rindex);
   index_check(Rarray, Rindex);
-  Address addr = get_array_elem_addr(T_FLOAT, Rarray, Rindex, Rtemp);
-
-#ifdef __SOFTFP__
-  __ str(R0_tos, addr);
-#else
-  __ str_float(S0_tos, addr);
-#endif // __SOFTFP__
+  Address addr = get_array_elem_addr_same_base(T_FLOAT, Rarray, Rindex, Rtemp);
+  __ access_store_at(T_FLOAT, IN_HEAP | IS_ARRAY, addr, noreg /* ftos */, noreg, noreg, noreg, false);
 }
 
 
@@ -1281,13 +1283,8 @@
   __ pop_i(Rindex);
   index_check(Rarray, Rindex);
 
-#ifdef __SOFTFP__
-  __ add(Rtemp, Rarray, AsmOperand(Rindex, lsl, LogBytesPerLong));
-  __ add(Rtemp, Rtemp, arrayOopDesc::base_offset_in_bytes(T_DOUBLE));
-  __ stmia(Rtemp, RegisterSet(R0_tos_lo, R1_tos_hi));
-#else
-  __ str_double(D0_tos, get_array_elem_addr(T_DOUBLE, Rarray, Rindex, Rtemp));
-#endif // __SOFTFP__
+  Address addr = get_array_elem_addr_same_base(T_DOUBLE, Rarray, Rindex, Rtemp);
+  __ access_store_at(T_DOUBLE, IN_HEAP | IS_ARRAY, addr, noreg /* dtos */, noreg, noreg, noreg, false);
 }
 
 
@@ -1370,7 +1367,8 @@
   __ b(L_skip, eq);
   __ and_32(R0_tos, R0_tos, 1); // if it is a T_BOOLEAN array, mask the stored value to 0/1
   __ bind(L_skip);
-  __ strb(R0_tos, get_array_elem_addr(T_BYTE, Rarray, Rindex, Rtemp));
+  Address addr = get_array_elem_addr_same_base(T_BYTE, Rarray, Rindex, Rtemp);
+  __ access_store_at(T_BYTE, IN_HEAP | IS_ARRAY, addr, R0_tos, noreg, noreg, noreg, false);
 }
 
 
@@ -1382,8 +1380,8 @@
 
   __ pop_i(Rindex);
   index_check(Rarray, Rindex);
-
-  __ strh(R0_tos, get_array_elem_addr(T_CHAR, Rarray, Rindex, Rtemp));
+  Address addr = get_array_elem_addr_same_base(T_CHAR, Rarray, Rindex, Rtemp);
+  __ access_store_at(T_CHAR, IN_HEAP | IS_ARRAY, addr, R0_tos, noreg, noreg, noreg, false);
 }
 
 
@@ -3182,7 +3180,7 @@
   // modes.
 
   // Size of fixed size code block for fast_version
-  const int log_max_block_size = 2;
+  const int log_max_block_size = AARCH64_ONLY(2) NOT_AARCH64(3);
   const int max_block_size = 1 << log_max_block_size;
 
   // Decide if fast version is enabled
@@ -3249,7 +3247,7 @@
     assert(btos == seq++, "btos has unexpected value");
     FixedSizeCodeBlock btos_block(_masm, max_block_size, fast_version);
     __ bind(Lbtos);
-    __ ldrsb(R0_tos, Address(Robj, Roffset));
+    __ access_load_at(T_BYTE, IN_HEAP, Address(Robj, Roffset), R0_tos, noreg, noreg, noreg);
     __ push(btos);
     // Rewrite bytecode to be faster
     if (!is_static && rc == may_rewrite) {
@@ -3263,7 +3261,7 @@
     assert(ztos == seq++, "btos has unexpected value");
     FixedSizeCodeBlock ztos_block(_masm, max_block_size, fast_version);
     __ bind(Lztos);
-    __ ldrsb(R0_tos, Address(Robj, Roffset));
+    __ access_load_at(T_BOOLEAN, IN_HEAP, Address(Robj, Roffset), R0_tos, noreg, noreg, noreg);
     __ push(ztos);
     // Rewrite bytecode to be faster (use btos fast getfield)
     if (!is_static && rc == may_rewrite) {
@@ -3277,7 +3275,7 @@
     assert(ctos == seq++, "ctos has unexpected value");
     FixedSizeCodeBlock ctos_block(_masm, max_block_size, fast_version);
     __ bind(Lctos);
-    __ ldrh(R0_tos, Address(Robj, Roffset));
+    __ access_load_at(T_CHAR, IN_HEAP, Address(Robj, Roffset), R0_tos, noreg, noreg, noreg);
     __ push(ctos);
     if (!is_static && rc == may_rewrite) {
       patch_bytecode(Bytecodes::_fast_cgetfield, R0_tmp, Rtemp);
@@ -3290,7 +3288,7 @@
     assert(stos == seq++, "stos has unexpected value");
     FixedSizeCodeBlock stos_block(_masm, max_block_size, fast_version);
     __ bind(Lstos);
-    __ ldrsh(R0_tos, Address(Robj, Roffset));
+    __ access_load_at(T_SHORT, IN_HEAP, Address(Robj, Roffset), R0_tos, noreg, noreg, noreg);
     __ push(stos);
     if (!is_static && rc == may_rewrite) {
       patch_bytecode(Bytecodes::_fast_sgetfield, R0_tmp, Rtemp);
@@ -3314,8 +3312,7 @@
 #ifdef AARCH64
     __ ldr(R0_tos, Address(Robj, Roffset));
 #else
-    __ add(Roffset, Robj, Roffset);
-    __ ldmia(Roffset, RegisterSet(R0_tos_lo, R1_tos_hi));
+    __ access_load_at(T_LONG, IN_HEAP, Address(Robj, Roffset), noreg /* ltos */, noreg, noreg, noreg);
 #endif // AARCH64
     __ push(ltos);
     if (!is_static && rc == may_rewrite) {
@@ -3331,7 +3328,7 @@
     __ bind(Lftos);
     // floats and ints are placed on stack in same way, so
     // we can use push(itos) to transfer value without using VFP
-    __ ldr_u32(R0_tos, Address(Robj, Roffset));
+    __ access_load_at(T_INT, IN_HEAP, Address(Robj, Roffset), R0_tos, noreg, noreg, noreg);
     __ push(itos);
     if (!is_static && rc == may_rewrite) {
       patch_bytecode(Bytecodes::_fast_fgetfield, R0_tmp, Rtemp);
@@ -3349,8 +3346,7 @@
 #ifdef AARCH64
     __ ldr(R0_tos, Address(Robj, Roffset));
 #else
-    __ add(Rtemp, Robj, Roffset);
-    __ ldmia(Rtemp, RegisterSet(R0_tos_lo, R1_tos_hi));
+    __ access_load_at(T_LONG, IN_HEAP, Address(Robj, Roffset), noreg /* ltos */, noreg, noreg, noreg);
 #endif // AARCH64
     __ push(ltos);
     if (!is_static && rc == may_rewrite) {
@@ -3385,7 +3381,7 @@
   // atos case can be merged with itos case (and thus moved out of table switch) on 32-bit ARM, fast version only
 
   __ bind(Lint);
-  __ ldr_s32(R0_tos, Address(Robj, Roffset));
+  __ access_load_at(T_INT, IN_HEAP, Address(Robj, Roffset), R0_tos, noreg, noreg, noreg);
   __ push(itos);
   // Rewrite bytecode to be faster
   if (!is_static && rc == may_rewrite) {
@@ -3597,7 +3593,7 @@
     __ bind(Lbtos);
     __ pop(btos);
     if (!is_static) pop_and_check_object(Robj);
-    __ strb(R0_tos, Address(Robj, Roffset));
+    __ access_store_at(T_BYTE, IN_HEAP, Address(Robj, Roffset), R0_tos, noreg, noreg, noreg, false);
     if (!is_static && rc == may_rewrite) {
       patch_bytecode(Bytecodes::_fast_bputfield, R0_tmp, Rtemp, true, byte_no);
     }
@@ -3611,8 +3607,7 @@
     __ bind(Lztos);
     __ pop(ztos);
     if (!is_static) pop_and_check_object(Robj);
-    __ and_32(R0_tos, R0_tos, 1);
-    __ strb(R0_tos, Address(Robj, Roffset));
+    __ access_store_at(T_BOOLEAN, IN_HEAP, Address(Robj, Roffset), R0_tos, noreg, noreg, noreg, false);
     if (!is_static && rc == may_rewrite) {
       patch_bytecode(Bytecodes::_fast_zputfield, R0_tmp, Rtemp, true, byte_no);
     }
@@ -3626,7 +3621,7 @@
     __ bind(Lctos);
     __ pop(ctos);
     if (!is_static) pop_and_check_object(Robj);
-    __ strh(R0_tos, Address(Robj, Roffset));
+    __ access_store_at(T_CHAR, IN_HEAP, Address(Robj, Roffset), R0_tos, noreg, noreg, noreg, false);
     if (!is_static && rc == may_rewrite) {
       patch_bytecode(Bytecodes::_fast_cputfield, R0_tmp, Rtemp, true, byte_no);
     }
@@ -3640,7 +3635,7 @@
     __ bind(Lstos);
     __ pop(stos);
     if (!is_static) pop_and_check_object(Robj);
-    __ strh(R0_tos, Address(Robj, Roffset));
+    __ access_store_at(T_SHORT, IN_HEAP, Address(Robj, Roffset), R0_tos, noreg, noreg, noreg, false);
     if (!is_static && rc == may_rewrite) {
       patch_bytecode(Bytecodes::_fast_sputfield, R0_tmp, Rtemp, true, byte_no);
     }
@@ -3665,8 +3660,7 @@
 #ifdef AARCH64
     __ str(R0_tos, Address(Robj, Roffset));
 #else
-    __ add(Roffset, Robj, Roffset);
-    __ stmia(Roffset, RegisterSet(R0_tos_lo, R1_tos_hi));
+    __ access_store_at(T_LONG, IN_HEAP, Address(Robj, Roffset), noreg /* ltos */, noreg, noreg, noreg, false);
 #endif // AARCH64
     if (!is_static && rc == may_rewrite) {
       patch_bytecode(Bytecodes::_fast_lputfield, R0_tmp, Rtemp, true, byte_no);
@@ -3683,7 +3677,7 @@
     // we can use pop(itos) to transfer value without using VFP
     __ pop(itos);
     if (!is_static) pop_and_check_object(Robj);
-    __ str_32(R0_tos, Address(Robj, Roffset));
+    __ access_store_at(T_INT, IN_HEAP, Address(Robj, Roffset), R0_tos, noreg, noreg, noreg, false);
     if (!is_static && rc == may_rewrite) {
       patch_bytecode(Bytecodes::_fast_fputfield, R0_tmp, Rtemp, true, byte_no);
     }
@@ -3702,8 +3696,7 @@
 #ifdef AARCH64
     __ str(R0_tos, Address(Robj, Roffset));
 #else
-    __ add(Rtemp, Robj, Roffset);
-    __ stmia(Rtemp, RegisterSet(R0_tos_lo, R1_tos_hi));
+    __ access_store_at(T_LONG, IN_HEAP, Address(Robj, Roffset), noreg /* ltos */, noreg, noreg, noreg, false);
 #endif // AARCH64
     if (!is_static && rc == may_rewrite) {
       patch_bytecode(Bytecodes::_fast_dputfield, R0_tmp, Rtemp, true, byte_no);
@@ -3732,7 +3725,7 @@
   __ bind(Lint);
   __ pop(itos);
   if (!is_static) pop_and_check_object(Robj);
-  __ str_32(R0_tos, Address(Robj, Roffset));
+  __ access_store_at(T_INT, IN_HEAP, Address(Robj, Roffset), R0_tos, noreg, noreg, noreg, false);
   if (!is_static && rc == may_rewrite) {
     patch_bytecode(Bytecodes::_fast_iputfield, R0_tmp, Rtemp, true, byte_no);
   }
@@ -3867,36 +3860,42 @@
   // Get object from stack
   pop_and_check_object(Robj);
 
+  Address addr = Address(Robj, Roffset);
   // access field
   switch (bytecode()) {
-    case Bytecodes::_fast_zputfield: __ and_32(R0_tos, R0_tos, 1);
-                                     // fall through
-    case Bytecodes::_fast_bputfield: __ strb(R0_tos, Address(Robj, Roffset)); break;
-    case Bytecodes::_fast_sputfield: // fall through
-    case Bytecodes::_fast_cputfield: __ strh(R0_tos, Address(Robj, Roffset)); break;
-    case Bytecodes::_fast_iputfield: __ str_32(R0_tos, Address(Robj, Roffset)); break;
+    case Bytecodes::_fast_zputfield:
+      __ access_store_at(T_BOOLEAN, IN_HEAP, addr, R0_tos, noreg, noreg, noreg, false);
+      break;
+    case Bytecodes::_fast_bputfield:
+      __ access_store_at(T_BYTE, IN_HEAP, addr, R0_tos, noreg, noreg, noreg, false);
+      break;
+    case Bytecodes::_fast_sputfield:
+      __ access_store_at(T_SHORT, IN_HEAP, addr, R0_tos, noreg, noreg, noreg, false);
+      break;
+    case Bytecodes::_fast_cputfield:
+      __ access_store_at(T_CHAR, IN_HEAP, addr, R0_tos, noreg, noreg, noreg,false);
+      break;
+    case Bytecodes::_fast_iputfield:
+      __ access_store_at(T_INT, IN_HEAP, addr, R0_tos, noreg, noreg, noreg, false);
+      break;
 #ifdef AARCH64
-    case Bytecodes::_fast_lputfield: __ str  (R0_tos, Address(Robj, Roffset)); break;
-    case Bytecodes::_fast_fputfield: __ str_s(S0_tos, Address(Robj, Roffset)); break;
-    case Bytecodes::_fast_dputfield: __ str_d(D0_tos, Address(Robj, Roffset)); break;
+    case Bytecodes::_fast_lputfield: __ str  (R0_tos, addr); break;
+    case Bytecodes::_fast_fputfield: __ str_s(S0_tos, addr); break;
+    case Bytecodes::_fast_dputfield: __ str_d(D0_tos, addr); break;
 #else
-    case Bytecodes::_fast_lputfield: __ add(Robj, Robj, Roffset);
-                                     __ stmia(Robj, RegisterSet(R0_tos_lo, R1_tos_hi)); break;
-
-#ifdef __SOFTFP__
-    case Bytecodes::_fast_fputfield: __ str(R0_tos, Address(Robj, Roffset));  break;
-    case Bytecodes::_fast_dputfield: __ add(Robj, Robj, Roffset);
-                                     __ stmia(Robj, RegisterSet(R0_tos_lo, R1_tos_hi)); break;
-#else
-    case Bytecodes::_fast_fputfield: __ add(Robj, Robj, Roffset);
-                                     __ fsts(S0_tos, Address(Robj));          break;
-    case Bytecodes::_fast_dputfield: __ add(Robj, Robj, Roffset);
-                                     __ fstd(D0_tos, Address(Robj));          break;
-#endif // __SOFTFP__
+    case Bytecodes::_fast_lputfield:
+      __ access_store_at(T_LONG, IN_HEAP, addr, noreg, noreg, noreg, noreg, false);
+      break;
+    case Bytecodes::_fast_fputfield:
+      __ access_store_at(T_FLOAT, IN_HEAP, addr, noreg, noreg, noreg, noreg, false);
+      break;
+    case Bytecodes::_fast_dputfield:
+      __ access_store_at(T_DOUBLE, IN_HEAP, addr, noreg, noreg, noreg, noreg, false);
+      break;
 #endif // AARCH64
 
     case Bytecodes::_fast_aputfield:
-      do_oop_store(_masm, Address(Robj, Roffset), R0_tos, Rtemp, R1_tmp, R2_tmp, false);
+      do_oop_store(_masm, addr, R0_tos, Rtemp, R1_tmp, R2_tmp, false);
       break;
 
     default:
@@ -3970,29 +3969,40 @@
   __ verify_oop(Robj);
   __ null_check(Robj, Rtemp);
 
+  Address addr = Address(Robj, Roffset);
   // access field
   switch (bytecode()) {
-    case Bytecodes::_fast_bgetfield: __ ldrsb(R0_tos, Address(Robj, Roffset)); break;
-    case Bytecodes::_fast_sgetfield: __ ldrsh(R0_tos, Address(Robj, Roffset)); break;
-    case Bytecodes::_fast_cgetfield: __ ldrh (R0_tos, Address(Robj, Roffset)); break;
-    case Bytecodes::_fast_igetfield: __ ldr_s32(R0_tos, Address(Robj, Roffset)); break;
+    case Bytecodes::_fast_bgetfield:
+      __ access_load_at(T_BYTE, IN_HEAP, addr, R0_tos, noreg, noreg, noreg);
+      break;
+    case Bytecodes::_fast_sgetfield:
+      __ access_load_at(T_SHORT, IN_HEAP, addr, R0_tos, noreg, noreg, noreg);
+      break;
+    case Bytecodes::_fast_cgetfield:
+      __ access_load_at(T_CHAR, IN_HEAP, addr, R0_tos, noreg, noreg, noreg);
+      break;
+    case Bytecodes::_fast_igetfield:
+      __ access_load_at(T_INT, IN_HEAP, addr, R0_tos, noreg, noreg, noreg);
+      break;
 #ifdef AARCH64
-    case Bytecodes::_fast_lgetfield: __ ldr  (R0_tos, Address(Robj, Roffset)); break;
-    case Bytecodes::_fast_fgetfield: __ ldr_s(S0_tos, Address(Robj, Roffset)); break;
-    case Bytecodes::_fast_dgetfield: __ ldr_d(D0_tos, Address(Robj, Roffset)); break;
+    case Bytecodes::_fast_lgetfield: __ ldr  (R0_tos, addr); break;
+    case Bytecodes::_fast_fgetfield: __ ldr_s(S0_tos, addr); break;
+    case Bytecodes::_fast_dgetfield: __ ldr_d(D0_tos, addr); break;
 #else
-    case Bytecodes::_fast_lgetfield: __ add(Roffset, Robj, Roffset);
-                                     __ ldmia(Roffset, RegisterSet(R0_tos_lo, R1_tos_hi)); break;
-#ifdef __SOFTFP__
-    case Bytecodes::_fast_fgetfield: __ ldr  (R0_tos, Address(Robj, Roffset)); break;
-    case Bytecodes::_fast_dgetfield: __ add(Roffset, Robj, Roffset);
-                                     __ ldmia(Roffset, RegisterSet(R0_tos_lo, R1_tos_hi)); break;
-#else
-    case Bytecodes::_fast_fgetfield: __ add(Roffset, Robj, Roffset); __ flds(S0_tos, Address(Roffset)); break;
-    case Bytecodes::_fast_dgetfield: __ add(Roffset, Robj, Roffset); __ fldd(D0_tos, Address(Roffset)); break;
-#endif // __SOFTFP__
+    case Bytecodes::_fast_lgetfield:
+      __ access_load_at(T_LONG, IN_HEAP, addr, noreg, noreg, noreg, noreg);
+      break;
+    case Bytecodes::_fast_fgetfield:
+      __ access_load_at(T_FLOAT, IN_HEAP, addr, noreg, noreg, noreg, noreg);
+      break;
+    case Bytecodes::_fast_dgetfield:
+      __ access_load_at(T_DOUBLE, IN_HEAP, addr, noreg, noreg, noreg, noreg);
+      break;
 #endif // AARCH64
-    case Bytecodes::_fast_agetfield: do_oop_load(_masm, R0_tos, Address(Robj, Roffset)); __ verify_oop(R0_tos); break;
+    case Bytecodes::_fast_agetfield:
+      do_oop_load(_masm, R0_tos, addr);
+      __ verify_oop(R0_tos);
+      break;
     default:
       ShouldNotReachHere();
   }
@@ -4070,7 +4080,7 @@
 #endif // AARCH64
 
   if (state == itos) {
-    __ ldr_s32(R0_tos, Address(Robj, Roffset));
+    __ access_load_at(T_INT, IN_HEAP, Address(Robj, Roffset), R0_tos, noreg, noreg, noreg);
   } else if (state == atos) {
     do_oop_load(_masm, R0_tos, Address(Robj, Roffset));
     __ verify_oop(R0_tos);
@@ -4081,8 +4091,7 @@
 #ifdef __SOFTFP__
     __ ldr(R0_tos, Address(Robj, Roffset));
 #else
-    __ add(Roffset, Robj, Roffset);
-    __ flds(S0_tos, Address(Roffset));
+    __ access_load_at(T_FLOAT, IN_HEAP, Address(Robj, Roffset), noreg /* ftos */, noreg, noreg, noreg);
 #endif // __SOFTFP__
 #endif // AARCH64
   } else {
--- a/src/hotspot/cpu/arm/templateTable_arm.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/arm/templateTable_arm.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -55,6 +55,7 @@
   static void store_category2_local(Register Rlocal_index, Register tmp);
 
   static Address get_array_elem_addr(BasicType elemType, Register array, Register index, Register temp);
+  static Address get_array_elem_addr_same_base(BasicType elemType, Register array, Register index, Register temp);
 
   static void jvmti_post_fast_field_mod(TosState state);
 
--- a/src/hotspot/cpu/arm/vtableStubs_arm.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/arm/vtableStubs_arm.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -48,17 +48,31 @@
 #endif
 
 VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
-  const int code_length = VtableStub::pd_code_size_limit(true);
-  VtableStub* s = new(code_length) VtableStub(true, vtable_index);
+  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
+  const int stub_code_length = code_size_limit(true);
+  VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index);
   // Can be NULL if there is no free space in the code cache.
   if (s == NULL) {
     return NULL;
   }
 
-  ResourceMark rm;
-  CodeBuffer cb(s->entry_point(), code_length);
+  // Count unused bytes in instruction sequences of variable size.
+  // We add them to the computed buffer size in order to avoid
+  // overflow in subsequently generated stubs.
+  address   start_pc;
+  int       slop_bytes = 0;
+  int       slop_delta = 0;
+
+  ResourceMark    rm;
+  CodeBuffer      cb(s->entry_point(), stub_code_length);
   MacroAssembler* masm = new MacroAssembler(&cb);
 
+#if (!defined(PRODUCT) && defined(COMPILER2))
+  if (CountCompiledCalls) {
+    // Implementation required?
+  }
+#endif
+
   assert(VtableStub::receiver_location() == R0->as_VMReg(), "receiver expected in R0");
 
   const Register tmp = Rtemp; // Rtemp OK, should be free at call sites
@@ -66,17 +80,33 @@
   address npe_addr = __ pc();
   __ load_klass(tmp, R0);
 
-  {
-  int entry_offset = in_bytes(Klass::vtable_start_offset()) + vtable_index * vtableEntry::size_in_bytes();
-  int method_offset = vtableEntry::method_offset_in_bytes() + entry_offset;
+#ifndef PRODUCT
+  if (DebugVtables) {
+    // Implementation required?
+  }
+#endif
+
+  start_pc = __ pc();
+  { // lookup virtual method
+    int entry_offset = in_bytes(Klass::vtable_start_offset()) + vtable_index * vtableEntry::size_in_bytes();
+    int method_offset = vtableEntry::method_offset_in_bytes() + entry_offset;
 
-  assert ((method_offset & (wordSize - 1)) == 0, "offset should be aligned");
-  int offset_mask = AARCH64_ONLY(0xfff << LogBytesPerWord) NOT_AARCH64(0xfff);
-  if (method_offset & ~offset_mask) {
-    __ add(tmp, tmp, method_offset & ~offset_mask);
+    assert ((method_offset & (wordSize - 1)) == 0, "offset should be aligned");
+    int offset_mask = AARCH64_ONLY(0xfff << LogBytesPerWord) NOT_AARCH64(0xfff);
+    if (method_offset & ~offset_mask) {
+      __ add(tmp, tmp, method_offset & ~offset_mask);
+    }
+    __ ldr(Rmethod, Address(tmp, method_offset & offset_mask));
   }
-  __ ldr(Rmethod, Address(tmp, method_offset & offset_mask));
+  slop_delta  = 8 - (int)(__ pc() - start_pc);
+  slop_bytes += slop_delta;
+  assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
+
+#ifndef PRODUCT
+  if (DebugVtables) {
+    // Implementation required?
   }
+#endif
 
   address ame_addr = __ pc();
 #ifdef AARCH64
@@ -87,35 +117,36 @@
 #endif // AARCH64
 
   masm->flush();
+  bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0);
 
-  if (PrintMiscellaneous && (WizardMode || Verbose)) {
-    tty->print_cr("vtable #%d at " PTR_FORMAT "[%d] left over: %d",
-                  vtable_index, p2i(s->entry_point()),
-                  (int)(s->code_end() - s->entry_point()),
-                  (int)(s->code_end() - __ pc()));
-  }
-  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
-  // FIXME ARM: need correct 'slop' - below is x86 code
-  // shut the door on sizing bugs
-  //int slop = 8;  // 32-bit offset is this much larger than a 13-bit one
-  //assert(vtable_index > 10 || __ pc() + slop <= s->code_end(), "room for 32-bit offset");
-
-  s->set_exception_points(npe_addr, ame_addr);
   return s;
 }
 
 VtableStub* VtableStubs::create_itable_stub(int itable_index) {
-  const int code_length = VtableStub::pd_code_size_limit(false);
-  VtableStub* s = new(code_length) VtableStub(false, itable_index);
+  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
+  const int stub_code_length = code_size_limit(false);
+  VtableStub* s = new(stub_code_length) VtableStub(false, itable_index);
   // Can be NULL if there is no free space in the code cache.
   if (s == NULL) {
     return NULL;
   }
+  // Count unused bytes in instruction sequences of variable size.
+  // We add them to the computed buffer size in order to avoid
+  // overflow in subsequently generated stubs.
+  address   start_pc;
+  int       slop_bytes = 0;
+  int       slop_delta = 0;
 
-  ResourceMark rm;
-  CodeBuffer cb(s->entry_point(), code_length);
+  ResourceMark    rm;
+  CodeBuffer      cb(s->entry_point(), stub_code_length);
   MacroAssembler* masm = new MacroAssembler(&cb);
 
+#if (!defined(PRODUCT) && defined(COMPILER2))
+  if (CountCompiledCalls) {
+    // Implementation required?
+  }
+#endif
+
   assert(VtableStub::receiver_location() == R0->as_VMReg(), "receiver expected in R0");
 
   // R0-R3 / R0-R7 registers hold the arguments and cannot be spoiled
@@ -123,15 +154,16 @@
   const Register Rintf   = AARCH64_ONLY(R10) NOT_AARCH64(R5);
   const Register Rscan   = AARCH64_ONLY(R11) NOT_AARCH64(R6);
 
+  Label L_no_such_interface;
+
   assert_different_registers(Ricklass, Rclass, Rintf, Rscan, Rtemp);
 
-  // Calculate the start of itable (itable goes after vtable)
-  const int scale = exact_log2(vtableEntry::size_in_bytes());
+  start_pc = __ pc();
+
+  // get receiver klass (also an implicit null-check)
   address npe_addr = __ pc();
   __ load_klass(Rclass, R0);
 
-  Label L_no_such_interface;
-
   // Receiver subtype check against REFC.
   __ ldr(Rintf, Address(Ricklass, CompiledICHolder::holder_klass_offset()));
   __ lookup_interface_method(// inputs: rec. class, interface, itable index
@@ -140,6 +172,9 @@
                              noreg, Rscan, Rtemp,
                              L_no_such_interface);
 
+  const ptrdiff_t  typecheckSize = __ pc() - start_pc;
+  start_pc = __ pc();
+
   // Get Method* and entry point for compiler
   __ ldr(Rintf, Address(Ricklass, CompiledICHolder::holder_metadata_offset()));
   __ lookup_interface_method(// inputs: rec. class, interface, itable index
@@ -148,6 +183,21 @@
                              Rmethod, Rscan, Rtemp,
                              L_no_such_interface);
 
+  const ptrdiff_t lookupSize = __ pc() - start_pc;
+
+  // Reduce "estimate" such that "padding" does not drop below 8.
+  const ptrdiff_t estimate = 140;
+  const ptrdiff_t codesize = typecheckSize + lookupSize;
+  slop_delta  = (int)(estimate - codesize);
+  slop_bytes += slop_delta;
+  assert(slop_delta >= 0, "itable #%d: Code size estimate (%d) for lookup_interface_method too small, required: %d", itable_index, (int)estimate, (int)codesize);
+
+#ifndef PRODUCT
+  if (DebugVtables) {
+    // Implementation required?
+  }
+#endif
+
   address ame_addr = __ pc();
 
 #ifdef AARCH64
@@ -158,7 +208,6 @@
 #endif // AARCH64
 
   __ bind(L_no_such_interface);
-
   // Handle IncompatibleClassChangeError in itable stubs.
   // More detailed error message.
   // We force resolving of the call site by jumping to the "handle
@@ -168,43 +217,13 @@
   __ jump(SharedRuntime::get_handle_wrong_method_stub(), relocInfo::runtime_call_type, Rtemp);
 
   masm->flush();
+  bookkeeping(masm, tty, s, npe_addr, ame_addr, false, itable_index, slop_bytes, 0);
 
-  if (PrintMiscellaneous && (WizardMode || Verbose)) {
-    tty->print_cr("itable #%d at " PTR_FORMAT "[%d] left over: %d",
-                  itable_index, p2i(s->entry_point()),
-                  (int)(s->code_end() - s->entry_point()),
-                  (int)(s->code_end() - __ pc()));
-  }
-  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
-  // FIXME ARM: need correct 'slop' - below is x86 code
-  // shut the door on sizing bugs
-  //int slop = 8;  // 32-bit offset is this much larger than a 13-bit one
-  //assert(itable_index > 10 || __ pc() + slop <= s->code_end(), "room for 32-bit offset");
-
-  s->set_exception_points(npe_addr, ame_addr);
   return s;
 }
 
-int VtableStub::pd_code_size_limit(bool is_vtable_stub) {
-  int instr_count;
-
-  if (is_vtable_stub) {
-    // vtable stub size
-    instr_count = NOT_AARCH64(4) AARCH64_ONLY(5);
-  } else {
-    // itable stub size
-    instr_count = NOT_AARCH64(31) AARCH64_ONLY(31);
-  }
-
-#ifdef AARCH64
-  if (UseCompressedClassPointers) {
-    instr_count += MacroAssembler::instr_count_for_decode_klass_not_null();
-  }
-#endif // AARCH64
-
-  return instr_count * Assembler::InstructionSize;
+int VtableStub::pd_code_alignment() {
+  // ARM32 cache line size is not an architected constant. We just align on word size.
+  const unsigned int icache_line_size = wordSize;
+  return icache_line_size;
 }
-
-int VtableStub::pd_code_alignment() {
-  return 8;
-}
--- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -2396,8 +2396,8 @@
     if (reg_conflict) { obj = dst; }
   }
 
-  ciMethodData* md;
-  ciProfileData* data;
+  ciMethodData* md = NULL;
+  ciProfileData* data = NULL;
   int mdo_offset_bias = 0;
   if (should_profile) {
     ciMethod* method = op->profiled_method();
@@ -2514,8 +2514,8 @@
     __ verify_oop(value);
     CodeStub* stub = op->stub();
     // Check if it needs to be profiled.
-    ciMethodData* md;
-    ciProfileData* data;
+    ciMethodData* md = NULL;
+    ciProfileData* data = NULL;
     int mdo_offset_bias = 0;
     if (should_profile) {
       ciMethod* method = op->profiled_method();
--- a/src/hotspot/cpu/ppc/frame_ppc.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/ppc/frame_ppc.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -67,8 +67,8 @@
     return false;
   }
 
-  // Unextended sp must be within the stack and above or equal sp
-  bool unextended_sp_safe = (unextended_sp < thread->stack_base()) && (unextended_sp >= sp);
+  // Unextended sp must be within the stack
+  bool unextended_sp_safe = (unextended_sp < thread->stack_base());
 
   if (!unextended_sp_safe) {
     return false;
@@ -76,9 +76,10 @@
 
   // An fp must be within the stack and above (but not equal) sp.
   bool fp_safe = (fp <= thread->stack_base()) &&  (fp > sp);
-  // an interpreter fp must be within the stack and above (but not equal) sp
-  bool fp_interp_safe = (fp <= thread->stack_base()) &&  (fp > sp) &&
-    ((fp - sp) >= (ijava_state_size + top_ijava_frame_abi_size));
+  // An interpreter fp must be within the stack and above (but not equal) sp.
+  // Moreover, it must be at least the size of the ijava_state structure.
+  bool fp_interp_safe = (fp <= thread->stack_base()) && (fp > sp) &&
+    ((fp - sp) >= ijava_state_size);
 
   // We know sp/unextended_sp are safe, only fp is questionable here
 
--- a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -2848,12 +2848,6 @@
   ld(displaced_header, oopDesc::mark_offset_in_bytes(), oop);
 
 
-  // Always do locking in runtime.
-  if (EmitSync & 0x01) {
-    cmpdi(flag, oop, 0); // Oop can't be 0 here => always false.
-    return;
-  }
-
   if (try_bias) {
     biased_locking_enter(flag, oop, displaced_header, temp, current_header, cont);
   }
@@ -2867,11 +2861,9 @@
 #endif // INCLUDE_RTM_OPT
 
   // Handle existing monitor.
-  if ((EmitSync & 0x02) == 0) {
-    // The object has an existing monitor iff (mark & monitor_value) != 0.
-    andi_(temp, displaced_header, markOopDesc::monitor_value);
-    bne(CCR0, object_has_monitor);
-  }
+  // The object has an existing monitor iff (mark & monitor_value) != 0.
+  andi_(temp, displaced_header, markOopDesc::monitor_value);
+  bne(CCR0, object_has_monitor);
 
   // Set displaced_header to be (markOop of object | UNLOCK_VALUE).
   ori(displaced_header, displaced_header, markOopDesc::unlocked_value);
@@ -2914,48 +2906,46 @@
   std(R0/*==0, perhaps*/, BasicLock::displaced_header_offset_in_bytes(), box);
 
   // Handle existing monitor.
-  if ((EmitSync & 0x02) == 0) {
-    b(cont);
-
-    bind(object_has_monitor);
-    // The object's monitor m is unlocked iff m->owner == NULL,
-    // otherwise m->owner may contain a thread or a stack address.
+  b(cont);
+
+  bind(object_has_monitor);
+  // The object's monitor m is unlocked iff m->owner == NULL,
+  // otherwise m->owner may contain a thread or a stack address.
 
 #if INCLUDE_RTM_OPT
-    // Use the same RTM locking code in 32- and 64-bit VM.
-    if (use_rtm) {
-      rtm_inflated_locking(flag, oop, displaced_header, box, temp, /*temp*/ current_header,
-                           rtm_counters, method_data, profile_rtm, cont);
-    } else {
+  // Use the same RTM locking code in 32- and 64-bit VM.
+  if (use_rtm) {
+    rtm_inflated_locking(flag, oop, displaced_header, box, temp, /*temp*/ current_header,
+                         rtm_counters, method_data, profile_rtm, cont);
+  } else {
 #endif // INCLUDE_RTM_OPT
 
-    // Try to CAS m->owner from NULL to current thread.
-    addi(temp, displaced_header, ObjectMonitor::owner_offset_in_bytes()-markOopDesc::monitor_value);
-    cmpxchgd(/*flag=*/flag,
-             /*current_value=*/current_header,
-             /*compare_value=*/(intptr_t)0,
-             /*exchange_value=*/R16_thread,
-             /*where=*/temp,
-             MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
-             MacroAssembler::cmpxchgx_hint_acquire_lock());
-
-    // Store a non-null value into the box.
-    std(box, BasicLock::displaced_header_offset_in_bytes(), box);
-
-#   ifdef ASSERT
-    bne(flag, cont);
-    // We have acquired the monitor, check some invariants.
-    addi(/*monitor=*/temp, temp, -ObjectMonitor::owner_offset_in_bytes());
-    // Invariant 1: _recursions should be 0.
-    //assert(ObjectMonitor::recursions_size_in_bytes() == 8, "unexpected size");
-    asm_assert_mem8_is_zero(ObjectMonitor::recursions_offset_in_bytes(), temp,
+  // Try to CAS m->owner from NULL to current thread.
+  addi(temp, displaced_header, ObjectMonitor::owner_offset_in_bytes()-markOopDesc::monitor_value);
+  cmpxchgd(/*flag=*/flag,
+           /*current_value=*/current_header,
+           /*compare_value=*/(intptr_t)0,
+           /*exchange_value=*/R16_thread,
+           /*where=*/temp,
+           MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
+           MacroAssembler::cmpxchgx_hint_acquire_lock());
+
+  // Store a non-null value into the box.
+  std(box, BasicLock::displaced_header_offset_in_bytes(), box);
+
+# ifdef ASSERT
+  bne(flag, cont);
+  // We have acquired the monitor, check some invariants.
+  addi(/*monitor=*/temp, temp, -ObjectMonitor::owner_offset_in_bytes());
+  // Invariant 1: _recursions should be 0.
+  //assert(ObjectMonitor::recursions_size_in_bytes() == 8, "unexpected size");
+  asm_assert_mem8_is_zero(ObjectMonitor::recursions_offset_in_bytes(), temp,
                             "monitor->_recursions should be 0", -1);
-#   endif
+# endif
 
 #if INCLUDE_RTM_OPT
-    } // use_rtm()
+  } // use_rtm()
 #endif
-  }
 
   bind(cont);
   // flag == EQ indicates success
@@ -2970,12 +2960,6 @@
   Label cont;
   Label object_has_monitor;
 
-  // Always do locking in runtime.
-  if (EmitSync & 0x01) {
-    cmpdi(flag, oop, 0); // Oop can't be 0 here => always false.
-    return;
-  }
-
   if (try_bias) {
     biased_locking_exit(flag, oop, current_header, cont);
   }
@@ -3002,13 +2986,11 @@
   beq(flag, cont);
 
   // Handle existing monitor.
-  if ((EmitSync & 0x02) == 0) {
-    // The object has an existing monitor iff (mark & monitor_value) != 0.
-    RTM_OPT_ONLY( if (!(UseRTMForStackLocks && use_rtm)) ) // skip load if already done
-    ld(current_header, oopDesc::mark_offset_in_bytes(), oop);
-    andi_(R0, current_header, markOopDesc::monitor_value);
-    bne(CCR0, object_has_monitor);
-  }
+  // The object has an existing monitor iff (mark & monitor_value) != 0.
+  RTM_OPT_ONLY( if (!(UseRTMForStackLocks && use_rtm)) ) // skip load if already done
+  ld(current_header, oopDesc::mark_offset_in_bytes(), oop);
+  andi_(R0, current_header, markOopDesc::monitor_value);
+  bne(CCR0, object_has_monitor);
 
   // Check if it is still a light weight lock, this is is true if we see
   // the stack address of the basicLock in the markOop of the object.
@@ -3026,40 +3008,38 @@
   assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
 
   // Handle existing monitor.
-  if ((EmitSync & 0x02) == 0) {
-    b(cont);
-
-    bind(object_has_monitor);
-    addi(current_header, current_header, -markOopDesc::monitor_value); // monitor
-    ld(temp,             ObjectMonitor::owner_offset_in_bytes(), current_header);
+  b(cont);
+
+  bind(object_has_monitor);
+  addi(current_header, current_header, -markOopDesc::monitor_value); // monitor
+  ld(temp,             ObjectMonitor::owner_offset_in_bytes(), current_header);
 
     // It's inflated.
 #if INCLUDE_RTM_OPT
-    if (use_rtm) {
-      Label L_regular_inflated_unlock;
-      // Clean monitor_value bit to get valid pointer
-      cmpdi(flag, temp, 0);
-      bne(flag, L_regular_inflated_unlock);
-      tend_();
-      b(cont);
-      bind(L_regular_inflated_unlock);
-    }
+  if (use_rtm) {
+    Label L_regular_inflated_unlock;
+    // Clean monitor_value bit to get valid pointer
+    cmpdi(flag, temp, 0);
+    bne(flag, L_regular_inflated_unlock);
+    tend_();
+    b(cont);
+    bind(L_regular_inflated_unlock);
+  }
 #endif
 
-    ld(displaced_header, ObjectMonitor::recursions_offset_in_bytes(), current_header);
-    xorr(temp, R16_thread, temp);      // Will be 0 if we are the owner.
-    orr(temp, temp, displaced_header); // Will be 0 if there are 0 recursions.
-    cmpdi(flag, temp, 0);
-    bne(flag, cont);
-
-    ld(temp,             ObjectMonitor::EntryList_offset_in_bytes(), current_header);
-    ld(displaced_header, ObjectMonitor::cxq_offset_in_bytes(), current_header);
-    orr(temp, temp, displaced_header); // Will be 0 if both are 0.
-    cmpdi(flag, temp, 0);
-    bne(flag, cont);
-    release();
-    std(temp, ObjectMonitor::owner_offset_in_bytes(), current_header);
-  }
+  ld(displaced_header, ObjectMonitor::recursions_offset_in_bytes(), current_header);
+  xorr(temp, R16_thread, temp);      // Will be 0 if we are the owner.
+  orr(temp, temp, displaced_header); // Will be 0 if there are 0 recursions.
+  cmpdi(flag, temp, 0);
+  bne(flag, cont);
+
+  ld(temp,             ObjectMonitor::EntryList_offset_in_bytes(), current_header);
+  ld(displaced_header, ObjectMonitor::cxq_offset_in_bytes(), current_header);
+  orr(temp, temp, displaced_header); // Will be 0 if both are 0.
+  cmpdi(flag, temp, 0);
+  bne(flag, cont);
+  release();
+  std(temp, ObjectMonitor::owner_offset_in_bytes(), current_header);
 
   bind(cont);
   // flag == EQ indicates success
--- a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -162,7 +162,7 @@
   // branch, jump
   //
 
-  inline void pd_patch_instruction(address branch, address target);
+  inline void pd_patch_instruction(address branch, address target, const char* file, int line);
   NOT_PRODUCT(static void pd_print_patched_instruction(address branch);)
 
   // Conditional far branch for destinations encodable in 24+2 bits.
--- a/src/hotspot/cpu/ppc/macroAssembler_ppc.inline.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.inline.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -186,7 +186,7 @@
   load_const(d, obj_addr);
 }
 
-inline void MacroAssembler::pd_patch_instruction(address branch, address target) {
+inline void MacroAssembler::pd_patch_instruction(address branch, address target, const char* file, int line) {
   jint& stub_inst = *(jint*) branch;
   stub_inst = patched_branch(target - branch, stub_inst, 0);
 }
--- a/src/hotspot/cpu/ppc/vtableStubs_ppc_64.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/ppc/vtableStubs_ppc_64.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -39,36 +39,39 @@
 
 #define __ masm->
 
-#ifdef PRODUCT
-#define BLOCK_COMMENT(str) // nothing
-#else
-#define BLOCK_COMMENT(str) __ block_comment(str)
-#endif
-#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
-
 #ifndef PRODUCT
 extern "C" void bad_compiled_vtable_index(JavaThread* thread, oopDesc* receiver, int index);
 #endif
 
-// Used by compiler only; may use only caller saved, non-argument
-// registers.
+// Used by compiler only; may use only caller saved, non-argument registers.
 VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
-  // PPC port: use fixed size.
-  const int code_length = VtableStub::pd_code_size_limit(true);
-  VtableStub* s = new (code_length) VtableStub(true, vtable_index);
-
+  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
+  const int stub_code_length = code_size_limit(true);
+  VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index);
   // Can be NULL if there is no free space in the code cache.
   if (s == NULL) {
     return NULL;
   }
 
-  ResourceMark rm;
-  CodeBuffer cb(s->entry_point(), code_length);
+  // Count unused bytes in instruction sequences of variable size.
+  // We add them to the computed buffer size in order to avoid
+  // overflow in subsequently generated stubs.
+  address   start_pc;
+  int       slop_bytes = 8; // just a two-instruction safety net
+  int       slop_delta = 0;
+
+  ResourceMark    rm;
+  CodeBuffer      cb(s->entry_point(), stub_code_length);
   MacroAssembler* masm = new MacroAssembler(&cb);
 
-#ifndef PRODUCT
+#if (!defined(PRODUCT) && defined(COMPILER2))
   if (CountCompiledCalls) {
+    start_pc = __ pc();
+    int load_const_maxLen = 5*BytesPerInstWord;  // load_const generates 5 instructions. Assume that as max size for laod_const_optimized
     int offs = __ load_const_optimized(R11_scratch1, SharedRuntime::nof_megamorphic_calls_addr(), R12_scratch2, true);
+    slop_delta  = load_const_maxLen - (__ pc() - start_pc);
+    slop_bytes += slop_delta;
+    assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
     __ lwz(R12_scratch2, offs, R11_scratch1);
     __ addi(R12_scratch2, R12_scratch2, 1);
     __ stw(R12_scratch2, offs, R11_scratch1);
@@ -77,17 +80,13 @@
 
   assert(VtableStub::receiver_location() == R3_ARG1->as_VMReg(), "receiver expected in R3_ARG1");
 
-  // Get receiver klass.
   const Register rcvr_klass = R11_scratch1;
-
-  // We might implicit NULL fault here.
   address npe_addr = __ pc(); // npe = null pointer exception
+  // check if we must do an explicit check (implicit checks disabled, offset too large).
   __ null_check(R3, oopDesc::klass_offset_in_bytes(), /*implicit only*/NULL);
+  // Get receiver klass.
   __ load_klass(rcvr_klass, R3);
 
- // Set method (in case of interpreted method), and destination address.
-  int entry_offset = in_bytes(Klass::vtable_start_offset()) + vtable_index*vtableEntry::size_in_bytes();
-
 #ifndef PRODUCT
   if (DebugVtables) {
     Label L;
@@ -102,7 +101,9 @@
   }
 #endif
 
-  int v_off = entry_offset + vtableEntry::method_offset_in_bytes();
+  int entry_offset = in_bytes(Klass::vtable_start_offset()) +
+                     vtable_index*vtableEntry::size_in_bytes();
+  int v_off        = entry_offset + vtableEntry::method_offset_in_bytes();
 
   __ ld(R19_method, (RegisterOrConstant)v_off, rcvr_klass);
 
@@ -116,40 +117,48 @@
   }
 #endif
 
-  // If the vtable entry is null, the method is abstract.
   address ame_addr = __ pc(); // ame = abstract method error
+                              // if the vtable entry is null, the method is abstract
+                              // NOTE: for vtable dispatches, the vtable entry will never be null.
+
   __ null_check(R19_method, in_bytes(Method::from_compiled_offset()), /*implicit only*/NULL);
   __ ld(R12_scratch2, in_bytes(Method::from_compiled_offset()), R19_method);
   __ mtctr(R12_scratch2);
   __ bctr();
 
   masm->flush();
-
-  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
-
-  s->set_exception_points(npe_addr, ame_addr);
+  bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0);
 
   return s;
 }
 
 VtableStub* VtableStubs::create_itable_stub(int itable_index) {
-  // PPC port: use fixed size.
-  const int code_length = VtableStub::pd_code_size_limit(false);
-  VtableStub* s = new (code_length) VtableStub(false, itable_index);
-
+  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
+  const int stub_code_length = code_size_limit(false);
+  VtableStub* s = new(stub_code_length) VtableStub(false, itable_index);
   // Can be NULL if there is no free space in the code cache.
   if (s == NULL) {
     return NULL;
   }
+  // Count unused bytes in instruction sequences of variable size.
+  // We add them to the computed buffer size in order to avoid
+  // overflow in subsequently generated stubs.
+  address   start_pc;
+  int       slop_bytes = 8; // just a two-instruction safety net
+  int       slop_delta = 0;
 
-  ResourceMark rm;
-  CodeBuffer cb(s->entry_point(), code_length);
+  ResourceMark    rm;
+  CodeBuffer      cb(s->entry_point(), stub_code_length);
   MacroAssembler* masm = new MacroAssembler(&cb);
-  address start_pc;
+  int             load_const_maxLen = 5*BytesPerInstWord;  // load_const generates 5 instructions. Assume that as max size for laod_const_optimized
 
-#ifndef PRODUCT
+#if (!defined(PRODUCT) && defined(COMPILER2))
   if (CountCompiledCalls) {
+    start_pc = __ pc();
     int offs = __ load_const_optimized(R11_scratch1, SharedRuntime::nof_megamorphic_calls_addr(), R12_scratch2, true);
+    slop_delta  = load_const_maxLen - (__ pc() - start_pc);
+    slop_bytes += slop_delta;
+    assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
     __ lwz(R12_scratch2, offs, R11_scratch1);
     __ addi(R12_scratch2, R12_scratch2, 1);
     __ stw(R12_scratch2, offs, R11_scratch1);
@@ -209,33 +218,22 @@
   // wrong method" stub, and so let the interpreter runtime do all the
   // dirty work.
   __ bind(L_no_such_interface);
+  start_pc = __ pc();
   __ load_const_optimized(R11_scratch1, SharedRuntime::get_handle_wrong_method_stub(), R12_scratch2);
+  slop_delta  = load_const_maxLen - (__ pc() - start_pc);
+  slop_bytes += slop_delta;
+  assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
   __ mtctr(R11_scratch1);
   __ bctr();
 
   masm->flush();
+  bookkeeping(masm, tty, s, npe_addr, ame_addr, false, itable_index, slop_bytes, 0);
 
-  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
-
-  s->set_exception_points(npe_addr, ame_addr);
   return s;
 }
 
-int VtableStub::pd_code_size_limit(bool is_vtable_stub) {
-  if (DebugVtables || CountCompiledCalls || VerifyOops) {
-    return 1000;
-  }
-  int size = is_vtable_stub ? 20 + 8 : 164 + 20; // Plain + safety
-  if (UseCompressedClassPointers) {
-    size += MacroAssembler::instr_size_for_decode_klass_not_null();
-  }
-  if (!ImplicitNullChecks || !os::zero_page_read_protected()) {
-    size += is_vtable_stub ? 8 : 12;
-  }
-  return size;
-}
-
 int VtableStub::pd_code_alignment() {
+  // Power cache line size is 128 bytes, but we want to limit alignment loss.
   const unsigned int icache_line_size = 32;
   return icache_line_size;
 }
--- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1904,7 +1904,7 @@
 
 // Only called when binding labels (share/vm/asm/assembler.cpp)
 // Pass arguments as intended. Do not pre-calculate distance.
-void MacroAssembler::pd_patch_instruction(address branch, address target) {
+void MacroAssembler::pd_patch_instruction(address branch, address target, const char* file, int line) {
   unsigned long stub_inst;
   int           inst_len = get_instruction(branch, &stub_inst);
 
@@ -3374,13 +3374,11 @@
   }
 
   // Handle existing monitor.
-  if ((EmitSync & 0x01) == 0) {
-    // The object has an existing monitor iff (mark & monitor_value) != 0.
-    guarantee(Immediate::is_uimm16(markOopDesc::monitor_value), "must be half-word");
-    z_lr(temp, displacedHeader);
-    z_nill(temp, markOopDesc::monitor_value);
-    z_brne(object_has_monitor);
-  }
+  // The object has an existing monitor iff (mark & monitor_value) != 0.
+  guarantee(Immediate::is_uimm16(markOopDesc::monitor_value), "must be half-word");
+  z_lr(temp, displacedHeader);
+  z_nill(temp, markOopDesc::monitor_value);
+  z_brne(object_has_monitor);
 
   // Set mark to markOop | markOopDesc::unlocked_value.
   z_oill(displacedHeader, markOopDesc::unlocked_value);
@@ -3411,28 +3409,26 @@
 
   z_bru(done);
 
-  if ((EmitSync & 0x01) == 0) {
-    Register zero = temp;
-    Register monitor_tagged = displacedHeader; // Tagged with markOopDesc::monitor_value.
-    bind(object_has_monitor);
-    // The object's monitor m is unlocked iff m->owner == NULL,
-    // otherwise m->owner may contain a thread or a stack address.
-    //
-    // Try to CAS m->owner from NULL to current thread.
-    z_lghi(zero, 0);
-    // If m->owner is null, then csg succeeds and sets m->owner=THREAD and CR=EQ.
-    z_csg(zero, Z_thread, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), monitor_tagged);
-    // Store a non-null value into the box.
-    z_stg(box, BasicLock::displaced_header_offset_in_bytes(), box);
+  Register zero = temp;
+  Register monitor_tagged = displacedHeader; // Tagged with markOopDesc::monitor_value.
+  bind(object_has_monitor);
+  // The object's monitor m is unlocked iff m->owner == NULL,
+  // otherwise m->owner may contain a thread or a stack address.
+  //
+  // Try to CAS m->owner from NULL to current thread.
+  z_lghi(zero, 0);
+  // If m->owner is null, then csg succeeds and sets m->owner=THREAD and CR=EQ.
+  z_csg(zero, Z_thread, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), monitor_tagged);
+  // Store a non-null value into the box.
+  z_stg(box, BasicLock::displaced_header_offset_in_bytes(), box);
 #ifdef ASSERT
-      z_brne(done);
-      // We've acquired the monitor, check some invariants.
-      // Invariant 1: _recursions should be 0.
-      asm_assert_mem8_is_zero(OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions), monitor_tagged,
-                              "monitor->_recursions should be 0", -1);
-      z_ltgr(zero, zero); // Set CR=EQ.
+  z_brne(done);
+  // We've acquired the monitor, check some invariants.
+  // Invariant 1: _recursions should be 0.
+  asm_assert_mem8_is_zero(OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions), monitor_tagged,
+                          "monitor->_recursions should be 0", -1);
+  z_ltgr(zero, zero); // Set CR=EQ.
 #endif
-  }
   bind(done);
 
   BLOCK_COMMENT("} compiler_fast_lock_object");
@@ -3461,13 +3457,11 @@
   z_bre(done);
 
   // Handle existing monitor.
-  if ((EmitSync & 0x02) == 0) {
-    // The object has an existing monitor iff (mark & monitor_value) != 0.
-    z_lg(currentHeader, oopDesc::mark_offset_in_bytes(), oop);
-    guarantee(Immediate::is_uimm16(markOopDesc::monitor_value), "must be half-word");
-    z_nill(currentHeader, markOopDesc::monitor_value);
-    z_brne(object_has_monitor);
-  }
+  // The object has an existing monitor iff (mark & monitor_value) != 0.
+  z_lg(currentHeader, oopDesc::mark_offset_in_bytes(), oop);
+  guarantee(Immediate::is_uimm16(markOopDesc::monitor_value), "must be half-word");
+  z_nill(currentHeader, markOopDesc::monitor_value);
+  z_brne(object_has_monitor);
 
   // Check if it is still a light weight lock, this is true if we see
   // the stack address of the basicLock in the markOop of the object
@@ -3477,20 +3471,18 @@
   z_bru(done); // Csg sets CR as desired.
 
   // Handle existing monitor.
-  if ((EmitSync & 0x02) == 0) {
-    bind(object_has_monitor);
-    z_lg(currentHeader, oopDesc::mark_offset_in_bytes(), oop);    // CurrentHeader is tagged with monitor_value set.
-    load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)));
-    z_brne(done);
-    load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-    z_brne(done);
-    load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList)));
-    z_brne(done);
-    load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq)));
-    z_brne(done);
-    z_release();
-    z_stg(temp/*=0*/, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), currentHeader);
-  }
+  bind(object_has_monitor);
+  z_lg(currentHeader, oopDesc::mark_offset_in_bytes(), oop);    // CurrentHeader is tagged with monitor_value set.
+  load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)));
+  z_brne(done);
+  load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
+  z_brne(done);
+  load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList)));
+  z_brne(done);
+  load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq)));
+  z_brne(done);
+  z_release();
+  z_stg(temp/*=0*/, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), currentHeader);
 
   bind(done);
 
--- a/src/hotspot/cpu/s390/macroAssembler_s390.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/s390/macroAssembler_s390.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -360,7 +360,7 @@
   // Use one generic function for all branch patches.
   static unsigned long patched_branch(address dest_pos, unsigned long inst, address inst_pos);
 
-  void pd_patch_instruction(address branch, address target);
+  void pd_patch_instruction(address branch, address target, const char* file, int line);
 
   // Extract relative address from "relative" instructions.
   static long get_pcrel_offset(unsigned long inst);
--- a/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1681,7 +1681,7 @@
   __ z_lg(Z_R1/*active_handles*/, thread_(active_handles));
   __ clear_mem(Address(Z_R1, JNIHandleBlock::top_offset_in_bytes()), 4);
 
-  // Bandle exceptions (exception handling will handle unlocking!).
+  // Handle exceptions (exception handling will handle unlocking!).
   {
     Label L;
     __ load_and_test_long(Z_R0/*pending_exception*/, thread_(pending_exception));
@@ -1710,17 +1710,9 @@
   __ notify_method_exit(true/*native_method*/, ilgl, InterpreterMacroAssembler::NotifyJVMTI);
 
   // Move native method result back into proper registers and return.
-  // C++ interpreter does not use result handler. So do we need to here? TODO(ZASM): check if correct.
-  { NearLabel no_oop_or_null;
   __ mem2freg_opt(Z_FRET, Address(Z_fp, _z_ijava_state_neg(fresult)));
-  __ load_and_test_long(Z_RET, Address(Z_fp, _z_ijava_state_neg(lresult)));
-  __ z_bre(no_oop_or_null); // No unboxing if the result is NULL.
-  __ load_absolute_address(Z_R1, AbstractInterpreter::result_handler(T_OBJECT));
-  __ compareU64_and_branch(Z_R1, Rresult_handler, Assembler::bcondNotEqual, no_oop_or_null);
-  __ z_lg(Z_RET, oop_tmp_offset, Z_fp);
-  __ verify_oop(Z_RET);
-  __ bind(no_oop_or_null);
-  }
+  __ mem2reg_opt(Z_RET, Address(Z_fp, _z_ijava_state_neg(lresult)));
+  __ call_stub(Rresult_handler);
 
   // Pop the native method's interpreter frame.
   __ pop_interpreter_frame(Z_R14 /*return_pc*/, Z_ARG2/*tmp1*/, Z_ARG3/*tmp2*/);
--- a/src/hotspot/cpu/s390/vtableStubs_s390.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/s390/vtableStubs_s390.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2016, 2017 SAP SE. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018 SAP SE. 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
@@ -37,9 +37,6 @@
 #include "opto/runtime.hpp"
 #endif
 
-// Machine-dependent part of VtableStubs: create vtableStub of correct
-// size and initialize its code.
-
 #define __ masm->
 
 #ifndef PRODUCT
@@ -48,123 +45,140 @@
 
 // Used by compiler only; may use only caller saved, non-argument registers.
 VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
-
-  const int   code_length = VtableStub::pd_code_size_limit(true);
-  VtableStub *s = new(code_length) VtableStub(true, vtable_index);
-  if (s == NULL) { // Indicates OOM In the code cache.
+  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
+  const int stub_code_length = code_size_limit(true);
+  VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index);
+  // Can be NULL if there is no free space in the code cache.
+  if (s == NULL) {
     return NULL;
   }
 
+  // Count unused bytes in instruction sequences of variable size.
+  // We add them to the computed buffer size in order to avoid
+  // overflow in subsequently generated stubs.
+  address   start_pc;
+  int       slop_bytes = 0;
+  int       slop_delta = 0;
+
   ResourceMark    rm;
-  CodeBuffer      cb(s->entry_point(), code_length);
-  MacroAssembler *masm = new MacroAssembler(&cb);
-  int     padding_bytes = 0;
+  CodeBuffer      cb(s->entry_point(), stub_code_length);
+  MacroAssembler* masm = new MacroAssembler(&cb);
 
 #if (!defined(PRODUCT) && defined(COMPILER2))
   if (CountCompiledCalls) {
-    // Count unused bytes
-    //                  worst case             actual size
-    padding_bytes += __ load_const_size() - __ load_const_optimized_rtn_len(Z_R1_scratch, (long)SharedRuntime::nof_megamorphic_calls_addr(), true);
-
+    //               worst case             actual size
+    slop_delta  = __ load_const_size() - __ load_const_optimized_rtn_len(Z_R1_scratch, (long)SharedRuntime::nof_megamorphic_calls_addr(), true);
+    slop_bytes += slop_delta;
+    assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
     // Use generic emitter for direct memory increment.
     // Abuse Z_method as scratch register for generic emitter.
     // It is loaded further down anyway before it is first used.
+    // No dynamic code size variance here, increment is 1, always.
     __ add2mem_32(Address(Z_R1_scratch), 1, Z_method);
   }
 #endif
 
   assert(VtableStub::receiver_location() == Z_R2->as_VMReg(), "receiver expected in Z_ARG1");
 
-  // Get receiver klass.
-  // Must do an explicit check if implicit checks are disabled.
-  address npe_addr = __ pc(); // npe == NULL ptr exception
+  const Register rcvr_klass   = Z_R1_scratch;
+  address        npe_addr     = __ pc(); // npe == NULL ptr exception
+  // check if we must do an explicit check (implicit checks disabled, offset too large).
   __ null_check(Z_ARG1, Z_R1_scratch, oopDesc::klass_offset_in_bytes());
-  const Register rcvr_klass = Z_R1_scratch;
+  // Get receiver klass.
   __ load_klass(rcvr_klass, Z_ARG1);
 
-  // Set method (in case of interpreted method), and destination address.
-  int entry_offset = in_bytes(Klass::vtable_start_offset()) +
-                     vtable_index * vtableEntry::size_in_bytes();
-
 #ifndef PRODUCT
   if (DebugVtables) {
-    Label L;
+    NearLabel L;
     // Check offset vs vtable length.
     const Register vtable_idx = Z_R0_scratch;
 
-    // Count unused bytes.
-    //                  worst case             actual size
-    padding_bytes += __ load_const_size() - __ load_const_optimized_rtn_len(vtable_idx, vtable_index*vtableEntry::size_in_bytes(), true);
+    //               worst case             actual size
+    slop_delta  = __ load_const_size() - __ load_const_optimized_rtn_len(vtable_idx, vtable_index*vtableEntry::size(), true);
+    slop_bytes += slop_delta;
+    assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
 
-    assert(Immediate::is_uimm12(in_bytes(Klass::vtable_length_offset())), "disp to large");
+    assert(Displacement::is_shortDisp(in_bytes(Klass::vtable_length_offset())), "disp to large");
     __ z_cl(vtable_idx, in_bytes(Klass::vtable_length_offset()), rcvr_klass);
     __ z_brl(L);
     __ z_lghi(Z_ARG3, vtable_index);  // Debug code, don't optimize.
     __ call_VM(noreg, CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), Z_ARG1, Z_ARG3, false);
     // Count unused bytes (assume worst case here).
-    padding_bytes += 12;
+    slop_bytes += 12;
     __ bind(L);
   }
 #endif
 
-  int v_off = entry_offset + vtableEntry::method_offset_in_bytes();
+  int entry_offset = in_bytes(Klass::vtable_start_offset()) +
+                     vtable_index * vtableEntry::size_in_bytes();
+  int v_off        = entry_offset + vtableEntry::method_offset_in_bytes();
 
+  // Set method (in case of interpreted method), and destination address.
   // Duplicate safety code from enc_class Java_Dynamic_Call_dynTOC.
   if (Displacement::is_validDisp(v_off)) {
     __ z_lg(Z_method/*method oop*/, v_off, rcvr_klass/*class oop*/);
     // Account for the load_const in the else path.
-    padding_bytes += __ load_const_size();
+    slop_delta  = __ load_const_size();
   } else {
     // Worse case, offset does not fit in displacement field.
-    __ load_const(Z_method, v_off); // Z_method temporarily holds the offset value.
+    //               worst case             actual size
+    slop_delta  = __ load_const_size() - __ load_const_optimized_rtn_len(Z_method, v_off, true);
     __ z_lg(Z_method/*method oop*/, 0, Z_method/*method offset*/, rcvr_klass/*class oop*/);
   }
+  slop_bytes += slop_delta;
 
 #ifndef PRODUCT
   if (DebugVtables) {
-    Label L;
+    NearLabel L;
     __ z_ltgr(Z_method, Z_method);
     __ z_brne(L);
-    __ stop("Vtable entry is ZERO",102);
+    __ stop("Vtable entry is ZERO", 102);
     __ bind(L);
   }
 #endif
 
-  address ame_addr = __ pc(); // ame = abstract method error
-
-  // Must do an explicit check if implicit checks are disabled.
+  // Must do an explicit check if offset too large or implicit checks are disabled.
+  address ame_addr = __ pc();
   __ null_check(Z_method, Z_R1_scratch, in_bytes(Method::from_compiled_offset()));
   __ z_lg(Z_R1_scratch, in_bytes(Method::from_compiled_offset()), Z_method);
   __ z_br(Z_R1_scratch);
 
   masm->flush();
-
-  s->set_exception_points(npe_addr, ame_addr);
+  bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0);
 
   return s;
 }
 
 VtableStub* VtableStubs::create_itable_stub(int itable_index) {
-  const int   code_length = VtableStub::pd_code_size_limit(false);
-  VtableStub *s = new(code_length) VtableStub(false, itable_index);
-  if (s == NULL) { // Indicates OOM in the code cache.
+  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
+  const int stub_code_length = code_size_limit(false);
+  VtableStub* s = new(stub_code_length) VtableStub(false, itable_index);
+  // Can be NULL if there is no free space in the code cache.
+  if (s == NULL) {
     return NULL;
   }
+  // Count unused bytes in instruction sequences of variable size.
+  // We add them to the computed buffer size in order to avoid
+  // overflow in subsequently generated stubs.
+  address   start_pc;
+  int       slop_bytes = 0;
+  int       slop_delta = 0;
 
   ResourceMark    rm;
-  CodeBuffer      cb(s->entry_point(), code_length);
-  MacroAssembler *masm = new MacroAssembler(&cb);
-  int     padding_bytes = 0;
+  CodeBuffer      cb(s->entry_point(), stub_code_length);
+  MacroAssembler* masm = new MacroAssembler(&cb);
 
 #if (!defined(PRODUCT) && defined(COMPILER2))
   if (CountCompiledCalls) {
-    // Count unused bytes
-    //                  worst case             actual size
-    padding_bytes += __ load_const_size() - __ load_const_optimized_rtn_len(Z_R1_scratch, (long)SharedRuntime::nof_megamorphic_calls_addr(), true);
-
+    //               worst case             actual size
+    slop_delta  = __ load_const_size() - __ load_const_optimized_rtn_len(Z_R1_scratch, (long)SharedRuntime::nof_megamorphic_calls_addr(), true);
+    slop_bytes += slop_delta;
+    assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
     // Use generic emitter for direct memory increment.
-    // Use Z_tmp_1 as scratch register for generic emitter.
-    __ add2mem_32((Z_R1_scratch), 1, Z_tmp_1);
+    // Abuse Z_method as scratch register for generic emitter.
+    // It is loaded further down anyway before it is first used.
+    // No dynamic code size variance here, increment is 1, always.
+    __ add2mem_32(Address(Z_R1_scratch), 1, Z_method);
   }
 #endif
 
@@ -178,7 +192,7 @@
                  interface  = Z_tmp_2;
 
   // Get receiver klass.
-  // Must do an explicit check if implicit checks are disabled.
+  // Must do an explicit check if offset too large or implicit checks are disabled.
   address npe_addr = __ pc(); // npe == NULL ptr exception
   __ null_check(Z_ARG1, Z_R1_scratch, oopDesc::klass_offset_in_bytes());
   __ load_klass(rcvr_klass, Z_ARG1);
@@ -195,10 +209,10 @@
 
 #ifndef PRODUCT
   if (DebugVtables) {
-    Label ok1;
+    NearLabel ok1;
     __ z_ltgr(Z_method, Z_method);
     __ z_brne(ok1);
-    __ stop("method is null",103);
+    __ stop("method is null", 103);
     __ bind(ok1);
   }
 #endif
@@ -213,39 +227,24 @@
 
   // Handle IncompatibleClassChangeError in itable stubs.
   __ bind(no_such_interface);
-  // Count unused bytes
-  //                  worst case          actual size
-  // We force resolving of the call site by jumping to
-  // the "handle wrong method" stub, and so let the
+  // more detailed IncompatibleClassChangeError
+  // we force re-resolving of the call site by jumping to
+  // the "handle wrong method" stub, thus letting the
   // interpreter runtime do all the dirty work.
-  padding_bytes += __ load_const_size() - __ load_const_optimized_rtn_len(Z_R1_scratch, (long)SharedRuntime::get_handle_wrong_method_stub(), true);
+  //               worst case          actual size
+  slop_delta  = __ load_const_size() - __ load_const_optimized_rtn_len(Z_R1_scratch, (long)SharedRuntime::get_handle_wrong_method_stub(), true);
+  slop_bytes += slop_delta;
+  assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
   __ z_br(Z_R1_scratch);
 
   masm->flush();
+  bookkeeping(masm, tty, s, npe_addr, ame_addr, false, itable_index, slop_bytes, 0);
 
-  s->set_exception_points(npe_addr, ame_addr);
   return s;
 }
 
-// In order to tune these parameters, run the JVM with VM options
-// +PrintMiscellaneous and +WizardMode to see information about
-// actual itable stubs. Run it with -Xmx31G -XX:+UseCompressedOops.
-int VtableStub::pd_code_size_limit(bool is_vtable_stub) {
-  int size = DebugVtables ? 216 : 0;
-  if (CountCompiledCalls) {
-    size += 6 * 4;
-  }
-  size += is_vtable_stub ? 36 : 140;
-  if (UseCompressedClassPointers) {
-    size += MacroAssembler::instr_size_for_decode_klass_not_null();
-  }
-  if (!ImplicitNullChecks) {
-    size += 36;
-  }
-  return size;
-}
-
 int VtableStub::pd_code_alignment() {
+  // System z cache line size is 256 bytes, but octoword-alignment is quite ok.
   const unsigned int icache_line_size = 32;
   return icache_line_size;
 }
--- a/src/hotspot/cpu/sparc/macroAssembler_sparc.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -2648,195 +2648,92 @@
      inc_counter((address) counters->total_entry_count_addr(), Rmark, Rscratch);
    }
 
-   if (EmitSync & 1) {
-     mov(3, Rscratch);
-     st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
-     cmp(SP, G0);
-     return ;
-   }
-
-   if (EmitSync & 2) {
-
-     // Fetch object's markword
-     ld_ptr(mark_addr, Rmark);
-
-     if (try_bias) {
-        biased_locking_enter(Roop, Rmark, Rscratch, done, NULL, counters);
-     }
-
-     // Save Rbox in Rscratch to be used for the cas operation
-     mov(Rbox, Rscratch);
-
-     // set Rmark to markOop | markOopDesc::unlocked_value
-     or3(Rmark, markOopDesc::unlocked_value, Rmark);
-
-     // Initialize the box.  (Must happen before we update the object mark!)
-     st_ptr(Rmark, Rbox, BasicLock::displaced_header_offset_in_bytes());
-
-     // compare object markOop with Rmark and if equal exchange Rscratch with object markOop
-     assert(mark_addr.disp() == 0, "cas must take a zero displacement");
-     cas_ptr(mark_addr.base(), Rmark, Rscratch);
-
-     // if compare/exchange succeeded we found an unlocked object and we now have locked it
-     // hence we are done
-     cmp(Rmark, Rscratch);
-     sub(Rscratch, STACK_BIAS, Rscratch);
-     brx(Assembler::equal, false, Assembler::pt, done);
-     delayed()->sub(Rscratch, SP, Rscratch);  //pull next instruction into delay slot
-
-     // we did not find an unlocked object so see if this is a recursive case
-     // sub(Rscratch, SP, Rscratch);
-     assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
-     andcc(Rscratch, 0xfffff003, Rscratch);
-     st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
-     bind (done);
-     return ;
-   }
-
    Label Egress ;
 
-   if (EmitSync & 256) {
-      Label IsInflated ;
-
-      ld_ptr(mark_addr, Rmark);           // fetch obj->mark
-      // Triage: biased, stack-locked, neutral, inflated
-      if (try_bias) {
-        biased_locking_enter(Roop, Rmark, Rscratch, done, NULL, counters);
-        // Invariant: if control reaches this point in the emitted stream
-        // then Rmark has not been modified.
-      }
-
-      // Store mark into displaced mark field in the on-stack basic-lock "box"
-      // Critically, this must happen before the CAS
-      // Maximize the ST-CAS distance to minimize the ST-before-CAS penalty.
-      st_ptr(Rmark, Rbox, BasicLock::displaced_header_offset_in_bytes());
-      andcc(Rmark, 2, G0);
-      brx(Assembler::notZero, false, Assembler::pn, IsInflated);
-      delayed()->
-
-      // Try stack-lock acquisition.
-      // Beware: the 1st instruction is in a delay slot
-      mov(Rbox,  Rscratch);
-      or3(Rmark, markOopDesc::unlocked_value, Rmark);
-      assert(mark_addr.disp() == 0, "cas must take a zero displacement");
-      cas_ptr(mark_addr.base(), Rmark, Rscratch);
-      cmp(Rmark, Rscratch);
-      brx(Assembler::equal, false, Assembler::pt, done);
-      delayed()->sub(Rscratch, SP, Rscratch);
-
-      // Stack-lock attempt failed - check for recursive stack-lock.
-      // See the comments below about how we might remove this case.
-      sub(Rscratch, STACK_BIAS, Rscratch);
-      assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
-      andcc(Rscratch, 0xfffff003, Rscratch);
-      br(Assembler::always, false, Assembler::pt, done);
-      delayed()-> st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
-
-      bind(IsInflated);
-      if (EmitSync & 64) {
-         // If m->owner != null goto IsLocked
-         // Pessimistic form: Test-and-CAS vs CAS
-         // The optimistic form avoids RTS->RTO cache line upgrades.
-         ld_ptr(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), Rscratch);
-         andcc(Rscratch, Rscratch, G0);
-         brx(Assembler::notZero, false, Assembler::pn, done);
-         delayed()->nop();
-         // m->owner == null : it's unlocked.
-      }
-
-      // Try to CAS m->owner from null to Self
-      // Invariant: if we acquire the lock then _recursions should be 0.
-      add(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), Rmark);
-      mov(G2_thread, Rscratch);
-      cas_ptr(Rmark, G0, Rscratch);
-      cmp(Rscratch, G0);
-      // Intentional fall-through into done
-   } else {
-      // Aggressively avoid the Store-before-CAS penalty
-      // Defer the store into box->dhw until after the CAS
-      Label IsInflated, Recursive ;
+   // Aggressively avoid the Store-before-CAS penalty
+   // Defer the store into box->dhw until after the CAS
+   Label IsInflated, Recursive ;
 
 // Anticipate CAS -- Avoid RTS->RTO upgrade
 // prefetch (mark_addr, Assembler::severalWritesAndPossiblyReads);
 
-      ld_ptr(mark_addr, Rmark);           // fetch obj->mark
-      // Triage: biased, stack-locked, neutral, inflated
-
-      if (try_bias) {
-        biased_locking_enter(Roop, Rmark, Rscratch, done, NULL, counters);
-        // Invariant: if control reaches this point in the emitted stream
-        // then Rmark has not been modified.
-      }
-      andcc(Rmark, 2, G0);
-      brx(Assembler::notZero, false, Assembler::pn, IsInflated);
-      delayed()->                         // Beware - dangling delay-slot
-
-      // Try stack-lock acquisition.
-      // Transiently install BUSY (0) encoding in the mark word.
-      // if the CAS of 0 into the mark was successful then we execute:
-      //   ST box->dhw  = mark   -- save fetched mark in on-stack basiclock box
-      //   ST obj->mark = box    -- overwrite transient 0 value
-      // This presumes TSO, of course.
-
-      mov(0, Rscratch);
-      or3(Rmark, markOopDesc::unlocked_value, Rmark);
-      assert(mark_addr.disp() == 0, "cas must take a zero displacement");
-      cas_ptr(mark_addr.base(), Rmark, Rscratch);
+   ld_ptr(mark_addr, Rmark);           // fetch obj->mark
+   // Triage: biased, stack-locked, neutral, inflated
+
+   if (try_bias) {
+     biased_locking_enter(Roop, Rmark, Rscratch, done, NULL, counters);
+     // Invariant: if control reaches this point in the emitted stream
+     // then Rmark has not been modified.
+   }
+   andcc(Rmark, 2, G0);
+   brx(Assembler::notZero, false, Assembler::pn, IsInflated);
+   delayed()->                         // Beware - dangling delay-slot
+
+   // Try stack-lock acquisition.
+   // Transiently install BUSY (0) encoding in the mark word.
+   // if the CAS of 0 into the mark was successful then we execute:
+   //   ST box->dhw  = mark   -- save fetched mark in on-stack basiclock box
+   //   ST obj->mark = box    -- overwrite transient 0 value
+   // This presumes TSO, of course.
+
+   mov(0, Rscratch);
+   or3(Rmark, markOopDesc::unlocked_value, Rmark);
+   assert(mark_addr.disp() == 0, "cas must take a zero displacement");
+   cas_ptr(mark_addr.base(), Rmark, Rscratch);
 // prefetch (mark_addr, Assembler::severalWritesAndPossiblyReads);
-      cmp(Rscratch, Rmark);
-      brx(Assembler::notZero, false, Assembler::pn, Recursive);
-      delayed()->st_ptr(Rmark, Rbox, BasicLock::displaced_header_offset_in_bytes());
-      if (counters != NULL) {
-        cond_inc(Assembler::equal, (address) counters->fast_path_entry_count_addr(), Rmark, Rscratch);
-      }
-      ba(done);
-      delayed()->st_ptr(Rbox, mark_addr);
-
-      bind(Recursive);
-      // Stack-lock attempt failed - check for recursive stack-lock.
-      // Tests show that we can remove the recursive case with no impact
-      // on refworkload 0.83.  If we need to reduce the size of the code
-      // emitted by compiler_lock_object() the recursive case is perfect
-      // candidate.
-      //
-      // A more extreme idea is to always inflate on stack-lock recursion.
-      // This lets us eliminate the recursive checks in compiler_lock_object
-      // and compiler_unlock_object and the (box->dhw == 0) encoding.
-      // A brief experiment - requiring changes to synchronizer.cpp, interpreter,
-      // and showed a performance *increase*.  In the same experiment I eliminated
-      // the fast-path stack-lock code from the interpreter and always passed
-      // control to the "slow" operators in synchronizer.cpp.
-
-      // RScratch contains the fetched obj->mark value from the failed CAS.
-      sub(Rscratch, STACK_BIAS, Rscratch);
-      sub(Rscratch, SP, Rscratch);
-      assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
-      andcc(Rscratch, 0xfffff003, Rscratch);
-      if (counters != NULL) {
-        // Accounting needs the Rscratch register
-        st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
-        cond_inc(Assembler::equal, (address) counters->fast_path_entry_count_addr(), Rmark, Rscratch);
-        ba_short(done);
-      } else {
-        ba(done);
-        delayed()->st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
-      }
-
-      bind   (IsInflated);
-
-      // Try to CAS m->owner from null to Self
-      // Invariant: if we acquire the lock then _recursions should be 0.
-      add(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), Rmark);
-      mov(G2_thread, Rscratch);
-      cas_ptr(Rmark, G0, Rscratch);
-      andcc(Rscratch, Rscratch, G0);             // set ICCs for done: icc.zf iff success
-      // set icc.zf : 1=success 0=failure
-      // ST box->displaced_header = NonZero.
-      // Any non-zero value suffices:
-      //    markOopDesc::unused_mark(), G2_thread, RBox, RScratch, rsp, etc.
-      st_ptr(Rbox, Rbox, BasicLock::displaced_header_offset_in_bytes());
-      // Intentional fall-through into done
+   cmp(Rscratch, Rmark);
+   brx(Assembler::notZero, false, Assembler::pn, Recursive);
+   delayed()->st_ptr(Rmark, Rbox, BasicLock::displaced_header_offset_in_bytes());
+   if (counters != NULL) {
+     cond_inc(Assembler::equal, (address) counters->fast_path_entry_count_addr(), Rmark, Rscratch);
    }
+   ba(done);
+   delayed()->st_ptr(Rbox, mark_addr);
+
+   bind(Recursive);
+   // Stack-lock attempt failed - check for recursive stack-lock.
+   // Tests show that we can remove the recursive case with no impact
+   // on refworkload 0.83.  If we need to reduce the size of the code
+   // emitted by compiler_lock_object() the recursive case is perfect
+   // candidate.
+   //
+   // A more extreme idea is to always inflate on stack-lock recursion.
+   // This lets us eliminate the recursive checks in compiler_lock_object
+   // and compiler_unlock_object and the (box->dhw == 0) encoding.
+   // A brief experiment - requiring changes to synchronizer.cpp, interpreter,
+   // and showed a performance *increase*.  In the same experiment I eliminated
+   // the fast-path stack-lock code from the interpreter and always passed
+   // control to the "slow" operators in synchronizer.cpp.
+
+   // RScratch contains the fetched obj->mark value from the failed CAS.
+   sub(Rscratch, STACK_BIAS, Rscratch);
+   sub(Rscratch, SP, Rscratch);
+   assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
+   andcc(Rscratch, 0xfffff003, Rscratch);
+   if (counters != NULL) {
+     // Accounting needs the Rscratch register
+     st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
+     cond_inc(Assembler::equal, (address) counters->fast_path_entry_count_addr(), Rmark, Rscratch);
+     ba_short(done);
+   } else {
+     ba(done);
+     delayed()->st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
+   }
+
+   bind   (IsInflated);
+
+   // Try to CAS m->owner from null to Self
+   // Invariant: if we acquire the lock then _recursions should be 0.
+   add(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), Rmark);
+   mov(G2_thread, Rscratch);
+   cas_ptr(Rmark, G0, Rscratch);
+   andcc(Rscratch, Rscratch, G0);             // set ICCs for done: icc.zf iff success
+   // set icc.zf : 1=success 0=failure
+   // ST box->displaced_header = NonZero.
+   // Any non-zero value suffices:
+   //    markOopDesc::unused_mark(), G2_thread, RBox, RScratch, rsp, etc.
+   st_ptr(Rbox, Rbox, BasicLock::displaced_header_offset_in_bytes());
+   // Intentional fall-through into done
 
    bind   (done);
 }
@@ -2848,30 +2745,6 @@
 
    Label done ;
 
-   if (EmitSync & 4) {
-     cmp(SP, G0);
-     return ;
-   }
-
-   if (EmitSync & 8) {
-     if (try_bias) {
-        biased_locking_exit(mark_addr, Rscratch, done);
-     }
-
-     // Test first if it is a fast recursive unlock
-     ld_ptr(Rbox, BasicLock::displaced_header_offset_in_bytes(), Rmark);
-     br_null_short(Rmark, Assembler::pt, done);
-
-     // Check if it is still a light weight lock, this is is true if we see
-     // the stack address of the basicLock in the markOop of the object
-     assert(mark_addr.disp() == 0, "cas must take a zero displacement");
-     cas_ptr(mark_addr.base(), Rbox, Rmark);
-     ba(done);
-     delayed()->cmp(Rbox, Rmark);
-     bind(done);
-     return ;
-   }
-
    // Beware ... If the aggregate size of the code emitted by CLO and CUO is
    // is too large performance rolls abruptly off a cliff.
    // This could be related to inlining policies, code cache management, or
@@ -2902,105 +2775,39 @@
    // close the resultant (and rare) race by having contended threads in
    // monitorenter periodically poll _owner.
 
-   if (EmitSync & 1024) {
-     // Emit code to check that _owner == Self
-     // We could fold the _owner test into subsequent code more efficiently
-     // than using a stand-alone check, but since _owner checking is off by
-     // default we don't bother. We also might consider predicating the
-     // _owner==Self check on Xcheck:jni or running on a debug build.
-     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), Rscratch);
-     orcc(Rscratch, G0, G0);
-     brx(Assembler::notZero, false, Assembler::pn, done);
-     delayed()->nop();
-   }
-
-   if (EmitSync & 512) {
-     // classic lock release code absent 1-0 locking
-     //   m->Owner = null;
-     //   membar #storeload
-     //   if (m->cxq|m->EntryList) == null goto Success
-     //   if (m->succ != null) goto Success
-     //   if CAS (&m->Owner,0,Self) != 0 goto Success
-     //   goto SlowPath
-     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)), Rbox);
-     orcc(Rbox, G0, G0);
-     brx(Assembler::notZero, false, Assembler::pn, done);
-     delayed()->nop();
-     st_ptr(G0, Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-     if (os::is_MP()) { membar(StoreLoad); }
-     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList)), Rscratch);
-     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq)), Rbox);
-     orcc(Rbox, Rscratch, G0);
-     brx(Assembler::zero, false, Assembler::pt, done);
-     delayed()->
-     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)), Rscratch);
-     andcc(Rscratch, Rscratch, G0);
-     brx(Assembler::notZero, false, Assembler::pt, done);
-     delayed()->andcc(G0, G0, G0);
-     add(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), Rmark);
-     mov(G2_thread, Rscratch);
-     cas_ptr(Rmark, G0, Rscratch);
-     cmp(Rscratch, G0);
-     // invert icc.zf and goto done
-     brx(Assembler::notZero, false, Assembler::pt, done);
-     delayed()->cmp(G0, G0);
-     br(Assembler::always, false, Assembler::pt, done);
-     delayed()->cmp(G0, 1);
-   } else {
-     // 1-0 form : avoids CAS and MEMBAR in the common case
-     // Do not bother to ratify that m->Owner == Self.
-     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)), Rbox);
-     orcc(Rbox, G0, G0);
-     brx(Assembler::notZero, false, Assembler::pn, done);
-     delayed()->
-     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList)), Rscratch);
-     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq)), Rbox);
-     orcc(Rbox, Rscratch, G0);
-     if (EmitSync & 16384) {
-       // As an optional optimization, if (EntryList|cxq) != null and _succ is null then
-       // we should transfer control directly to the slow-path.
-       // This test makes the reacquire operation below very infrequent.
-       // The logic is equivalent to :
-       //   if (cxq|EntryList) == null : Owner=null; goto Success
-       //   if succ == null : goto SlowPath
-       //   Owner=null; membar #storeload
-       //   if succ != null : goto Success
-       //   if CAS(&Owner,null,Self) != null goto Success
-       //   goto SlowPath
-       brx(Assembler::zero, true, Assembler::pt, done);
-       delayed()->
-       st_ptr(G0, Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-       ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)), Rscratch);
-       andcc(Rscratch, Rscratch, G0) ;
-       brx(Assembler::zero, false, Assembler::pt, done);
-       delayed()->orcc(G0, 1, G0);
-       st_ptr(G0, Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-     } else {
-       brx(Assembler::zero, false, Assembler::pt, done);
-       delayed()->
-       st_ptr(G0, Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-     }
-     if (os::is_MP()) { membar(StoreLoad); }
-     // Check that _succ is (or remains) non-zero
-     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)), Rscratch);
-     andcc(Rscratch, Rscratch, G0);
-     brx(Assembler::notZero, false, Assembler::pt, done);
-     delayed()->andcc(G0, G0, G0);
-     add(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), Rmark);
-     mov(G2_thread, Rscratch);
-     cas_ptr(Rmark, G0, Rscratch);
-     cmp(Rscratch, G0);
-     // invert icc.zf and goto done
-     // A slightly better v8+/v9 idiom would be the following:
-     //   movrnz Rscratch,1,Rscratch
-     //   ba done
-     //   xorcc Rscratch,1,G0
-     // In v8+ mode the idiom would be valid IFF Rscratch was a G or O register
-     brx(Assembler::notZero, false, Assembler::pt, done);
-     delayed()->cmp(G0, G0);
-     br(Assembler::always, false, Assembler::pt, done);
-     delayed()->cmp(G0, 1);
-   }
+   // 1-0 form : avoids CAS and MEMBAR in the common case
+   // Do not bother to ratify that m->Owner == Self.
+   ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)), Rbox);
+   orcc(Rbox, G0, G0);
+   brx(Assembler::notZero, false, Assembler::pn, done);
+   delayed()->
+   ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList)), Rscratch);
+   ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq)), Rbox);
+   orcc(Rbox, Rscratch, G0);
+   brx(Assembler::zero, false, Assembler::pt, done);
+   delayed()->
+   st_ptr(G0, Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
+
+   if (os::is_MP()) { membar(StoreLoad); }
+   // Check that _succ is (or remains) non-zero
+   ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)), Rscratch);
+   andcc(Rscratch, Rscratch, G0);
+   brx(Assembler::notZero, false, Assembler::pt, done);
+   delayed()->andcc(G0, G0, G0);
+   add(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), Rmark);
+   mov(G2_thread, Rscratch);
+   cas_ptr(Rmark, G0, Rscratch);
+   cmp(Rscratch, G0);
+   // invert icc.zf and goto done
+   // A slightly better v8+/v9 idiom would be the following:
+   //   movrnz Rscratch,1,Rscratch
+   //   ba done
+   //   xorcc Rscratch,1,G0
+   // In v8+ mode the idiom would be valid IFF Rscratch was a G or O register
+   brx(Assembler::notZero, false, Assembler::pt, done);
+   delayed()->cmp(G0, G0);
+   br(Assembler::always, false, Assembler::pt, done);
+   delayed()->cmp(G0, 1);
 
    bind   (LStacked);
    // Consider: we could replace the expensive CAS in the exit
--- a/src/hotspot/cpu/sparc/macroAssembler_sparc.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -659,7 +659,7 @@
 
   // Required platform-specific helpers for Label::patch_instructions.
   // They _shadow_ the declarations in AbstractAssembler, which are undefined.
-  void pd_patch_instruction(address branch, address target);
+  void pd_patch_instruction(address branch, address target, const char* file, int line);
 
   // sethi Macro handles optimizations and relocations
 private:
--- a/src/hotspot/cpu/sparc/macroAssembler_sparc.inline.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.inline.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -38,7 +38,7 @@
 }
 
 
-inline void MacroAssembler::pd_patch_instruction(address branch, address target) {
+inline void MacroAssembler::pd_patch_instruction(address branch, address target, const char* file, int line) {
   jint& stub_inst = *(jint*) branch;
   stub_inst = patched_branch(target - branch, stub_inst, 0);
 }
--- a/src/hotspot/cpu/sparc/vtableStubs_sparc.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/sparc/vtableStubs_sparc.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -41,32 +41,38 @@
 
 #define __ masm->
 
-
 #ifndef PRODUCT
 extern "C" void bad_compiled_vtable_index(JavaThread* thread, oopDesc* receiver, int index);
 #endif
 
 
 // Used by compiler only; may use only caller saved, non-argument registers
-// NOTE:  %%%% if any change is made to this stub make sure that the function
-//             pd_code_size_limit is changed to ensure the correct size for VtableStub
 VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
-  const int sparc_code_length = VtableStub::pd_code_size_limit(true);
-  VtableStub* s = new(sparc_code_length) VtableStub(true, vtable_index);
+  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
+  const int stub_code_length = code_size_limit(true);
+  VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index);
   // Can be NULL if there is no free space in the code cache.
   if (s == NULL) {
     return NULL;
   }
 
-  ResourceMark rm;
-  CodeBuffer cb(s->entry_point(), sparc_code_length);
+  // Count unused bytes in instruction sequences of variable size.
+  // We add them to the computed buffer size in order to avoid
+  // overflow in subsequently generated stubs.
+  address   start_pc;
+  int       slop_bytes = 0;
+  int       slop_delta = 0;
+  const int index_dependent_slop     = ((vtable_index < 512) ? 2 : 0)*BytesPerInstWord; // code size change with transition from 13-bit to 32-bit constant (@index == 512?).
+
+  ResourceMark    rm;
+  CodeBuffer      cb(s->entry_point(), stub_code_length);
   MacroAssembler* masm = new MacroAssembler(&cb);
 
-#ifndef PRODUCT
+#if (!defined(PRODUCT) && defined(COMPILER2))
   if (CountCompiledCalls) {
     __ inc_counter(SharedRuntime::nof_megamorphic_calls_addr(), G5, G3_scratch);
   }
-#endif /* PRODUCT */
+#endif // PRODUCT
 
   assert(VtableStub::receiver_location() == O0->as_VMReg(), "receiver expected in O0");
 
@@ -74,20 +80,33 @@
   address npe_addr = __ pc();
   __ load_klass(O0, G3_scratch);
 
-  // set Method* (in case of interpreted method), and destination address
 #ifndef PRODUCT
   if (DebugVtables) {
     Label L;
     // check offset vs vtable length
     __ ld(G3_scratch, in_bytes(Klass::vtable_length_offset()), G5);
     __ cmp_and_br_short(G5, vtable_index*vtableEntry::size(), Assembler::greaterUnsigned, Assembler::pt, L);
+
+    // set generates 8 instructions (worst case), 1 instruction (best case)
+    start_pc = __ pc();
     __ set(vtable_index, O2);
+    slop_delta  = __ worst_case_insts_for_set()*BytesPerInstWord - (__ pc() - start_pc);
+    slop_bytes += slop_delta;
+    assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
+
+    // there is no variance in call_VM() emitted code.
     __ call_VM(noreg, CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), O0, O2);
     __ bind(L);
   }
 #endif
 
+  // set Method* (in case of interpreted method), and destination address
+  start_pc = __ pc();
   __ lookup_virtual_method(G3_scratch, vtable_index, G5_method);
+  // lookup_virtual_method generates 3 instructions (worst case), 1 instruction (best case)
+  slop_delta  = 3*BytesPerInstWord - (int)(__ pc() - start_pc);
+  slop_bytes += slop_delta;
+  assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
 
 #ifndef PRODUCT
   if (DebugVtables) {
@@ -109,37 +128,41 @@
   __ delayed()->nop();
 
   masm->flush();
+  slop_bytes += index_dependent_slop; // add'l slop for size variance due to large itable offsets
+  bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, index_dependent_slop);
 
-  if (PrintMiscellaneous && (WizardMode || Verbose)) {
-    tty->print_cr("vtable #%d at " PTR_FORMAT "[%d] left over: %d",
-                  vtable_index, p2i(s->entry_point()),
-                  (int)(s->code_end() - s->entry_point()),
-                  (int)(s->code_end() - __ pc()));
-  }
-  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
-  // shut the door on sizing bugs
-  int slop = 2*BytesPerInstWord;  // 32-bit offset is this much larger than a 13-bit one
-  assert(vtable_index > 10 || __ pc() + slop <= s->code_end(), "room for sethi;add");
-
-  s->set_exception_points(npe_addr, ame_addr);
   return s;
 }
 
 
-// NOTE:  %%%% if any change is made to this stub make sure that the function
-//             pd_code_size_limit is changed to ensure the correct size for VtableStub
 VtableStub* VtableStubs::create_itable_stub(int itable_index) {
-  const int sparc_code_length = VtableStub::pd_code_size_limit(false);
-  VtableStub* s = new(sparc_code_length) VtableStub(false, itable_index);
+  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
+  const int stub_code_length = code_size_limit(false);
+  VtableStub* s = new(stub_code_length) VtableStub(false, itable_index);
   // Can be NULL if there is no free space in the code cache.
   if (s == NULL) {
     return NULL;
   }
+  // Count unused bytes in instruction sequences of variable size.
+  // We add them to the computed buffer size in order to avoid
+  // overflow in subsequently generated stubs.
+  address   start_pc;
+  int       slop_bytes = 0;
+  int       slop_delta = 0;
+  const int index_dependent_slop     = ((itable_index < 512) ? 2 : 0)*BytesPerInstWord; // code size change with transition from 13-bit to 32-bit constant (@index == 512?).
 
-  ResourceMark rm;
-  CodeBuffer cb(s->entry_point(), sparc_code_length);
+  ResourceMark    rm;
+  CodeBuffer      cb(s->entry_point(), stub_code_length);
   MacroAssembler* masm = new MacroAssembler(&cb);
 
+#if (!defined(PRODUCT) && defined(COMPILER2))
+  if (CountCompiledCalls) {
+//  Use G3_scratch, G4_scratch as work regs for inc_counter.
+//  These are defined before use further down.
+    __ inc_counter(SharedRuntime::nof_megamorphic_calls_addr(), G3_scratch, G4_scratch);
+  }
+#endif // PRODUCT
+
   Register G3_Klass = G3_scratch;
   Register G5_icholder = G5;  // Passed in as an argument
   Register G4_interface = G4_scratch;
@@ -160,15 +183,10 @@
   // and so those registers are not available here.
   __ save(SP,-frame::register_save_words*wordSize,SP);
 
-#ifndef PRODUCT
-  if (CountCompiledCalls) {
-    __ inc_counter(SharedRuntime::nof_megamorphic_calls_addr(), L0, L1);
-  }
-#endif /* PRODUCT */
+  Label    L_no_such_interface;
+  Register L5_method = L5;
 
-  Label L_no_such_interface;
-
-  Register L5_method = L5;
+  start_pc = __ pc();
 
   // Receiver subtype check against REFC.
   __ ld_ptr(G5_icholder, CompiledICHolder::holder_klass_offset(), G4_interface);
@@ -179,6 +197,9 @@
                              L_no_such_interface,
                              /*return_method=*/ false);
 
+  const ptrdiff_t typecheckSize = __ pc() - start_pc;
+  start_pc = __ pc();
+
   // Get Method* and entrypoint for compiler
   __ ld_ptr(G5_icholder, CompiledICHolder::holder_metadata_offset(), G4_interface);
   __ lookup_interface_method(// inputs: rec. class, interface, itable index
@@ -187,6 +208,19 @@
                              L5_method, L2, L3,
                              L_no_such_interface);
 
+  const ptrdiff_t lookupSize = __ pc() - start_pc;
+
+  // Reduce "estimate" such that "padding" does not drop below 8.
+  // Do not target a left-over number of zero, because a very
+  // large vtable or itable offset (> 4K) will require an extra
+  // sethi/or pair of instructions.
+  // Found typecheck(60) + lookup(72) to exceed previous extimate (32*4).
+  const ptrdiff_t estimate = 36*BytesPerInstWord;
+  const ptrdiff_t codesize = typecheckSize + lookupSize + index_dependent_slop;
+  slop_delta  = (int)(estimate - codesize);
+  slop_bytes += slop_delta;
+  assert(slop_delta >= 0, "itable #%d: Code size estimate (%d) for lookup_interface_method too small, required: %d", itable_index, (int)estimate, (int)codesize);
+
 #ifndef PRODUCT
   if (DebugVtables) {
     Label L01;
@@ -222,88 +256,12 @@
   __ delayed()->restore();
 
   masm->flush();
+  slop_bytes += index_dependent_slop; // add'l slop for size variance due to large itable offsets
+  bookkeeping(masm, tty, s, npe_addr, ame_addr, false, itable_index, slop_bytes, index_dependent_slop);
 
-  if (PrintMiscellaneous && (WizardMode || Verbose)) {
-    tty->print_cr("itable #%d at " PTR_FORMAT "[%d] left over: %d",
-                  itable_index, p2i(s->entry_point()),
-                  (int)(s->code_end() - s->entry_point()),
-                  (int)(s->code_end() - __ pc()));
-  }
-  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
-  // shut the door on sizing bugs
-  int slop = 2*BytesPerInstWord;  // 32-bit offset is this much larger than a 13-bit one
-  assert(itable_index > 10 || __ pc() + slop <= s->code_end(), "room for sethi;add");
-
-  s->set_exception_points(npe_addr, ame_addr);
   return s;
 }
 
-
-int VtableStub::pd_code_size_limit(bool is_vtable_stub) {
-  if (DebugVtables || CountCompiledCalls || VerifyOops) return 1000;
-  else {
-    const int slop = 2*BytesPerInstWord; // sethi;add  (needed for long offsets)
-    if (is_vtable_stub) {
-      // ld;ld;ld,jmp,nop
-      const int basic = 5*BytesPerInstWord +
-                        // shift;add for load_klass (only shift with zero heap based)
-                        (UseCompressedClassPointers ?
-                          MacroAssembler::instr_size_for_decode_klass_not_null() : 0);
-      return basic + slop;
-    } else {
-      const int basic = 54 * BytesPerInstWord +
-                        // shift;add for load_klass (only shift with zero heap based)
-                        (UseCompressedClassPointers ?
-                          MacroAssembler::instr_size_for_decode_klass_not_null() : 0);
-      return (basic + slop);
-    }
-  }
-
-  // In order to tune these parameters, run the JVM with VM options
-  // +PrintMiscellaneous and +WizardMode to see information about
-  // actual itable stubs.  Look for lines like this:
-  //   itable #1 at 0x5551212[116] left over: 8
-  // Reduce the constants so that the "left over" number is 8
-  // Do not aim at a left-over number of zero, because a very
-  // large vtable or itable offset (> 4K) will require an extra
-  // sethi/or pair of instructions.
-  //
-  // The JVM98 app. _202_jess has a megamorphic interface call.
-  // The itable code looks like this:
-  // Decoding VtableStub itbl[1]@16
-  //   ld  [ %o0 + 4 ], %g3
-  //   save  %sp, -64, %sp
-  //   ld  [ %g3 + 0xe8 ], %l2
-  //   sll  %l2, 2, %l2
-  //   add  %l2, 0x134, %l2
-  //   add  %g3, %l2, %l2
-  //   add  %g3, 4, %g3
-  //   ld  [ %l2 ], %l5
-  //   brz,pn   %l5, throw_icce
-  //   cmp  %l5, %g5
-  //   be  %icc, success
-  //   add  %l2, 8, %l2
-  // loop:
-  //   ld  [ %l2 ], %l5
-  //   brz,pn   %l5, throw_icce
-  //   cmp  %l5, %g5
-  //   bne,pn   %icc, loop
-  //   add  %l2, 8, %l2
-  // success:
-  //   ld  [ %l2 + -4 ], %l2
-  //   ld  [ %g3 + %l2 ], %l5
-  //   restore  %l5, 0, %g5
-  //   ld  [ %g5 + 0x44 ], %g3
-  //   jmp  %g3
-  //   nop
-  // throw_icce:
-  //   sethi  %hi(throw_ICCE_entry), %g3
-  //   ! 5 more instructions here, LP64_ONLY
-  //   jmp  %g3 + %lo(throw_ICCE_entry)
-  //   restore
-}
-
-
 int VtableStub::pd_code_alignment() {
   // UltraSPARC cache line size is 8 instructions:
   const unsigned int icache_line_size = 32;
--- a/src/hotspot/cpu/x86/assembler_x86.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/x86/assembler_x86.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -2041,7 +2041,7 @@
   }
 }
 
-void Assembler::jccb(Condition cc, Label& L) {
+void Assembler::jccb_0(Condition cc, Label& L, const char* file, int line) {
   if (L.is_bound()) {
     const int short_size = 2;
     address entry = target(L);
@@ -2051,7 +2051,7 @@
     if (delta != 0) {
       dist += (dist < 0 ? (-delta) :delta);
     }
-    assert(is8bit(dist), "Dispacement too large for a short jmp");
+    assert(is8bit(dist), "Dispacement too large for a short jmp at %s:%d", file, line);
 #endif
     intptr_t offs = (intptr_t)entry - (intptr_t)pc();
     // 0111 tttn #8-bit disp
@@ -2059,7 +2059,7 @@
     emit_int8((offs - short_size) & 0xFF);
   } else {
     InstructionMark im(this);
-    L.add_patch_at(code(), locator());
+    L.add_patch_at(code(), locator(), file, line);
     emit_int8(0x70 | cc);
     emit_int8(0);
   }
@@ -2114,7 +2114,7 @@
   emit_data(disp, rspec.reloc(), call32_operand);
 }
 
-void Assembler::jmpb(Label& L) {
+void Assembler::jmpb_0(Label& L, const char* file, int line) {
   if (L.is_bound()) {
     const int short_size = 2;
     address entry = target(L);
@@ -2125,14 +2125,14 @@
     if (delta != 0) {
       dist += (dist < 0 ? (-delta) :delta);
     }
-    assert(is8bit(dist), "Dispacement too large for a short jmp");
+    assert(is8bit(dist), "Dispacement too large for a short jmp at %s:%d", file, line);
 #endif
     intptr_t offs = entry - pc();
     emit_int8((unsigned char)0xEB);
     emit_int8((offs - short_size) & 0xFF);
   } else {
     InstructionMark im(this);
-    L.add_patch_at(code(), locator());
+    L.add_patch_at(code(), locator(), file, line);
     emit_int8((unsigned char)0xEB);
     emit_int8(0);
   }
--- a/src/hotspot/cpu/x86/assembler_x86.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/x86/assembler_x86.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1302,7 +1302,11 @@
   // WARNING: be very careful using this for forward jumps.  If the label is
   // not bound within an 8-bit offset of this instruction, a run-time error
   // will occur.
-  void jccb(Condition cc, Label& L);
+
+  // Use macro to record file and line number.
+  #define jccb(cc, L) jccb_0(cc, L, __FILE__, __LINE__)
+
+  void jccb_0(Condition cc, Label& L, const char* file, int line);
 
   void jmp(Address entry);    // pc <- entry
 
@@ -1315,7 +1319,11 @@
   // WARNING: be very careful using this for forward jumps.  If the label is
   // not bound within an 8-bit offset of this instruction, a run-time error
   // will occur.
-  void jmpb(Label& L);
+
+  // Use macro to record file and line number.
+  #define jmpb(L) jmpb_0(L, __FILE__, __LINE__)
+
+  void jmpb_0(Label& L, const char* file, int line);
 
   void ldmxcsr( Address src );
 
--- a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -3605,7 +3605,7 @@
     }
   } else {
     __ testptr(tmp, tmp);
-    __ jccb(Assembler::notZero, update);
+    __ jcc(Assembler::notZero, update);
     __ stop("unexpect null obj");
 #endif
   }
@@ -3620,7 +3620,7 @@
       __ push(tmp);
       __ mov_metadata(tmp, exact_klass->constant_encoding());
       __ cmpptr(tmp, Address(rsp, 0));
-      __ jccb(Assembler::equal, ok);
+      __ jcc(Assembler::equal, ok);
       __ stop("exact klass and actual klass differ");
       __ bind(ok);
       __ pop(tmp);
--- a/src/hotspot/cpu/x86/globals_x86.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/x86/globals_x86.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -119,7 +119,7 @@
   product(bool, UseStoreImmI16, true,                                       \
           "Use store immediate 16-bits value instruction on x86")           \
                                                                             \
-  product(intx, UseAVX, 3,                                                  \
+  product(intx, UseAVX, 2,                                                  \
           "Highest supported AVX instructions set on x86/x64")              \
           range(0, 99)                                                      \
                                                                             \
--- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1721,227 +1721,160 @@
   if (counters != NULL) {
     atomic_incl(ExternalAddress((address)counters->total_entry_count_addr()), scrReg);
   }
-  if (EmitSync & 1) {
-      // set box->dhw = markOopDesc::unused_mark()
-      // Force all sync thru slow-path: slow_enter() and slow_exit()
-      movptr (Address(boxReg, 0), (int32_t)intptr_t(markOopDesc::unused_mark()));
-      cmpptr (rsp, (int32_t)NULL_WORD);
-  } else {
-    // Possible cases that we'll encounter in fast_lock
-    // ------------------------------------------------
-    // * Inflated
-    //    -- unlocked
-    //    -- Locked
-    //       = by self
-    //       = by other
-    // * biased
-    //    -- by Self
-    //    -- by other
-    // * neutral
-    // * stack-locked
-    //    -- by self
-    //       = sp-proximity test hits
-    //       = sp-proximity test generates false-negative
-    //    -- by other
-    //
-
-    Label IsInflated, DONE_LABEL;
-
-    // it's stack-locked, biased or neutral
-    // TODO: optimize away redundant LDs of obj->mark and improve the markword triage
-    // order to reduce the number of conditional branches in the most common cases.
-    // Beware -- there's a subtle invariant that fetch of the markword
-    // at [FETCH], below, will never observe a biased encoding (*101b).
-    // If this invariant is not held we risk exclusion (safety) failure.
-    if (UseBiasedLocking && !UseOptoBiasInlining) {
-      biased_locking_enter(boxReg, objReg, tmpReg, scrReg, false, DONE_LABEL, NULL, counters);
-    }
+
+  // Possible cases that we'll encounter in fast_lock
+  // ------------------------------------------------
+  // * Inflated
+  //    -- unlocked
+  //    -- Locked
+  //       = by self
+  //       = by other
+  // * biased
+  //    -- by Self
+  //    -- by other
+  // * neutral
+  // * stack-locked
+  //    -- by self
+  //       = sp-proximity test hits
+  //       = sp-proximity test generates false-negative
+  //    -- by other
+  //
+
+  Label IsInflated, DONE_LABEL;
+
+  // it's stack-locked, biased or neutral
+  // TODO: optimize away redundant LDs of obj->mark and improve the markword triage
+  // order to reduce the number of conditional branches in the most common cases.
+  // Beware -- there's a subtle invariant that fetch of the markword
+  // at [FETCH], below, will never observe a biased encoding (*101b).
+  // If this invariant is not held we risk exclusion (safety) failure.
+  if (UseBiasedLocking && !UseOptoBiasInlining) {
+    biased_locking_enter(boxReg, objReg, tmpReg, scrReg, false, DONE_LABEL, NULL, counters);
+  }
 
 #if INCLUDE_RTM_OPT
-    if (UseRTMForStackLocks && use_rtm) {
-      rtm_stack_locking(objReg, tmpReg, scrReg, cx2Reg,
-                        stack_rtm_counters, method_data, profile_rtm,
-                        DONE_LABEL, IsInflated);
-    }
+  if (UseRTMForStackLocks && use_rtm) {
+    rtm_stack_locking(objReg, tmpReg, scrReg, cx2Reg,
+                      stack_rtm_counters, method_data, profile_rtm,
+                      DONE_LABEL, IsInflated);
+  }
 #endif // INCLUDE_RTM_OPT
 
-    movptr(tmpReg, Address(objReg, oopDesc::mark_offset_in_bytes()));          // [FETCH]
-    testptr(tmpReg, markOopDesc::monitor_value); // inflated vs stack-locked|neutral|biased
-    jccb(Assembler::notZero, IsInflated);
-
-    // Attempt stack-locking ...
-    orptr (tmpReg, markOopDesc::unlocked_value);
-    movptr(Address(boxReg, 0), tmpReg);          // Anticipate successful CAS
-    if (os::is_MP()) {
-      lock();
-    }
-    cmpxchgptr(boxReg, Address(objReg, oopDesc::mark_offset_in_bytes()));      // Updates tmpReg
-    if (counters != NULL) {
-      cond_inc32(Assembler::equal,
-                 ExternalAddress((address)counters->fast_path_entry_count_addr()));
-    }
-    jcc(Assembler::equal, DONE_LABEL);           // Success
-
-    // Recursive locking.
-    // The object is stack-locked: markword contains stack pointer to BasicLock.
-    // Locked by current thread if difference with current SP is less than one page.
-    subptr(tmpReg, rsp);
-    // Next instruction set ZFlag == 1 (Success) if difference is less then one page.
-    andptr(tmpReg, (int32_t) (NOT_LP64(0xFFFFF003) LP64_ONLY(7 - os::vm_page_size())) );
-    movptr(Address(boxReg, 0), tmpReg);
-    if (counters != NULL) {
-      cond_inc32(Assembler::equal,
-                 ExternalAddress((address)counters->fast_path_entry_count_addr()));
-    }
-    jmp(DONE_LABEL);
-
-    bind(IsInflated);
-    // The object is inflated. tmpReg contains pointer to ObjectMonitor* + markOopDesc::monitor_value
+  movptr(tmpReg, Address(objReg, oopDesc::mark_offset_in_bytes()));          // [FETCH]
+  testptr(tmpReg, markOopDesc::monitor_value); // inflated vs stack-locked|neutral|biased
+  jccb(Assembler::notZero, IsInflated);
+
+  // Attempt stack-locking ...
+  orptr (tmpReg, markOopDesc::unlocked_value);
+  movptr(Address(boxReg, 0), tmpReg);          // Anticipate successful CAS
+  if (os::is_MP()) {
+    lock();
+  }
+  cmpxchgptr(boxReg, Address(objReg, oopDesc::mark_offset_in_bytes()));      // Updates tmpReg
+  if (counters != NULL) {
+    cond_inc32(Assembler::equal,
+               ExternalAddress((address)counters->fast_path_entry_count_addr()));
+  }
+  jcc(Assembler::equal, DONE_LABEL);           // Success
+
+  // Recursive locking.
+  // The object is stack-locked: markword contains stack pointer to BasicLock.
+  // Locked by current thread if difference with current SP is less than one page.
+  subptr(tmpReg, rsp);
+  // Next instruction set ZFlag == 1 (Success) if difference is less then one page.
+  andptr(tmpReg, (int32_t) (NOT_LP64(0xFFFFF003) LP64_ONLY(7 - os::vm_page_size())) );
+  movptr(Address(boxReg, 0), tmpReg);
+  if (counters != NULL) {
+    cond_inc32(Assembler::equal,
+               ExternalAddress((address)counters->fast_path_entry_count_addr()));
+  }
+  jmp(DONE_LABEL);
+
+  bind(IsInflated);
+  // The object is inflated. tmpReg contains pointer to ObjectMonitor* + markOopDesc::monitor_value
 
 #if INCLUDE_RTM_OPT
-    // Use the same RTM locking code in 32- and 64-bit VM.
-    if (use_rtm) {
-      rtm_inflated_locking(objReg, boxReg, tmpReg, scrReg, cx1Reg, cx2Reg,
-                           rtm_counters, method_data, profile_rtm, DONE_LABEL);
-    } else {
+  // Use the same RTM locking code in 32- and 64-bit VM.
+  if (use_rtm) {
+    rtm_inflated_locking(objReg, boxReg, tmpReg, scrReg, cx1Reg, cx2Reg,
+                         rtm_counters, method_data, profile_rtm, DONE_LABEL);
+  } else {
 #endif // INCLUDE_RTM_OPT
 
 #ifndef _LP64
-    // The object is inflated.
-
-    // boxReg refers to the on-stack BasicLock in the current frame.
-    // We'd like to write:
-    //   set box->_displaced_header = markOopDesc::unused_mark().  Any non-0 value suffices.
-    // This is convenient but results a ST-before-CAS penalty.  The following CAS suffers
-    // additional latency as we have another ST in the store buffer that must drain.
-
-    if (EmitSync & 8192) {
-       movptr(Address(boxReg, 0), 3);            // results in ST-before-CAS penalty
-       get_thread (scrReg);
-       movptr(boxReg, tmpReg);                    // consider: LEA box, [tmp-2]
-       movptr(tmpReg, NULL_WORD);                 // consider: xor vs mov
-       if (os::is_MP()) {
-         lock();
-       }
-       cmpxchgptr(scrReg, Address(boxReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-    } else
-    if ((EmitSync & 128) == 0) {                      // avoid ST-before-CAS
-       // register juggle because we need tmpReg for cmpxchgptr below
-       movptr(scrReg, boxReg);
-       movptr(boxReg, tmpReg);                   // consider: LEA box, [tmp-2]
-
-       // Using a prefetchw helps avoid later RTS->RTO upgrades and cache probes
-       if ((EmitSync & 2048) && VM_Version::supports_3dnow_prefetch() && os::is_MP()) {
-          // prefetchw [eax + Offset(_owner)-2]
-          prefetchw(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-       }
-
-       if ((EmitSync & 64) == 0) {
-         // Optimistic form: consider XORL tmpReg,tmpReg
-         movptr(tmpReg, NULL_WORD);
-       } else {
-         // Can suffer RTS->RTO upgrades on shared or cold $ lines
-         // Test-And-CAS instead of CAS
-         movptr(tmpReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));   // rax, = m->_owner
-         testptr(tmpReg, tmpReg);                   // Locked ?
-         jccb  (Assembler::notZero, DONE_LABEL);
-       }
-
-       // Appears unlocked - try to swing _owner from null to non-null.
-       // Ideally, I'd manifest "Self" with get_thread and then attempt
-       // to CAS the register containing Self into m->Owner.
-       // But we don't have enough registers, so instead we can either try to CAS
-       // rsp or the address of the box (in scr) into &m->owner.  If the CAS succeeds
-       // we later store "Self" into m->Owner.  Transiently storing a stack address
-       // (rsp or the address of the box) into  m->owner is harmless.
-       // Invariant: tmpReg == 0.  tmpReg is EAX which is the implicit cmpxchg comparand.
-       if (os::is_MP()) {
-         lock();
-       }
-       cmpxchgptr(scrReg, Address(boxReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-       movptr(Address(scrReg, 0), 3);          // box->_displaced_header = 3
-       // If we weren't able to swing _owner from NULL to the BasicLock
-       // then take the slow path.
-       jccb  (Assembler::notZero, DONE_LABEL);
-       // update _owner from BasicLock to thread
-       get_thread (scrReg);                    // beware: clobbers ICCs
-       movptr(Address(boxReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), scrReg);
-       xorptr(boxReg, boxReg);                 // set icc.ZFlag = 1 to indicate success
-
-       // If the CAS fails we can either retry or pass control to the slow-path.
-       // We use the latter tactic.
-       // Pass the CAS result in the icc.ZFlag into DONE_LABEL
-       // If the CAS was successful ...
-       //   Self has acquired the lock
-       //   Invariant: m->_recursions should already be 0, so we don't need to explicitly set it.
-       // Intentional fall-through into DONE_LABEL ...
-    } else {
-       movptr(Address(boxReg, 0), intptr_t(markOopDesc::unused_mark()));  // results in ST-before-CAS penalty
-       movptr(boxReg, tmpReg);
-
-       // Using a prefetchw helps avoid later RTS->RTO upgrades and cache probes
-       if ((EmitSync & 2048) && VM_Version::supports_3dnow_prefetch() && os::is_MP()) {
-          // prefetchw [eax + Offset(_owner)-2]
-          prefetchw(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-       }
-
-       if ((EmitSync & 64) == 0) {
-         // Optimistic form
-         xorptr  (tmpReg, tmpReg);
-       } else {
-         // Can suffer RTS->RTO upgrades on shared or cold $ lines
-         movptr(tmpReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));   // rax, = m->_owner
-         testptr(tmpReg, tmpReg);                   // Locked ?
-         jccb  (Assembler::notZero, DONE_LABEL);
-       }
-
-       // Appears unlocked - try to swing _owner from null to non-null.
-       // Use either "Self" (in scr) or rsp as thread identity in _owner.
-       // Invariant: tmpReg == 0.  tmpReg is EAX which is the implicit cmpxchg comparand.
-       get_thread (scrReg);
-       if (os::is_MP()) {
-         lock();
-       }
-       cmpxchgptr(scrReg, Address(boxReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-
-       // If the CAS fails we can either retry or pass control to the slow-path.
-       // We use the latter tactic.
-       // Pass the CAS result in the icc.ZFlag into DONE_LABEL
-       // If the CAS was successful ...
-       //   Self has acquired the lock
-       //   Invariant: m->_recursions should already be 0, so we don't need to explicitly set it.
-       // Intentional fall-through into DONE_LABEL ...
-    }
+  // The object is inflated.
+
+  // boxReg refers to the on-stack BasicLock in the current frame.
+  // We'd like to write:
+  //   set box->_displaced_header = markOopDesc::unused_mark().  Any non-0 value suffices.
+  // This is convenient but results a ST-before-CAS penalty.  The following CAS suffers
+  // additional latency as we have another ST in the store buffer that must drain.
+
+  // avoid ST-before-CAS
+  // register juggle because we need tmpReg for cmpxchgptr below
+  movptr(scrReg, boxReg);
+  movptr(boxReg, tmpReg);                   // consider: LEA box, [tmp-2]
+
+  // Optimistic form: consider XORL tmpReg,tmpReg
+  movptr(tmpReg, NULL_WORD);
+
+  // Appears unlocked - try to swing _owner from null to non-null.
+  // Ideally, I'd manifest "Self" with get_thread and then attempt
+  // to CAS the register containing Self into m->Owner.
+  // But we don't have enough registers, so instead we can either try to CAS
+  // rsp or the address of the box (in scr) into &m->owner.  If the CAS succeeds
+  // we later store "Self" into m->Owner.  Transiently storing a stack address
+  // (rsp or the address of the box) into  m->owner is harmless.
+  // Invariant: tmpReg == 0.  tmpReg is EAX which is the implicit cmpxchg comparand.
+  if (os::is_MP()) {
+    lock();
+  }
+  cmpxchgptr(scrReg, Address(boxReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
+  movptr(Address(scrReg, 0), 3);          // box->_displaced_header = 3
+  // If we weren't able to swing _owner from NULL to the BasicLock
+  // then take the slow path.
+  jccb  (Assembler::notZero, DONE_LABEL);
+  // update _owner from BasicLock to thread
+  get_thread (scrReg);                    // beware: clobbers ICCs
+  movptr(Address(boxReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), scrReg);
+  xorptr(boxReg, boxReg);                 // set icc.ZFlag = 1 to indicate success
+
+  // If the CAS fails we can either retry or pass control to the slow-path.
+  // We use the latter tactic.
+  // Pass the CAS result in the icc.ZFlag into DONE_LABEL
+  // If the CAS was successful ...
+  //   Self has acquired the lock
+  //   Invariant: m->_recursions should already be 0, so we don't need to explicitly set it.
+  // Intentional fall-through into DONE_LABEL ...
 #else // _LP64
-    // It's inflated
-    movq(scrReg, tmpReg);
-    xorq(tmpReg, tmpReg);
-
-    if (os::is_MP()) {
-      lock();
-    }
-    cmpxchgptr(r15_thread, Address(scrReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-    // Unconditionally set box->_displaced_header = markOopDesc::unused_mark().
-    // Without cast to int32_t movptr will destroy r10 which is typically obj.
-    movptr(Address(boxReg, 0), (int32_t)intptr_t(markOopDesc::unused_mark()));
-    // Intentional fall-through into DONE_LABEL ...
-    // Propagate ICC.ZF from CAS above into DONE_LABEL.
+  // It's inflated
+  movq(scrReg, tmpReg);
+  xorq(tmpReg, tmpReg);
+
+  if (os::is_MP()) {
+    lock();
+  }
+  cmpxchgptr(r15_thread, Address(scrReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
+  // Unconditionally set box->_displaced_header = markOopDesc::unused_mark().
+  // Without cast to int32_t movptr will destroy r10 which is typically obj.
+  movptr(Address(boxReg, 0), (int32_t)intptr_t(markOopDesc::unused_mark()));
+  // Intentional fall-through into DONE_LABEL ...
+  // Propagate ICC.ZF from CAS above into DONE_LABEL.
 #endif // _LP64
 #if INCLUDE_RTM_OPT
-    } // use_rtm()
+  } // use_rtm()
 #endif
-    // DONE_LABEL is a hot target - we'd really like to place it at the
-    // start of cache line by padding with NOPs.
-    // See the AMD and Intel software optimization manuals for the
-    // most efficient "long" NOP encodings.
-    // Unfortunately none of our alignment mechanisms suffice.
-    bind(DONE_LABEL);
-
-    // At DONE_LABEL the icc ZFlag is set as follows ...
-    // Fast_Unlock uses the same protocol.
-    // ZFlag == 1 -> Success
-    // ZFlag == 0 -> Failure - force control through the slow-path
-  }
+  // DONE_LABEL is a hot target - we'd really like to place it at the
+  // start of cache line by padding with NOPs.
+  // See the AMD and Intel software optimization manuals for the
+  // most efficient "long" NOP encodings.
+  // Unfortunately none of our alignment mechanisms suffice.
+  bind(DONE_LABEL);
+
+  // At DONE_LABEL the icc ZFlag is set as follows ...
+  // Fast_Unlock uses the same protocol.
+  // ZFlag == 1 -> Success
+  // ZFlag == 0 -> Failure - force control through the slow-path
 }
 
 // obj: object to unlock
@@ -1980,293 +1913,179 @@
   assert(boxReg == rax, "");
   assert_different_registers(objReg, boxReg, tmpReg);
 
-  if (EmitSync & 4) {
-    // Disable - inhibit all inlining.  Force control through the slow-path
-    cmpptr (rsp, 0);
-  } else {
-    Label DONE_LABEL, Stacked, CheckSucc;
-
-    // Critically, the biased locking test must have precedence over
-    // and appear before the (box->dhw == 0) recursive stack-lock test.
-    if (UseBiasedLocking && !UseOptoBiasInlining) {
-       biased_locking_exit(objReg, tmpReg, DONE_LABEL);
-    }
+  Label DONE_LABEL, Stacked, CheckSucc;
+
+  // Critically, the biased locking test must have precedence over
+  // and appear before the (box->dhw == 0) recursive stack-lock test.
+  if (UseBiasedLocking && !UseOptoBiasInlining) {
+    biased_locking_exit(objReg, tmpReg, DONE_LABEL);
+  }
 
 #if INCLUDE_RTM_OPT
-    if (UseRTMForStackLocks && use_rtm) {
-      assert(!UseBiasedLocking, "Biased locking is not supported with RTM locking");
-      Label L_regular_unlock;
-      movptr(tmpReg, Address(objReg, oopDesc::mark_offset_in_bytes()));           // fetch markword
-      andptr(tmpReg, markOopDesc::biased_lock_mask_in_place); // look at 3 lock bits
-      cmpptr(tmpReg, markOopDesc::unlocked_value);            // bits = 001 unlocked
-      jccb(Assembler::notEqual, L_regular_unlock);  // if !HLE RegularLock
-      xend();                                       // otherwise end...
-      jmp(DONE_LABEL);                              // ... and we're done
-      bind(L_regular_unlock);
-    }
+  if (UseRTMForStackLocks && use_rtm) {
+    assert(!UseBiasedLocking, "Biased locking is not supported with RTM locking");
+    Label L_regular_unlock;
+    movptr(tmpReg, Address(objReg, oopDesc::mark_offset_in_bytes()));           // fetch markword
+    andptr(tmpReg, markOopDesc::biased_lock_mask_in_place); // look at 3 lock bits
+    cmpptr(tmpReg, markOopDesc::unlocked_value);            // bits = 001 unlocked
+    jccb(Assembler::notEqual, L_regular_unlock);  // if !HLE RegularLock
+    xend();                                       // otherwise end...
+    jmp(DONE_LABEL);                              // ... and we're done
+    bind(L_regular_unlock);
+  }
 #endif
 
-    cmpptr(Address(boxReg, 0), (int32_t)NULL_WORD); // Examine the displaced header
-    jcc   (Assembler::zero, DONE_LABEL);            // 0 indicates recursive stack-lock
-    movptr(tmpReg, Address(objReg, oopDesc::mark_offset_in_bytes()));             // Examine the object's markword
-    testptr(tmpReg, markOopDesc::monitor_value);    // Inflated?
-    jccb  (Assembler::zero, Stacked);
-
-    // It's inflated.
+  cmpptr(Address(boxReg, 0), (int32_t)NULL_WORD); // Examine the displaced header
+  jcc   (Assembler::zero, DONE_LABEL);            // 0 indicates recursive stack-lock
+  movptr(tmpReg, Address(objReg, oopDesc::mark_offset_in_bytes()));             // Examine the object's markword
+  testptr(tmpReg, markOopDesc::monitor_value);    // Inflated?
+  jccb  (Assembler::zero, Stacked);
+
+  // It's inflated.
 #if INCLUDE_RTM_OPT
-    if (use_rtm) {
-      Label L_regular_inflated_unlock;
-      int owner_offset = OM_OFFSET_NO_MONITOR_VALUE_TAG(owner);
-      movptr(boxReg, Address(tmpReg, owner_offset));
-      testptr(boxReg, boxReg);
-      jccb(Assembler::notZero, L_regular_inflated_unlock);
-      xend();
-      jmpb(DONE_LABEL);
-      bind(L_regular_inflated_unlock);
-    }
+  if (use_rtm) {
+    Label L_regular_inflated_unlock;
+    int owner_offset = OM_OFFSET_NO_MONITOR_VALUE_TAG(owner);
+    movptr(boxReg, Address(tmpReg, owner_offset));
+    testptr(boxReg, boxReg);
+    jccb(Assembler::notZero, L_regular_inflated_unlock);
+    xend();
+    jmpb(DONE_LABEL);
+    bind(L_regular_inflated_unlock);
+  }
 #endif
 
-    // Despite our balanced locking property we still check that m->_owner == Self
-    // as java routines or native JNI code called by this thread might
-    // have released the lock.
-    // Refer to the comments in synchronizer.cpp for how we might encode extra
-    // state in _succ so we can avoid fetching EntryList|cxq.
-    //
-    // I'd like to add more cases in fast_lock() and fast_unlock() --
-    // such as recursive enter and exit -- but we have to be wary of
-    // I$ bloat, T$ effects and BP$ effects.
-    //
-    // If there's no contention try a 1-0 exit.  That is, exit without
-    // a costly MEMBAR or CAS.  See synchronizer.cpp for details on how
-    // we detect and recover from the race that the 1-0 exit admits.
-    //
-    // Conceptually Fast_Unlock() must execute a STST|LDST "release" barrier
-    // before it STs null into _owner, releasing the lock.  Updates
-    // to data protected by the critical section must be visible before
-    // we drop the lock (and thus before any other thread could acquire
-    // the lock and observe the fields protected by the lock).
-    // IA32's memory-model is SPO, so STs are ordered with respect to
-    // each other and there's no need for an explicit barrier (fence).
-    // See also http://gee.cs.oswego.edu/dl/jmm/cookbook.html.
+  // Despite our balanced locking property we still check that m->_owner == Self
+  // as java routines or native JNI code called by this thread might
+  // have released the lock.
+  // Refer to the comments in synchronizer.cpp for how we might encode extra
+  // state in _succ so we can avoid fetching EntryList|cxq.
+  //
+  // I'd like to add more cases in fast_lock() and fast_unlock() --
+  // such as recursive enter and exit -- but we have to be wary of
+  // I$ bloat, T$ effects and BP$ effects.
+  //
+  // If there's no contention try a 1-0 exit.  That is, exit without
+  // a costly MEMBAR or CAS.  See synchronizer.cpp for details on how
+  // we detect and recover from the race that the 1-0 exit admits.
+  //
+  // Conceptually Fast_Unlock() must execute a STST|LDST "release" barrier
+  // before it STs null into _owner, releasing the lock.  Updates
+  // to data protected by the critical section must be visible before
+  // we drop the lock (and thus before any other thread could acquire
+  // the lock and observe the fields protected by the lock).
+  // IA32's memory-model is SPO, so STs are ordered with respect to
+  // each other and there's no need for an explicit barrier (fence).
+  // See also http://gee.cs.oswego.edu/dl/jmm/cookbook.html.
 #ifndef _LP64
-    get_thread (boxReg);
-    if ((EmitSync & 4096) && VM_Version::supports_3dnow_prefetch() && os::is_MP()) {
-      // prefetchw [ebx + Offset(_owner)-2]
-      prefetchw(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-    }
-
-    // Note that we could employ various encoding schemes to reduce
-    // the number of loads below (currently 4) to just 2 or 3.
-    // Refer to the comments in synchronizer.cpp.
-    // In practice the chain of fetches doesn't seem to impact performance, however.
-    xorptr(boxReg, boxReg);
-    if ((EmitSync & 65536) == 0 && (EmitSync & 256)) {
-       // Attempt to reduce branch density - AMD's branch predictor.
-       orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)));
-       orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList)));
-       orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq)));
-       jccb  (Assembler::notZero, DONE_LABEL);
-       movptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), NULL_WORD);
-       jmpb  (DONE_LABEL);
-    } else {
-       orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)));
-       jccb  (Assembler::notZero, DONE_LABEL);
-       movptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList)));
-       orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq)));
-       jccb  (Assembler::notZero, CheckSucc);
-       movptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), NULL_WORD);
-       jmpb  (DONE_LABEL);
-    }
-
-    // The Following code fragment (EmitSync & 65536) improves the performance of
-    // contended applications and contended synchronization microbenchmarks.
-    // Unfortunately the emission of the code - even though not executed - causes regressions
-    // in scimark and jetstream, evidently because of $ effects.  Replacing the code
-    // with an equal number of never-executed NOPs results in the same regression.
-    // We leave it off by default.
-
-    if ((EmitSync & 65536) != 0) {
-       Label LSuccess, LGoSlowPath ;
-
-       bind  (CheckSucc);
-
-       // Optional pre-test ... it's safe to elide this
-       cmpptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)), (int32_t)NULL_WORD);
-       jccb(Assembler::zero, LGoSlowPath);
-
-       // We have a classic Dekker-style idiom:
-       //    ST m->_owner = 0 ; MEMBAR; LD m->_succ
-       // There are a number of ways to implement the barrier:
-       // (1) lock:andl &m->_owner, 0
-       //     is fast, but mask doesn't currently support the "ANDL M,IMM32" form.
-       //     LOCK: ANDL [ebx+Offset(_Owner)-2], 0
-       //     Encodes as 81 31 OFF32 IMM32 or 83 63 OFF8 IMM8
-       // (2) If supported, an explicit MFENCE is appealing.
-       //     In older IA32 processors MFENCE is slower than lock:add or xchg
-       //     particularly if the write-buffer is full as might be the case if
-       //     if stores closely precede the fence or fence-equivalent instruction.
-       //     See https://blogs.oracle.com/dave/entry/instruction_selection_for_volatile_fences
-       //     as the situation has changed with Nehalem and Shanghai.
-       // (3) In lieu of an explicit fence, use lock:addl to the top-of-stack
-       //     The $lines underlying the top-of-stack should be in M-state.
-       //     The locked add instruction is serializing, of course.
-       // (4) Use xchg, which is serializing
-       //     mov boxReg, 0; xchgl boxReg, [tmpReg + Offset(_owner)-2] also works
-       // (5) ST m->_owner = 0 and then execute lock:orl &m->_succ, 0.
-       //     The integer condition codes will tell us if succ was 0.
-       //     Since _succ and _owner should reside in the same $line and
-       //     we just stored into _owner, it's likely that the $line
-       //     remains in M-state for the lock:orl.
-       //
-       // We currently use (3), although it's likely that switching to (2)
-       // is correct for the future.
-
-       movptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), NULL_WORD);
-       if (os::is_MP()) {
-         lock(); addptr(Address(rsp, 0), 0);
-       }
-       // Ratify _succ remains non-null
-       cmpptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)), 0);
-       jccb  (Assembler::notZero, LSuccess);
-
-       xorptr(boxReg, boxReg);                  // box is really EAX
-       if (os::is_MP()) { lock(); }
-       cmpxchgptr(rsp, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-       // There's no successor so we tried to regrab the lock with the
-       // placeholder value. If that didn't work, then another thread
-       // grabbed the lock so we're done (and exit was a success).
-       jccb  (Assembler::notEqual, LSuccess);
-       // Since we're low on registers we installed rsp as a placeholding in _owner.
-       // Now install Self over rsp.  This is safe as we're transitioning from
-       // non-null to non=null
-       get_thread (boxReg);
-       movptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), boxReg);
-       // Intentional fall-through into LGoSlowPath ...
-
-       bind  (LGoSlowPath);
-       orptr(boxReg, 1);                      // set ICC.ZF=0 to indicate failure
-       jmpb  (DONE_LABEL);
-
-       bind  (LSuccess);
-       xorptr(boxReg, boxReg);                 // set ICC.ZF=1 to indicate success
-       jmpb  (DONE_LABEL);
-    }
-
-    bind (Stacked);
-    // It's not inflated and it's not recursively stack-locked and it's not biased.
-    // It must be stack-locked.
-    // Try to reset the header to displaced header.
-    // The "box" value on the stack is stable, so we can reload
-    // and be assured we observe the same value as above.
-    movptr(tmpReg, Address(boxReg, 0));
-    if (os::is_MP()) {
-      lock();
-    }
-    cmpxchgptr(tmpReg, Address(objReg, oopDesc::mark_offset_in_bytes())); // Uses RAX which is box
-    // Intention fall-thru into DONE_LABEL
-
-    // DONE_LABEL is a hot target - we'd really like to place it at the
-    // start of cache line by padding with NOPs.
-    // See the AMD and Intel software optimization manuals for the
-    // most efficient "long" NOP encodings.
-    // Unfortunately none of our alignment mechanisms suffice.
-    if ((EmitSync & 65536) == 0) {
-       bind (CheckSucc);
-    }
+  get_thread (boxReg);
+
+  // Note that we could employ various encoding schemes to reduce
+  // the number of loads below (currently 4) to just 2 or 3.
+  // Refer to the comments in synchronizer.cpp.
+  // In practice the chain of fetches doesn't seem to impact performance, however.
+  xorptr(boxReg, boxReg);
+  orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)));
+  jccb  (Assembler::notZero, DONE_LABEL);
+  movptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList)));
+  orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq)));
+  jccb  (Assembler::notZero, CheckSucc);
+  movptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), NULL_WORD);
+  jmpb  (DONE_LABEL);
+
+  bind (Stacked);
+  // It's not inflated and it's not recursively stack-locked and it's not biased.
+  // It must be stack-locked.
+  // Try to reset the header to displaced header.
+  // The "box" value on the stack is stable, so we can reload
+  // and be assured we observe the same value as above.
+  movptr(tmpReg, Address(boxReg, 0));
+  if (os::is_MP()) {
+    lock();
+  }
+  cmpxchgptr(tmpReg, Address(objReg, oopDesc::mark_offset_in_bytes())); // Uses RAX which is box
+  // Intention fall-thru into DONE_LABEL
+
+  // DONE_LABEL is a hot target - we'd really like to place it at the
+  // start of cache line by padding with NOPs.
+  // See the AMD and Intel software optimization manuals for the
+  // most efficient "long" NOP encodings.
+  // Unfortunately none of our alignment mechanisms suffice.
+  bind (CheckSucc);
 #else // _LP64
-    // It's inflated
-    if (EmitSync & 1024) {
-      // Emit code to check that _owner == Self
-      // We could fold the _owner test into subsequent code more efficiently
-      // than using a stand-alone check, but since _owner checking is off by
-      // default we don't bother. We also might consider predicating the
-      // _owner==Self check on Xcheck:jni or running on a debug build.
-      movptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-      xorptr(boxReg, r15_thread);
-    } else {
-      xorptr(boxReg, boxReg);
-    }
-    orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)));
-    jccb  (Assembler::notZero, DONE_LABEL);
-    movptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq)));
-    orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList)));
-    jccb  (Assembler::notZero, CheckSucc);
-    movptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), (int32_t)NULL_WORD);
-    jmpb  (DONE_LABEL);
-
-    if ((EmitSync & 65536) == 0) {
-      // Try to avoid passing control into the slow_path ...
-      Label LSuccess, LGoSlowPath ;
-      bind  (CheckSucc);
-
-      // The following optional optimization can be elided if necessary
-      // Effectively: if (succ == null) goto SlowPath
-      // The code reduces the window for a race, however,
-      // and thus benefits performance.
-      cmpptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)), (int32_t)NULL_WORD);
-      jccb  (Assembler::zero, LGoSlowPath);
-
-      xorptr(boxReg, boxReg);
-      if ((EmitSync & 16) && os::is_MP()) {
-        xchgptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-      } else {
-        movptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), (int32_t)NULL_WORD);
-        if (os::is_MP()) {
-          // Memory barrier/fence
-          // Dekker pivot point -- fulcrum : ST Owner; MEMBAR; LD Succ
-          // Instead of MFENCE we use a dummy locked add of 0 to the top-of-stack.
-          // This is faster on Nehalem and AMD Shanghai/Barcelona.
-          // See https://blogs.oracle.com/dave/entry/instruction_selection_for_volatile_fences
-          // We might also restructure (ST Owner=0;barrier;LD _Succ) to
-          // (mov box,0; xchgq box, &m->Owner; LD _succ) .
-          lock(); addl(Address(rsp, 0), 0);
-        }
-      }
-      cmpptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)), (int32_t)NULL_WORD);
-      jccb  (Assembler::notZero, LSuccess);
-
-      // Rare inopportune interleaving - race.
-      // The successor vanished in the small window above.
-      // The lock is contended -- (cxq|EntryList) != null -- and there's no apparent successor.
-      // We need to ensure progress and succession.
-      // Try to reacquire the lock.
-      // If that fails then the new owner is responsible for succession and this
-      // thread needs to take no further action and can exit via the fast path (success).
-      // If the re-acquire succeeds then pass control into the slow path.
-      // As implemented, this latter mode is horrible because we generated more
-      // coherence traffic on the lock *and* artifically extended the critical section
-      // length while by virtue of passing control into the slow path.
-
-      // box is really RAX -- the following CMPXCHG depends on that binding
-      // cmpxchg R,[M] is equivalent to rax = CAS(M,rax,R)
-      if (os::is_MP()) { lock(); }
-      cmpxchgptr(r15_thread, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
-      // There's no successor so we tried to regrab the lock.
-      // If that didn't work, then another thread grabbed the
-      // lock so we're done (and exit was a success).
-      jccb  (Assembler::notEqual, LSuccess);
-      // Intentional fall-through into slow-path
-
-      bind  (LGoSlowPath);
-      orl   (boxReg, 1);                      // set ICC.ZF=0 to indicate failure
-      jmpb  (DONE_LABEL);
-
-      bind  (LSuccess);
-      testl (boxReg, 0);                      // set ICC.ZF=1 to indicate success
-      jmpb  (DONE_LABEL);
-    }
-
-    bind  (Stacked);
-    movptr(tmpReg, Address (boxReg, 0));      // re-fetch
-    if (os::is_MP()) { lock(); }
-    cmpxchgptr(tmpReg, Address(objReg, oopDesc::mark_offset_in_bytes())); // Uses RAX which is box
-
-    if (EmitSync & 65536) {
-       bind (CheckSucc);
-    }
+  // It's inflated
+  xorptr(boxReg, boxReg);
+  orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)));
+  jccb  (Assembler::notZero, DONE_LABEL);
+  movptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq)));
+  orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList)));
+  jccb  (Assembler::notZero, CheckSucc);
+  movptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), (int32_t)NULL_WORD);
+  jmpb  (DONE_LABEL);
+
+  // Try to avoid passing control into the slow_path ...
+  Label LSuccess, LGoSlowPath ;
+  bind  (CheckSucc);
+
+  // The following optional optimization can be elided if necessary
+  // Effectively: if (succ == null) goto SlowPath
+  // The code reduces the window for a race, however,
+  // and thus benefits performance.
+  cmpptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)), (int32_t)NULL_WORD);
+  jccb  (Assembler::zero, LGoSlowPath);
+
+  xorptr(boxReg, boxReg);
+  movptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), (int32_t)NULL_WORD);
+  if (os::is_MP()) {
+    // Memory barrier/fence
+    // Dekker pivot point -- fulcrum : ST Owner; MEMBAR; LD Succ
+    // Instead of MFENCE we use a dummy locked add of 0 to the top-of-stack.
+    // This is faster on Nehalem and AMD Shanghai/Barcelona.
+    // See https://blogs.oracle.com/dave/entry/instruction_selection_for_volatile_fences
+    // We might also restructure (ST Owner=0;barrier;LD _Succ) to
+    // (mov box,0; xchgq box, &m->Owner; LD _succ) .
+    lock(); addl(Address(rsp, 0), 0);
+  }
+  cmpptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)), (int32_t)NULL_WORD);
+  jccb  (Assembler::notZero, LSuccess);
+
+  // Rare inopportune interleaving - race.
+  // The successor vanished in the small window above.
+  // The lock is contended -- (cxq|EntryList) != null -- and there's no apparent successor.
+  // We need to ensure progress and succession.
+  // Try to reacquire the lock.
+  // If that fails then the new owner is responsible for succession and this
+  // thread needs to take no further action and can exit via the fast path (success).
+  // If the re-acquire succeeds then pass control into the slow path.
+  // As implemented, this latter mode is horrible because we generated more
+  // coherence traffic on the lock *and* artifically extended the critical section
+  // length while by virtue of passing control into the slow path.
+
+  // box is really RAX -- the following CMPXCHG depends on that binding
+  // cmpxchg R,[M] is equivalent to rax = CAS(M,rax,R)
+  if (os::is_MP()) { lock(); }
+  cmpxchgptr(r15_thread, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
+  // There's no successor so we tried to regrab the lock.
+  // If that didn't work, then another thread grabbed the
+  // lock so we're done (and exit was a success).
+  jccb  (Assembler::notEqual, LSuccess);
+  // Intentional fall-through into slow-path
+
+  bind  (LGoSlowPath);
+  orl   (boxReg, 1);                      // set ICC.ZF=0 to indicate failure
+  jmpb  (DONE_LABEL);
+
+  bind  (LSuccess);
+  testl (boxReg, 0);                      // set ICC.ZF=1 to indicate success
+  jmpb  (DONE_LABEL);
+
+  bind  (Stacked);
+  movptr(tmpReg, Address (boxReg, 0));      // re-fetch
+  if (os::is_MP()) { lock(); }
+  cmpxchgptr(tmpReg, Address(objReg, oopDesc::mark_offset_in_bytes())); // Uses RAX which is box
+
 #endif
-    bind(DONE_LABEL);
-  }
+  bind(DONE_LABEL);
 }
 #endif // COMPILER2
 
@@ -4166,19 +3985,22 @@
   if ((dst_enc < 16) && (nds_enc < 16)) {
     vandps(dst, nds, negate_field, vector_len);
   } else if ((src_enc < 16) && (dst_enc < 16)) {
+    // Use src scratch register
     evmovdqul(src, nds, Assembler::AVX_512bit);
     vandps(dst, src, negate_field, vector_len);
+  } else if (dst_enc < 16) {
+    evmovdqul(dst, nds, Assembler::AVX_512bit);
+    vandps(dst, dst, negate_field, vector_len);
+  } else if (nds_enc < 16) {
+    vandps(nds, nds, negate_field, vector_len);
+    evmovdqul(dst, nds, Assembler::AVX_512bit);
   } else if (src_enc < 16) {
     evmovdqul(src, nds, Assembler::AVX_512bit);
     vandps(src, src, negate_field, vector_len);
     evmovdqul(dst, src, Assembler::AVX_512bit);
-  } else if (dst_enc < 16) {
-    evmovdqul(src, xmm0, Assembler::AVX_512bit);
-    evmovdqul(xmm0, nds, Assembler::AVX_512bit);
-    vandps(dst, xmm0, negate_field, vector_len);
-    evmovdqul(xmm0, src, Assembler::AVX_512bit);
   } else {
     if (src_enc != dst_enc) {
+      // Use src scratch register
       evmovdqul(src, xmm0, Assembler::AVX_512bit);
       evmovdqul(xmm0, nds, Assembler::AVX_512bit);
       vandps(xmm0, xmm0, negate_field, vector_len);
@@ -4201,17 +4023,19 @@
   if ((dst_enc < 16) && (nds_enc < 16)) {
     vandpd(dst, nds, negate_field, vector_len);
   } else if ((src_enc < 16) && (dst_enc < 16)) {
+    // Use src scratch register
     evmovdqul(src, nds, Assembler::AVX_512bit);
     vandpd(dst, src, negate_field, vector_len);
+  } else if (dst_enc < 16) {
+    evmovdqul(dst, nds, Assembler::AVX_512bit);
+    vandpd(dst, dst, negate_field, vector_len);
+  } else if (nds_enc < 16) {
+    vandpd(nds, nds, negate_field, vector_len);
+    evmovdqul(dst, nds, Assembler::AVX_512bit);
   } else if (src_enc < 16) {
     evmovdqul(src, nds, Assembler::AVX_512bit);
     vandpd(src, src, negate_field, vector_len);
     evmovdqul(dst, src, Assembler::AVX_512bit);
-  } else if (dst_enc < 16) {
-    evmovdqul(src, xmm0, Assembler::AVX_512bit);
-    evmovdqul(xmm0, nds, Assembler::AVX_512bit);
-    vandpd(dst, xmm0, negate_field, vector_len);
-    evmovdqul(xmm0, src, Assembler::AVX_512bit);
   } else {
     if (src_enc != dst_enc) {
       evmovdqul(src, xmm0, Assembler::AVX_512bit);
@@ -4282,6 +4106,7 @@
     evmovdqul(nds, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, dst, Assembler::AVX_512bit);
     Assembler::vpaddb(xmm0, xmm0, src, vector_len);
+    evmovdqul(dst, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, nds, Assembler::AVX_512bit);
   }
 }
@@ -4330,7 +4155,7 @@
   } else if (dst_enc < 16) {
     Assembler::vpaddw(dst, dst, src, vector_len);
   } else if (nds_enc < 16) {
-    // implies dst_enc in upper bank with src as scratch
+    // implies dst_enc in upper bank with nds as scratch
     evmovdqul(nds, dst, Assembler::AVX_512bit);
     Assembler::vpaddw(nds, nds, src, vector_len);
     evmovdqul(dst, nds, Assembler::AVX_512bit);
@@ -4339,6 +4164,7 @@
     evmovdqul(nds, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, dst, Assembler::AVX_512bit);
     Assembler::vpaddw(xmm0, xmm0, src, vector_len);
+    evmovdqul(dst, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, nds, Assembler::AVX_512bit);
   }
 }
@@ -4522,6 +4348,7 @@
     evmovdqul(nds, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, dst, Assembler::AVX_512bit);
     Assembler::vpmullw(xmm0, xmm0, src, vector_len);
+    evmovdqul(dst, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, nds, Assembler::AVX_512bit);
   }
 }
@@ -4578,7 +4405,8 @@
     // worse case scenario, all regs in upper bank
     evmovdqul(nds, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, dst, Assembler::AVX_512bit);
-    Assembler::vpsubw(xmm0, xmm0, src, vector_len);
+    Assembler::vpsubb(xmm0, xmm0, src, vector_len);
+    evmovdqul(dst, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, nds, Assembler::AVX_512bit);
   }
 }
@@ -4636,6 +4464,7 @@
     evmovdqul(nds, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, dst, Assembler::AVX_512bit);
     Assembler::vpsubw(xmm0, xmm0, src, vector_len);
+    evmovdqul(dst, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, nds, Assembler::AVX_512bit);
   }
 }
@@ -4649,7 +4478,7 @@
   } else if ((dst_enc < 16) && (shift_enc < 16)) {
     Assembler::vpsraw(dst, dst, shift, vector_len);
   } else if ((dst_enc < 16) && (nds_enc < 16)) {
-    // use nds_enc as scratch with shift
+    // use nds as scratch with shift
     evmovdqul(nds, shift, Assembler::AVX_512bit);
     Assembler::vpsraw(dst, dst, nds, vector_len);
   } else if ((shift_enc < 16) && (nds_enc < 16)) {
@@ -4664,7 +4493,7 @@
     Assembler::vpsraw(dst, dst, xmm0, vector_len);
     evmovdqul(xmm0, nds, Assembler::AVX_512bit);
   } else if (nds_enc < 16) {
-    // use nds as dest as temps
+    // use nds and dst as temps
     evmovdqul(nds, dst, Assembler::AVX_512bit);
     evmovdqul(dst, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, shift, Assembler::AVX_512bit);
@@ -4677,8 +4506,7 @@
     evmovdqul(nds, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm1, shift, Assembler::AVX_512bit);
     evmovdqul(xmm0, dst, Assembler::AVX_512bit);
-    Assembler::vpsllw(xmm0, xmm0, xmm1, vector_len);
-    evmovdqul(xmm1, dst, Assembler::AVX_512bit);
+    Assembler::vpsraw(xmm0, xmm0, xmm1, vector_len);
     evmovdqul(dst, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, nds, Assembler::AVX_512bit);
     pop_zmm(xmm1);
@@ -4702,6 +4530,7 @@
     evmovdqul(nds, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, dst, Assembler::AVX_512bit);
     Assembler::vpsraw(xmm0, xmm0, shift, vector_len);
+    evmovdqul(dst, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, nds, Assembler::AVX_512bit);
   }
 }
@@ -4715,7 +4544,7 @@
   } else if ((dst_enc < 16) && (shift_enc < 16)) {
     Assembler::vpsrlw(dst, dst, shift, vector_len);
   } else if ((dst_enc < 16) && (nds_enc < 16)) {
-    // use nds_enc as scratch with shift
+    // use nds as scratch with shift
     evmovdqul(nds, shift, Assembler::AVX_512bit);
     Assembler::vpsrlw(dst, dst, nds, vector_len);
   } else if ((shift_enc < 16) && (nds_enc < 16)) {
@@ -4730,7 +4559,7 @@
     Assembler::vpsrlw(dst, dst, xmm0, vector_len);
     evmovdqul(xmm0, nds, Assembler::AVX_512bit);
   } else if (nds_enc < 16) {
-    // use nds as dest as temps
+    // use nds and dst as temps
     evmovdqul(nds, dst, Assembler::AVX_512bit);
     evmovdqul(dst, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, shift, Assembler::AVX_512bit);
@@ -4743,8 +4572,7 @@
     evmovdqul(nds, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm1, shift, Assembler::AVX_512bit);
     evmovdqul(xmm0, dst, Assembler::AVX_512bit);
-    Assembler::vpsllw(xmm0, xmm0, xmm1, vector_len);
-    evmovdqul(xmm1, dst, Assembler::AVX_512bit);
+    Assembler::vpsrlw(xmm0, xmm0, xmm1, vector_len);
     evmovdqul(dst, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, nds, Assembler::AVX_512bit);
     pop_zmm(xmm1);
@@ -4768,6 +4596,7 @@
     evmovdqul(nds, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, dst, Assembler::AVX_512bit);
     Assembler::vpsrlw(xmm0, xmm0, shift, vector_len);
+    evmovdqul(dst, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, nds, Assembler::AVX_512bit);
   }
 }
@@ -4781,7 +4610,7 @@
   } else if ((dst_enc < 16) && (shift_enc < 16)) {
     Assembler::vpsllw(dst, dst, shift, vector_len);
   } else if ((dst_enc < 16) && (nds_enc < 16)) {
-    // use nds_enc as scratch with shift
+    // use nds as scratch with shift
     evmovdqul(nds, shift, Assembler::AVX_512bit);
     Assembler::vpsllw(dst, dst, nds, vector_len);
   } else if ((shift_enc < 16) && (nds_enc < 16)) {
@@ -4796,7 +4625,7 @@
     Assembler::vpsllw(dst, dst, xmm0, vector_len);
     evmovdqul(xmm0, nds, Assembler::AVX_512bit);
   } else if (nds_enc < 16) {
-    // use nds as dest as temps
+    // use nds and dst as temps
     evmovdqul(nds, dst, Assembler::AVX_512bit);
     evmovdqul(dst, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, shift, Assembler::AVX_512bit);
@@ -4810,7 +4639,6 @@
     evmovdqul(xmm1, shift, Assembler::AVX_512bit);
     evmovdqul(xmm0, dst, Assembler::AVX_512bit);
     Assembler::vpsllw(xmm0, xmm0, xmm1, vector_len);
-    evmovdqul(xmm1, dst, Assembler::AVX_512bit);
     evmovdqul(dst, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, nds, Assembler::AVX_512bit);
     pop_zmm(xmm1);
@@ -4834,6 +4662,7 @@
     evmovdqul(nds, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, dst, Assembler::AVX_512bit);
     Assembler::vpsllw(xmm0, xmm0, shift, vector_len);
+    evmovdqul(dst, xmm0, Assembler::AVX_512bit);
     evmovdqul(xmm0, nds, Assembler::AVX_512bit);
   }
 }
@@ -7130,7 +6959,7 @@
 
   bind(RET_NOT_FOUND);
   movl(result, -1);
-  jmpb(CLEANUP);
+  jmp(CLEANUP);
 
   bind(FOUND_SUBSTR);
   // Compute start addr of substr
@@ -7148,7 +6977,7 @@
     addl(tmp, cnt2);
     // Found result if we matched whole substring.
     cmpl(tmp, stride);
-    jccb(Assembler::lessEqual, RET_FOUND);
+    jcc(Assembler::lessEqual, RET_FOUND);
 
     // Repeat search for small substring (<= 8 chars)
     // from new point 'str1' without reloading substring.
@@ -7248,7 +7077,7 @@
     jcc(Assembler::carryClear, FOUND_CHAR);
     addptr(result, 32);
     subl(tmp, 2*stride);
-    jccb(Assembler::notZero, SCAN_TO_16_CHAR_LOOP);
+    jcc(Assembler::notZero, SCAN_TO_16_CHAR_LOOP);
     jmp(SCAN_TO_8_CHAR);
     bind(SCAN_TO_8_CHAR_INIT);
     movdl(vec1, ch);
@@ -7278,7 +7107,7 @@
   jcc(Assembler::carryClear, FOUND_CHAR);
   addptr(result, 16);
   subl(tmp, stride);
-  jccb(Assembler::notZero, SCAN_TO_8_CHAR_LOOP);
+  jcc(Assembler::notZero, SCAN_TO_8_CHAR_LOOP);
   bind(SCAN_TO_CHAR);
   testl(cnt1, cnt1);
   jcc(Assembler::zero, RET_NOT_FOUND);
@@ -7857,7 +7686,7 @@
       // Compare 16-byte vectors
       andl(result, 0x0000000f);  //   tail count (in bytes)
       andl(len, 0xfffffff0);   // vector count (in bytes)
-      jccb(Assembler::zero, COMPARE_TAIL);
+      jcc(Assembler::zero, COMPARE_TAIL);
 
       lea(ary1, Address(ary1, len, Address::times_1));
       negptr(len);
@@ -7869,12 +7698,12 @@
       bind(COMPARE_WIDE_VECTORS);
       movdqu(vec1, Address(ary1, len, Address::times_1));
       ptest(vec1, vec2);
-      jccb(Assembler::notZero, TRUE_LABEL);
+      jcc(Assembler::notZero, TRUE_LABEL);
       addptr(len, 16);
       jcc(Assembler::notZero, COMPARE_WIDE_VECTORS);
 
       testl(result, result);
-      jccb(Assembler::zero, FALSE_LABEL);
+      jcc(Assembler::zero, FALSE_LABEL);
 
       movdqu(vec1, Address(ary1, result, Address::times_1, -16));
       ptest(vec1, vec2);
@@ -9069,7 +8898,7 @@
     jcc(Assembler::notZero, VECTOR32_NOT_EQUAL);//mismatch found
     addq(result, 32);
     subq(length, 32);
-    jccb(Assembler::greaterEqual, VECTOR32_LOOP);
+    jcc(Assembler::greaterEqual, VECTOR32_LOOP);
     addq(length, 32);
     jcc(Assembler::equal, SAME_TILL_END);
     //falling through if less than 32 bytes left //close the branch here.
@@ -9140,24 +8969,24 @@
   load_unsigned_byte(tmp2, Address(objb, result));
   xorl(tmp1, tmp2);
   testl(tmp1, tmp1);
-  jccb(Assembler::notZero, BYTES_NOT_EQUAL);//mismatch found
+  jcc(Assembler::notZero, BYTES_NOT_EQUAL);//mismatch found
   decq(length);
-  jccb(Assembler::zero, SAME_TILL_END);
+  jcc(Assembler::zero, SAME_TILL_END);
   incq(result);
   load_unsigned_byte(tmp1, Address(obja, result));
   load_unsigned_byte(tmp2, Address(objb, result));
   xorl(tmp1, tmp2);
   testl(tmp1, tmp1);
-  jccb(Assembler::notZero, BYTES_NOT_EQUAL);//mismatch found
+  jcc(Assembler::notZero, BYTES_NOT_EQUAL);//mismatch found
   decq(length);
-  jccb(Assembler::zero, SAME_TILL_END);
+  jcc(Assembler::zero, SAME_TILL_END);
   incq(result);
   load_unsigned_byte(tmp1, Address(obja, result));
   load_unsigned_byte(tmp2, Address(objb, result));
   xorl(tmp1, tmp2);
   testl(tmp1, tmp1);
-  jccb(Assembler::notZero, BYTES_NOT_EQUAL);//mismatch found
-  jmpb(SAME_TILL_END);
+  jcc(Assembler::notZero, BYTES_NOT_EQUAL);//mismatch found
+  jmp(SAME_TILL_END);
 
   if (UseAVX >= 2) {
     bind(VECTOR32_NOT_EQUAL);
@@ -9168,7 +8997,7 @@
     bsfq(tmp1, tmp1);
     addq(result, tmp1);
     shrq(result);
-    jmpb(DONE);
+    jmp(DONE);
   }
 
   bind(VECTOR16_NOT_EQUAL);
@@ -10590,7 +10419,7 @@
     andl(len, 0xfffffff0);    // vector count (in chars)
     andl(result, 0x0000000f);    // tail count (in chars)
     testl(len, len);
-    jccb(Assembler::zero, copy_16);
+    jcc(Assembler::zero, copy_16);
 
     // compress 16 chars per iter
     movdl(tmp1Reg, tmp5);
--- a/src/hotspot/cpu/x86/macroAssembler_x86.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/x86/macroAssembler_x86.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -99,7 +99,7 @@
 
   // Required platform-specific helpers for Label::patch_instructions.
   // They _shadow_ the declarations in AbstractAssembler, which are undefined.
-  void pd_patch_instruction(address branch, address target) {
+  void pd_patch_instruction(address branch, address target, const char* file, int line) {
     unsigned char op = branch[0];
     assert(op == 0xE8 /* call */ ||
         op == 0xE9 /* jmp */ ||
@@ -113,7 +113,7 @@
       // short offset operators (jmp and jcc)
       char* disp = (char*) &branch[1];
       int imm8 = target - (address) &disp[1];
-      guarantee(this->is8bit(imm8), "Short forward jump exceeds 8-bit offset");
+      guarantee(this->is8bit(imm8), "Short forward jump exceeds 8-bit offset at %s:%d", file, line);
       *disp = imm8;
     } else {
       int* disp = (int*) &branch[(op == 0x0F || op == 0xC7)? 2: 1];
--- a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -275,7 +275,7 @@
     if (EnableJVMCI) {
       Label L;
       __ cmpb(Address(r15_thread, JavaThread::pending_monitorenter_offset()), 0);
-      __ jccb(Assembler::zero, L);
+      __ jcc(Assembler::zero, L);
       __ stop("unexpected pending monitor in deopt entry");
       __ bind(L);
     }
--- a/src/hotspot/cpu/x86/templateTable_x86.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/x86/templateTable_x86.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -4080,7 +4080,7 @@
     // make sure rdx was multiple of 8
     Label L;
     // Ignore partial flag stall after shrl() since it is debug VM
-    __ jccb(Assembler::carryClear, L);
+    __ jcc(Assembler::carryClear, L);
     __ stop("object size is not multiple of 2 - adjust this code");
     __ bind(L);
     // rdx must be > 0, no extra check needed here
--- a/src/hotspot/cpu/x86/vtableStubs_x86_32.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/x86/vtableStubs_x86_32.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -55,25 +55,34 @@
 // Available now, but may become callee-save at some point:
 //   rsi, rdi
 // Note that rax and rdx are also used for return values.
-//
+
 VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
-  const int i486_code_length = VtableStub::pd_code_size_limit(true);
-  VtableStub* s = new(i486_code_length) VtableStub(true, vtable_index);
+  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
+  const int stub_code_length = code_size_limit(true);
+  VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index);
   // Can be NULL if there is no free space in the code cache.
   if (s == NULL) {
     return NULL;
   }
 
-  ResourceMark rm;
-  CodeBuffer cb(s->entry_point(), i486_code_length);
+  // Count unused bytes in instruction sequences of variable size.
+  // We add them to the computed buffer size in order to avoid
+  // overflow in subsequently generated stubs.
+  address   start_pc;
+  int       slop_bytes = 0;
+  int       slop_delta = 0;
+  // No variance was detected in vtable stub sizes. Setting index_dependent_slop == 0 will unveil any deviation from this observation.
+  const int index_dependent_slop     = 0;
+
+  ResourceMark    rm;
+  CodeBuffer      cb(s->entry_point(), stub_code_length);
   MacroAssembler* masm = new MacroAssembler(&cb);
 
-#ifndef PRODUCT
-
+#if (!defined(PRODUCT) && defined(COMPILER2))
   if (CountCompiledCalls) {
     __ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
   }
-#endif /* PRODUCT */
+#endif
 
   // get receiver (need to skip return address on top of stack)
   assert(VtableStub::receiver_location() == rcx->as_VMReg(), "receiver expected in rcx");
@@ -85,11 +94,21 @@
 #ifndef PRODUCT
   if (DebugVtables) {
     Label L;
+    start_pc = __ pc();
     // check offset vs vtable length
     __ cmpl(Address(rax, Klass::vtable_length_offset()), vtable_index*vtableEntry::size());
+    slop_delta  = 6 - (__ pc() - start_pc);  // cmpl varies in length, depending on data
+    slop_bytes += slop_delta;
+    assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
+
     __ jcc(Assembler::greater, L);
     __ movl(rbx, vtable_index);
+    // VTABLE TODO: find upper bound for call_VM length.
+    start_pc = __ pc();
     __ call_VM(noreg, CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), rcx, rbx);
+    slop_delta  = 480 - (__ pc() - start_pc);
+    slop_bytes += slop_delta;
+    assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
     __ bind(L);
   }
 #endif // PRODUCT
@@ -97,8 +116,13 @@
   const Register method = rbx;
 
   // load Method* and target address
+  start_pc = __ pc();
   __ lookup_virtual_method(rax, vtable_index, method);
+  slop_delta  = 6 - (int)(__ pc() - start_pc);
+  slop_bytes += slop_delta;
+  assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
 
+#ifndef PRODUCT
   if (DebugVtables) {
     Label L;
     __ cmpptr(method, (int32_t)NULL_WORD);
@@ -108,55 +132,53 @@
     __ stop("Vtable entry is NULL");
     __ bind(L);
   }
+#endif // PRODUCT
 
-  // rax,: receiver klass
+  // rax: receiver klass
   // method (rbx): Method*
   // rcx: receiver
   address ame_addr = __ pc();
   __ jmp( Address(method, Method::from_compiled_offset()));
 
   masm->flush();
+  slop_bytes += index_dependent_slop; // add'l slop for size variance due to large itable offsets
+  bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, index_dependent_slop);
 
-  if (PrintMiscellaneous && (WizardMode || Verbose)) {
-    tty->print_cr("vtable #%d at " PTR_FORMAT "[%d] left over: %d",
-                  vtable_index, p2i(s->entry_point()),
-                  (int)(s->code_end() - s->entry_point()),
-                  (int)(s->code_end() - __ pc()));
-  }
-  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
-  // shut the door on sizing bugs
-  int slop = 3;  // 32-bit offset is this much larger than an 8-bit one
-  assert(vtable_index > 10 || __ pc() + slop <= s->code_end(), "room for 32-bit offset");
-
-  s->set_exception_points(npe_addr, ame_addr);
   return s;
 }
 
 
 VtableStub* VtableStubs::create_itable_stub(int itable_index) {
-  // Note well: pd_code_size_limit is the absolute minimum we can get away with.  If you
-  //            add code here, bump the code stub size returned by pd_code_size_limit!
-  const int i486_code_length = VtableStub::pd_code_size_limit(false);
-  VtableStub* s = new(i486_code_length) VtableStub(false, itable_index);
+  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
+  const int stub_code_length = code_size_limit(false);
+  VtableStub* s = new(stub_code_length) VtableStub(false, itable_index);
   // Can be NULL if there is no free space in the code cache.
   if (s == NULL) {
     return NULL;
   }
+  // Count unused bytes in instruction sequences of variable size.
+  // We add them to the computed buffer size in order to avoid
+  // overflow in subsequently generated stubs.
+  address   start_pc;
+  int       slop_bytes = 0;
+  int       slop_delta = 0;
+  const int index_dependent_slop = (itable_index == 0) ? 4 :     // code size change with transition from 8-bit to 32-bit constant (@index == 32).
+                                   (itable_index < 32) ? 3 : 0;  // index == 0 generates even shorter code.
 
-  ResourceMark rm;
-  CodeBuffer cb(s->entry_point(), i486_code_length);
+  ResourceMark    rm;
+  CodeBuffer      cb(s->entry_point(), stub_code_length);
   MacroAssembler* masm = new MacroAssembler(&cb);
 
+#if (!defined(PRODUCT) && defined(COMPILER2))
+  if (CountCompiledCalls) {
+    __ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
+  }
+#endif /* PRODUCT */
+
   // Entry arguments:
   //  rax: CompiledICHolder
   //  rcx: Receiver
 
-#ifndef PRODUCT
-  if (CountCompiledCalls) {
-    __ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
-  }
-#endif /* PRODUCT */
-
   // Most registers are in use; we'll use rax, rbx, rsi, rdi
   // (If we need to make rsi, rdi callee-save, do a push/pop here.)
   const Register recv_klass_reg     = rsi;
@@ -171,10 +193,12 @@
   Label L_no_such_interface;
 
   // get receiver klass (also an implicit null-check)
+  assert(VtableStub::receiver_location() ==  rcx->as_VMReg(), "receiver expected in  rcx");
   address npe_addr = __ pc();
-  assert(VtableStub::receiver_location() ==  rcx->as_VMReg(), "receiver expected in  rcx");
   __ load_klass(recv_klass_reg, rcx);
 
+  start_pc = __ pc();
+
   // Receiver subtype check against REFC.
   // Destroys recv_klass_reg value.
   __ lookup_interface_method(// inputs: rec. class, interface
@@ -184,6 +208,9 @@
                              L_no_such_interface,
                              /*return_method=*/false);
 
+  const ptrdiff_t  typecheckSize = __ pc() - start_pc;
+  start_pc = __ pc();
+
   // Get selected method from declaring class and itable index
   const Register method = rbx;
   __ load_klass(recv_klass_reg, rcx); // restore recv_klass_reg
@@ -193,19 +220,30 @@
                              method, temp_reg,
                              L_no_such_interface);
 
+  const ptrdiff_t  lookupSize = __ pc() - start_pc;
+
+  // We expect we need index_dependent_slop extra bytes. Reason:
+  // The emitted code in lookup_interface_method changes when itable_index exceeds 31.
+  // For windows, a narrow estimate was found to be 104. Other OSes not tested.
+  const ptrdiff_t estimate = 104;
+  const ptrdiff_t codesize = typecheckSize + lookupSize + index_dependent_slop;
+  slop_delta  = (int)(estimate - codesize);
+  slop_bytes += slop_delta;
+  assert(slop_delta >= 0, "itable #%d: Code size estimate (%d) for lookup_interface_method too small, required: %d", itable_index, (int)estimate, (int)codesize);
+
   // method (rbx): Method*
   // rcx: receiver
 
 #ifdef ASSERT
   if (DebugVtables) {
-      Label L1;
-      __ cmpptr(method, (int32_t)NULL_WORD);
-      __ jcc(Assembler::equal, L1);
-      __ cmpptr(Address(method, Method::from_compiled_offset()), (int32_t)NULL_WORD);
-      __ jcc(Assembler::notZero, L1);
-      __ stop("Method* is null");
-      __ bind(L1);
-    }
+    Label L1;
+    __ cmpptr(method, (int32_t)NULL_WORD);
+    __ jcc(Assembler::equal, L1);
+    __ cmpptr(Address(method, Method::from_compiled_offset()), (int32_t)NULL_WORD);
+    __ jcc(Assembler::notZero, L1);
+    __ stop("Method* is null");
+    __ bind(L1);
+  }
 #endif // ASSERT
 
   address ame_addr = __ pc();
@@ -219,70 +257,15 @@
   // dirty work.
   __ jump(RuntimeAddress(SharedRuntime::get_handle_wrong_method_stub()));
 
-  __ flush();
+  masm->flush();
+  slop_bytes += index_dependent_slop; // add'l slop for size variance due to large itable offsets
+  bookkeeping(masm, tty, s, npe_addr, ame_addr, false, itable_index, slop_bytes, index_dependent_slop);
 
-  if (PrintMiscellaneous && (WizardMode || Verbose)) {
-    tty->print_cr("itable #%d at " PTR_FORMAT "[%d] left over: %d",
-                  itable_index, p2i(s->entry_point()),
-                  (int)(s->code_end() - s->entry_point()),
-                  (int)(s->code_end() - __ pc()));
-  }
-  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
-  // shut the door on sizing bugs
-  int slop = 3;  // 32-bit offset is this much larger than an 8-bit one
-  assert(itable_index > 10 || __ pc() + slop <= s->code_end(), "room for 32-bit offset");
-
-  s->set_exception_points(npe_addr, ame_addr);
   return s;
 }
 
-
-
-int VtableStub::pd_code_size_limit(bool is_vtable_stub) {
-  if (is_vtable_stub) {
-    // Vtable stub size
-    return (DebugVtables ? 210 : 16) + (CountCompiledCalls ? 6 : 0);
-  } else {
-    // Itable stub size
-    return (DebugVtables ? 256 : 110) + (CountCompiledCalls ? 6 : 0);
-  }
-  // In order to tune these parameters, run the JVM with VM options
-  // +PrintMiscellaneous and +WizardMode to see information about
-  // actual itable stubs.  Look for lines like this:
-  //   itable #1 at 0x5551212[65] left over: 3
-  // Reduce the constants so that the "left over" number is >=3
-  // for the common cases.
-  // Do not aim at a left-over number of zero, because a
-  // large vtable or itable index (> 16) will require a 32-bit
-  // immediate displacement instead of an 8-bit one.
-  //
-  // The JVM98 app. _202_jess has a megamorphic interface call.
-  // The itable code looks like this:
-  // Decoding VtableStub itbl[1]@1
-  //   mov    0x4(%ecx),%esi
-  //   mov    0xe8(%esi),%edi
-  //   lea    0x130(%esi,%edi,4),%edi
-  //   add    $0x7,%edi
-  //   and    $0xfffffff8,%edi
-  //   lea    0x4(%esi),%esi
-  //   mov    (%edi),%ebx
-  //   cmp    %ebx,%eax
-  //   je     success
-  // loop:
-  //   test   %ebx,%ebx
-  //   je     throw_icce
-  //   add    $0x8,%edi
-  //   mov    (%edi),%ebx
-  //   cmp    %ebx,%eax
-  //   jne    loop
-  // success:
-  //   mov    0x4(%edi),%edi
-  //   mov    (%esi,%edi,1),%ebx
-  //   jmp    *0x44(%ebx)
-  // throw_icce:
-  //   jmp    throw_ICCE_entry
+int VtableStub::pd_code_alignment() {
+  // x86 cache line size is 64 bytes, but we want to limit alignment loss.
+  const unsigned int icache_line_size = wordSize;
+  return icache_line_size;
 }
-
-int VtableStub::pd_code_alignment() {
-  return wordSize;
-}
--- a/src/hotspot/cpu/x86/vtableStubs_x86_64.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/x86/vtableStubs_x86_64.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,24 +42,32 @@
 #define __ masm->
 
 #ifndef PRODUCT
-extern "C" void bad_compiled_vtable_index(JavaThread* thread,
-                                          oop receiver,
-                                          int index);
+extern "C" void bad_compiled_vtable_index(JavaThread* thread, oop receiver, int index);
 #endif
 
 VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
-  const int amd64_code_length = VtableStub::pd_code_size_limit(true);
-  VtableStub* s = new(amd64_code_length) VtableStub(true, vtable_index);
+  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
+  const int stub_code_length = code_size_limit(true);
+  VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index);
   // Can be NULL if there is no free space in the code cache.
   if (s == NULL) {
     return NULL;
   }
 
-  ResourceMark rm;
-  CodeBuffer cb(s->entry_point(), amd64_code_length);
+  // Count unused bytes in instruction sequences of variable size.
+  // We add them to the computed buffer size in order to avoid
+  // overflow in subsequently generated stubs.
+  address   start_pc;
+  int       slop_bytes = 0;
+  int       slop_delta = 0;
+  // No variance was detected in vtable stub sizes. Setting index_dependent_slop == 0 will unveil any deviation from this observation.
+  const int index_dependent_slop     = 0;
+
+  ResourceMark    rm;
+  CodeBuffer      cb(s->entry_point(), stub_code_length);
   MacroAssembler* masm = new MacroAssembler(&cb);
 
-#ifndef PRODUCT
+#if (!defined(PRODUCT) && defined(COMPILER2))
   if (CountCompiledCalls) {
     __ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
   }
@@ -77,22 +85,35 @@
 #ifndef PRODUCT
   if (DebugVtables) {
     Label L;
+    start_pc = __ pc();
     // check offset vs vtable length
-    __ cmpl(Address(rax, Klass::vtable_length_offset()),
-            vtable_index * vtableEntry::size());
+    __ cmpl(Address(rax, Klass::vtable_length_offset()), vtable_index*vtableEntry::size());
+    slop_delta  = 12 - (__ pc() - start_pc);  // cmpl varies in length, depending on data
+    slop_bytes += slop_delta;
+    assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
+
     __ jcc(Assembler::greater, L);
     __ movl(rbx, vtable_index);
-    __ call_VM(noreg,
-               CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), j_rarg0, rbx);
+    // VTABLE TODO: find upper bound for call_VM length.
+    start_pc = __ pc();
+    __ call_VM(noreg, CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), j_rarg0, rbx);
+    slop_delta  = 480 - (__ pc() - start_pc);
+    slop_bytes += slop_delta;
+    assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
     __ bind(L);
   }
 #endif // PRODUCT
 
-  // load Method* and target address
   const Register method = rbx;
 
+  // load Method* and target address
+  start_pc = __ pc();
   __ lookup_virtual_method(rax, vtable_index, method);
+  slop_delta  = 8 - (int)(__ pc() - start_pc);
+  slop_bytes += slop_delta;
+  assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
 
+#ifndef PRODUCT
   if (DebugVtables) {
     Label L;
     __ cmpptr(method, (int32_t)NULL_WORD);
@@ -102,50 +123,48 @@
     __ stop("Vtable entry is NULL");
     __ bind(L);
   }
+#endif // PRODUCT
+
   // rax: receiver klass
-  // rbx: Method*
+  // method (rbx): Method*
   // rcx: receiver
   address ame_addr = __ pc();
   __ jmp( Address(rbx, Method::from_compiled_offset()));
 
-  __ flush();
+  masm->flush();
+  slop_bytes += index_dependent_slop; // add'l slop for size variance due to large itable offsets
+  bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, index_dependent_slop);
 
-  if (PrintMiscellaneous && (WizardMode || Verbose)) {
-    tty->print_cr("vtable #%d at " PTR_FORMAT "[%d] left over: %d",
-                  vtable_index, p2i(s->entry_point()),
-                  (int)(s->code_end() - s->entry_point()),
-                  (int)(s->code_end() - __ pc()));
-  }
-  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
-  // shut the door on sizing bugs
-  int slop = 3;  // 32-bit offset is this much larger than an 8-bit one
-  assert(vtable_index > 10 || __ pc() + slop <= s->code_end(), "room for 32-bit offset");
-
-  s->set_exception_points(npe_addr, ame_addr);
   return s;
 }
 
 
 VtableStub* VtableStubs::create_itable_stub(int itable_index) {
-  // Note well: pd_code_size_limit is the absolute minimum we can get
-  // away with.  If you add code here, bump the code stub size
-  // returned by pd_code_size_limit!
-  const int amd64_code_length = VtableStub::pd_code_size_limit(false);
-  VtableStub* s = new(amd64_code_length) VtableStub(false, itable_index);
+  // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
+  const int stub_code_length = code_size_limit(false);
+  VtableStub* s = new(stub_code_length) VtableStub(false, itable_index);
   // Can be NULL if there is no free space in the code cache.
   if (s == NULL) {
     return NULL;
   }
+  // Count unused bytes in instruction sequences of variable size.
+  // We add them to the computed buffer size in order to avoid
+  // overflow in subsequently generated stubs.
+  address   start_pc;
+  int       slop_bytes = 0;
+  int       slop_delta = 0;
+  const int index_dependent_slop = (itable_index == 0) ? 4 :     // code size change with transition from 8-bit to 32-bit constant (@index == 16).
+                                   (itable_index < 16) ? 3 : 0;  // index == 0 generates even shorter code.
 
-  ResourceMark rm;
-  CodeBuffer cb(s->entry_point(), amd64_code_length);
-  MacroAssembler* masm = new MacroAssembler(&cb);
+  ResourceMark    rm;
+  CodeBuffer      cb(s->entry_point(), stub_code_length);
+  MacroAssembler *masm = new MacroAssembler(&cb);
 
-#ifndef PRODUCT
+#if (!defined(PRODUCT) && defined(COMPILER2))
   if (CountCompiledCalls) {
     __ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
   }
-#endif
+#endif // PRODUCT
 
   // Entry arguments:
   //  rax: CompiledICHolder
@@ -158,17 +177,19 @@
   const Register resolved_klass_reg = rbx; // resolved interface klass (REFC)
   const Register temp_reg           = r11;
 
-  Label L_no_such_interface;
-
   const Register icholder_reg = rax;
   __ movptr(resolved_klass_reg, Address(icholder_reg, CompiledICHolder::holder_klass_offset()));
   __ movptr(holder_klass_reg,   Address(icholder_reg, CompiledICHolder::holder_metadata_offset()));
 
+  Label L_no_such_interface;
+
   // get receiver klass (also an implicit null-check)
   assert(VtableStub::receiver_location() == j_rarg0->as_VMReg(), "receiver expected in j_rarg0");
   address npe_addr = __ pc();
   __ load_klass(recv_klass_reg, j_rarg0);
 
+  start_pc = __ pc();
+
   // Receiver subtype check against REFC.
   // Destroys recv_klass_reg value.
   __ lookup_interface_method(// inputs: rec. class, interface
@@ -178,6 +199,9 @@
                              L_no_such_interface,
                              /*return_method=*/false);
 
+  const ptrdiff_t  typecheckSize = __ pc() - start_pc;
+  start_pc = __ pc();
+
   // Get selected method from declaring class and itable index
   const Register method = rbx;
   __ load_klass(recv_klass_reg, j_rarg0);   // restore recv_klass_reg
@@ -187,6 +211,17 @@
                              method, temp_reg,
                              L_no_such_interface);
 
+  const ptrdiff_t  lookupSize = __ pc() - start_pc;
+
+  // We expect we need index_dependent_slop extra bytes. Reason:
+  // The emitted code in lookup_interface_method changes when itable_index exceeds 15.
+  // For linux, a very narrow estimate would be 112, but Solaris requires some more space (130).
+  const ptrdiff_t estimate = 136;
+  const ptrdiff_t codesize = typecheckSize + lookupSize + index_dependent_slop;
+  slop_delta  = (int)(estimate - codesize);
+  slop_bytes += slop_delta;
+  assert(slop_delta >= 0, "itable #%d: Code size estimate (%d) for lookup_interface_method too small, required: %d", itable_index, (int)estimate, (int)codesize);
+
   // If we take a trap while this arg is on the stack we will not
   // be able to walk the stack properly. This is not an issue except
   // when there are mistakes in this assembly code that could generate
@@ -207,8 +242,6 @@
   }
 #endif // ASSERT
 
-  // rbx: Method*
-  // j_rarg0: receiver
   address ame_addr = __ pc();
   __ jmp(Address(method, Method::from_compiled_offset()));
 
@@ -220,68 +253,15 @@
   // dirty work.
   __ jump(RuntimeAddress(SharedRuntime::get_handle_wrong_method_stub()));
 
-  __ flush();
+  masm->flush();
+  slop_bytes += index_dependent_slop; // add'l slop for size variance due to large itable offsets
+  bookkeeping(masm, tty, s, npe_addr, ame_addr, false, itable_index, slop_bytes, index_dependent_slop);
 
-  if (PrintMiscellaneous && (WizardMode || Verbose)) {
-    tty->print_cr("itable #%d at " PTR_FORMAT "[%d] left over: %d",
-                  itable_index, p2i(s->entry_point()),
-                  (int)(s->code_end() - s->entry_point()),
-                  (int)(s->code_end() - __ pc()));
-  }
-  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
-  // shut the door on sizing bugs
-  int slop = 3;  // 32-bit offset is this much larger than an 8-bit one
-  assert(itable_index > 10 || __ pc() + slop <= s->code_end(), "room for 32-bit offset");
-
-  s->set_exception_points(npe_addr, ame_addr);
   return s;
 }
 
-int VtableStub::pd_code_size_limit(bool is_vtable_stub) {
-  if (is_vtable_stub) {
-    // Vtable stub size
-    return (DebugVtables ? 512 : 24) + (CountCompiledCalls ? 13 : 0) +
-           (UseCompressedClassPointers ?  MacroAssembler::instr_size_for_decode_klass_not_null() : 0);
-  } else {
-    // Itable stub size
-    return (DebugVtables ? 512 : 140) + (CountCompiledCalls ? 13 : 0) +
-           (UseCompressedClassPointers ? 2 * MacroAssembler::instr_size_for_decode_klass_not_null() : 0);
-  }
-  // In order to tune these parameters, run the JVM with VM options
-  // +PrintMiscellaneous and +WizardMode to see information about
-  // actual itable stubs.  Look for lines like this:
-  //   itable #1 at 0x5551212[71] left over: 3
-  // Reduce the constants so that the "left over" number is >=3
-  // for the common cases.
-  // Do not aim at a left-over number of zero, because a
-  // large vtable or itable index (>= 32) will require a 32-bit
-  // immediate displacement instead of an 8-bit one.
-  //
-  // The JVM98 app. _202_jess has a megamorphic interface call.
-  // The itable code looks like this:
-  // Decoding VtableStub itbl[1]@12
-  //   mov    0x8(%rsi),%r10
-  //   mov    0x198(%r10),%r11d
-  //   lea    0x218(%r10,%r11,8),%r11
-  //   lea    0x8(%r10),%r10
-  //   mov    (%r11),%rbx
-  //   cmp    %rbx,%rax
-  //   je     success
-  // loop:
-  //   test   %rbx,%rbx
-  //   je     throw_icce
-  //   add    $0x10,%r11
-  //   mov    (%r11),%rbx
-  //   cmp    %rbx,%rax
-  //   jne    loop
-  // success:
-  //   mov    0x8(%r11),%r11d
-  //   mov    (%r10,%r11,1),%rbx
-  //   jmpq   *0x60(%rbx)
-  // throw_icce:
-  //   jmpq   throw_ICCE_entry
+int VtableStub::pd_code_alignment() {
+  // x86 cache line size is 64 bytes, but we want to limit alignment loss.
+  const unsigned int icache_line_size = wordSize;
+  return icache_line_size;
 }
-
-int VtableStub::pd_code_alignment() {
-  return wordSize;
-}
--- a/src/hotspot/cpu/x86/x86.ad	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/x86/x86.ad	Fri Sep 07 15:46:39 2018 -0700
@@ -1252,8 +1252,8 @@
 
 #ifdef _LP64
   static uint size_deopt_handler() {
-    // three 5 byte instructions
-    return 15;
+    // three 5 byte instructions plus one move for unreachable address.
+    return 15+3;
   }
 #else
   static uint size_deopt_handler() {
@@ -1322,7 +1322,7 @@
 #endif
 
   __ jump(RuntimeAddress(SharedRuntime::deopt_blob()->unpack()));
-  assert(__ offset() - offset <= (int) size_deopt_handler(), "overflow");
+  assert(__ offset() - offset <= (int) size_deopt_handler(), "overflow %d", (__ offset() - offset));
   __ end_a_stub();
   return offset;
 }
@@ -5645,7 +5645,7 @@
 %}
 
 instruct vadd4B_mem_evex_special(vecS dst, vecS src, memory mem) %{
-  predicate(VM_Version::supports_avx512bw() && n->as_Vector()->length() == 4);
+  predicate(VM_Version::supports_avx512nobw() && n->as_Vector()->length() == 4);
   match(Set dst (AddVB dst (LoadVector mem)));
   effect(TEMP src);
   format %{ "vpaddb  $dst,$src,$mem\t! add packed4B" %}
@@ -5723,7 +5723,7 @@
 %}
 
 instruct vadd8B_mem_evex_special(vecD dst, vecD src, memory mem) %{
-  predicate(VM_Version::supports_avx512bw() && n->as_Vector()->length() == 8);
+  predicate(VM_Version::supports_avx512nobw() && n->as_Vector()->length() == 8);
   match(Set dst (AddVB dst (LoadVector mem)));
   effect(TEMP src);
   format %{ "vpaddb  $dst,$src,$mem\t! add packed8B" %}
@@ -5801,7 +5801,7 @@
 %}
 
 instruct vadd16B_mem_evex_special(vecX dst, vecX src, memory mem) %{
-  predicate(VM_Version::supports_avx512bw() && n->as_Vector()->length() == 16);
+  predicate(VM_Version::supports_avx512nobw() && n->as_Vector()->length() == 16);
   match(Set dst (AddVB dst (LoadVector mem)));
   effect(TEMP src);
   format %{ "vpaddb  $dst,$src,$mem\t! add packed16B" %}
@@ -5869,7 +5869,7 @@
 %}
 
 instruct vadd32B_mem_evex_special(vecY dst, vecY src, memory mem) %{
-  predicate(VM_Version::supports_avx512bw() && n->as_Vector()->length() == 32);
+  predicate(VM_Version::supports_avx512nobw() && n->as_Vector()->length() == 32);
   match(Set dst (AddVB dst (LoadVector mem)));
   effect(TEMP src);
   format %{ "vpaddb  $dst,$src,$mem\t! add packed32B" %}
@@ -5970,7 +5970,7 @@
 %}
 
 instruct vadd2S_mem_evex_special(vecS dst, vecS src, memory mem) %{
-  predicate(VM_Version::supports_avx512bw() && n->as_Vector()->length() == 2);
+  predicate(VM_Version::supports_avx512nobw() && n->as_Vector()->length() == 2);
   match(Set dst (AddVS dst (LoadVector mem)));
   effect(TEMP src);
   format %{ "vpaddw  $dst,$src,$mem\t! add packed2S" %}
@@ -6048,7 +6048,7 @@
 %}
 
 instruct vadd4S_mem_evex_special(vecD dst, vecD src, memory mem) %{
-  predicate(VM_Version::supports_avx512bw() && n->as_Vector()->length() == 4);
+  predicate(VM_Version::supports_avx512nobw() && n->as_Vector()->length() == 4);
   match(Set dst (AddVS dst (LoadVector mem)));
   effect(TEMP src);
   format %{ "vpaddw  $dst,$src,$mem\t! add packed4S" %}
@@ -6126,7 +6126,7 @@
 %}
 
 instruct vadd8S_mem_evex_special(vecX dst, vecX src, memory mem) %{
-  predicate(VM_Version::supports_avx512bw() && n->as_Vector()->length() == 8);
+  predicate(VM_Version::supports_avx512nobw() && n->as_Vector()->length() == 8);
   match(Set dst (AddVS dst (LoadVector mem)));
   effect(TEMP src);
   format %{ "vpaddw  $dst,$src,$mem\t! add packed8S" %}
@@ -6194,7 +6194,7 @@
 %}
 
 instruct vadd16S_mem_evex_special(vecY dst, vecY src, memory mem) %{
-  predicate(VM_Version::supports_avx512bw() && n->as_Vector()->length() == 16);
+  predicate(VM_Version::supports_avx512nobw() && n->as_Vector()->length() == 16);
   match(Set dst (AddVS dst (LoadVector mem)));
   effect(TEMP src);
   format %{ "vpaddw  $dst,$src,$mem\t! add packed16S" %}
--- a/src/hotspot/cpu/zero/assembler_zero.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/zero/assembler_zero.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -49,7 +49,7 @@
 }
 #endif
 
-void Assembler::pd_patch_instruction(address branch, address target) {
+void Assembler::pd_patch_instruction(address branch, address target, const char* file, int line) {
   ShouldNotCallThis();
 }
 
--- a/src/hotspot/cpu/zero/assembler_zero.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/zero/assembler_zero.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -36,7 +36,7 @@
   Assembler(CodeBuffer* code) : AbstractAssembler(code) {}
 
  public:
-  void pd_patch_instruction(address branch, address target);
+  void pd_patch_instruction(address branch, address target, const char* file, int line);
 };
 
 class MacroAssembler : public Assembler {
--- a/src/hotspot/cpu/zero/vtableStubs_zero.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/cpu/zero/vtableStubs_zero.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -37,11 +37,6 @@
   return NULL;
 }
 
-int VtableStub::pd_code_size_limit(bool is_vtable_stub) {
-  ShouldNotCallThis();
-  return 0;
-}
-
 int VtableStub::pd_code_alignment() {
   ShouldNotCallThis();
   return 0;
--- a/src/hotspot/os/aix/safepointMechanism_aix.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/os/aix/safepointMechanism_aix.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,6 +27,7 @@
 #include "runtime/globals.hpp"
 #include "runtime/os.hpp"
 #include "runtime/safepointMechanism.hpp"
+#include "services/memTracker.hpp"
 #include <sys/mman.h>
 
 void SafepointMechanism::pd_initialize() {
@@ -95,6 +96,9 @@
   log_info(os)("SafePoint Polling address: " INTPTR_FORMAT, p2i(map_address));
   os::set_polling_page((address)(map_address));
 
+  // Register polling page with NMT.
+  MemTracker::record_virtual_memory_reserve_and_commit(map_address, map_size, CALLER_PC, mtSafepoint);
+
   // Use same page for ThreadLocalHandshakes without SIGTRAP
   if (ThreadLocalHandshakes) {
     set_uses_thread_local_poll();
--- a/src/hotspot/os/linux/os_linux.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/os/linux/os_linux.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1742,7 +1742,7 @@
 
 #if  (defined IA32)
   static  Elf32_Half running_arch_code=EM_386;
-#elif   (defined AMD64)
+#elif   (defined AMD64) || (defined X32)
   static  Elf32_Half running_arch_code=EM_X86_64;
 #elif  (defined IA64)
   static  Elf32_Half running_arch_code=EM_IA_64;
--- a/src/hotspot/os/solaris/attachListener_solaris.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/os/solaris/attachListener_solaris.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -294,12 +294,17 @@
     int return_fd = -1;
     SolarisAttachOperation* op = NULL;
 
-    // no listener
+    // wait up to 10 seconds for listener to be up and running
     jint res = 0;
-    if (!AttachListener::is_initialized()) {
-      // how did we get here?
-      debug_only(warning("door_call when not enabled"));
-      res = (jint)SolarisAttachListener::ATTACH_ERROR_INTERNAL;
+    int sleep_count = 0;
+    while (!AttachListener::is_initialized()) {
+      sleep(1); // 1 second
+      sleep_count++;
+      if (sleep_count > 10) { // try for 10 seconds
+        debug_only(warning("door_call when not enabled"));
+        res = (jint)SolarisAttachListener::ATTACH_ERROR_INTERNAL;
+        break;
+      }
     }
 
     // check client credentials
--- a/src/hotspot/os/windows/attachListener_windows.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/os/windows/attachListener_windows.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -184,9 +184,14 @@
 // Also we need to be careful not to execute anything that results in more than a 4k stack.
 //
 int Win32AttachListener::enqueue(char* cmd, char* arg0, char* arg1, char* arg2, char* pipename) {
-  // listener not running
-  if (!AttachListener::is_initialized()) {
-    return ATTACH_ERROR_DISABLED;
+  // wait up to 10 seconds for listener to be up and running
+  int sleep_count = 0;
+  while (!AttachListener::is_initialized()) {
+    Sleep(1000); // 1 second
+    sleep_count++;
+    if (sleep_count > 10) { // try for 10 seconds
+      return ATTACH_ERROR_DISABLED;
+    }
   }
 
   // check that all paramteres to the operation
--- a/src/hotspot/share/adlc/formssel.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/adlc/formssel.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -641,22 +641,6 @@
 }
 
 
-bool InstructForm::is_wide_memory_kill(FormDict &globals) const {
-  if( _matrule == NULL ) return false;
-  if( !_matrule->_opType ) return false;
-
-  if( strcmp(_matrule->_opType,"MemBarRelease") == 0 ) return true;
-  if( strcmp(_matrule->_opType,"MemBarAcquire") == 0 ) return true;
-  if( strcmp(_matrule->_opType,"MemBarReleaseLock") == 0 ) return true;
-  if( strcmp(_matrule->_opType,"MemBarAcquireLock") == 0 ) return true;
-  if( strcmp(_matrule->_opType,"MemBarStoreStore") == 0 ) return true;
-  if( strcmp(_matrule->_opType,"MemBarVolatile") == 0 ) return true;
-  if( strcmp(_matrule->_opType,"StoreFence") == 0 ) return true;
-  if( strcmp(_matrule->_opType,"LoadFence") == 0 ) return true;
-
-  return false;
-}
-
 int InstructForm::memory_operand(FormDict &globals) const {
   // Machine independent loads must be checked for anti-dependences
   // Check if instruction has a USE of a memory operand class, or a def.
@@ -1171,6 +1155,9 @@
   else if (is_ideal_nop()) {
     return "MachNopNode";
   }
+  else if( is_ideal_membar()) {
+    return "MachMemBarNode";
+  }
   else if (is_ideal_jump()) {
     return "MachJumpNode";
   }
@@ -4116,7 +4103,8 @@
     !strcmp(_opType,"StoreFence") ||
     !strcmp(_opType,"MemBarVolatile") ||
     !strcmp(_opType,"MemBarCPUOrder") ||
-    !strcmp(_opType,"MemBarStoreStore");
+    !strcmp(_opType,"MemBarStoreStore") ||
+    !strcmp(_opType,"OnSpinWait");
 }
 
 bool MatchRule::is_ideal_loadPC() const {
--- a/src/hotspot/share/adlc/formssel.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/adlc/formssel.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -191,7 +191,6 @@
   // loads from memory, so must check for anti-dependence
   virtual bool        needs_anti_dependence_check(FormDict &globals) const;
   virtual int         memory_operand(FormDict &globals) const;
-          bool        is_wide_memory_kill(FormDict &globals) const;
 
   enum memory_operand_type {
     NO_MEMORY_OPERAND = -1,
--- a/src/hotspot/share/adlc/output_c.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/adlc/output_c.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -3263,10 +3263,6 @@
 
     // Analyze machine instructions that either USE or DEF memory.
     int memory_operand = instr->memory_operand(_globalNames);
-    // Some guys kill all of memory
-    if ( instr->is_wide_memory_kill(_globalNames) ) {
-      memory_operand = InstructForm::MANY_MEMORY_OPERANDS;
-    }
 
     if ( memory_operand != InstructForm::NO_MEMORY_OPERAND ) {
       if( memory_operand == InstructForm::MANY_MEMORY_OPERANDS ) {
--- a/src/hotspot/share/adlc/output_h.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/adlc/output_h.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -2002,10 +2002,6 @@
 
     // Analyze machine instructions that either USE or DEF memory.
     int memory_operand = instr->memory_operand(_globalNames);
-    // Some guys kill all of memory
-    if ( instr->is_wide_memory_kill(_globalNames) ) {
-      memory_operand = InstructForm::MANY_MEMORY_OPERANDS;
-    }
     if ( memory_operand != InstructForm::NO_MEMORY_OPERAND ) {
       if( memory_operand == InstructForm::MANY_MEMORY_OPERANDS ) {
         fprintf(fp,"  virtual const TypePtr *adr_type() const;\n");
--- a/src/hotspot/share/asm/assembler.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/asm/assembler.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -151,12 +151,16 @@
   } // end (UseStackBanging)
 }
 
-void Label::add_patch_at(CodeBuffer* cb, int branch_loc) {
+void Label::add_patch_at(CodeBuffer* cb, int branch_loc, const char* file, int line) {
   assert(_loc == -1, "Label is unbound");
   // Don't add patch locations during scratch emit.
   if (cb->insts()->scratch_emit()) { return; }
   if (_patch_index < PatchCacheSize) {
     _patches[_patch_index] = branch_loc;
+#ifdef ASSERT
+    _lines[_patch_index] = line;
+    _files[_patch_index] = file;
+#endif
   } else {
     if (_patch_overflow == NULL) {
       _patch_overflow = cb->create_patch_overflow();
@@ -174,10 +178,16 @@
   while (_patch_index > 0) {
     --_patch_index;
     int branch_loc;
+    int line = 0;
+    const char* file = NULL;
     if (_patch_index >= PatchCacheSize) {
       branch_loc = _patch_overflow->pop();
     } else {
       branch_loc = _patches[_patch_index];
+#ifdef ASSERT
+      line = _lines[_patch_index];
+      file = _files[_patch_index];
+#endif
     }
     int branch_sect = CodeBuffer::locator_sect(branch_loc);
     address branch = cb->locator_address(branch_loc);
@@ -201,7 +211,7 @@
 #endif //ASSERT
 
     // Push the target offset into the branch instruction.
-    masm->pd_patch_instruction(branch, target);
+    masm->pd_patch_instruction(branch, target, file, line);
   }
 }
 
--- a/src/hotspot/share/asm/assembler.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/asm/assembler.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -73,7 +73,7 @@
  */
 class Label {
  private:
-  enum { PatchCacheSize = 4 };
+  enum { PatchCacheSize = 4 debug_only( +4 ) };
 
   // _loc encodes both the binding state (via its sign)
   // and the binding locator (via its value) of a label.
@@ -98,6 +98,11 @@
   // The label will be bound to a location near its users.
   bool _is_near;
 
+#ifdef ASSERT
+  // Sourcre file and line location of jump instruction
+  int _lines[PatchCacheSize];
+  const char* _files[PatchCacheSize];
+#endif
  public:
 
   /**
@@ -141,7 +146,7 @@
    * @param cb         the code buffer being patched
    * @param branch_loc the locator of the branch instruction in the code buffer
    */
-  void add_patch_at(CodeBuffer* cb, int branch_loc);
+  void add_patch_at(CodeBuffer* cb, int branch_loc, const char* file = NULL, int line = 0);
 
   /**
    * Iterate over the list of patches, resolving the instructions
@@ -447,7 +452,7 @@
    * @param branch the location of the instruction to patch
    * @param masm the assembler which generated the branch
    */
-  void pd_patch_instruction(address branch, address target);
+  void pd_patch_instruction(address branch, address target, const char* file, int line);
 
 };
 
--- a/src/hotspot/share/c1/c1_LIRGenerator.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -2979,7 +2979,10 @@
   __ move_wide(jobj_addr, result);
   __ cmp(lir_cond_equal, result, LIR_OprFact::oopConst(NULL));
   __ branch(lir_cond_equal, T_OBJECT, L_end->label());
-  __ move_wide(new LIR_Address(result, T_OBJECT), result);
+
+  LIR_Opr jobj = new_register(T_OBJECT);
+  __ move(result, jobj);
+  access_load(IN_NATIVE, T_OBJECT, LIR_OprFact::address(new LIR_Address(jobj, T_OBJECT)), result);
 
   __ branch_destination(L_end->label());
 }
@@ -3215,7 +3218,7 @@
 void LIRGenerator::do_ProfileCall(ProfileCall* x) {
   // Need recv in a temporary register so it interferes with the other temporaries
   LIR_Opr recv = LIR_OprFact::illegalOpr;
-  LIR_Opr mdo = new_register(T_OBJECT);
+  LIR_Opr mdo = new_register(T_METADATA);
   // tmp is used to hold the counters on SPARC
   LIR_Opr tmp = new_pointer_register();
 
--- a/src/hotspot/share/classfile/classListParser.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/classfile/classListParser.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -273,9 +273,9 @@
 // This function is used for loading classes for customized class loaders
 // during archive dumping.
 InstanceKlass* ClassListParser::load_class_from_source(Symbol* class_name, TRAPS) {
-#if !(defined(_LP64) && (defined(LINUX)|| defined(SOLARIS)))
-  // The only supported platforms are: (1) Linux/64-bit and (2) Solaris/64-bit
-  //
+#if !(defined(_LP64) && (defined(LINUX)|| defined(SOLARIS) || defined(__APPLE__)))
+  // The only supported platforms are: (1) Linux/64-bit and (2) Solaris/64-bit and
+  // (3) MacOSX/64-bit
   // This #if condition should be in sync with the areCustomLoadersSupportedForCDS
   // method in test/lib/jdk/test/lib/Platform.java.
   error("AppCDS custom class loaders not supported on this platform");
--- a/src/hotspot/share/classfile/classLoaderData.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/classfile/classLoaderData.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -544,6 +544,7 @@
 static ClassLoaderDataGraphKlassIteratorStatic static_klass_iterator;
 
 InstanceKlass* ClassLoaderDataGraph::try_get_next_class() {
+  assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
   return static_klass_iterator.try_get_next_class();
 }
 
@@ -895,6 +896,7 @@
 }
 
 void ClassLoaderDataGraph::clean_deallocate_lists(bool walk_previous_versions) {
+  assert(SafepointSynchronize::is_at_safepoint(), "must only be called at safepoint");
   uint loaders_processed = 0;
   for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
     // is_alive check will be necessary for concurrent class unloading.
@@ -1065,43 +1067,43 @@
 // Add a new class loader data node to the list.  Assign the newly created
 // ClassLoaderData into the java/lang/ClassLoader object as a hidden field
 ClassLoaderData* ClassLoaderDataGraph::add_to_graph(Handle loader, bool is_unsafe_anonymous) {
-  NoSafepointVerifier no_safepoints; // we mustn't GC until we've installed the
-                                     // ClassLoaderData in the graph since the CLD
-                                     // contains oops in _handles that must be walked.
+
 
-  ClassLoaderData* cld = new ClassLoaderData(loader, is_unsafe_anonymous);
+  ClassLoaderData* cld;
+  {
+    NoSafepointVerifier no_safepoints; // we mustn't GC until we've installed the
+                                       // ClassLoaderData in the loader since the CLD
+                                       // contains oops in _handles that must be walked.
+                                       // GC will find the CLD through the loader after this.
 
-  if (!is_unsafe_anonymous) {
-    // First, Atomically set it
-    ClassLoaderData* old = java_lang_ClassLoader::cmpxchg_loader_data(cld, loader(), NULL);
-    if (old != NULL) {
-      delete cld;
-      // Returns the data.
-      return old;
+    cld = new ClassLoaderData(loader, is_unsafe_anonymous);
+
+    if (!is_unsafe_anonymous) {
+      // First, Atomically set it
+      ClassLoaderData* old = java_lang_ClassLoader::cmpxchg_loader_data(cld, loader(), NULL);
+      if (old != NULL) {
+        delete cld;
+        // Returns the data.
+        return old;
+      }
     }
   }
 
+  MutexLocker ml(ClassLoaderDataGraph_lock);
+
   // We won the race, and therefore the task of adding the data to the list of
   // class loader data
-  ClassLoaderData** list_head = &_head;
-  ClassLoaderData* next = _head;
-
-  do {
-    cld->set_next(next);
-    ClassLoaderData* exchanged = Atomic::cmpxchg(cld, list_head, next);
-    if (exchanged == next) {
-      LogTarget(Trace, class, loader, data) lt;
-      if (lt.is_enabled()) {
-        ResourceMark rm;
-        LogStream ls(lt);
-        ls.print("create ");
-        cld->print_value_on(&ls);
-        ls.cr();
-      }
-      return cld;
-    }
-    next = exchanged;
-  } while (true);
+  cld->set_next(_head);
+  _head = cld;
+  LogTarget(Trace, class, loader, data) lt;
+  if (lt.is_enabled()) {
+    ResourceMark rm;
+    LogStream ls(lt);
+    ls.print("create ");
+    cld->print_value_on(&ls);
+    ls.cr();
+  }
+  return cld;
 }
 
 ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool is_unsafe_anonymous) {
@@ -1115,13 +1117,14 @@
 }
 
 void ClassLoaderDataGraph::cld_do(CLDClosure* cl) {
-  for (ClassLoaderData* cld = _head; cl != NULL && cld != NULL; cld = cld->next()) {
+  assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
+  for (ClassLoaderData* cld = _head;  cld != NULL; cld = cld->_next) {
     cl->do_cld(cld);
   }
 }
 
 void ClassLoaderDataGraph::cld_unloading_do(CLDClosure* cl) {
-  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
+  assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
   // Only walk the head until any clds not purged from prior unloading
   // (CMS doesn't purge right away).
   for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) {
@@ -1131,6 +1134,7 @@
 }
 
 void ClassLoaderDataGraph::roots_cld_do(CLDClosure* strong, CLDClosure* weak) {
+  assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
   for (ClassLoaderData* cld = _head;  cld != NULL; cld = cld->_next) {
     CLDClosure* closure = cld->keep_alive() ? strong : weak;
     if (closure != NULL) {
@@ -1140,6 +1144,7 @@
 }
 
 void ClassLoaderDataGraph::always_strong_cld_do(CLDClosure* cl) {
+  assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
   if (ClassUnloading) {
     roots_cld_do(cl, NULL);
   } else {
@@ -1147,41 +1152,90 @@
   }
 }
 
+// Closure for locking and iterating through classes.
+LockedClassesDo::LockedClassesDo(classes_do_func_t f) : _function(f) {
+  ClassLoaderDataGraph_lock->lock();
+}
+
+LockedClassesDo::LockedClassesDo() : _function(NULL) {
+  // callers provide their own do_klass
+  ClassLoaderDataGraph_lock->lock();
+}
+
+LockedClassesDo::~LockedClassesDo() { ClassLoaderDataGraph_lock->unlock(); }
+
+
+// Iterating over the CLDG needs to be locked because
+// unloading can remove entries concurrently soon.
+class ClassLoaderDataGraphIterator : public StackObj {
+  ClassLoaderData* _next;
+  HandleMark       _hm;  // clean up handles when this is done.
+  Handle           _holder;
+  Thread*          _thread;
+
+  void hold_next() {
+    if (_next != NULL) {
+      _holder = Handle(_thread, _next->holder_phantom());
+    }
+  }
+public:
+  ClassLoaderDataGraphIterator() : _next(ClassLoaderDataGraph::_head) {
+    _thread = Thread::current();
+    assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
+    hold_next();
+  }
+
+  bool repeat() const {
+    return _next != NULL;
+  }
+
+  ClassLoaderData* get_next() {
+    ClassLoaderData* next = _next;
+    if (_next != NULL) {
+      _next = _next->next();
+      hold_next();
+    }
+    return next;
+  }
+};
+
+// These functions assume that the caller has locked the ClassLoaderDataGraph_lock
+// if they are not calling the function from a safepoint.
 void ClassLoaderDataGraph::classes_do(KlassClosure* klass_closure) {
-  Thread* thread = Thread::current();
-  for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
-    Handle holder(thread, cld->holder_phantom());
+  ClassLoaderDataGraphIterator iter;
+  while (iter.repeat()) {
+    ClassLoaderData* cld = iter.get_next();
     cld->classes_do(klass_closure);
   }
 }
 
 void ClassLoaderDataGraph::classes_do(void f(Klass* const)) {
-  Thread* thread = Thread::current();
-  for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
-    Handle holder(thread, cld->holder_phantom());
+  ClassLoaderDataGraphIterator iter;
+  while (iter.repeat()) {
+    ClassLoaderData* cld = iter.get_next();
     cld->classes_do(f);
   }
 }
 
 void ClassLoaderDataGraph::methods_do(void f(Method*)) {
-  Thread* thread = Thread::current();
-  for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
-    Handle holder(thread, cld->holder_phantom());
+  ClassLoaderDataGraphIterator iter;
+  while (iter.repeat()) {
+    ClassLoaderData* cld = iter.get_next();
     cld->methods_do(f);
   }
 }
 
 void ClassLoaderDataGraph::modules_do(void f(ModuleEntry*)) {
   assert_locked_or_safepoint(Module_lock);
-  Thread* thread = Thread::current();
-  for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
-    Handle holder(thread, cld->holder_phantom());
+  ClassLoaderDataGraphIterator iter;
+  while (iter.repeat()) {
+    ClassLoaderData* cld = iter.get_next();
     cld->modules_do(f);
   }
 }
 
 void ClassLoaderDataGraph::modules_unloading_do(void f(ModuleEntry*)) {
-  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
+  assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
   // Only walk the head until any clds not purged from prior unloading
   // (CMS doesn't purge right away).
   for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) {
@@ -1192,15 +1246,15 @@
 
 void ClassLoaderDataGraph::packages_do(void f(PackageEntry*)) {
   assert_locked_or_safepoint(Module_lock);
-  Thread* thread = Thread::current();
-  for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
-    Handle holder(thread, cld->holder_phantom());
+  ClassLoaderDataGraphIterator iter;
+  while (iter.repeat()) {
+    ClassLoaderData* cld = iter.get_next();
     cld->packages_do(f);
   }
 }
 
 void ClassLoaderDataGraph::packages_unloading_do(void f(PackageEntry*)) {
-  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
+  assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
   // Only walk the head until any clds not purged from prior unloading
   // (CMS doesn't purge right away).
   for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) {
@@ -1210,15 +1264,23 @@
 }
 
 void ClassLoaderDataGraph::loaded_classes_do(KlassClosure* klass_closure) {
-  Thread* thread = Thread::current();
-  for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
-    Handle holder(thread, cld->holder_phantom());
+  ClassLoaderDataGraphIterator iter;
+  while (iter.repeat()) {
+    ClassLoaderData* cld = iter.get_next();
     cld->loaded_classes_do(klass_closure);
   }
 }
 
+// This case can block but cannot do unloading (called from CDS)
+void ClassLoaderDataGraph::unlocked_loaded_classes_do(KlassClosure* klass_closure) {
+  for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
+    cld->loaded_classes_do(klass_closure);
+  }
+}
+
+
 void ClassLoaderDataGraph::classes_unloading_do(void f(Klass* const)) {
-  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
+  assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
   // Only walk the head until any clds not purged from prior unloading
   // (CMS doesn't purge right away).
   for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) {
@@ -1227,24 +1289,22 @@
   }
 }
 
-#define FOR_ALL_DICTIONARY(X) for (ClassLoaderData* X = _head; X != NULL; X = X->next()) \
-                                if (X->dictionary() != NULL)
+#define FOR_ALL_DICTIONARY(X)   ClassLoaderDataGraphIterator iter; \
+                                ClassLoaderData* X; \
+                                while ((X = iter.get_next()) != NULL) \
+                                  if (X->dictionary() != NULL)
 
 // Walk classes in the loaded class dictionaries in various forms.
 // Only walks the classes defined in this class loader.
 void ClassLoaderDataGraph::dictionary_classes_do(void f(InstanceKlass*)) {
-  Thread* thread = Thread::current();
   FOR_ALL_DICTIONARY(cld) {
-    Handle holder(thread, cld->holder_phantom());
     cld->dictionary()->classes_do(f);
   }
 }
 
 // Only walks the classes defined in this class loader.
 void ClassLoaderDataGraph::dictionary_classes_do(void f(InstanceKlass*, TRAPS), TRAPS) {
-  Thread* thread = Thread::current();
   FOR_ALL_DICTIONARY(cld) {
-    Handle holder(thread, cld->holder_phantom());
     cld->dictionary()->classes_do(f, CHECK);
   }
 }
@@ -1275,6 +1335,7 @@
 }
 
 GrowableArray<ClassLoaderData*>* ClassLoaderDataGraph::new_clds() {
+  assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
   assert(_head == NULL || _saved_head != NULL, "remember_new_clds(true) not called?");
 
   GrowableArray<ClassLoaderData*>* array = new GrowableArray<ClassLoaderData*>();
@@ -1301,6 +1362,7 @@
 
 #ifndef PRODUCT
 bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) {
+  assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
   for (ClassLoaderData* data = _head; data != NULL; data = data->next()) {
     if (loader_data == data) {
       return true;
@@ -1314,6 +1376,7 @@
 // Move class loader data from main list to the unloaded list for unloading
 // and deallocation later.
 bool ClassLoaderDataGraph::do_unloading(bool do_cleaning) {
+  assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
 
   // Indicate whether safepoint cleanup is needed.
   _safepoint_cleanup_needed |= do_cleaning;
@@ -1362,6 +1425,8 @@
 // There's at least one dead class loader.  Purge refererences of healthy module
 // reads lists and package export lists to modules belonging to dead loaders.
 void ClassLoaderDataGraph::clean_module_and_package_info() {
+  assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
+
   ClassLoaderData* data = _head;
   while (data != NULL) {
     // Remove entries in the dictionary of live class loader that have
@@ -1418,6 +1483,7 @@
 
 ClassLoaderDataGraphKlassIteratorAtomic::ClassLoaderDataGraphKlassIteratorAtomic()
     : _next_klass(NULL) {
+  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
   ClassLoaderData* cld = ClassLoaderDataGraph::_head;
   Klass* klass = NULL;
 
@@ -1474,6 +1540,7 @@
 }
 
 ClassLoaderDataGraphMetaspaceIterator::ClassLoaderDataGraphMetaspaceIterator() {
+  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
   _data = ClassLoaderDataGraph::_head;
 }
 
@@ -1488,14 +1555,18 @@
 }
 
 void ClassLoaderDataGraph::verify() {
-  for (ClassLoaderData* data = _head; data != NULL; data = data->next()) {
-    data->verify();
+  ClassLoaderDataGraphIterator iter;
+  while (iter.repeat()) {
+    ClassLoaderData* cld = iter.get_next();
+    cld->verify();
   }
 }
 
 void ClassLoaderDataGraph::print_on(outputStream * const out) {
-  for (ClassLoaderData* data = _head; data != NULL; data = data->next()) {
-    data->print_on(out);
+  ClassLoaderDataGraphIterator iter;
+  while (iter.repeat()) {
+    ClassLoaderData* cld = iter.get_next();
+    cld->print_on(out);
   }
 }
 #endif // PRODUCT
--- a/src/hotspot/share/classfile/classLoaderData.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/classfile/classLoaderData.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -70,6 +70,7 @@
   friend class ClassLoaderDataGraphMetaspaceIterator;
   friend class ClassLoaderDataGraphKlassIteratorAtomic;
   friend class ClassLoaderDataGraphKlassIteratorStatic;
+  friend class ClassLoaderDataGraphIterator;
   friend class VMStructs;
  private:
   // All CLDs (except the null CLD) can be reached by walking _head->_next->...
@@ -118,6 +119,7 @@
   static void packages_do(void f(PackageEntry*));
   static void packages_unloading_do(void f(PackageEntry*));
   static void loaded_classes_do(KlassClosure* klass_closure);
+  static void unlocked_loaded_classes_do(KlassClosure* klass_closure);
   static void classes_unloading_do(void f(Klass* const));
   static bool do_unloading(bool do_cleaning);
 
@@ -177,6 +179,20 @@
 #endif
 };
 
+class LockedClassesDo : public KlassClosure {
+  typedef void (*classes_do_func_t)(Klass*);
+  classes_do_func_t _function;
+public:
+  LockedClassesDo();  // For callers who provide their own do_klass
+  LockedClassesDo(classes_do_func_t function);
+  ~LockedClassesDo();
+
+  void do_klass(Klass* k) {
+    (*_function)(k);
+  }
+};
+
+
 // ClassLoaderData class
 
 class ClassLoaderData : public CHeapObj<mtClass> {
@@ -213,6 +229,7 @@
   };
 
   friend class ClassLoaderDataGraph;
+  friend class ClassLoaderDataGraphIterator;
   friend class ClassLoaderDataGraphKlassIteratorAtomic;
   friend class ClassLoaderDataGraphKlassIteratorStatic;
   friend class ClassLoaderDataGraphMetaspaceIterator;
--- a/src/hotspot/share/classfile/javaClasses.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/classfile/javaClasses.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1213,6 +1213,14 @@
 bool java_lang_Class::restore_archived_mirror(Klass *k,
                                               Handle class_loader, Handle module,
                                               Handle protection_domain, TRAPS) {
+  // Postpone restoring archived mirror until java.lang.Class is loaded. Please
+  // see more details in SystemDictionary::resolve_preloaded_classes().
+  if (!SystemDictionary::Class_klass_loaded()) {
+    assert(fixup_mirror_list() != NULL, "fixup_mirror_list not initialized");
+    fixup_mirror_list()->push(k);
+    return true;
+  }
+
   oop m = MetaspaceShared::materialize_archived_object(k->archived_java_mirror_raw_narrow());
 
   if (m == NULL) {
@@ -1225,10 +1233,6 @@
   assert(MetaspaceShared::is_archive_object(m), "must be archived mirror object");
   Handle mirror(THREAD, m);
 
-  // The java.lang.Class field offsets were archived and reloaded from archive.
-  // No need to put classes on the fixup_mirror_list before java.lang.Class
-  // is loaded.
-
   if (!k->is_array_klass()) {
     // - local static final fields with initial values were initialized at dump time
 
--- a/src/hotspot/share/classfile/protectionDomainCache.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/classfile/protectionDomainCache.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -44,11 +44,19 @@
 
 ProtectionDomainCacheTable::ProtectionDomainCacheTable(int table_size)
   : Hashtable<ClassLoaderWeakHandle, mtClass>(table_size, sizeof(ProtectionDomainCacheEntry))
-{
+{   _dead_entries = false;
+    _total_oops_removed = 0;
+}
+
+void ProtectionDomainCacheTable::trigger_cleanup() {
+  MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
+  _dead_entries = true;
+  Service_lock->notify_all();
 }
 
 void ProtectionDomainCacheTable::unlink() {
-  assert(SafepointSynchronize::is_at_safepoint(), "must be");
+  MutexLocker ml(SystemDictionary_lock);
+  int oops_removed = 0;
   for (int i = 0; i < table_size(); ++i) {
     ProtectionDomainCacheEntry** p = bucket_addr(i);
     ProtectionDomainCacheEntry* entry = bucket(i);
@@ -57,7 +65,8 @@
       if (pd != NULL) {
         p = entry->next_addr();
       } else {
-        LogTarget(Debug, protectiondomain) lt;
+        oops_removed++;
+        LogTarget(Debug, protectiondomain, table) lt;
         if (lt.is_enabled()) {
           LogStream ls(lt);
           ls.print_cr("protection domain unlinked at %d", i);
@@ -69,9 +78,12 @@
       entry = *p;
     }
   }
+  _total_oops_removed += oops_removed;
+  _dead_entries = false;
 }
 
 void ProtectionDomainCacheTable::print_on(outputStream* st) const {
+  assert_locked_or_safepoint(SystemDictionary_lock);
   st->print_cr("Protection domain cache table (table_size=%d, classes=%d)",
                table_size(), number_of_entries());
   for (int index = 0; index < table_size(); index++) {
@@ -124,6 +136,7 @@
 }
 
 ProtectionDomainCacheEntry* ProtectionDomainCacheTable::find_entry(int index, Handle protection_domain) {
+  assert_locked_or_safepoint(SystemDictionary_lock);
   for (ProtectionDomainCacheEntry* e = bucket(index); e != NULL; e = e->next()) {
     if (oopDesc::equals(e->object_no_keepalive(), protection_domain())) {
       return e;
@@ -138,6 +151,13 @@
   assert(index == index_for(protection_domain), "incorrect index?");
   assert(find_entry(index, protection_domain) == NULL, "no double entry");
 
+  LogTarget(Debug, protectiondomain, table) lt;
+  if (lt.is_enabled()) {
+    LogStream ls(lt);
+    ls.print("protection domain added ");
+    protection_domain->print_value_on(&ls);
+    ls.cr();
+  }
   ClassLoaderWeakHandle w = ClassLoaderWeakHandle::create(protection_domain);
   ProtectionDomainCacheEntry* p = new_entry(hash, w);
   Hashtable<ClassLoaderWeakHandle, mtClass>::add_entry(index, p);
--- a/src/hotspot/share/classfile/protectionDomainCache.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/classfile/protectionDomainCache.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -85,6 +85,9 @@
   ProtectionDomainCacheEntry* add_entry(int index, unsigned int hash, Handle protection_domain);
   ProtectionDomainCacheEntry* find_entry(int index, Handle protection_domain);
 
+  bool _dead_entries;
+  int _total_oops_removed;
+
 public:
   ProtectionDomainCacheTable(int table_size);
   ProtectionDomainCacheEntry* get(Handle protection_domain);
@@ -93,6 +96,11 @@
 
   void print_on(outputStream* st) const;
   void verify();
+
+  bool has_work() { return _dead_entries; }
+  void trigger_cleanup();
+
+  int removed_entries_count() { return _total_oops_removed; };
 };
 
 
--- a/src/hotspot/share/classfile/systemDictionary.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/classfile/systemDictionary.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1884,7 +1884,7 @@
     // Oops referenced by the protection domain cache table may get unreachable independently
     // of the class loader (eg. cached protection domain oops). So we need to
     // explicitly unlink them here.
-    _pd_cache_table->unlink();
+    _pd_cache_table->trigger_cleanup();
   }
 
   if (do_cleaning) {
@@ -1919,6 +1919,7 @@
 
 void SystemDictionary::methods_do(void f(Method*)) {
   // Walk methods in loaded classes
+  MutexLocker ml(ClassLoaderDataGraph_lock);
   ClassLoaderDataGraph::methods_do(f);
   // Walk method handle intrinsics
   invoke_method_table()->methods_do(f);
@@ -1936,6 +1937,7 @@
 void SystemDictionary::remove_classes_in_error_state() {
   ClassLoaderData::the_null_class_loader_data()->dictionary()->remove_classes_in_error_state();
   RemoveClassesClosure rcc;
+  MutexLocker ml(ClassLoaderDataGraph_lock);
   ClassLoaderDataGraph::cld_do(&rcc);
 }
 
@@ -2026,6 +2028,22 @@
 #if INCLUDE_CDS
   if (UseSharedSpaces) {
     resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Object_klass), scan, CHECK);
+
+    // It's unsafe to access the archived heap regions before they
+    // are fixed up, so we must do the fixup as early as possible
+    // before the archived java objects are accessed by functions
+    // such as java_lang_Class::restore_archived_mirror and
+    // ConstantPool::restore_unshareable_info (restores the archived
+    // resolved_references array object).
+    //
+    // MetaspaceShared::fixup_mapped_heap_regions() fills the empty
+    // spaces in the archived heap regions and may use
+    // SystemDictionary::Object_klass(), so we can do this only after
+    // Object_klass is resolved. See the above resolve_wk_klasses_through()
+    // call. No mirror objects are accessed/restored in the above call.
+    // Mirrors are restored after java.lang.Class is loaded.
+    MetaspaceShared::fixup_mapped_heap_regions();
+
     // Initialize the constant pool for the Object_class
     Object_klass()->constants()->restore_unshareable_info(CHECK);
     resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
--- a/src/hotspot/share/classfile/systemDictionary.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/classfile/systemDictionary.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -376,6 +376,9 @@
   // System loader lock
   static oop system_loader_lock()           { return _system_loader_lock_obj; }
 
+  // Protection Domain Table
+  static ProtectionDomainCacheTable* pd_cache_table() { return _pd_cache_table; }
+
 public:
   // Sharing support.
   static void reorder_dictionary_for_sharing() NOT_CDS_RETURN;
--- a/src/hotspot/share/code/codeHeapState.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/code/codeHeapState.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -2168,9 +2168,8 @@
 
         // this_blob->as_nmethod_or_null() is safe. Inlined, maybe invisible on stack.
         nmethod*    nm     = this_blob->as_nmethod_or_null();
-        Method*     method = (nm == NULL) ? NULL : nm->method();  // may be uninitialized, i.e. != NULL, but invalid
-        if ((nm != NULL) && (method != NULL) && (cbType != nMethod_dead) && (cbType != nMethod_inconstruction) &&
-            os::is_readable_pointer(method) && os::is_readable_pointer(method->constants())) {
+        if (CompiledMethod::nmethod_access_is_safe(nm)) {
+          Method* method = nm->method();
           ResourceMark rm;
           //---<  collect all data to locals as quickly as possible  >---
           unsigned int total_size = nm->total_size();
--- a/src/hotspot/share/code/compiledMethod.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/code/compiledMethod.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -619,3 +619,18 @@
     }
   }
 }
+
+// Iterating over all nmethods, e.g. with the help of CodeCache::nmethods_do(fun) was found
+// to not be inherently safe. There is a chance that fields are seen which are not properly
+// initialized. This happens despite the fact that nmethods_do() asserts the CodeCache_lock
+// to be held.
+// To bundle knowledge about necessary checks in one place, this function was introduced.
+// It is not claimed that these checks are sufficient, but they were found to be necessary.
+bool CompiledMethod::nmethod_access_is_safe(nmethod* nm) {
+  Method* method = (nm == NULL) ? NULL : nm->method();  // nm->method() may be uninitialized, i.e. != NULL, but invalid
+  return (nm != NULL) && (method != NULL) && (method->signature() != NULL) &&
+         !nm->is_zombie() && !nm->is_not_installed() &&
+         os::is_readable_pointer(method) &&
+         os::is_readable_pointer(method->constants()) &&
+         os::is_readable_pointer(method->signature());
+}
--- a/src/hotspot/share/code/compiledMethod.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/code/compiledMethod.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -238,6 +238,8 @@
     return _mark_for_deoptimization_status != deoptimize_noupdate;
   }
 
+  static bool nmethod_access_is_safe(nmethod* nm);
+
   // tells whether frames described by this nmethod can be deoptimized
   // note: native wrappers cannot be deoptimized.
   bool can_be_deoptimized() const { return is_java_method(); }
--- a/src/hotspot/share/code/vtableStubs.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/code/vtableStubs.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -26,6 +26,7 @@
 #include "code/vtableStubs.hpp"
 #include "compiler/compileBroker.hpp"
 #include "compiler/disassembler.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/instanceKlass.hpp"
@@ -92,6 +93,32 @@
 
 VtableStub* VtableStubs::_table[VtableStubs::N];
 int VtableStubs::_number_of_vtable_stubs = 0;
+int VtableStubs::_vtab_stub_size = 0;
+int VtableStubs::_itab_stub_size = 0;
+
+#if defined(PRODUCT)
+  // These values are good for the PRODUCT case (no tracing).
+  static const int first_vtableStub_size =  64;
+  static const int first_itableStub_size = 256;
+#else
+  // These values are good for the non-PRODUCT case (when tracing can be switched on).
+  // To find out, run test workload with
+  //   -Xlog:vtablestubs=Trace -XX:+CountCompiledCalls -XX:+DebugVtables
+  // and use the reported "estimate" value.
+  // Here is a list of observed worst-case values:
+  //               vtable  itable
+  // aarch64:         460     324
+  // arm:               ?       ?
+  // ppc (linux, BE): 404     288
+  // ppc (linux, LE): 356     276
+  // ppc (AIX):       416     296
+  // s390x:           408     256
+  // Solaris-sparc:   792     348
+  // x86 (Linux):     670     309
+  // x86 (MacOS):     682     321
+  static const int first_vtableStub_size = 1024;
+  static const int first_itableStub_size =  512;
+#endif
 
 
 void VtableStubs::initialize() {
@@ -107,6 +134,77 @@
 }
 
 
+int VtableStubs::code_size_limit(bool is_vtable_stub) {
+  if (is_vtable_stub) {
+    return _vtab_stub_size > 0 ? _vtab_stub_size : first_vtableStub_size;
+  } else { // itable stub
+    return _itab_stub_size > 0 ? _itab_stub_size : first_itableStub_size;
+  }
+}   // code_size_limit
+
+
+void VtableStubs::check_and_set_size_limit(bool is_vtable_stub,
+                                           int  code_size,
+                                           int  padding) {
+  const char* name = is_vtable_stub ? "vtable" : "itable";
+
+  guarantee(code_size <= code_size_limit(is_vtable_stub),
+            "buffer overflow in %s stub, code_size is %d, limit is %d", name, code_size, code_size_limit(is_vtable_stub));
+
+  if (is_vtable_stub) {
+    if (log_is_enabled(Trace, vtablestubs)) {
+      if ( (_vtab_stub_size > 0) && ((code_size + padding) > _vtab_stub_size) ) {
+        log_trace(vtablestubs)("%s size estimate needed adjustment from %d to %d bytes",
+                               name, _vtab_stub_size, code_size + padding);
+      }
+    }
+    if ( (code_size + padding) > _vtab_stub_size ) {
+      _vtab_stub_size = code_size + padding;
+    }
+  } else {  // itable stub
+    if (log_is_enabled(Trace, vtablestubs)) {
+      if ( (_itab_stub_size > 0) && ((code_size + padding) > _itab_stub_size) ) {
+        log_trace(vtablestubs)("%s size estimate needed adjustment from %d to %d bytes",
+                               name, _itab_stub_size, code_size + padding);
+      }
+    }
+    if ( (code_size + padding) > _itab_stub_size ) {
+      _itab_stub_size = code_size + padding;
+    }
+  }
+  return;
+}   // check_and_set_size_limit
+
+
+void VtableStubs::bookkeeping(MacroAssembler* masm, outputStream* out, VtableStub* s,
+                              address npe_addr, address ame_addr,   bool is_vtable_stub,
+                              int     index,    int     slop_bytes, int  index_dependent_slop) {
+  const char* name        = is_vtable_stub ? "vtable" : "itable";
+  const int   stub_length = code_size_limit(is_vtable_stub);
+
+  if (log_is_enabled(Trace, vtablestubs)) {
+    log_trace(vtablestubs)("%s #%d at " PTR_FORMAT ": size: %d, estimate: %d, slop area: %d",
+                           name, index, p2i(s->code_begin()),
+                           (int)(masm->pc() - s->code_begin()),
+                           stub_length,
+                           (int)(s->code_end() - masm->pc()));
+  }
+  guarantee(masm->pc() <= s->code_end(), "%s #%d: overflowed buffer, estimated len: %d, actual len: %d, overrun: %d",
+                                         name, index, stub_length,
+                                         (int)(masm->pc() - s->code_begin()),
+                                         (int)(masm->pc() - s->code_end()));
+  assert((masm->pc() + index_dependent_slop) <= s->code_end(), "%s #%d: spare space for 32-bit offset: required = %d, available = %d",
+                                         name, index, index_dependent_slop,
+                                         (int)(s->code_end() - masm->pc()));
+
+  // After the first vtable/itable stub is generated, we have a much
+  // better estimate for the stub size. Remember/update this
+  // estimate after some sanity checks.
+  check_and_set_size_limit(is_vtable_stub, masm->offset(), slop_bytes);
+  s->set_exception_points(npe_addr, ame_addr);
+}
+
+
 address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) {
   assert(vtable_index >= 0, "must be positive");
 
@@ -173,10 +271,7 @@
   uint hash = VtableStubs::hash(stub->is_vtable_stub(), stub->index());
   VtableStub* s;
   for (s = _table[hash]; s != NULL && s != stub; s = s->next()) {}
-  if (s == stub) {
-    return s;
-  }
-  return NULL;
+  return (s == stub) ? s : NULL;
 }
 
 bool VtableStubs::contains(address pc) {
--- a/src/hotspot/share/code/vtableStubs.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/code/vtableStubs.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -25,12 +25,94 @@
 #ifndef SHARE_VM_CODE_VTABLESTUBS_HPP
 #define SHARE_VM_CODE_VTABLESTUBS_HPP
 
+#include "asm/macroAssembler.hpp"
 #include "code/vmreg.hpp"
 #include "memory/allocation.hpp"
 
 // A VtableStub holds an individual code stub for a pair (vtable index, #args) for either itables or vtables
 // There's a one-to-one relationship between a VtableStub and such a pair.
 
+// A word on VtableStub sizing:
+//   Such a vtable/itable stub consists of the instance data
+//   and an immediately following CodeBuffer.
+//   Unfortunately, the required space for the code buffer varies, depending on
+//   the setting of compile time macros (PRODUCT, ASSERT, ...) and of command line
+//   parameters. Actual data may have an influence on the size as well.
+//
+//   A simple approximation for the VtableStub size would be to just take a value
+//   "large enough" for all circumstances - a worst case estimate.
+//   As there can exist many stubs - and they never go away - we certainly don't
+//   want to waste more code cache space than absolutely necessary.
+//
+//   We need a different approach which, as far as possible, should be independent
+//   from or adaptive to code size variations. These variations may be caused by
+//   changed compile time or run time switches as well as by changed emitter code.
+//
+//   Here is the idea:
+//   For the first stub we generate, we allocate a "large enough" code buffer.
+//   Once all instructions are emitted, we know the actual size of the stub.
+//   Remembering that size allows us to allocate a tightly matching code buffer
+//   for all subsequent stubs. That covers all "static variance", i.e. all variance
+//   that is due to compile time macros, command line parameters, machine capabilities,
+//   and other influences which are immutable for the life span of the vm.
+//
+//   Life isn't always that easy. Code size may depend on actual data, "load constant"
+//   being an example for that. All code segments with such "dynamic variance" require
+//   additional care. We need to know or estimate the worst case code size for each
+//   such segment. With that knowledge, we can maintain a "slop counter" in the
+//   platform-specific stub emitters. It accumulates the difference between worst-case
+//   and actual code size. When the stub is fully generated, the actual stub size is
+//   adjusted (increased) by the slop counter value.
+//
+//   As a result, we allocate all but the first code buffers with the same, tightly matching size.
+//
+
+// VtableStubs creates the code stubs for compiled calls through vtables.
+// There is one stub per (vtable index, args_size) pair, and the stubs are
+// never deallocated. They don't need to be GCed because they contain no oops.
+class VtableStub;
+
+class VtableStubs : AllStatic {
+ public:                                         // N must be public (some compilers need this for _table)
+  enum {
+    N    = 256,                                  // size of stub table; must be power of two
+    mask = N - 1
+  };
+
+ private:
+  friend class VtableStub;
+  static VtableStub* _table[N];                  // table of existing stubs
+  static int         _number_of_vtable_stubs;    // number of stubs created so far (for statistics)
+  static int         _vtab_stub_size;            // current size estimate for vtable stub (quasi-constant)
+  static int         _itab_stub_size;            // current size estimate for itable stub (quasi-constant)
+
+  static VtableStub* create_vtable_stub(int vtable_index);
+  static VtableStub* create_itable_stub(int vtable_index);
+  static VtableStub* lookup            (bool is_vtable_stub, int vtable_index);
+  static void        enter             (bool is_vtable_stub, int vtable_index, VtableStub* s);
+  static inline uint hash              (bool is_vtable_stub, int vtable_index);
+  static address     find_stub         (bool is_vtable_stub, int vtable_index);
+  static void        bookkeeping(MacroAssembler* masm, outputStream* out, VtableStub* s,
+                                 address npe_addr, address ame_addr,   bool is_vtable_stub,
+                                 int     index,    int     slop_bytes, int  index_dependent_slop);
+  static int         code_size_limit(bool is_vtable_stub);
+  static void        check_and_set_size_limit(bool is_vtable_stub,
+                                              int   code_size,
+                                              int   padding);
+
+ public:
+  static address     find_vtable_stub(int vtable_index) { return find_stub(true,  vtable_index); }
+  static address     find_itable_stub(int itable_index) { return find_stub(false, itable_index); }
+
+  static VtableStub* entry_point(address pc);                        // vtable stub entry point for a pc
+  static bool        contains(address pc);                           // is pc within any stub?
+  static VtableStub* stub_containing(address pc);                    // stub containing pc or NULL
+  static int         number_of_vtable_stubs() { return _number_of_vtable_stubs; }
+  static void        initialize();
+  static void        vtable_stub_do(void f(VtableStub*));            // iterates over all vtable stubs
+};
+
+
 class VtableStub {
  private:
   friend class VtableStubs;
@@ -58,7 +140,7 @@
 
  public:
   address code_begin() const                     { return (address)(this + 1); }
-  address code_end() const                       { return code_begin() + pd_code_size_limit(_is_vtable_stub); }
+  address code_end() const                       { return code_begin() + VtableStubs::code_size_limit(_is_vtable_stub); }
   address entry_point() const                    { return code_begin(); }
   static int entry_offset()                      { return sizeof(class VtableStub); }
 
@@ -78,7 +160,6 @@
   }
 
   // platform-dependent routines
-  static int  pd_code_size_limit(bool is_vtable_stub);
   static int  pd_code_alignment();
   // CNC: Removed because vtable stubs are now made with an ideal graph
   // static bool pd_disregard_arg_size();
@@ -100,38 +181,4 @@
 
 };
 
-
-// VtableStubs creates the code stubs for compiled calls through vtables.
-// There is one stub per (vtable index, args_size) pair, and the stubs are
-// never deallocated. They don't need to be GCed because they contain no oops.
-
-class VtableStubs : AllStatic {
- public:                                         // N must be public (some compilers need this for _table)
-  enum {
-    N    = 256,                                  // size of stub table; must be power of two
-    mask = N - 1
-  };
-
- private:
-  static VtableStub* _table[N];                  // table of existing stubs
-  static int         _number_of_vtable_stubs;    // number of stubs created so far (for statistics)
-
-  static VtableStub* create_vtable_stub(int vtable_index);
-  static VtableStub* create_itable_stub(int vtable_index);
-  static VtableStub* lookup            (bool is_vtable_stub, int vtable_index);
-  static void        enter             (bool is_vtable_stub, int vtable_index, VtableStub* s);
-  static inline uint hash              (bool is_vtable_stub, int vtable_index);
-  static address     find_stub         (bool is_vtable_stub, int vtable_index);
-
- public:
-  static address     find_vtable_stub(int vtable_index) { return find_stub(true,  vtable_index); }
-  static address     find_itable_stub(int itable_index) { return find_stub(false, itable_index); }
-  static VtableStub* entry_point(address pc);                        // vtable stub entry point for a pc
-  static bool        contains(address pc);                           // is pc within any stub?
-  static VtableStub* stub_containing(address pc);                    // stub containing pc or NULL
-  static int         number_of_vtable_stubs() { return _number_of_vtable_stubs; }
-  static void        initialize();
-  static void        vtable_stub_do(void f(VtableStub*));            // iterates over all vtable stubs
-};
-
 #endif // SHARE_VM_CODE_VTABLESTUBS_HPP
--- a/src/hotspot/share/compiler/compileBroker.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/compiler/compileBroker.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1637,6 +1637,12 @@
  * out to be a problem.
  */
 void CompileBroker::shutdown_compiler_runtime(AbstractCompiler* comp, CompilerThread* thread) {
+  // Free buffer blob, if allocated
+  if (thread->get_buffer_blob() != NULL) {
+    MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
+    CodeCache::free(thread->get_buffer_blob());
+  }
+
   if (comp->should_perform_shutdown()) {
     // There are two reasons for shutting down the compiler
     // 1) compiler runtime initialization failed
@@ -1767,6 +1773,11 @@
             tty->print_cr("Removing compiler thread %s after " JLONG_FORMAT " ms idle time",
                           thread->name(), thread->idle_time_millis());
           }
+          // Free buffer blob, if allocated
+          if (thread->get_buffer_blob() != NULL) {
+            MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
+            CodeCache::free(thread->get_buffer_blob());
+          }
           return; // Stop this thread.
         }
       }
--- a/src/hotspot/share/gc/cms/cmsCardTable.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/cms/cmsCardTable.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -79,7 +79,7 @@
   pst->set_n_tasks(n_strides);
 
   uint stride = 0;
-  while (!pst->is_task_claimed(/* reference */ stride)) {
+  while (pst->try_claim_task(/* reference */ stride)) {
     process_stride(sp, mr, stride, n_strides,
                    cl, ct,
                    lowest_non_clean,
--- a/src/hotspot/share/gc/cms/cmsHeap.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/cms/cmsHeap.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -69,7 +69,7 @@
     GenCollectedHeap(policy,
                      Generation::ParNew,
                      Generation::ConcurrentMarkSweep,
-                     "ParNew::CMS"),
+                     "ParNew:CMS"),
     _eden_pool(NULL),
     _survivor_pool(NULL),
     _old_pool(NULL) {
@@ -231,7 +231,7 @@
   }
 
   if (young_gen_as_roots &&
-      !_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
+      _process_strong_tasks->try_claim_task(GCH_PS_younger_gens)) {
     root_closure->set_generation(young_gen());
     young_gen()->oop_iterate(root_closure);
     root_closure->reset_generation();
--- a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -3225,7 +3225,7 @@
   }
 
   size_t chunk_size = sp->marking_task_size();
-  while (!pst->is_task_claimed(/* reference */ nth_task)) {
+  while (pst->try_claim_task(/* reference */ nth_task)) {
     // Having claimed the nth task in this space,
     // compute the chunk that it corresponds to:
     MemRegion span = MemRegion(aligned_start + nth_task*chunk_size,
@@ -4074,6 +4074,8 @@
 
 // The freelist lock is needed to prevent asserts, is it really needed?
 void CMSCollector::preclean_cld(MarkRefsIntoAndScanClosure* cl, Mutex* freelistLock) {
+  // Needed to walk CLDG
+  MutexLocker ml(ClassLoaderDataGraph_lock);
 
   cl->set_freelistLock(freelistLock);
 
@@ -4494,7 +4496,7 @@
   if (n_tasks > 0) {
     assert(pst->valid(), "Uninitialized use?");
     HeapWord *start, *end;
-    while (!pst->is_task_claimed(/* reference */ nth_task)) {
+    while (pst->try_claim_task(/* reference */ nth_task)) {
       // We claimed task # nth_task; compute its boundaries.
       if (chunk_top == 0) {  // no samples were taken
         assert(nth_task == 0 && n_tasks == 1, "Can have only 1 eden task");
@@ -4580,7 +4582,7 @@
   assert(is_aligned(start_addr, alignment), "Check alignment");
   assert(is_aligned(chunk_size, alignment), "Check alignment");
 
-  while (!pst->is_task_claimed(/* reference */ nth_task)) {
+  while (pst->try_claim_task(/* reference */ nth_task)) {
     // Having claimed the nth_task, compute corresponding mem-region,
     // which is a-fortiori aligned correctly (i.e. at a MUT boundary).
     // The alignment restriction ensures that we do not need any
--- a/src/hotspot/share/gc/epsilon/epsilon_globals.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/epsilon/epsilon_globals.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -79,7 +79,7 @@
           "improves performance at the expense of per-thread memory waste. "\
           "Lower value improves memory footprint, but penalizes actively "  \
           "allocating threads.")                                            \
-          range(1, max_intx)                                                \
+          range(1.0, DBL_MAX)                                               \
                                                                             \
   experimental(size_t, EpsilonTLABDecayTime, 1000,                          \
           "TLAB sizing policy decays to initial size after thread had not " \
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -4654,6 +4654,10 @@
   _g1mm->initialize_serviceability();
 }
 
+MemoryUsage G1CollectedHeap::memory_usage() {
+  return _g1mm->memory_usage();
+}
+
 GrowableArray<GCMemoryManager*> G1CollectedHeap::memory_managers() {
   return _g1mm->memory_managers();
 }
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -961,6 +961,7 @@
   virtual SoftRefPolicy* soft_ref_policy();
 
   virtual void initialize_serviceability();
+  virtual MemoryUsage memory_usage();
   virtual GrowableArray<GCMemoryManager*> memory_managers();
   virtual GrowableArray<MemoryPool*> memory_pools();
 
--- a/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -28,23 +28,8 @@
 #include "gc/g1/heapRegion.hpp"
 #include "memory/virtualspace.hpp"
 
-void G1CMBitMap::print_on_error(outputStream* st, const char* prefix) const {
-  _bm.print_on_error(st, prefix);
-}
-
-size_t G1CMBitMap::compute_size(size_t heap_size) {
-  return ReservedSpace::allocation_align_size_up(heap_size / mark_distance());
-}
-
-size_t G1CMBitMap::mark_distance() {
-  return MinObjAlignmentInBytes * BitsPerByte;
-}
-
 void G1CMBitMap::initialize(MemRegion heap, G1RegionToSpaceMapper* storage) {
-  _covered = heap;
-
-  _bm = BitMapView((BitMap::bm_word_t*) storage->reserved().start(), _covered.word_size() >> _shifter);
-
+  MarkBitMap::initialize(heap, storage->reserved());
   storage->set_mapping_changed_listener(&_listener);
 }
 
@@ -57,19 +42,17 @@
   _bm->clear_range(mr);
 }
 
-void G1CMBitMap::clear_range(MemRegion mr) {
-  MemRegion intersection = mr.intersection(_covered);
-  assert(!intersection.is_empty(),
-         "Given range from " PTR_FORMAT " to " PTR_FORMAT " is completely outside the heap",
-         p2i(mr.start()), p2i(mr.end()));
-  // convert address range into offset range
-  _bm.at_put_range(addr_to_offset(intersection.start()),
-                   addr_to_offset(intersection.end()), false);
-}
-
 void G1CMBitMap::clear_region(HeapRegion* region) {
  if (!region->is_empty()) {
    MemRegion mr(region->bottom(), region->top());
    clear_range(mr);
  }
 }
+
+#ifdef ASSERT
+void G1CMBitMap::check_mark(HeapWord* addr) {
+  assert(G1CollectedHeap::heap()->is_in_exact(addr),
+         "Trying to access bitmap " PTR_FORMAT " for address " PTR_FORMAT " not in the heap.",
+         p2i(this), p2i(addr));
+}
+#endif
--- a/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -26,6 +26,7 @@
 #define SHARE_VM_GC_G1_G1CONCURRENTMARKBITMAP_HPP
 
 #include "gc/g1/g1RegionToSpaceMapper.hpp"
+#include "gc/shared/markBitMap.hpp"
 #include "memory/memRegion.hpp"
 #include "oops/oopsHierarchy.hpp"
 #include "utilities/bitMap.hpp"
@@ -59,68 +60,24 @@
 
 // A generic mark bitmap for concurrent marking.  This is essentially a wrapper
 // around the BitMap class that is based on HeapWords, with one bit per (1 << _shifter) HeapWords.
-class G1CMBitMap {
-  MemRegion _covered;    // The heap area covered by this bitmap.
-
-  const int _shifter;    // Shift amount from heap index to bit index in the bitmap.
-
-  BitMapView _bm;        // The actual bitmap.
+class G1CMBitMap : public MarkBitMap {
 
   G1CMBitMapMappingChangedListener _listener;
 
-  inline void check_mark(HeapWord* addr) NOT_DEBUG_RETURN;
+protected:
 
-  // Convert from bit offset to address.
-  HeapWord* offset_to_addr(size_t offset) const {
-    return _covered.start() + (offset << _shifter);
-  }
-  // Convert from address to bit offset.
-  size_t addr_to_offset(const HeapWord* addr) const {
-    return pointer_delta(addr, _covered.start()) >> _shifter;
-  }
+  virtual void check_mark(HeapWord* addr) NOT_DEBUG_RETURN;
+
 public:
-  static size_t compute_size(size_t heap_size);
-  // Returns the amount of bytes on the heap between two marks in the bitmap.
-  static size_t mark_distance();
-  // Returns how many bytes (or bits) of the heap a single byte (or bit) of the
-  // mark bitmap corresponds to. This is the same as the mark distance above.
-  static size_t heap_map_factor() {
-    return mark_distance();
-  }
 
-  G1CMBitMap() : _covered(), _shifter(LogMinObjAlignment), _bm(), _listener() { _listener.set_bitmap(this); }
+  G1CMBitMap() : MarkBitMap(), _listener() { _listener.set_bitmap(this); }
 
   // Initializes the underlying BitMap to cover the given area.
   void initialize(MemRegion heap, G1RegionToSpaceMapper* storage);
 
-  // Read marks
-  bool is_marked(oop obj) const;
-  bool is_marked(HeapWord* addr) const {
-    assert(_covered.contains(addr),
-           "Address " PTR_FORMAT " is outside underlying space from " PTR_FORMAT " to " PTR_FORMAT,
-           p2i(addr), p2i(_covered.start()), p2i(_covered.end()));
-    return _bm.at(addr_to_offset(addr));
-  }
-
   // Apply the closure to the addresses that correspond to marked bits in the bitmap.
   inline bool iterate(G1CMBitMapClosure* cl, MemRegion mr);
 
-  // Return the address corresponding to the next marked bit at or after
-  // "addr", and before "limit", if "limit" is non-NULL.  If there is no
-  // such bit, returns "limit" if that is non-NULL, or else "endWord()".
-  inline HeapWord* get_next_marked_addr(const HeapWord* addr,
-                                        const HeapWord* limit) const;
-
-  void print_on_error(outputStream* st, const char* prefix) const;
-
-  // Write marks.
-  inline void mark(HeapWord* addr);
-  inline void clear(HeapWord* addr);
-  inline void clear(oop obj);
-  inline bool par_mark(HeapWord* addr);
-  inline bool par_mark(oop obj);
-
-  void clear_range(MemRegion mr);
   void clear_region(HeapRegion* hr);
 };
 
--- a/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.inline.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.inline.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -26,6 +26,7 @@
 #define SHARE_VM_GC_G1_G1CONCURRENTMARKBITMAP_INLINE_HPP
 
 #include "gc/g1/g1ConcurrentMarkBitMap.hpp"
+#include "gc/shared/markBitMap.inline.hpp"
 #include "memory/memRegion.hpp"
 #include "utilities/align.hpp"
 #include "utilities/bitMap.inline.hpp"
@@ -50,49 +51,4 @@
   return true;
 }
 
-inline HeapWord* G1CMBitMap::get_next_marked_addr(const HeapWord* addr,
-                                                  const HeapWord* limit) const {
-  assert(limit != NULL, "limit must not be NULL");
-  // Round addr up to a possible object boundary to be safe.
-  size_t const addr_offset = addr_to_offset(align_up(addr, HeapWordSize << _shifter));
-  size_t const limit_offset = addr_to_offset(limit);
-  size_t const nextOffset = _bm.get_next_one_offset(addr_offset, limit_offset);
-  return offset_to_addr(nextOffset);
-}
-
-#ifdef ASSERT
-inline void G1CMBitMap::check_mark(HeapWord* addr) {
-  assert(G1CollectedHeap::heap()->is_in_exact(addr),
-         "Trying to access bitmap " PTR_FORMAT " for address " PTR_FORMAT " not in the heap.",
-         p2i(this), p2i(addr));
-}
-#endif
-
-inline void G1CMBitMap::mark(HeapWord* addr) {
-  check_mark(addr);
-  _bm.set_bit(addr_to_offset(addr));
-}
-
-inline void G1CMBitMap::clear(HeapWord* addr) {
-  check_mark(addr);
-  _bm.clear_bit(addr_to_offset(addr));
-}
-
-inline bool G1CMBitMap::par_mark(HeapWord* addr) {
-  check_mark(addr);
-  return _bm.par_set_bit(addr_to_offset(addr));
-}
-
-inline bool G1CMBitMap::par_mark(oop obj) {
-  return par_mark((HeapWord*) obj);
-}
-
-inline bool G1CMBitMap::is_marked(oop obj) const{
-  return is_marked((HeapWord*) obj);
-}
-
-inline void G1CMBitMap::clear(oop obj) {
-  clear((HeapWord*) obj);
-}
-
 #endif // SHARE_VM_GC_G1_G1CONCURRENTMARKBITMAP_INLINE_HPP
--- a/src/hotspot/share/gc/g1/g1MemoryPool.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1MemoryPool.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -48,9 +48,7 @@
                     false /* support_usage_threshold */) { }
 
 MemoryUsage G1EdenPool::get_memory_usage() {
-  size_t committed  = _g1mm->eden_space_committed();
-
-  return MemoryUsage(initial_size(), used_in_bytes(), committed, max_size());
+  return _g1mm->eden_space_memory_usage(initial_size(), max_size());
 }
 
 G1SurvivorPool::G1SurvivorPool(G1CollectedHeap* g1h, size_t initial_size) :
@@ -61,9 +59,7 @@
                     false /* support_usage_threshold */) { }
 
 MemoryUsage G1SurvivorPool::get_memory_usage() {
-  size_t committed  = _g1mm->survivor_space_committed();
-
-  return MemoryUsage(initial_size(), used_in_bytes(), committed, max_size());
+  return _g1mm->survivor_space_memory_usage(initial_size(), max_size());
 }
 
 G1OldGenPool::G1OldGenPool(G1CollectedHeap* g1h, size_t initial_size, size_t max_size) :
@@ -74,7 +70,5 @@
                     true /* support_usage_threshold */) { }
 
 MemoryUsage G1OldGenPool::get_memory_usage() {
-  size_t committed  = _g1mm->old_gen_committed();
-
-  return MemoryUsage(initial_size(), used_in_bytes(), committed, max_size());
+  return _g1mm->old_gen_memory_usage(initial_size(), max_size());
 }
--- a/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -170,7 +170,9 @@
   // Given that this survivor space is not used, we update it here
   // once to reflect that its used space is 0 so that we don't have to
   // worry about updating it again later.
-  _from_space_counters->update_used(0);
+  if (UsePerfData) {
+    _from_space_counters->update_used(0);
+  }
 
   //  name "generation.0.space.2"
   // See _old_space_counters for additional counters
@@ -200,6 +202,11 @@
   _incremental_memory_manager.add_pool(_old_gen_pool, false /* always_affected_by_gc */);
 }
 
+MemoryUsage G1MonitoringSupport::memory_usage() {
+  MutexLockerEx x(MonitoringSupport_lock, Mutex::_no_safepoint_check_flag);
+  return MemoryUsage(InitialHeapSize, _overall_used, _overall_committed, _g1h->max_capacity());
+}
+
 GrowableArray<GCMemoryManager*> G1MonitoringSupport::memory_managers() {
   GrowableArray<GCMemoryManager*> memory_managers(2);
   memory_managers.append(&_incremental_memory_manager);
@@ -218,6 +225,7 @@
 void G1MonitoringSupport::recalculate_sizes() {
   assert_heap_locked_or_at_safepoint(true);
 
+  MutexLockerEx x(MonitoringSupport_lock, Mutex::_no_safepoint_check_flag);
   // Recalculate all the sizes from scratch.
 
   uint young_list_length = _g1h->young_regions_count();
@@ -294,13 +302,41 @@
 }
 
 void G1MonitoringSupport::update_eden_size() {
-  // Recalculate everything - this is fast enough.
+  // Recalculate everything - this should be fast enough and we are sure that we do not
+  // miss anything.
   recalculate_sizes();
   if (UsePerfData) {
     _eden_space_counters->update_used(_eden_space_used);
   }
 }
 
+MemoryUsage G1MonitoringSupport::eden_space_memory_usage(size_t initial_size, size_t max_size) {
+  MutexLockerEx x(MonitoringSupport_lock, Mutex::_no_safepoint_check_flag);
+
+  return MemoryUsage(initial_size,
+                     _eden_space_used,
+                     _eden_space_committed,
+                     max_size);
+}
+
+MemoryUsage G1MonitoringSupport::survivor_space_memory_usage(size_t initial_size, size_t max_size) {
+  MutexLockerEx x(MonitoringSupport_lock, Mutex::_no_safepoint_check_flag);
+
+  return MemoryUsage(initial_size,
+                     _survivor_space_used,
+                     _survivor_space_committed,
+                     max_size);
+}
+
+MemoryUsage G1MonitoringSupport::old_gen_memory_usage(size_t initial_size, size_t max_size) {
+  MutexLockerEx x(MonitoringSupport_lock, Mutex::_no_safepoint_check_flag);
+
+  return MemoryUsage(initial_size,
+                     _old_gen_used,
+                     _old_gen_committed,
+                     max_size);
+}
+
 G1MonitoringScope::G1MonitoringScope(G1MonitoringSupport* g1mm, bool full_gc, bool all_memory_pools_affected) :
   _tcs(full_gc ? g1mm->_full_collection_counters : g1mm->_incremental_collection_counters),
   _tms(full_gc ? &g1mm->_full_gc_memory_manager : &g1mm->_incremental_memory_manager,
--- a/src/hotspot/share/gc/g1/g1MonitoringSupport.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1MonitoringSupport.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -29,6 +29,7 @@
 #include "gc/shared/generationCounters.hpp"
 #include "services/memoryManager.hpp"
 #include "services/memoryService.hpp"
+#include "runtime/mutex.hpp"
 
 class CollectorCounters;
 class G1CollectedHeap;
@@ -198,6 +199,8 @@
   ~G1MonitoringSupport();
 
   void initialize_serviceability();
+
+  MemoryUsage memory_usage();
   GrowableArray<GCMemoryManager*> memory_managers();
   GrowableArray<MemoryPool*> memory_pools();
 
@@ -230,16 +233,22 @@
   //   MemoryService
   //   jstat counters
   //   Tracing
+  // Values may not be consistent wrt to each other.
 
   size_t young_gen_committed()        { return _young_gen_committed; }
 
-  size_t eden_space_committed()       { return _eden_space_committed; }
   size_t eden_space_used()            { return _eden_space_used; }
-  size_t survivor_space_committed()   { return _survivor_space_committed; }
   size_t survivor_space_used()        { return _survivor_space_used; }
 
   size_t old_gen_committed()          { return _old_gen_committed; }
   size_t old_gen_used()               { return _old_gen_used; }
+
+  // Monitoring support for MemoryPools. Values in the returned MemoryUsage are
+  // guaranteed to be consistent with each other.
+  MemoryUsage eden_space_memory_usage(size_t initial_size, size_t max_size);
+  MemoryUsage survivor_space_memory_usage(size_t initial_size, size_t max_size);
+
+  MemoryUsage old_gen_memory_usage(size_t initial_size, size_t max_size);
 };
 
 // Scope object for java.lang.management support.
--- a/src/hotspot/share/gc/g1/g1RootProcessor.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1RootProcessor.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -95,7 +95,7 @@
   {
     // Now the CM ref_processor roots.
     G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::CMRefRoots, worker_i);
-    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_refProcessor_oops_do)) {
+    if (_process_strong_tasks.try_claim_task(G1RP_PS_refProcessor_oops_do)) {
       // We need to treat the discovered reference lists of the
       // concurrent mark ref processor as roots and keep entries
       // (which are added by the marking threads) on them live
@@ -127,7 +127,7 @@
   // as implicitly live).
   {
     G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::SATBFiltering, worker_i);
-    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_filter_satb_buffers) && _g1h->collector_state()->mark_or_rebuild_in_progress()) {
+    if (_process_strong_tasks.try_claim_task(G1RP_PS_filter_satb_buffers) && _g1h->collector_state()->mark_or_rebuild_in_progress()) {
       G1BarrierSet::satb_mark_queue_set().filter_thread_buffers();
     }
   }
@@ -224,7 +224,7 @@
   // let the thread process the weak CLDs and nmethods.
   {
     G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::CLDGRoots, worker_i);
-    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_ClassLoaderDataGraph_oops_do)) {
+    if (_process_strong_tasks.try_claim_task(G1RP_PS_ClassLoaderDataGraph_oops_do)) {
       ClassLoaderDataGraph::roots_cld_do(closures->strong_clds(), closures->weak_clds());
     }
   }
@@ -245,35 +245,35 @@
 
   {
     G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::UniverseRoots, worker_i);
-    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_Universe_oops_do)) {
+    if (_process_strong_tasks.try_claim_task(G1RP_PS_Universe_oops_do)) {
       Universe::oops_do(strong_roots);
     }
   }
 
   {
     G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::JNIRoots, worker_i);
-    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_JNIHandles_oops_do)) {
+    if (_process_strong_tasks.try_claim_task(G1RP_PS_JNIHandles_oops_do)) {
       JNIHandles::oops_do(strong_roots);
     }
   }
 
   {
     G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ObjectSynchronizerRoots, worker_i);
-    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_ObjectSynchronizer_oops_do)) {
+    if (_process_strong_tasks.try_claim_task(G1RP_PS_ObjectSynchronizer_oops_do)) {
       ObjectSynchronizer::oops_do(strong_roots);
     }
   }
 
   {
     G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ManagementRoots, worker_i);
-    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_Management_oops_do)) {
+    if (_process_strong_tasks.try_claim_task(G1RP_PS_Management_oops_do)) {
       Management::oops_do(strong_roots);
     }
   }
 
   {
     G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::JVMTIRoots, worker_i);
-    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_jvmti_oops_do)) {
+    if (_process_strong_tasks.try_claim_task(G1RP_PS_jvmti_oops_do)) {
       JvmtiExport::oops_do(strong_roots);
     }
   }
@@ -281,7 +281,7 @@
 #if INCLUDE_AOT
   if (UseAOT) {
     G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::AOTCodeRoots, worker_i);
-    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_aot_oops_do)) {
+    if (_process_strong_tasks.try_claim_task(G1RP_PS_aot_oops_do)) {
         AOTLoader::oops_do(strong_roots);
     }
   }
@@ -289,7 +289,7 @@
 
   {
     G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::SystemDictionaryRoots, worker_i);
-    if (!_process_strong_tasks.is_task_claimed(G1RP_PS_SystemDictionary_oops_do)) {
+    if (_process_strong_tasks.try_claim_task(G1RP_PS_SystemDictionary_oops_do)) {
       SystemDictionary::oops_do(strong_roots);
     }
   }
@@ -308,7 +308,7 @@
 void G1RootProcessor::process_code_cache_roots(CodeBlobClosure* code_closure,
                                                G1GCPhaseTimes* phase_times,
                                                uint worker_i) {
-  if (!_process_strong_tasks.is_task_claimed(G1RP_PS_CodeCache_oops_do)) {
+  if (_process_strong_tasks.try_claim_task(G1RP_PS_CodeCache_oops_do)) {
     CodeCache::blobs_do(code_closure);
   }
 }
--- a/src/hotspot/share/gc/shared/barrierSet.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/shared/barrierSet.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -30,13 +30,45 @@
 
 BarrierSet* BarrierSet::_barrier_set = NULL;
 
+class SetBarrierSetNonJavaThread : public ThreadClosure {
+  BarrierSet* _barrier_set;
+  size_t _count;
+
+public:
+  SetBarrierSetNonJavaThread(BarrierSet* barrier_set) :
+    _barrier_set(barrier_set), _count(0) {}
+
+  virtual void do_thread(Thread* thread) {
+    _barrier_set->on_thread_create(thread);
+    ++_count;
+  }
+
+  size_t count() const { return _count; }
+};
+
 void BarrierSet::set_barrier_set(BarrierSet* barrier_set) {
   assert(_barrier_set == NULL, "Already initialized");
   _barrier_set = barrier_set;
 
-  // The barrier set was not initialized when the this thread (the main thread)
-  // was created, so the call to BarrierSet::on_thread_create() had to be deferred
-  // until we have a barrier set. Now we have a barrier set, so we make the call.
+  // Some threads are created before the barrier set, so the call to
+  // BarrierSet::on_thread_create had to be deferred for them.  Now that
+  // we have the barrier set, do those deferred calls.
+
+  // First do any non-JavaThreads.
+  SetBarrierSetNonJavaThread njt_closure(_barrier_set);
+  Threads::non_java_threads_do(&njt_closure);
+
+  // Do the current (main) thread.  Ensure it's the one and only
+  // JavaThread so far.  Also verify that it isn't yet on the thread
+  // list, else we'd also need to call BarrierSet::on_thread_attach.
+  assert(Thread::current()->is_Java_thread(),
+         "Expected main thread to be a JavaThread");
+  assert((njt_closure.count() + 1) == Threads::threads_before_barrier_set(),
+         "Unexpected JavaThreads before barrier set initialization: "
+         "Non-JavaThreads: " SIZE_FORMAT ", all: " SIZE_FORMAT,
+         njt_closure.count(), Threads::threads_before_barrier_set());
+  assert(!JavaThread::current()->on_thread_list(),
+         "Main thread already on thread list.");
   _barrier_set->on_thread_create(Thread::current());
 }
 
--- a/src/hotspot/share/gc/shared/c1/barrierSetC1.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/shared/c1/barrierSetC1.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -321,7 +321,7 @@
       __ cmp(lir_cond_equal, base.result(), LIR_OprFact::oopConst(NULL));
       __ branch(lir_cond_equal, T_OBJECT, cont->label());
     }
-    LIR_Opr src_klass = gen->new_register(T_OBJECT);
+    LIR_Opr src_klass = gen->new_register(T_METADATA);
     if (gen_type_check) {
       // We have determined that offset == referent_offset && src != null.
       // if (src->_klass->_reference_type == REF_NONE) -> continue
--- a/src/hotspot/share/gc/shared/collectedHeap.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/shared/collectedHeap.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -328,6 +328,11 @@
   } while (true);  // Until a GC is done
 }
 
+MemoryUsage CollectedHeap::memory_usage() {
+  return MemoryUsage(InitialHeapSize, used(), capacity(), max_capacity());
+}
+
+
 #ifndef PRODUCT
 void CollectedHeap::check_for_non_bad_heap_word_value(HeapWord* addr, size_t size) {
   if (CheckMemoryInitialization && ZapUnusedHeapArea) {
--- a/src/hotspot/share/gc/shared/collectedHeap.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/shared/collectedHeap.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -31,6 +31,7 @@
 #include "runtime/handles.hpp"
 #include "runtime/perfData.hpp"
 #include "runtime/safepoint.hpp"
+#include "services/memoryUsage.hpp"
 #include "utilities/debug.hpp"
 #include "utilities/events.hpp"
 #include "utilities/formatBuffer.hpp"
@@ -423,6 +424,7 @@
   // Return the SoftRefPolicy for the heap;
   virtual SoftRefPolicy* soft_ref_policy() = 0;
 
+  virtual MemoryUsage memory_usage();
   virtual GrowableArray<GCMemoryManager*> memory_managers() = 0;
   virtual GrowableArray<MemoryPool*> memory_pools() = 0;
 
--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -792,7 +792,7 @@
   // could be trying to change the termination condition while the task
   // is executing in another GC worker.
 
-  if (!_process_strong_tasks->is_task_claimed(GCH_PS_ClassLoaderDataGraph_oops_do)) {
+  if (_process_strong_tasks->try_claim_task(GCH_PS_ClassLoaderDataGraph_oops_do)) {
     ClassLoaderDataGraph::roots_cld_do(strong_cld_closure, weak_cld_closure);
   }
 
@@ -802,32 +802,32 @@
   bool is_par = scope->n_threads() > 1;
   Threads::possibly_parallel_oops_do(is_par, strong_roots, roots_from_code_p);
 
-  if (!_process_strong_tasks->is_task_claimed(GCH_PS_Universe_oops_do)) {
+  if (_process_strong_tasks->try_claim_task(GCH_PS_Universe_oops_do)) {
     Universe::oops_do(strong_roots);
   }
   // Global (strong) JNI handles
-  if (!_process_strong_tasks->is_task_claimed(GCH_PS_JNIHandles_oops_do)) {
+  if (_process_strong_tasks->try_claim_task(GCH_PS_JNIHandles_oops_do)) {
     JNIHandles::oops_do(strong_roots);
   }
 
-  if (!_process_strong_tasks->is_task_claimed(GCH_PS_ObjectSynchronizer_oops_do)) {
+  if (_process_strong_tasks->try_claim_task(GCH_PS_ObjectSynchronizer_oops_do)) {
     ObjectSynchronizer::oops_do(strong_roots);
   }
-  if (!_process_strong_tasks->is_task_claimed(GCH_PS_Management_oops_do)) {
+  if (_process_strong_tasks->try_claim_task(GCH_PS_Management_oops_do)) {
     Management::oops_do(strong_roots);
   }
-  if (!_process_strong_tasks->is_task_claimed(GCH_PS_jvmti_oops_do)) {
+  if (_process_strong_tasks->try_claim_task(GCH_PS_jvmti_oops_do)) {
     JvmtiExport::oops_do(strong_roots);
   }
-  if (UseAOT && !_process_strong_tasks->is_task_claimed(GCH_PS_aot_oops_do)) {
+  if (UseAOT && _process_strong_tasks->try_claim_task(GCH_PS_aot_oops_do)) {
     AOTLoader::oops_do(strong_roots);
   }
 
-  if (!_process_strong_tasks->is_task_claimed(GCH_PS_SystemDictionary_oops_do)) {
+  if (_process_strong_tasks->try_claim_task(GCH_PS_SystemDictionary_oops_do)) {
     SystemDictionary::oops_do(strong_roots);
   }
 
-  if (!_process_strong_tasks->is_task_claimed(GCH_PS_CodeCache_oops_do)) {
+  if (_process_strong_tasks->try_claim_task(GCH_PS_CodeCache_oops_do)) {
     if (so & SO_ScavengeCodeCache) {
       assert(code_roots != NULL, "must supply closure for code cache");
 
@@ -876,7 +876,7 @@
                 cld_closure, cld_closure, &mark_code_closure);
   process_string_table_roots(scope, root_closure, par_state_string);
 
-  if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
+  if (_process_strong_tasks->try_claim_task(GCH_PS_younger_gens)) {
     root_closure->reset_generation();
   }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/shared/markBitMap.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "gc/shared/markBitMap.inline.hpp"
+#include "memory/virtualspace.hpp"
+
+void MarkBitMap::print_on_error(outputStream* st, const char* prefix) const {
+  _bm.print_on_error(st, prefix);
+}
+
+size_t MarkBitMap::compute_size(size_t heap_size) {
+  return ReservedSpace::allocation_align_size_up(heap_size / mark_distance());
+}
+
+size_t MarkBitMap::mark_distance() {
+  return MinObjAlignmentInBytes * BitsPerByte;
+}
+
+void MarkBitMap::initialize(MemRegion heap, MemRegion storage) {
+  _covered = heap;
+
+  _bm = BitMapView((BitMap::bm_word_t*) storage.start(), _covered.word_size() >> _shifter);
+}
+
+void MarkBitMap::clear_range(MemRegion mr) {
+  MemRegion intersection = mr.intersection(_covered);
+  assert(!intersection.is_empty(),
+         "Given range from " PTR_FORMAT " to " PTR_FORMAT " is completely outside the heap",
+         p2i(mr.start()), p2i(mr.end()));
+  // convert address range into offset range
+  _bm.at_put_range(addr_to_offset(intersection.start()),
+                   addr_to_offset(intersection.end()), false);
+}
+
+#ifdef ASSERT
+void MarkBitMap::check_mark(HeapWord* addr) {
+  assert(Universe::heap()->is_in_reserved(addr),
+         "Trying to access bitmap " PTR_FORMAT " for address " PTR_FORMAT " not in the heap.",
+         p2i(this), p2i(addr));
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/shared/markBitMap.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ *
+ */
+
+#ifndef SHARE_VM_GC_SHARED_MARKBITMAP_HPP
+#define SHARE_VM_GC_SHARED_MARKBITMAP_HPP
+
+#include "memory/memRegion.hpp"
+#include "oops/oopsHierarchy.hpp"
+#include "utilities/bitMap.hpp"
+
+// A generic mark bitmap for concurrent marking.  This is essentially a wrapper
+// around the BitMap class that is based on HeapWords, with one bit per (1 << _shifter) HeapWords.
+class MarkBitMap {
+protected:
+  MemRegion _covered;    // The heap area covered by this bitmap.
+
+  const int _shifter;    // Shift amount from heap index to bit index in the bitmap.
+
+  BitMapView _bm;        // The actual bitmap.
+
+  virtual void check_mark(HeapWord* addr) NOT_DEBUG_RETURN;
+
+  // Convert from bit offset to address.
+  HeapWord* offset_to_addr(size_t offset) const {
+    return _covered.start() + (offset << _shifter);
+  }
+  // Convert from address to bit offset.
+  size_t addr_to_offset(const HeapWord* addr) const {
+    return pointer_delta(addr, _covered.start()) >> _shifter;
+  }
+public:
+  static size_t compute_size(size_t heap_size);
+  // Returns the amount of bytes on the heap between two marks in the bitmap.
+  static size_t mark_distance();
+  // Returns how many bytes (or bits) of the heap a single byte (or bit) of the
+  // mark bitmap corresponds to. This is the same as the mark distance above.
+  static size_t heap_map_factor() {
+    return mark_distance();
+  }
+
+  MarkBitMap() : _covered(), _shifter(LogMinObjAlignment), _bm() {}
+
+  // Initializes the underlying BitMap to cover the given area.
+  void initialize(MemRegion heap, MemRegion storage);
+
+  // Read marks
+  bool is_marked(oop obj) const;
+  bool is_marked(HeapWord* addr) const {
+    assert(_covered.contains(addr),
+           "Address " PTR_FORMAT " is outside underlying space from " PTR_FORMAT " to " PTR_FORMAT,
+           p2i(addr), p2i(_covered.start()), p2i(_covered.end()));
+    return _bm.at(addr_to_offset(addr));
+  }
+
+  // Return the address corresponding to the next marked bit at or after
+  // "addr", and before "limit", if "limit" is non-NULL.  If there is no
+  // such bit, returns "limit" if that is non-NULL, or else "endWord()".
+  inline HeapWord* get_next_marked_addr(const HeapWord* addr,
+                                        const HeapWord* limit) const;
+
+  void print_on_error(outputStream* st, const char* prefix) const;
+
+  // Write marks.
+  inline void mark(HeapWord* addr);
+  inline void clear(HeapWord* addr);
+  inline void clear(oop obj);
+  inline bool par_mark(HeapWord* addr);
+  inline bool par_mark(oop obj);
+
+  void clear_range(MemRegion mr);
+};
+
+#endif // SHARE_VM_GC_SHARED_MARKBITMAP_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/shared/markBitMap.inline.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ *
+ */
+
+#ifndef SHARE_VM_GC_SHARED_MARKBITMAP_INLINE_HPP
+#define SHARE_VM_GC_SHARED_MARKBITMAP_INLINE_HPP
+
+#include "gc/shared/collectedHeap.hpp"
+#include "gc/shared/markBitMap.hpp"
+#include "memory/memRegion.hpp"
+#include "memory/universe.hpp"
+#include "utilities/align.hpp"
+#include "utilities/bitMap.inline.hpp"
+
+inline HeapWord* MarkBitMap::get_next_marked_addr(const HeapWord* addr,
+                                                const HeapWord* limit) const {
+  assert(limit != NULL, "limit must not be NULL");
+  // Round addr up to a possible object boundary to be safe.
+  size_t const addr_offset = addr_to_offset(align_up(addr, HeapWordSize << _shifter));
+  size_t const limit_offset = addr_to_offset(limit);
+  size_t const nextOffset = _bm.get_next_one_offset(addr_offset, limit_offset);
+  return offset_to_addr(nextOffset);
+}
+
+inline void MarkBitMap::mark(HeapWord* addr) {
+  check_mark(addr);
+  _bm.set_bit(addr_to_offset(addr));
+}
+
+inline void MarkBitMap::clear(HeapWord* addr) {
+  check_mark(addr);
+  _bm.clear_bit(addr_to_offset(addr));
+}
+
+inline bool MarkBitMap::par_mark(HeapWord* addr) {
+  check_mark(addr);
+  return _bm.par_set_bit(addr_to_offset(addr));
+}
+
+inline bool MarkBitMap::par_mark(oop obj) {
+  return par_mark((HeapWord*) obj);
+}
+
+inline bool MarkBitMap::is_marked(oop obj) const{
+  return is_marked((HeapWord*) obj);
+}
+
+inline void MarkBitMap::clear(oop obj) {
+  clear((HeapWord*) obj);
+}
+
+#endif // SHARE_VM_GC_SHARED_MARKBITMAP_INLINE_HPP
--- a/src/hotspot/share/gc/shared/preservedMarks.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/shared/preservedMarks.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -100,7 +100,7 @@
 public:
   virtual void work(uint worker_id) {
     uint task_id = 0;
-    while (!_sub_tasks.is_task_claimed(/* reference */ task_id)) {
+    while (_sub_tasks.try_claim_task(/* reference */ task_id)) {
       _preserved_marks_set->get(task_id)->restore_and_increment(_total_size_addr);
     }
     _sub_tasks.all_tasks_completed();
--- a/src/hotspot/share/gc/shared/weakProcessor.inline.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/shared/weakProcessor.inline.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -47,7 +47,7 @@
   FOR_EACH_WEAK_PROCESSOR_PHASE(phase) {
     if (WeakProcessorPhases::is_serial(phase)) {
       uint serial_index = WeakProcessorPhases::serial_index(phase);
-      if (!_serial_phases_done.is_task_claimed(serial_index)) {
+      if (_serial_phases_done.try_claim_task(serial_index)) {
         WeakProcessorPhaseTimeTracker pt(_phase_times, phase);
         WeakProcessorPhases::processor(phase)(is_alive, keep_alive);
       }
--- a/src/hotspot/share/gc/shared/weakProcessorPhases.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/shared/weakProcessorPhases.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -59,7 +59,14 @@
 }
 
 bool WeakProcessorPhases::is_serial(Phase phase) {
+  // serial_phase_count is 0 if JFR and JVMTI are both not built,
+  // making this check with unsigned lhs redundant
+#if INCLUDE_JVMTI || INCLUDE_JFR
   return (index(phase) - serial_phase_start) < serial_phase_count;
+#else
+  STATIC_ASSERT(serial_phase_count == 0);
+  return false;
+#endif
 }
 
 bool WeakProcessorPhases::is_oop_storage(Phase phase) {
--- a/src/hotspot/share/gc/shared/workgroup.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/shared/workgroup.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -429,16 +429,16 @@
 #endif
 }
 
-bool SubTasksDone::is_task_claimed(uint t) {
+bool SubTasksDone::try_claim_task(uint t) {
   assert(t < _n_tasks, "bad task id.");
   uint old = _tasks[t];
   if (old == 0) {
     old = Atomic::cmpxchg(1u, &_tasks[t], 0u);
   }
   assert(_tasks[t] == 1, "What else?");
-  bool res = old != 0;
+  bool res = old == 0;
 #ifdef ASSERT
-  if (!res) {
+  if (res) {
     assert(_claimed < _n_tasks, "Too many tasks claimed; missing clear?");
     Atomic::inc(&_claimed);
   }
@@ -476,16 +476,16 @@
   return _n_threads > 0;
 }
 
-bool SequentialSubTasksDone::is_task_claimed(uint& t) {
+bool SequentialSubTasksDone::try_claim_task(uint& t) {
   t = _n_claimed;
   while (t < _n_tasks) {
     uint res = Atomic::cmpxchg(t+1, &_n_claimed, t);
     if (res == t) {
-      return false;
+      return true;
     }
     t = res;
   }
-  return true;
+  return false;
 }
 
 bool SequentialSubTasksDone::all_tasks_completed() {
--- a/src/hotspot/share/gc/shared/workgroup.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/shared/workgroup.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -332,9 +332,10 @@
   // True iff the object is in a valid state.
   bool valid();
 
-  // Returns "false" if the task "t" is unclaimed, and ensures that task is
-  // claimed.  The task "t" is required to be within the range of "this".
-  bool is_task_claimed(uint t);
+  // Attempt to claim the task "t", returning true if successful,
+  // false if it has already been claimed.  The task "t" is required
+  // to be within the range of "this".
+  bool try_claim_task(uint t);
 
   // The calling thread asserts that it has attempted to claim all the
   // tasks that it will try to claim.  Every thread in the parallel task
@@ -391,11 +392,11 @@
   // agree on the number of tasks.
   void set_n_tasks(uint t) { _n_tasks = t; }
 
-  // Returns false if the next task in the sequence is unclaimed,
-  // and ensures that it is claimed. Will set t to be the index
-  // of the claimed task in the sequence. Will return true if
-  // the task cannot be claimed and there are none left to claim.
-  bool is_task_claimed(uint& t);
+  // Attempt to claim the next unclaimed task in the sequence,
+  // returning true if successful, with t set to the index of the
+  // claimed task.  Returns false if there are no more unclaimed tasks
+  // in the sequence.
+  bool try_claim_task(uint& t);
 
   // The calling thread asserts that it has attempted to claim
   // all the tasks it possibly can in the sequence. Every thread
--- a/src/hotspot/share/gc/z/zBarrierSet.inline.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/z/zBarrierSet.inline.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -210,16 +210,10 @@
 template <DecoratorSet decorators, typename BarrierSetT>
 template <typename T>
 inline oop ZBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_load_not_in_heap(T* addr) {
-  const oop o = Raw::oop_load_not_in_heap(addr);
+  verify_decorators_absent<ON_UNKNOWN_OOP_REF>();
 
-  if (HasDecorator<decorators, ON_PHANTOM_OOP_REF>::value) {
-    return load_barrier_on_oop_field_preloaded(addr, o);
-  }
-
-  verify_decorators_present<ON_STRONG_OOP_REF>();
-  verify_decorators_absent<AS_NO_KEEPALIVE>();
-
-  return o;
+  const oop o = Raw::oop_load_not_in_heap(addr);
+  return load_barrier_on_oop_field_preloaded(addr, o);
 }
 
 template <DecoratorSet decorators, typename BarrierSetT>
--- a/src/hotspot/share/gc/z/zRootsIterator.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/z/zRootsIterator.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -52,28 +52,21 @@
 static const ZStatSubPhase ZSubPhasePauseRoots("Pause Roots");
 static const ZStatSubPhase ZSubPhasePauseRootsTeardown("Pause Roots Teardown");
 static const ZStatSubPhase ZSubPhasePauseRootsUniverse("Pause Roots Universe");
-static const ZStatSubPhase ZSubPhasePauseRootsVMWeakHandles("Pause Roots VMWeakHandles");
 static const ZStatSubPhase ZSubPhasePauseRootsJNIHandles("Pause Roots JNIHandles");
-static const ZStatSubPhase ZSubPhasePauseRootsJNIWeakHandles("Pause Roots JNIWeakHandles");
 static const ZStatSubPhase ZSubPhasePauseRootsObjectSynchronizer("Pause Roots ObjectSynchronizer");
 static const ZStatSubPhase ZSubPhasePauseRootsManagement("Pause Roots Management");
 static const ZStatSubPhase ZSubPhasePauseRootsJVMTIExport("Pause Roots JVMTIExport");
 static const ZStatSubPhase ZSubPhasePauseRootsJVMTIWeakExport("Pause Roots JVMTIWeakExport");
-static const ZStatSubPhase ZSubPhasePauseRootsJFRWeak("Pause Roots JRFWeak");
 static const ZStatSubPhase ZSubPhasePauseRootsSystemDictionary("Pause Roots SystemDictionary");
 static const ZStatSubPhase ZSubPhasePauseRootsClassLoaderDataGraph("Pause Roots ClassLoaderDataGraph");
 static const ZStatSubPhase ZSubPhasePauseRootsThreads("Pause Roots Threads");
 static const ZStatSubPhase ZSubPhasePauseRootsCodeCache("Pause Roots CodeCache");
-static const ZStatSubPhase ZSubPhasePauseRootsStringTable("Pause Roots StringTable");
 
 static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup");
 static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots");
 static const ZStatSubPhase ZSubPhasePauseWeakRootsTeardown("Pause Weak Roots Teardown");
-static const ZStatSubPhase ZSubPhasePauseWeakRootsVMWeakHandles("Pause Weak Roots VMWeakHandles");
-static const ZStatSubPhase ZSubPhasePauseWeakRootsJNIWeakHandles("Pause Weak Roots JNIWeakHandles");
 static const ZStatSubPhase ZSubPhasePauseWeakRootsJVMTIWeakExport("Pause Weak Roots JVMTIWeakExport");
 static const ZStatSubPhase ZSubPhasePauseWeakRootsJFRWeak("Pause Weak Roots JFRWeak");
-static const ZStatSubPhase ZSubPhasePauseWeakRootsStringTable("Pause Weak Roots StringTable");
 
 static const ZStatSubPhase ZSubPhaseConcurrentWeakRoots("Concurrent Weak Roots");
 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsVMWeakHandles("Concurrent Weak Roots VMWeakHandles");
@@ -135,24 +128,17 @@
 }
 
 ZRootsIterator::ZRootsIterator() :
-    _vm_weak_handles_iter(SystemDictionary::vm_weak_oop_storage()),
     _jni_handles_iter(JNIHandles::global_handles()),
-    _jni_weak_handles_iter(JNIHandles::weak_global_handles()),
-    _string_table_iter(StringTable::weak_storage()),
     _universe(this),
     _object_synchronizer(this),
     _management(this),
     _jvmti_export(this),
     _jvmti_weak_export(this),
-    _jfr_weak(this),
     _system_dictionary(this),
-    _vm_weak_handles(this),
     _jni_handles(this),
-    _jni_weak_handles(this),
     _class_loader_data_graph(this),
     _threads(this),
-    _code_cache(this),
-    _string_table(this) {
+    _code_cache(this) {
   assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
   ZStatTimer timer(ZSubPhasePauseRootsSetup);
   Threads::change_thread_claim_parity();
@@ -177,21 +163,11 @@
   Universe::oops_do(cl);
 }
 
-void ZRootsIterator::do_vm_weak_handles(OopClosure* cl) {
-  ZStatTimer timer(ZSubPhasePauseRootsVMWeakHandles);
-  _vm_weak_handles_iter.oops_do(cl);
-}
-
 void ZRootsIterator::do_jni_handles(OopClosure* cl) {
   ZStatTimer timer(ZSubPhasePauseRootsJNIHandles);
   _jni_handles_iter.oops_do(cl);
 }
 
-void ZRootsIterator::do_jni_weak_handles(OopClosure* cl) {
-  ZStatTimer timer(ZSubPhasePauseRootsJNIWeakHandles);
-  _jni_weak_handles_iter.oops_do(cl);
-}
-
 void ZRootsIterator::do_object_synchronizer(OopClosure* cl) {
   ZStatTimer timer(ZSubPhasePauseRootsObjectSynchronizer);
   ObjectSynchronizer::oops_do(cl);
@@ -213,14 +189,6 @@
   JvmtiExport::weak_oops_do(&always_alive, cl);
 }
 
-void ZRootsIterator::do_jfr_weak(OopClosure* cl) {
-#if INCLUDE_JFR
-  ZStatTimer timer(ZSubPhasePauseRootsJFRWeak);
-  AlwaysTrueClosure always_alive;
-  Jfr::weak_oops_do(&always_alive, cl);
-#endif
-}
-
 void ZRootsIterator::do_system_dictionary(OopClosure* cl) {
   ZStatTimer timer(ZSubPhasePauseRootsSystemDictionary);
   SystemDictionary::oops_do(cl);
@@ -263,11 +231,6 @@
   ZNMethodTable::oops_do(cl);
 }
 
-void ZRootsIterator::do_string_table(OopClosure* cl) {
-  ZStatTimer timer(ZSubPhasePauseRootsStringTable);
-  _string_table_iter.oops_do(cl);
-}
-
 void ZRootsIterator::oops_do(OopClosure* cl, bool visit_jvmti_weak_export) {
   ZStatTimer timer(ZSubPhasePauseRoots);
   _universe.oops_do(cl);
@@ -279,28 +242,14 @@
   _class_loader_data_graph.oops_do(cl);
   _threads.oops_do(cl);
   _code_cache.oops_do(cl);
-  if (!ZWeakRoots) {
+  if (visit_jvmti_weak_export) {
     _jvmti_weak_export.oops_do(cl);
-    _jfr_weak.oops_do(cl);
-    _vm_weak_handles.oops_do(cl);
-    _jni_weak_handles.oops_do(cl);
-    _string_table.oops_do(cl);
-  } else {
-    if (visit_jvmti_weak_export) {
-      _jvmti_weak_export.oops_do(cl);
-    }
   }
 }
 
 ZWeakRootsIterator::ZWeakRootsIterator() :
-    _vm_weak_handles_iter(SystemDictionary::vm_weak_oop_storage()),
-    _jni_weak_handles_iter(JNIHandles::weak_global_handles()),
-    _string_table_iter(StringTable::weak_storage()),
     _jvmti_weak_export(this),
-    _jfr_weak(this),
-    _vm_weak_handles(this),
-    _jni_weak_handles(this),
-    _string_table(this) {
+    _jfr_weak(this) {
   assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
   ZStatTimer timer(ZSubPhasePauseWeakRootsSetup);
   StringTable::reset_dead_counter();
@@ -311,16 +260,6 @@
   StringTable::finish_dead_counter();
 }
 
-void ZWeakRootsIterator::do_vm_weak_handles(BoolObjectClosure* is_alive, OopClosure* cl) {
-  ZStatTimer timer(ZSubPhasePauseWeakRootsVMWeakHandles);
-  _vm_weak_handles_iter.weak_oops_do(is_alive, cl);
-}
-
-void ZWeakRootsIterator::do_jni_weak_handles(BoolObjectClosure* is_alive, OopClosure* cl) {
-  ZStatTimer timer(ZSubPhasePauseWeakRootsJNIWeakHandles);
-  _jni_weak_handles_iter.weak_oops_do(is_alive, cl);
-}
-
 void ZWeakRootsIterator::do_jvmti_weak_export(BoolObjectClosure* is_alive, OopClosure* cl) {
   ZStatTimer timer(ZSubPhasePauseWeakRootsJVMTIWeakExport);
   JvmtiExport::weak_oops_do(is_alive, cl);
@@ -333,51 +272,10 @@
 #endif
 }
 
-class ZStringTableDeadCounterBoolObjectClosure : public BoolObjectClosure  {
-private:
-  BoolObjectClosure* const _cl;
-  size_t                   _ndead;
-
-public:
-  ZStringTableDeadCounterBoolObjectClosure(BoolObjectClosure* cl) :
-      _cl(cl),
-      _ndead(0) {}
-
-  ~ZStringTableDeadCounterBoolObjectClosure() {
-    StringTable::inc_dead_counter(_ndead);
-  }
-
-  virtual bool do_object_b(oop obj) {
-    if (_cl->do_object_b(obj)) {
-      return true;
-    }
-
-    _ndead++;
-    return false;
-  }
-};
-
-void ZWeakRootsIterator::do_string_table(BoolObjectClosure* is_alive, OopClosure* cl) {
-  ZStatTimer timer(ZSubPhasePauseWeakRootsStringTable);
-  ZStringTableDeadCounterBoolObjectClosure counter_is_alive(is_alive);
-  _string_table_iter.weak_oops_do(&counter_is_alive, cl);
-}
-
 void ZWeakRootsIterator::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* cl) {
   ZStatTimer timer(ZSubPhasePauseWeakRoots);
-  if (ZWeakRoots) {
-    _jvmti_weak_export.weak_oops_do(is_alive, cl);
-    _jfr_weak.weak_oops_do(is_alive, cl);
-    if (!ZConcurrentVMWeakHandles) {
-      _vm_weak_handles.weak_oops_do(is_alive, cl);
-    }
-    if (!ZConcurrentJNIWeakGlobalHandles) {
-      _jni_weak_handles.weak_oops_do(is_alive, cl);
-    }
-    if (!ZConcurrentStringTable) {
-      _string_table.weak_oops_do(is_alive, cl);
-    }
-  }
+  _jvmti_weak_export.weak_oops_do(is_alive, cl);
+  _jfr_weak.weak_oops_do(is_alive, cl);
 }
 
 void ZWeakRootsIterator::oops_do(OopClosure* cl) {
@@ -443,17 +341,9 @@
 
 void ZConcurrentWeakRootsIterator::oops_do(OopClosure* cl) {
   ZStatTimer timer(ZSubPhaseConcurrentWeakRoots);
-  if (ZWeakRoots) {
-    if (ZConcurrentVMWeakHandles) {
-      _vm_weak_handles.oops_do(cl);
-    }
-    if (ZConcurrentJNIWeakGlobalHandles) {
-      _jni_weak_handles.oops_do(cl);
-    }
-    if (ZConcurrentStringTable) {
-      _string_table.oops_do(cl);
-    }
-  }
+  _vm_weak_handles.oops_do(cl);
+  _jni_weak_handles.oops_do(cl);
+  _string_table.oops_do(cl);
 }
 
 ZThreadRootsIterator::ZThreadRootsIterator() :
--- a/src/hotspot/share/gc/z/zRootsIterator.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/z/zRootsIterator.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -78,40 +78,29 @@
 
 class ZRootsIterator {
 private:
-  ZOopStorageIterator _vm_weak_handles_iter;
   ZOopStorageIterator _jni_handles_iter;
-  ZOopStorageIterator _jni_weak_handles_iter;
-  ZOopStorageIterator _string_table_iter;
 
   void do_universe(OopClosure* cl);
-  void do_vm_weak_handles(OopClosure* cl);
   void do_jni_handles(OopClosure* cl);
-  void do_jni_weak_handles(OopClosure* cl);
   void do_object_synchronizer(OopClosure* cl);
   void do_management(OopClosure* cl);
   void do_jvmti_export(OopClosure* cl);
   void do_jvmti_weak_export(OopClosure* cl);
-  void do_jfr_weak(OopClosure* cl);
   void do_system_dictionary(OopClosure* cl);
   void do_class_loader_data_graph(OopClosure* cl);
   void do_threads(OopClosure* cl);
   void do_code_cache(OopClosure* cl);
-  void do_string_table(OopClosure* cl);
 
   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_universe>                  _universe;
   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_object_synchronizer>       _object_synchronizer;
   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_management>                _management;
   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_jvmti_export>              _jvmti_export;
   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_jvmti_weak_export>         _jvmti_weak_export;
-  ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_jfr_weak>                  _jfr_weak;
   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_system_dictionary>         _system_dictionary;
-  ZParallelOopsDo<ZRootsIterator, &ZRootsIterator::do_vm_weak_handles>         _vm_weak_handles;
   ZParallelOopsDo<ZRootsIterator, &ZRootsIterator::do_jni_handles>             _jni_handles;
-  ZParallelOopsDo<ZRootsIterator, &ZRootsIterator::do_jni_weak_handles>        _jni_weak_handles;
   ZParallelOopsDo<ZRootsIterator, &ZRootsIterator::do_class_loader_data_graph> _class_loader_data_graph;
   ZParallelOopsDo<ZRootsIterator, &ZRootsIterator::do_threads>                 _threads;
   ZParallelOopsDo<ZRootsIterator, &ZRootsIterator::do_code_cache>              _code_cache;
-  ZParallelOopsDo<ZRootsIterator, &ZRootsIterator::do_string_table>            _string_table;
 
 public:
   ZRootsIterator();
@@ -122,21 +111,11 @@
 
 class ZWeakRootsIterator {
 private:
-  ZOopStorageIterator _vm_weak_handles_iter;
-  ZOopStorageIterator _jni_weak_handles_iter;
-  ZOopStorageIterator _string_table_iter;
-
-  void do_vm_weak_handles(BoolObjectClosure* is_alive, OopClosure* cl);
-  void do_jni_weak_handles(BoolObjectClosure* is_alive, OopClosure* cl);
   void do_jvmti_weak_export(BoolObjectClosure* is_alive, OopClosure* cl);
   void do_jfr_weak(BoolObjectClosure* is_alive, OopClosure* cl);
-  void do_string_table(BoolObjectClosure* is_alive, OopClosure* cl);
 
   ZSerialWeakOopsDo<ZWeakRootsIterator, &ZWeakRootsIterator::do_jvmti_weak_export>  _jvmti_weak_export;
   ZSerialWeakOopsDo<ZWeakRootsIterator, &ZWeakRootsIterator::do_jfr_weak>           _jfr_weak;
-  ZParallelWeakOopsDo<ZWeakRootsIterator, &ZWeakRootsIterator::do_vm_weak_handles>  _vm_weak_handles;
-  ZParallelWeakOopsDo<ZWeakRootsIterator, &ZWeakRootsIterator::do_jni_weak_handles> _jni_weak_handles;
-  ZParallelWeakOopsDo<ZWeakRootsIterator, &ZWeakRootsIterator::do_string_table>     _string_table;
 
 public:
   ZWeakRootsIterator();
--- a/src/hotspot/share/gc/z/z_globals.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/gc/z/z_globals.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -79,18 +79,6 @@
   diagnostic(bool, ZVerifyForwarding, false,                                \
           "Verify forwarding tables")                                       \
                                                                             \
-  diagnostic(bool, ZWeakRoots, true,                                        \
-          "Treat JNI WeakGlobalRefs and StringTable as weak roots")         \
-                                                                            \
-  diagnostic(bool, ZConcurrentStringTable, true,                            \
-          "Clean StringTable concurrently")                                 \
-                                                                            \
-  diagnostic(bool, ZConcurrentVMWeakHandles, true,                          \
-          "Clean VM WeakHandles concurrently")                              \
-                                                                            \
-  diagnostic(bool, ZConcurrentJNIWeakGlobalHandles, true,                   \
-          "Clean JNI WeakGlobalRefs concurrently")                          \
-                                                                            \
   diagnostic(bool, ZOptimizeLoadBarriers, true,                             \
           "Apply load barrier optimizations")                               \
                                                                             \
--- a/src/hotspot/share/interpreter/bytecodeHistogram.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/interpreter/bytecodeHistogram.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -74,7 +74,7 @@
 // A bytecode pair is any sequence of two consequtive bytecodes.
 
 class BytecodePairHistogram: AllStatic {
- public: // for SparcWorks
+ public: // for solstudio
   enum Constants {
     log2_number_of_codes = 8,                         // use a power of 2 for faster addressing
     number_of_codes      = 1 << log2_number_of_codes, // must be no less than Bytecodes::number_of_codes
--- a/src/hotspot/share/interpreter/rewriter.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/interpreter/rewriter.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -400,7 +400,9 @@
       }
     }
 
-    assert(bc_length != 0, "impossible bytecode length");
+    // Continuing with an invalid bytecode will fail in the loop below.
+    // So guarantee here.
+    guarantee(bc_length > 0, "Verifier should have caught this invalid bytecode");
 
     switch (c) {
       case Bytecodes::_lookupswitch   : {
--- a/src/hotspot/share/jfr/periodic/jfrModuleEvent.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/jfr/periodic/jfrModuleEvent.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -121,12 +121,14 @@
 
 void JfrModuleEvent::generate_module_dependency_events() {
   invocation_time = JfrTicks::now();
-  MutexLockerEx module_lock(Module_lock);
+  MutexLocker cld_lock(ClassLoaderDataGraph_lock);
+  MutexLocker module_lock(Module_lock);
   ClassLoaderDataGraph::modules_do(&module_dependency_event_callback);
 }
 
 void JfrModuleEvent::generate_module_export_events() {
   invocation_time = JfrTicks::now();
-  MutexLockerEx module_lock(Module_lock);
+  MutexLocker cld_lock(ClassLoaderDataGraph_lock);
+  MutexLocker module_lock(Module_lock);
   ClassLoaderDataGraph::packages_do(&module_export_event_callback);
 }
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -149,7 +149,9 @@
 
 void JfrTypeManager::write_type_set() {
   // can safepoint here because of Module_lock
+  MutexLockerEx cld_lock(SafepointSynchronize::is_at_safepoint() ? NULL : ClassLoaderDataGraph_lock);
   MutexLockerEx lock(SafepointSynchronize::is_at_safepoint() ? NULL : Module_lock);
+
   JfrCheckpointWriter writer(true, true, Thread::current());
   TypeSet set;
   set.serialize(writer);
--- a/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -74,6 +74,10 @@
     Module_lock->unlock();
   }
 
+  if (ClassLoaderDataGraph_lock->owned_by_self()) {
+    ClassLoaderDataGraph_lock->unlock();
+  }
+
   if (Heap_lock->owned_by_self()) {
     Heap_lock->unlock();
   }
--- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1059,11 +1059,10 @@
               } else {
                 // some object might already have been re-allocated, only reallocate the non-allocated ones
                 objects = new GrowableArray<ScopeValue*>(scope->objects()->length());
-                int ii = 0;
                 for (int i = 0; i < scope->objects()->length(); i++) {
                   ObjectValue* sv = (ObjectValue*) scope->objects()->at(i);
                   if (sv->value().is_null()) {
-                    objects->at_put(ii++, sv);
+                    objects->append(sv);
                   }
                 }
               }
--- a/src/hotspot/share/logging/logTag.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/logging/logTag.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -170,7 +170,8 @@
   LOG_TAG(vmoperation) \
   LOG_TAG(vmthread) \
   LOG_TAG(vtables) \
-  LOG_TAG(workgang)
+  LOG_TAG(vtablestubs) \
+  LOG_TAG(workgang) \
   LOG_TAG_LIST_EXT
 
 #define PREFIX_LOG_TAG(T) (LogTag::_##T)
--- a/src/hotspot/share/memory/allocation.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/memory/allocation.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -107,34 +107,40 @@
 };
 #endif
 
+#define MEMORY_TYPES_DO(f) \
+  /* Memory type by sub systems. It occupies lower byte. */  \
+  f(mtJavaHeap,      "Java Heap")   /* Java heap                                 */ \
+  f(mtClass,         "Class")       /* Java classes                              */ \
+  f(mtThread,        "Thread")      /* thread objects                            */ \
+  f(mtThreadStack,   "Thread Stack")                                                \
+  f(mtCode,          "Code")        /* generated code                            */ \
+  f(mtGC,            "GC")                                                          \
+  f(mtCompiler,      "Compiler")                                                    \
+  f(mtInternal,      "Internal")    /* memory used by VM, but does not belong to */ \
+                                    /* any of above categories, and not used by  */ \
+                                    /* NMT                                       */ \
+  f(mtOther,         "Other")       /* memory not used by VM                     */ \
+  f(mtSymbol,        "Symbol")                                                      \
+  f(mtNMT,           "Native Memory Tracking")  /* memory used by NMT            */ \
+  f(mtClassShared,   "Shared class space")      /* class data sharing            */ \
+  f(mtChunk,         "Arena Chunk") /* chunk that holds content of arenas        */ \
+  f(mtTest,          "Test")        /* Test type for verifying NMT               */ \
+  f(mtTracing,       "Tracing")                                                     \
+  f(mtLogging,       "Logging")                                                     \
+  f(mtArguments,     "Arguments")                                                   \
+  f(mtModule,        "Module")                                                      \
+  f(mtSafepoint,     "Safepoint")                                                   \
+  f(mtNone,          "Unknown")                                                     \
+  //end
+
+#define MEMORY_TYPE_DECLARE_ENUM(type, human_readable) \
+  type,
 
 /*
  * Memory types
  */
 enum MemoryType {
-  // Memory type by sub systems. It occupies lower byte.
-  mtJavaHeap,          // Java heap
-  mtClass,             // memory class for Java classes
-  mtThread,            // memory for thread objects
-  mtThreadStack,
-  mtCode,              // memory for generated code
-  mtGC,                // memory for GC
-  mtCompiler,          // memory for compiler
-  mtInternal,          // memory used by VM, but does not belong to
-                       // any of above categories, and not used for
-                       // native memory tracking
-  mtOther,             // memory not used by VM
-  mtSymbol,            // symbol
-  mtNMT,               // memory used by native memory tracking
-  mtClassShared,       // class data sharing
-  mtChunk,             // chunk that holds content of arenas
-  mtTest,              // Test type for verifying NMT
-  mtTracing,           // memory used for Tracing
-  mtLogging,           // memory for logging
-  mtArguments,         // memory for argument processing
-  mtModule,            // memory for module processing
-  mtSafepoint,         // memory for safepoint support
-  mtNone,              // undefined
+  MEMORY_TYPES_DO(MEMORY_TYPE_DECLARE_ENUM)
   mt_number_of_types   // number of memory types (mtDontTrack
                        // is not included as validate type)
 };
--- a/src/hotspot/share/memory/heapInspection.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/memory/heapInspection.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -153,11 +153,17 @@
   }
 }
 
-void KlassInfoTable::AllClassesFinder::do_klass(Klass* k) {
-  // This has the SIDE EFFECT of creating a KlassInfoEntry
-  // for <k>, if one doesn't exist yet.
-  _table->lookup(k);
-}
+class KlassInfoTable::AllClassesFinder : public LockedClassesDo {
+  KlassInfoTable *_table;
+public:
+  AllClassesFinder(KlassInfoTable* table) : _table(table) {}
+  virtual void do_klass(Klass* k) {
+    // This has the SIDE EFFECT of creating a KlassInfoEntry
+    // for <k>, if one doesn't exist yet.
+    _table->lookup(k);
+  }
+};
+
 
 KlassInfoTable::KlassInfoTable(bool add_all_classes) {
   _size_of_instances_in_words = 0;
--- a/src/hotspot/share/memory/heapInspection.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/memory/heapInspection.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -247,12 +247,7 @@
   uint hash(const Klass* p);
   KlassInfoEntry* lookup(Klass* k); // allocates if not found!
 
-  class AllClassesFinder : public KlassClosure {
-    KlassInfoTable *_table;
-   public:
-    AllClassesFinder(KlassInfoTable* table) : _table(table) {}
-    virtual void do_klass(Klass* k);
-  };
+  class AllClassesFinder;
 
  public:
   KlassInfoTable(bool add_all_classes);
--- a/src/hotspot/share/memory/metaspaceShared.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/memory/metaspaceShared.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -76,6 +76,7 @@
 bool MetaspaceShared::_archive_loading_failed = false;
 bool MetaspaceShared::_remapped_readwrite = false;
 bool MetaspaceShared::_open_archive_heap_region_mapped = false;
+bool MetaspaceShared::_archive_heap_region_fixed = false;
 address MetaspaceShared::_cds_i2i_entry_code_buffers = NULL;
 size_t MetaspaceShared::_cds_i2i_entry_code_buffers_size = 0;
 size_t MetaspaceShared::_core_spaces_size = 0;
@@ -1619,7 +1620,7 @@
   LinkSharedClassesClosure link_closure(THREAD);
   do {
     link_closure.reset();
-    ClassLoaderDataGraph::loaded_classes_do(&link_closure);
+    ClassLoaderDataGraph::unlocked_loaded_classes_do(&link_closure);
     guarantee(!HAS_PENDING_EXCEPTION, "exception in link_class");
   } while (link_closure.made_progress());
 
@@ -1631,7 +1632,7 @@
       // we should come here only if there are unverifiable classes, which
       // shouldn't happen in normal cases. So better safe than sorry.
       check_closure.reset();
-      ClassLoaderDataGraph::loaded_classes_do(&check_closure);
+      ClassLoaderDataGraph::unlocked_loaded_classes_do(&check_closure);
     } while (check_closure.made_progress());
 
     if (IgnoreUnverifiableClassesDuringDump) {
@@ -1940,6 +1941,8 @@
 }
 
 oop MetaspaceShared::materialize_archived_object(narrowOop v) {
+  assert(archive_heap_region_fixed(),
+         "must be called after archive heap regions are fixed");
   if (!CompressedOops::is_null(v)) {
     oop obj = HeapShared::decode_with_archived_oop_encoding_mode(v);
     return G1CollectedHeap::heap()->materialize_archived_object(obj);
@@ -1970,6 +1973,7 @@
 void MetaspaceShared::fixup_mapped_heap_regions() {
   FileMapInfo *mapinfo = FileMapInfo::current_info();
   mapinfo->fixup_mapped_heap_regions();
+  set_archive_heap_region_fixed();
 }
 #endif // INCLUDE_CDS_JAVA_HEAP
 
--- a/src/hotspot/share/memory/metaspaceShared.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/memory/metaspaceShared.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -59,6 +59,7 @@
   static bool _archive_loading_failed;
   static bool _remapped_readwrite;
   static bool _open_archive_heap_region_mapped;
+  static bool _archive_heap_region_fixed;
   static address _cds_i2i_entry_code_buffers;
   static size_t  _cds_i2i_entry_code_buffers_size;
   static size_t  _core_spaces_size;
@@ -114,6 +115,14 @@
   static oop archive_heap_object(oop obj, Thread* THREAD);
   static oop materialize_archived_object(narrowOop v);
   static void archive_klass_objects(Thread* THREAD);
+
+  static void set_archive_heap_region_fixed() {
+    _archive_heap_region_fixed = true;
+  }
+
+  static bool archive_heap_region_fixed() {
+    return _archive_heap_region_fixed;
+  }
 #endif
 
   static bool is_archive_object(oop p) NOT_CDS_JAVA_HEAP_RETURN_(false);
--- a/src/hotspot/share/memory/universe.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/memory/universe.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -332,7 +332,6 @@
              SystemDictionary::Cloneable_klass(), "u3");
       assert(_the_array_interfaces_array->at(1) ==
              SystemDictionary::Serializable_klass(), "u3");
-      MetaspaceShared::fixup_mapped_heap_regions();
     } else
 #endif
     {
@@ -545,6 +544,7 @@
 
 
 void Universe::reinitialize_itables(TRAPS) {
+  MutexLocker mcld(ClassLoaderDataGraph_lock);
   ClassLoaderDataGraph::dictionary_classes_do(initialize_itable_for_klass, CHECK);
 }
 
--- a/src/hotspot/share/oops/klassVtable.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/oops/klassVtable.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1595,7 +1595,8 @@
   }
 
   static void compute() {
-    ClassLoaderDataGraph::classes_do(do_class);
+    LockedClassesDo locked_do_class(&do_class);
+    ClassLoaderDataGraph::classes_do(&locked_do_class);
     fixed  = no_klasses * oopSize;      // vtable length
     // filler size is a conservative approximation
     filler = oopSize * (no_klasses - no_instance_klasses) * (sizeof(InstanceKlass) - sizeof(ArrayKlass) - 1);
--- a/src/hotspot/share/opto/compile.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/opto/compile.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -544,7 +544,9 @@
 
     ResourceMark rm;
     _scratch_const_size = const_size;
-    int size = (MAX_inst_size + MAX_stubs_size + _scratch_const_size);
+    int locs_size = sizeof(relocInfo) * MAX_locs_size;
+    int slop = 2 * CodeSection::end_slop(); // space between sections
+    int size = (MAX_inst_size + MAX_stubs_size + _scratch_const_size + slop + locs_size);
     blob = BufferBlob::create("Compile::scratch_buffer", size);
     // Record the buffer blob for next time.
     set_scratch_buffer_blob(blob);
--- a/src/hotspot/share/opto/library_call.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/opto/library_call.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -2863,8 +2863,7 @@
   Node* tls_ptr = _gvn.transform(new ThreadLocalNode());
 
   Node* jobj_ptr = basic_plus_adr(top(), tls_ptr,
-                                  in_bytes(THREAD_LOCAL_WRITER_OFFSET_JFR)
-                                  );
+                                  in_bytes(THREAD_LOCAL_WRITER_OFFSET_JFR));
 
   Node* jobj = make_load(control(), jobj_ptr, TypeRawPtr::BOTTOM, T_ADDRESS, MemNode::unordered);
 
@@ -2879,16 +2878,17 @@
          PATH_LIMIT };
 
   RegionNode* result_rgn = new RegionNode(PATH_LIMIT);
-  PhiNode*    result_val = new PhiNode(result_rgn, TypePtr::BOTTOM);
+  PhiNode*    result_val = new PhiNode(result_rgn, TypeInstPtr::BOTTOM);
 
   Node* jobj_is_null = _gvn.transform(new IfTrueNode(iff_jobj_null));
   result_rgn->init_req(_null_path, jobj_is_null);
   result_val->init_req(_null_path, null());
 
   Node* jobj_is_not_null = _gvn.transform(new IfFalseNode(iff_jobj_null));
-  result_rgn->init_req(_normal_path, jobj_is_not_null);
-
-  Node* res = make_load(jobj_is_not_null, jobj, TypeInstPtr::NOTNULL, T_OBJECT, MemNode::unordered);
+  set_control(jobj_is_not_null);
+  Node* res = access_load(jobj, TypeInstPtr::NOTNULL, T_OBJECT,
+                          IN_NATIVE | C2_CONTROL_DEPENDENT_LOAD);
+  result_rgn->init_req(_normal_path, control());
   result_val->init_req(_normal_path, res);
 
   set_result(result_rgn, result_val);
--- a/src/hotspot/share/opto/machnode.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/opto/machnode.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -811,6 +811,13 @@
   return &jvms_for_throw;
 }
 
+uint MachMemBarNode::size_of() const { return sizeof(*this); }
+
+const TypePtr *MachMemBarNode::adr_type() const {
+  return _adr_type;
+}
+
+
 //=============================================================================
 #ifndef PRODUCT
 void labelOper::int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const {
--- a/src/hotspot/share/opto/machnode.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/opto/machnode.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1000,6 +1000,19 @@
   virtual JVMState* jvms() const;
 };
 
+class MachMemBarNode : public MachNode {
+  virtual uint size_of() const; // Size is bigger
+public:
+  const TypePtr* _adr_type;     // memory effects
+  MachMemBarNode() : MachNode() {
+    init_class_id(Class_MachMemBar);
+    _adr_type = TypePtr::BOTTOM; // the default: all of memory
+  }
+
+  void set_adr_type(const TypePtr* atp) { _adr_type = atp; }
+  virtual const TypePtr *adr_type() const;
+};
+
 
 //------------------------------MachTempNode-----------------------------------
 // Node used by the adlc to construct inputs to represent temporary registers
--- a/src/hotspot/share/opto/matcher.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/opto/matcher.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1002,6 +1002,9 @@
             m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
             if (C->failing())  return NULL;
             if (m == NULL) { Matcher::soft_match_failure(); return NULL; }
+            if (n->is_MemBar()) {
+              m->as_MachMemBar()->set_adr_type(n->adr_type());
+            }
           } else {                  // Nothing the matcher cares about
             if (n->is_Proj() && n->in(0) != NULL && n->in(0)->is_Multi()) {       // Projections?
               // Convert to machine-dependent projection
--- a/src/hotspot/share/opto/node.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/opto/node.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -107,6 +107,7 @@
 class MachSpillCopyNode;
 class MachTempNode;
 class MachMergeNode;
+class MachMemBarNode;
 class Matcher;
 class MemBarNode;
 class MemBarStoreStoreNode;
@@ -659,6 +660,7 @@
       DEFINE_CLASS_ID(MachConstant,     Mach, 5)
         DEFINE_CLASS_ID(MachJump,       MachConstant, 0)
       DEFINE_CLASS_ID(MachMerge,        Mach, 6)
+      DEFINE_CLASS_ID(MachMemBar,       Mach, 7)
 
     DEFINE_CLASS_ID(Type,  Node, 2)
       DEFINE_CLASS_ID(Phi,   Type, 0)
@@ -852,6 +854,7 @@
   DEFINE_CLASS_QUERY(MachSafePoint)
   DEFINE_CLASS_QUERY(MachSpillCopy)
   DEFINE_CLASS_QUERY(MachTemp)
+  DEFINE_CLASS_QUERY(MachMemBar)
   DEFINE_CLASS_QUERY(MachMerge)
   DEFINE_CLASS_QUERY(Mem)
   DEFINE_CLASS_QUERY(MemBar)
--- a/src/hotspot/share/opto/subnode.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/opto/subnode.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1348,6 +1348,15 @@
   return NULL;
 }
 
+static bool is_counted_loop_cmp(Node *cmp) {
+  Node *n = cmp->in(1)->in(1);
+  return n != NULL &&
+         n->is_Phi() &&
+         n->in(0) != NULL &&
+         n->in(0)->is_CountedLoop() &&
+         n->in(0)->as_CountedLoop()->phi() == n;
+}
+
 //------------------------------Ideal------------------------------------------
 Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) {
   // Change "bool tst (cmp con x)" into "bool ~tst (cmp x con)".
@@ -1406,7 +1415,7 @@
   // Change ((x & m) u<= m) or ((m & x) u<= m) to always true
   // Same with ((x & m) u< m+1) and ((m & x) u< m+1)
   if (cop == Op_CmpU &&
-      cmp1->Opcode() == Op_AndI) {
+      cmp1_op == Op_AndI) {
     Node* bound = NULL;
     if (_test._test == BoolTest::le) {
       bound = cmp2;
@@ -1424,7 +1433,7 @@
   // This is the off-by-one variant of the above
   if (cop == Op_CmpU &&
       _test._test == BoolTest::lt &&
-      cmp1->Opcode() == Op_AndI) {
+      cmp1_op == Op_AndI) {
     Node* l = cmp1->in(1);
     Node* r = cmp1->in(2);
     for (int repeat = 0; repeat < 2; repeat++) {
@@ -1445,13 +1454,24 @@
     }
   }
 
+  // Change x u< 1 or x u<= 0 to x == 0
+  if (cop == Op_CmpU &&
+      cmp1_op != Op_LoadRange &&
+      ((_test._test == BoolTest::lt &&
+        cmp2->find_int_con(-1) == 1) ||
+       (_test._test == BoolTest::le &&
+        cmp2->find_int_con(-1) == 0))) {
+    Node* ncmp = phase->transform(new CmpINode(cmp1, phase->intcon(0)));
+    return new BoolNode(ncmp, BoolTest::eq);
+  }
+
   // Change (arraylength <= 0) or (arraylength == 0)
   //   into (arraylength u<= 0)
   // Also change (arraylength != 0) into (arraylength u> 0)
   // The latter version matches the code pattern generated for
   // array range checks, which will more likely be optimized later.
   if (cop == Op_CmpI &&
-      cmp1->Opcode() == Op_LoadRange &&
+      cmp1_op == Op_LoadRange &&
       cmp2->find_int_con(-1) == 0) {
     if (_test._test == BoolTest::le || _test._test == BoolTest::eq) {
       Node* ncmp = phase->transform(new CmpUNode(cmp1, cmp2));
@@ -1481,17 +1501,32 @@
   // due to possible integer overflow.
   if ((_test._test == BoolTest::eq || _test._test == BoolTest::ne) &&
         (cop == Op_CmpI) &&
-        (cmp1->Opcode() == Op_SubI) &&
+        (cmp1_op == Op_SubI) &&
         ( cmp2_type == TypeInt::ZERO ) ) {
     Node *ncmp = phase->transform( new CmpINode(cmp1->in(1),cmp1->in(2)));
     return new BoolNode( ncmp, _test._test );
   }
 
+  // Same as above but with and AddI of a constant
+  if ((_test._test == BoolTest::eq || _test._test == BoolTest::ne) &&
+      cop == Op_CmpI &&
+      cmp1_op == Op_AddI &&
+      cmp1->in(2) != NULL &&
+      phase->type(cmp1->in(2))->isa_int() &&
+      phase->type(cmp1->in(2))->is_int()->is_con() &&
+      cmp2_type == TypeInt::ZERO &&
+      !is_counted_loop_cmp(cmp) // modifying the exit test of a counted loop messes the counted loop shape
+      ) {
+    const TypeInt* cmp1_in2 = phase->type(cmp1->in(2))->is_int();
+    Node *ncmp = phase->transform( new CmpINode(cmp1->in(1),phase->intcon(-cmp1_in2->_hi)));
+    return new BoolNode( ncmp, _test._test );
+  }
+
   // Change (-A vs 0) into (A vs 0) by commuting the test.  Disallow in the
   // most general case because negating 0x80000000 does nothing.  Needed for
   // the CmpF3/SubI/CmpI idiom.
   if( cop == Op_CmpI &&
-      cmp1->Opcode() == Op_SubI &&
+      cmp1_op == Op_SubI &&
       cmp2_type == TypeInt::ZERO &&
       phase->type( cmp1->in(1) ) == TypeInt::ZERO &&
       phase->type( cmp1->in(2) )->higher_equal(TypeInt::SYMINT) ) {
--- a/src/hotspot/share/prims/jvmtiEnter.xsl	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/prims/jvmtiEnter.xsl	Fri Sep 07 15:46:39 2018 -0700
@@ -405,7 +405,7 @@
     <xsl:otherwise> 
       <xsl:choose>
         <xsl:when test="count(@phase)=0 or contains(@phase,'live') or contains(@phase,'start')">
-	  <xsl:text>if (this_thread == NULL || (!this_thread->is_Java_thread() &amp;&amp; !this_thread->is_VM_thread())) {</xsl:text>
+	  <xsl:text>if (this_thread == NULL || (!this_thread->is_Java_thread() &amp;&amp; !this_thread->is_Named_thread())) {</xsl:text>
         </xsl:when>
         <xsl:otherwise>
           <xsl:text>if (!this_thread->is_Java_thread()) {</xsl:text> 
--- a/src/hotspot/share/prims/jvmtiEnvBase.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1489,6 +1489,7 @@
 jvmtiError
 JvmtiModuleClosure::get_all_modules(JvmtiEnv* env, jint* module_count_ptr, jobject** modules_ptr) {
   ResourceMark rm;
+  MutexLocker mcld(ClassLoaderDataGraph_lock);
   MutexLocker ml(Module_lock);
 
   _tbl = new GrowableArray<OopHandle>(77);
--- a/src/hotspot/share/prims/jvmtiExport.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/prims/jvmtiExport.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -2722,7 +2722,14 @@
   // should not happen since we're trying to configure for event collection
   guarantee(state != NULL, "exiting thread called setup_jvmti_thread_state");
   if (is_vm_object_alloc_event()) {
-    _prev = state->get_vm_object_alloc_event_collector();
+    JvmtiVMObjectAllocEventCollector *prev = state->get_vm_object_alloc_event_collector();
+
+    // If we have a previous collector and it is disabled, it means this allocation came from a
+    // callback induced VM Object allocation, do not register this collector then.
+    if (prev && !prev->is_enabled()) {
+      return;
+    }
+    _prev = prev;
     state->set_vm_object_alloc_event_collector((JvmtiVMObjectAllocEventCollector *)this);
   } else if (is_dynamic_code_event()) {
     _prev = state->get_dynamic_code_event_collector();
--- a/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -107,6 +107,7 @@
 
     // Iterate through all classes in ClassLoaderDataGraph
     // and collect them using the LoadedClassesClosure
+    MutexLocker mcld(ClassLoaderDataGraph_lock);
     ClassLoaderDataGraph::loaded_classes_do(&closure);
   }
 
--- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -699,7 +699,6 @@
   // Check whether the class NestHost attribute has been changed.
   Thread* thread = Thread::current();
   ResourceMark rm(thread);
-  JvmtiThreadState *state = JvmtiThreadState::state_for((JavaThread*)thread);
   u2 the_nest_host_idx = the_class->nest_host_index();
   u2 scr_nest_host_idx = scratch_class->nest_host_index();
 
--- a/src/hotspot/share/prims/jvmtiTagMap.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/prims/jvmtiTagMap.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -2875,14 +2875,26 @@
       ConstantPool* pool = ik->constants();
       for (int i = 1; i < pool->length(); i++) {
         constantTag tag = pool->tag_at(i).value();
-        if (tag.is_string() || tag.is_klass()) {
+        if (tag.is_string() || tag.is_klass() || tag.is_unresolved_klass()) {
           oop entry;
           if (tag.is_string()) {
             entry = pool->resolved_string_at(i);
             // If the entry is non-null it is resolved.
-            if (entry == NULL) continue;
+            if (entry == NULL) {
+              continue;
+            }
+          } else if (tag.is_klass()) {
+            entry = pool->resolved_klass_at(i)->java_mirror();
           } else {
-            entry = pool->resolved_klass_at(i)->java_mirror();
+            // Code generated by JIT and AOT compilers might not resolve constant
+            // pool entries.  Treat them as resolved if they are loaded.
+            assert(tag.is_unresolved_klass(), "must be");
+            constantPoolHandle cp(Thread::current(), pool);
+            Klass* klass = ConstantPool::klass_at_if_loaded(cp, i);
+            if (klass == NULL) {
+              continue;
+            }
+            entry = klass->java_mirror();
           }
           if (!CallbackInvoker::report_constant_pool_reference(mirror, entry, (jint)i)) {
             return false;
--- a/src/hotspot/share/prims/jvmtiTrace.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/prims/jvmtiTrace.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -291,7 +291,7 @@
 // return the name of the current thread
 const char *JvmtiTrace::safe_get_current_thread_name() {
   if (JvmtiEnv::is_vm_live()) {
-    return JvmtiTrace::safe_get_thread_name(Thread::current());
+    return JvmtiTrace::safe_get_thread_name(Thread::current_or_null());
   } else {
     return "VM not live";
   }
--- a/src/hotspot/share/prims/resolvedMethodTable.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/prims/resolvedMethodTable.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -143,8 +143,7 @@
 }
 
 // Removing entries
-int ResolvedMethodTable::_oops_removed = 0;
-int ResolvedMethodTable::_oops_counted = 0;
+int ResolvedMethodTable::_total_oops_removed = 0;
 
 // There are no dead entries at start
 bool ResolvedMethodTable::_dead_entries = false;
@@ -159,8 +158,8 @@
 // This is done by the ServiceThread after being notified on class unloading
 void ResolvedMethodTable::unlink() {
   MutexLocker ml(ResolvedMethodTable_lock);
-  _oops_removed = 0;
-  _oops_counted = 0;
+  int _oops_removed = 0;
+  int _oops_counted = 0;
   for (int i = 0; i < _the_table->table_size(); ++i) {
     ResolvedMethodEntry** p = _the_table->bucket_addr(i);
     ResolvedMethodEntry* entry = _the_table->bucket(i);
@@ -185,6 +184,7 @@
   }
   log_debug(membername, table) ("ResolvedMethod entries counted %d removed %d",
                                 _oops_counted, _oops_removed);
+  _total_oops_removed += _oops_removed;
   _dead_entries = false;
 }
 
--- a/src/hotspot/share/prims/resolvedMethodTable.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/prims/resolvedMethodTable.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -56,8 +56,7 @@
     _table_size  = 1007
   };
 
-  static int _oops_removed;
-  static int _oops_counted;
+  static int _total_oops_removed;
 
   static bool _dead_entries;
 
@@ -95,6 +94,8 @@
   static bool has_work() { return _dead_entries; }
   static void trigger_cleanup();
 
+  static int removed_entries_count() { return _total_oops_removed; };
+
 #if INCLUDE_JVMTI
   // It is called at safepoint only for RedefineClasses
   static void adjust_method_entries(bool * trace_name_printed);
--- a/src/hotspot/share/prims/whitebox.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/prims/whitebox.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -28,6 +28,7 @@
 
 #include "classfile/classLoaderData.hpp"
 #include "classfile/modules.hpp"
+#include "classfile/protectionDomainCache.hpp"
 #include "classfile/stringTable.hpp"
 #include "code/codeCache.hpp"
 #include "compiler/methodMatcher.hpp"
@@ -48,6 +49,7 @@
 #include "oops/objArrayOop.inline.hpp"
 #include "oops/oop.inline.hpp"
 #include "oops/typeArrayOop.inline.hpp"
+#include "prims/resolvedMethodTable.hpp"
 #include "prims/wbtestmethods/parserTests.hpp"
 #include "prims/whitebox.inline.hpp"
 #include "runtime/arguments.hpp"
@@ -145,7 +147,7 @@
   return os::large_page_size();
 WB_END
 
-class WBIsKlassAliveClosure : public KlassClosure {
+class WBIsKlassAliveClosure : public LockedClassesDo {
     Symbol* _name;
     bool _found;
 public:
@@ -1972,6 +1974,14 @@
 #endif
 WB_END
 
+WB_ENTRY(jint, WB_ResolvedMethodRemovedCount(JNIEnv* env, jobject o))
+  return (jint) ResolvedMethodTable::removed_entries_count();
+WB_END
+
+WB_ENTRY(jint, WB_ProtectionDomainRemovedCount(JNIEnv* env, jobject o))
+  return (jint) SystemDictionary::pd_cache_table()->removed_entries_count();
+WB_END
+
 
 #define CC (char*)
 
@@ -2193,6 +2203,8 @@
   {CC"isContainerized",           CC"()Z",            (void*)&WB_IsContainerized },
   {CC"printOsInfo",               CC"()V",            (void*)&WB_PrintOsInfo },
   {CC"disableElfSectionCache",    CC"()V",            (void*)&WB_DisableElfSectionCache },
+  {CC"resolvedMethodRemovedCount",     CC"()I",       (void*)&WB_ResolvedMethodRemovedCount },
+  {CC"protectionDomainRemovedCount",   CC"()I",       (void*)&WB_ProtectionDomainRemovedCount },
 };
 
 
--- a/src/hotspot/share/runtime/arguments.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/runtime/arguments.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -572,6 +572,9 @@
   { "PrintSafepointStatistics",      JDK_Version::jdk(11),     JDK_Version::jdk(12), JDK_Version::jdk(13) },
   { "PrintSafepointStatisticsTimeout",JDK_Version::jdk(11),    JDK_Version::jdk(12), JDK_Version::jdk(13) },
   { "PrintSafepointStatisticsCount", JDK_Version::jdk(11),     JDK_Version::jdk(12), JDK_Version::jdk(13) },
+  { "TransmitErrorReport",           JDK_Version::undefined(), JDK_Version::jdk(12), JDK_Version::jdk(13) },
+  { "ErrorReportServer",             JDK_Version::undefined(), JDK_Version::jdk(12), JDK_Version::jdk(13) },
+  { "EmitSync",                      JDK_Version::undefined(), JDK_Version::jdk(12), JDK_Version::jdk(13) },
 
 #ifdef TEST_VERIFY_SPECIAL_JVM_FLAGS
   { "dep > obs",                    JDK_Version::jdk(9), JDK_Version::jdk(8), JDK_Version::undefined() },
@@ -3975,7 +3978,7 @@
     }
   }
 #ifdef COMPILER2
-  if (!UseBiasedLocking || EmitSync != 0) {
+  if (!UseBiasedLocking) {
     UseOptoBiasInlining = false;
   }
 #endif
--- a/src/hotspot/share/runtime/globals.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/runtime/globals.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -830,10 +830,6 @@
   experimental(ccstr, SyncKnobs, NULL,                                      \
                "(Unstable) Various monitor synchronization tunables")       \
                                                                             \
-  experimental(intx, EmitSync, 0,                                           \
-               "(Unsafe, Unstable) "                                        \
-               "Control emission of inline sync fast-path code")            \
-                                                                            \
   product(intx, MonitorBound, 0, "Bound Monitor population")                \
           range(0, max_jint)                                                \
                                                                             \
@@ -2417,12 +2413,6 @@
   manageable(bool, PrintConcurrentLocks, false,                             \
           "Print java.util.concurrent locks in thread dump")                \
                                                                             \
-  product(bool, TransmitErrorReport, false,                                 \
-          "Enable error report transmission on erroneous termination")      \
-                                                                            \
-  product(ccstr, ErrorReportServer, NULL,                                   \
-          "Override built-in error report server address")                  \
-                                                                            \
   /* Shared spaces */                                                       \
                                                                             \
   product(bool, UseSharedSpaces, true,                                      \
--- a/src/hotspot/share/runtime/java.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/runtime/java.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -333,7 +333,7 @@
     klassVtable::print_statistics();
     klassItable::print_statistics();
   }
-  if (VerifyOops) {
+  if (VerifyOops && Verbose) {
     tty->print_cr("+VerifyOops count: %d", StubRoutines::verify_oop_count());
   }
 
@@ -346,6 +346,7 @@
 
   if (PrintSystemDictionaryAtExit) {
     ResourceMark rm;
+    MutexLocker mcld(ClassLoaderDataGraph_lock);
     SystemDictionary::print();
     ClassLoaderDataGraph::print();
   }
@@ -494,6 +495,7 @@
     Universe::print_on(&ls_info);
     if (log.is_trace()) {
       LogStream ls_trace(log.trace());
+      MutexLocker mcld(ClassLoaderDataGraph_lock);
       ClassLoaderDataGraph::print_on(&ls_trace);
     }
   }
--- a/src/hotspot/share/runtime/mutexLocker.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/runtime/mutexLocker.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -88,6 +88,7 @@
 Mutex*   Shared_DirtyCardQ_lock       = NULL;
 Mutex*   MarkStackFreeList_lock       = NULL;
 Mutex*   MarkStackChunkList_lock      = NULL;
+Mutex*   MonitoringSupport_lock       = NULL;
 Mutex*   ParGCRareEvent_lock          = NULL;
 Mutex*   DerivedPointerTableGC_lock   = NULL;
 Monitor* CGCPhaseManager_lock         = NULL;
@@ -147,6 +148,7 @@
 Monitor* CodeHeapStateAnalytics_lock  = NULL;
 
 Mutex*   MetaspaceExpand_lock         = NULL;
+Mutex*   ClassLoaderDataGraph_lock    = NULL;
 
 #define MAX_NUM_MUTEX 128
 static Monitor * _mutex_array[MAX_NUM_MUTEX];
@@ -215,6 +217,8 @@
 
     def(MarkStackFreeList_lock     , PaddedMutex  , leaf     ,   true,  Monitor::_safepoint_check_never);
     def(MarkStackChunkList_lock    , PaddedMutex  , leaf     ,   true,  Monitor::_safepoint_check_never);
+
+    def(MonitoringSupport_lock     , PaddedMutex  , native   ,   true,  Monitor::_safepoint_check_never);      // used for serviceability monitoring support
   }
   def(ParGCRareEvent_lock          , PaddedMutex  , leaf     ,   true,  Monitor::_safepoint_check_sometimes);
   def(DerivedPointerTableGC_lock   , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_never);
@@ -224,6 +228,7 @@
   def(OopMapCacheAlloc_lock        , PaddedMutex  , leaf,        true,  Monitor::_safepoint_check_always);     // used for oop_map_cache allocation.
 
   def(MetaspaceExpand_lock         , PaddedMutex  , leaf-1,      true,  Monitor::_safepoint_check_never);
+  def(ClassLoaderDataGraph_lock    , PaddedMutex  , nonleaf,     true,  Monitor::_safepoint_check_always);
 
   def(Patching_lock                , PaddedMutex  , special,     true,  Monitor::_safepoint_check_never);      // used for safepointing and code patching.
   def(Service_lock                 , PaddedMonitor, special,     true,  Monitor::_safepoint_check_never);      // used for service thread operations
--- a/src/hotspot/share/runtime/mutexLocker.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/runtime/mutexLocker.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -94,6 +94,7 @@
                                                  // non-Java threads.
 extern Mutex*   MarkStackFreeList_lock;          // Protects access to the global mark stack free list.
 extern Mutex*   MarkStackChunkList_lock;         // Protects access to the global mark stack chunk list.
+extern Mutex*   MonitoringSupport_lock;          // Protects updates to the serviceability memory pools.
 extern Mutex*   ParGCRareEvent_lock;             // Synchronizes various (rare) parallel GC ops.
 extern Mutex*   Compile_lock;                    // a lock held when Compilation is updating code (used to block CodeCache traversal, CHA updates, etc)
 extern Monitor* MethodCompileQueue_lock;         // a lock held when method compilations are enqueued, dequeued
@@ -145,6 +146,7 @@
 #endif
 
 extern Mutex*   MetaspaceExpand_lock;            // protects Metaspace virtualspace and chunk expansions
+extern Mutex*   ClassLoaderDataGraph_lock;       // protects CLDG list, needed for concurrent unloading
 
 
 extern Monitor* CodeHeapStateAnalytics_lock;     // lock print functions against concurrent analyze functions.
--- a/src/hotspot/share/runtime/safepoint.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/runtime/safepoint.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -628,7 +628,7 @@
     // All threads deflate monitors and mark nmethods (if necessary).
     Threads::possibly_parallel_threads_do(true, &_cleanup_threads_cl);
 
-    if (!_subtasks.is_task_claimed(SafepointSynchronize::SAFEPOINT_CLEANUP_DEFLATE_MONITORS)) {
+    if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_DEFLATE_MONITORS)) {
       const char* name = "deflating idle monitors";
       EventSafepointCleanupTask event;
       TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
@@ -638,7 +638,7 @@
       }
     }
 
-    if (!_subtasks.is_task_claimed(SafepointSynchronize::SAFEPOINT_CLEANUP_UPDATE_INLINE_CACHES)) {
+    if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_UPDATE_INLINE_CACHES)) {
       const char* name = "updating inline caches";
       EventSafepointCleanupTask event;
       TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
@@ -648,7 +648,7 @@
       }
     }
 
-    if (!_subtasks.is_task_claimed(SafepointSynchronize::SAFEPOINT_CLEANUP_COMPILATION_POLICY)) {
+    if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_COMPILATION_POLICY)) {
       const char* name = "compilation policy safepoint handler";
       EventSafepointCleanupTask event;
       TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
@@ -658,7 +658,7 @@
       }
     }
 
-    if (!_subtasks.is_task_claimed(SafepointSynchronize::SAFEPOINT_CLEANUP_SYMBOL_TABLE_REHASH)) {
+    if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_SYMBOL_TABLE_REHASH)) {
       if (SymbolTable::needs_rehashing()) {
         const char* name = "rehashing symbol table";
         EventSafepointCleanupTask event;
@@ -670,7 +670,7 @@
       }
     }
 
-    if (!_subtasks.is_task_claimed(SafepointSynchronize::SAFEPOINT_CLEANUP_STRING_TABLE_REHASH)) {
+    if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_STRING_TABLE_REHASH)) {
       if (StringTable::needs_rehashing()) {
         const char* name = "rehashing string table";
         EventSafepointCleanupTask event;
@@ -682,7 +682,7 @@
       }
     }
 
-    if (!_subtasks.is_task_claimed(SafepointSynchronize::SAFEPOINT_CLEANUP_CLD_PURGE)) {
+    if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_CLD_PURGE)) {
       // CMS delays purging the CLDG until the beginning of the next safepoint and to
       // make sure concurrent sweep is done
       const char* name = "purging class loader data graph";
@@ -694,7 +694,7 @@
       }
     }
 
-    if (!_subtasks.is_task_claimed(SafepointSynchronize::SAFEPOINT_CLEANUP_SYSTEM_DICTIONARY_RESIZE)) {
+    if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_SYSTEM_DICTIONARY_RESIZE)) {
       const char* name = "resizing system dictionaries";
       EventSafepointCleanupTask event;
       TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
--- a/src/hotspot/share/runtime/serviceThread.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/runtime/serviceThread.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -23,8 +23,10 @@
  */
 
 #include "precompiled.hpp"
+#include "classfile/protectionDomainCache.hpp"
 #include "classfile/stringTable.hpp"
 #include "classfile/symbolTable.hpp"
+#include "classfile/systemDictionary.hpp"
 #include "runtime/interfaceSupport.inline.hpp"
 #include "runtime/javaCalls.hpp"
 #include "runtime/serviceThread.hpp"
@@ -88,6 +90,7 @@
     bool stringtable_work = false;
     bool symboltable_work = false;
     bool resolved_method_table_work = false;
+    bool protection_domain_table_work = false;
     JvmtiDeferredEvent jvmti_event;
     {
       // Need state transition ThreadBlockInVM so that this thread
@@ -107,7 +110,8 @@
               !(has_dcmd_notification_event = DCmdFactory::has_pending_jmx_notification()) &&
               !(stringtable_work = StringTable::has_work()) &&
               !(symboltable_work = SymbolTable::has_work()) &&
-              !(resolved_method_table_work = ResolvedMethodTable::has_work())) {
+              !(resolved_method_table_work = ResolvedMethodTable::has_work()) &&
+              !(protection_domain_table_work = SystemDictionary::pd_cache_table()->has_work())) {
         // wait until one of the sensors has pending requests, or there is a
         // pending JVMTI event or JMX GC notification to post
         Service_lock->wait(Mutex::_no_safepoint_check_flag);
@@ -145,6 +149,10 @@
     if (resolved_method_table_work) {
       ResolvedMethodTable::unlink();
     }
+
+    if (protection_domain_table_work) {
+      SystemDictionary::pd_cache_table()->unlink();
+    }
   }
 }
 
--- a/src/hotspot/share/runtime/sharedRuntime.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/runtime/sharedRuntime.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -2135,16 +2135,14 @@
   static int _max_size;                       // max. arg size seen
 
   static void add_method_to_histogram(nmethod* nm) {
-    // These checks are taken from CodeHeapState::print_names()
-    Method* m = (nm == NULL) ? NULL : nm->method();  // nm->method() may be uninitialized, i.e. != NULL, but invalid
-    if ((nm != NULL) && (m != NULL) && !nm->is_zombie() && !nm->is_not_installed() &&
-        os::is_readable_pointer(m) && os::is_readable_pointer(m->constants())) {
-      ArgumentCount args(m->signature());
-      int arity   = args.size() + (m->is_static() ? 0 : 1);
-      int argsize = m->size_of_parameters();
+    if (CompiledMethod::nmethod_access_is_safe(nm)) {
+      Method* method = nm->method();
+      ArgumentCount args(method->signature());
+      int arity   = args.size() + (method->is_static() ? 0 : 1);
+      int argsize = method->size_of_parameters();
       arity   = MIN2(arity, MAX_ARITY-1);
       argsize = MIN2(argsize, MAX_ARITY-1);
-      int count = nm->method()->compiled_invocation_count();
+      int count = method->compiled_invocation_count();
       _arity_histogram[arity]  += count;
       _size_histogram[argsize] += count;
       _max_arity = MAX2(_max_arity, arity);
--- a/src/hotspot/share/runtime/thread.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/runtime/thread.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -307,13 +307,15 @@
   }
 #endif // ASSERT
 
-  // Notify the barrier set that a thread is being created. Note that the
-  // main thread is created before a barrier set is available. The call to
-  // BarrierSet::on_thread_create() for the main thread is therefore deferred
-  // until it calls BarrierSet::set_barrier_set().
+  // Notify the barrier set that a thread is being created. Note that some
+  // threads are created before a barrier set is available. The call to
+  // BarrierSet::on_thread_create() for these threads is therefore deferred
+  // to BarrierSet::set_barrier_set().
   BarrierSet* const barrier_set = BarrierSet::barrier_set();
   if (barrier_set != NULL) {
     barrier_set->on_thread_create(this);
+  } else {
+    DEBUG_ONLY(Threads::inc_threads_before_barrier_set();)
   }
 }
 
@@ -3340,11 +3342,6 @@
 }
 
 CompilerThread::~CompilerThread() {
-  // Free buffer blob, if allocated
-  if (get_buffer_blob() != NULL) {
-    MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
-    CodeCache::free(get_buffer_blob());
-  }
   // Delete objects which were allocated on heap.
   delete _counters;
 }
@@ -3402,6 +3399,7 @@
 
 #ifdef ASSERT
 bool        Threads::_vm_complete = false;
+size_t      Threads::_threads_before_barrier_set = 0;
 #endif
 
 static inline void *prefetch_and_load_ptr(void **addr, intx prefetch_interval) {
--- a/src/hotspot/share/runtime/thread.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/runtime/thread.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -2146,6 +2146,7 @@
   static int         _thread_claim_parity;
 #ifdef ASSERT
   static bool        _vm_complete;
+  static size_t      _threads_before_barrier_set;
 #endif
 
   static void initialize_java_lang_classes(JavaThread* main_thread, TRAPS);
@@ -2215,7 +2216,15 @@
 
 #ifdef ASSERT
   static bool is_vm_complete() { return _vm_complete; }
-#endif
+
+  static size_t threads_before_barrier_set() {
+    return _threads_before_barrier_set;
+  }
+
+  static void inc_threads_before_barrier_set() {
+    ++_threads_before_barrier_set;
+  }
+#endif // ASSERT
 
   // Verification
   static void verify();
--- a/src/hotspot/share/runtime/threadHeapSampler.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/runtime/threadHeapSampler.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -104,8 +104,10 @@
 }
 
 void ThreadHeapSampler::pick_next_sample(size_t overflowed_bytes) {
-  if (get_sampling_interval() == 1) {
-    _bytes_until_sample = 1;
+  // Explicitly test if the sampling interval is 0, return 0 to sample every
+  // allocation.
+  if (get_sampling_interval() == 0) {
+    _bytes_until_sample = 0;
     return;
   }
 
--- a/src/hotspot/share/runtime/vmStructs.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/runtime/vmStructs.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -72,7 +72,7 @@
   int32_t  isStatic;               // Indicates whether following field is an offset or an address
   uint64_t offset;                 // Offset of field within structure; only used for nonstatic fields
   void* address;                   // Address of field; only used for static fields
-                                   // ("offset" can not be reused because of apparent SparcWorks compiler bug
+                                   // ("offset" can not be reused because of apparent solstudio compiler bug
                                    // in generation of initializer data)
 } VMStructEntry;
 
--- a/src/hotspot/share/services/heapDumper.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/services/heapDumper.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -1464,6 +1464,7 @@
   bool skip_operation() const;
 
   // writes a HPROF_LOAD_CLASS record
+  class ClassesDo;
   static void do_load_class(Klass* k);
 
   // writes a HPROF_GC_CLASS_DUMP record for the given class
@@ -1821,7 +1822,10 @@
   SymbolTable::symbols_do(&sym_dumper);
 
   // write HPROF_LOAD_CLASS records
-  ClassLoaderDataGraph::classes_do(&do_load_class);
+  {
+    LockedClassesDo locked_load_classes(&do_load_class);
+    ClassLoaderDataGraph::classes_do(&locked_load_classes);
+  }
   Universe::basic_type_classes_do(&do_load_class);
 
   // write HPROF_FRAME and HPROF_TRACE records
@@ -1832,7 +1836,10 @@
   DumperSupport::write_dump_header(writer());
 
   // Writes HPROF_GC_CLASS_DUMP records
-  ClassLoaderDataGraph::classes_do(&do_class_dump);
+  {
+    LockedClassesDo locked_dump_class(&do_class_dump);
+    ClassLoaderDataGraph::classes_do(&locked_dump_class);
+  }
   Universe::basic_type_classes_do(&do_basic_type_array_class_dump);
   check_segment_length();
 
--- a/src/hotspot/share/services/management.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/services/management.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -713,50 +713,53 @@
 JVM_ENTRY(jobject, jmm_GetMemoryUsage(JNIEnv* env, jboolean heap))
   ResourceMark rm(THREAD);
 
-  // Calculate the memory usage
-  size_t total_init = 0;
-  size_t total_used = 0;
-  size_t total_committed = 0;
-  size_t total_max = 0;
-  bool   has_undefined_init_size = false;
-  bool   has_undefined_max_size = false;
+  MemoryUsage usage;
+
+  if (heap) {
+    usage = Universe::heap()->memory_usage();
+  } else {
+    // Calculate the memory usage by summing up the pools.
+    size_t total_init = 0;
+    size_t total_used = 0;
+    size_t total_committed = 0;
+    size_t total_max = 0;
+    bool   has_undefined_init_size = false;
+    bool   has_undefined_max_size = false;
 
-  for (int i = 0; i < MemoryService::num_memory_pools(); i++) {
-    MemoryPool* pool = MemoryService::get_memory_pool(i);
-    if ((heap && pool->is_heap()) || (!heap && pool->is_non_heap())) {
-      MemoryUsage u = pool->get_memory_usage();
-      total_used += u.used();
-      total_committed += u.committed();
+    for (int i = 0; i < MemoryService::num_memory_pools(); i++) {
+      MemoryPool* pool = MemoryService::get_memory_pool(i);
+      if (pool->is_non_heap()) {
+        MemoryUsage u = pool->get_memory_usage();
+        total_used += u.used();
+        total_committed += u.committed();
 
-      if (u.init_size() == (size_t)-1) {
-        has_undefined_init_size = true;
-      }
-      if (!has_undefined_init_size) {
-        total_init += u.init_size();
-      }
+        if (u.init_size() == MemoryUsage::undefined_size()) {
+          has_undefined_init_size = true;
+        }
+        if (!has_undefined_init_size) {
+          total_init += u.init_size();
+        }
 
-      if (u.max_size() == (size_t)-1) {
-        has_undefined_max_size = true;
-      }
-      if (!has_undefined_max_size) {
-        total_max += u.max_size();
+        if (u.max_size() == MemoryUsage::undefined_size()) {
+          has_undefined_max_size = true;
+        }
+        if (!has_undefined_max_size) {
+          total_max += u.max_size();
+        }
       }
     }
-  }
 
-  // if any one of the memory pool has undefined init_size or max_size,
-  // set it to -1
-  if (has_undefined_init_size) {
-    total_init = (size_t)-1;
+    // if any one of the memory pool has undefined init_size or max_size,
+    // set it to MemoryUsage::undefined_size()
+    if (has_undefined_init_size) {
+      total_init = MemoryUsage::undefined_size();
+    }
+    if (has_undefined_max_size) {
+      total_max = MemoryUsage::undefined_size();
+    }
+
+    usage = MemoryUsage(total_init, total_used, total_committed, total_max);
   }
-  if (has_undefined_max_size) {
-    total_max = (size_t)-1;
-  }
-
-  MemoryUsage usage((heap ? InitialHeapSize : total_init),
-                    total_used,
-                    total_committed,
-                    (heap ? Universe::heap()->max_capacity() : total_max));
 
   Handle obj = MemoryService::create_MemoryUsage_obj(usage, CHECK_NULL);
   return JNIHandles::make_local(env, obj());
--- a/src/hotspot/share/services/nmtCommon.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/services/nmtCommon.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -25,27 +25,11 @@
 #include "services/nmtCommon.hpp"
 #include "utilities/globalDefinitions.hpp"
 
+#define MEMORY_TYPE_DECLARE_NAME(type, human_readable) \
+  human_readable,
+
 const char* NMTUtil::_memory_type_names[] = {
-  "Java Heap",
-  "Class",
-  "Thread",
-  "Thread Stack",
-  "Code",
-  "GC",
-  "Compiler",
-  "Internal",
-  "Other",
-  "Symbol",
-  "Native Memory Tracking",
-  "Shared class space",
-  "Arena Chunk",
-  "Test",
-  "Tracing",
-  "Logging",
-  "Arguments",
-  "Module",
-  "Safepoint",
-  "Unknown"
+  MEMORY_TYPES_DO(MEMORY_TYPE_DECLARE_NAME)
 };
 
 
--- a/src/hotspot/share/utilities/count_trailing_zeros.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/utilities/count_trailing_zeros.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -89,7 +89,7 @@
 /*****************************************************************************
  * Oracle Studio
  *****************************************************************************/
-#elif defined(TARGET_COMPILER_sparcWorks)
+#elif defined(TARGET_COMPILER_solstudio)
 
 // No compiler built-in / intrinsic, so use inline assembler.
 
--- a/src/hotspot/share/utilities/errorReporter.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2011, 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 "precompiled.hpp"
-#include "utilities/errorReporter.hpp"
-
-ErrorReporter::ErrorReporter() {}
-
-void ErrorReporter::call(FILE* fd, char* buffer, int length) {
-}
-
--- a/src/hotspot/share/utilities/errorReporter.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef SHARE_VM_UTILITIES_ERRORREPORTER_HPP
-#define SHARE_VM_UTILITIES_ERRORREPORTER_HPP
-
-#include "utilities/globalDefinitions.hpp"
-#include "memory/allocation.hpp"
-
-class ErrorReporter : public StackObj {
-
-public:
-  ErrorReporter();
-  ~ErrorReporter(){};
-
-  void call(FILE* fd, char *buffer, int length);
-};
-
-#endif // ndef SHARE_VM_UTILITIES_ERRORREPORTER_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/utilities/globalDefinitions_solstudio.hpp	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,264 @@
+/*
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_SOLSTUDIO_HPP
+#define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_SOLSTUDIO_HPP
+
+#include "jni.h"
+
+// This file holds compiler-dependent includes,
+// globally used constants & types, class (forward)
+// declarations and a few frequently used utility functions.
+
+
+# include <ctype.h>
+# include <string.h>
+# include <strings.h>     // for bsd'isms
+# include <stdarg.h>
+# include <stddef.h>      // for offsetof
+# include <stdio.h>
+# include <stdlib.h>
+# include <wchar.h>
+# include <stdarg.h>
+#ifdef SOLARIS
+# include <ieeefp.h>
+#endif
+# include <math.h>
+# include <time.h>
+# include <fcntl.h>
+# include <dlfcn.h>
+# include <pthread.h>
+#ifdef SOLARIS
+# include <thread.h>
+#endif
+# include <limits.h>
+# include <errno.h>
+#ifdef SOLARIS
+# include <sys/trap.h>
+# include <sys/regset.h>
+# include <sys/procset.h>
+# include <ucontext.h>
+# include <setjmp.h>
+#endif
+# ifdef SOLARIS_MUTATOR_LIBTHREAD
+# include <sys/procfs.h>
+# endif
+
+#include <inttypes.h>
+
+// Solaris 8 doesn't provide definitions of these
+#ifdef SOLARIS
+#ifndef PRIdPTR
+#if defined(_LP64)
+#define PRIdPTR                 "ld"
+#define PRIuPTR                 "lu"
+#define PRIxPTR                 "lx"
+#else
+#define PRIdPTR                 "d"
+#define PRIuPTR                 "u"
+#define PRIxPTR                 "x"
+#endif
+#endif
+#endif
+
+#ifdef LINUX
+# include <signal.h>
+# include <ucontext.h>
+# include <sys/time.h>
+#endif
+
+
+// 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures
+// When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in
+// system header files.  On 32-bit architectures, there is no problem.
+// On 64-bit architectures, defining NULL as a 32-bit constant can cause
+// problems with varargs functions: C++ integral promotion rules say for
+// varargs, we pass the argument 0 as an int.  So, if NULL was passed to a
+// varargs function it will remain 32-bits.  Depending on the calling
+// convention of the machine, if the argument is passed on the stack then
+// only 32-bits of the "NULL" pointer may be initialized to zero.  The
+// other 32-bits will be garbage.  If the varargs function is expecting a
+// pointer when it extracts the argument, then we have a problem.
+//
+// Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0.
+//
+// Note: this fix doesn't work well on Linux because NULL will be overwritten
+// whenever a system header file is included. Linux handles NULL correctly
+// through a special type '__null'.
+#ifdef SOLARIS
+#ifdef _LP64
+#undef NULL
+#define NULL 0L
+#else
+#ifndef NULL
+#define NULL 0
+#endif
+#endif
+#endif
+
+// NULL vs NULL_WORD:
+// On Linux NULL is defined as a special type '__null'. Assigning __null to
+// integer variable will cause gcc warning. Use NULL_WORD in places where a
+// pointer is stored as integer value. On some platforms, sizeof(intptr_t) >
+// sizeof(void*), so here we want something which is integer type, but has the
+// same size as a pointer.
+#ifdef LINUX
+  #ifdef _LP64
+    #define NULL_WORD  0L
+  #else
+    // Cast 0 to intptr_t rather than int32_t since they are not the same type
+    // on some platforms.
+    #define NULL_WORD  ((intptr_t)0)
+  #endif
+#else
+  #define NULL_WORD  NULL
+#endif
+
+#ifndef LINUX
+// Compiler-specific primitive types
+typedef unsigned short     uint16_t;
+#ifndef _UINT32_T
+#define _UINT32_T
+typedef unsigned int       uint32_t;
+#endif
+#if !defined(_SYS_INT_TYPES_H)
+#ifndef _UINT64_T
+#define _UINT64_T
+typedef unsigned long long uint64_t;
+#endif
+// %%%% how to access definition of intptr_t portably in 5.5 onward?
+typedef int                     intptr_t;
+typedef unsigned int            uintptr_t;
+// If this gets an error, figure out a symbol XXX that implies the
+// prior definition of intptr_t, and add "&& !defined(XXX)" above.
+#endif
+#endif
+
+// On solaris 8, UINTPTR_MAX is defined as empty.
+// Everywhere else it's an actual value.
+#if UINTPTR_MAX - 1 == -1
+#undef UINTPTR_MAX
+#ifdef _LP64
+#define UINTPTR_MAX UINT64_MAX
+#else
+#define UINTPTR_MAX UINT32_MAX
+#endif /* ifdef _LP64 */
+#endif
+
+// Additional Java basic types
+
+typedef unsigned char      jubyte;
+typedef unsigned short     jushort;
+typedef unsigned int       juint;
+typedef unsigned long long julong;
+
+
+#ifdef SOLARIS
+// ANSI C++ fixes
+// NOTE:In the ANSI committee's continuing attempt to make each version
+// of C++ incompatible with the previous version, you can no longer cast
+// pointers to functions without specifying linkage unless you want to get
+// warnings.
+//
+// This also means that pointers to functions can no longer be "hidden"
+// in opaque types like void * because at the invokation point warnings
+// will be generated. While this makes perfect sense from a type safety
+// point of view it causes a lot of warnings on old code using C header
+// files. Here are some typedefs to make the job of silencing warnings
+// a bit easier.
+//
+// The final kick in the teeth is that you can only have extern "C" linkage
+// specified at file scope. So these typedefs are here rather than in the
+// .hpp for the class (os:Solaris usually) that needs them.
+
+extern "C" {
+   typedef int (*int_fnP_thread_t_iP_uP_stack_tP_gregset_t)(thread_t, int*, unsigned *, stack_t*, gregset_t);
+   typedef int (*int_fnP_thread_t_i_gregset_t)(thread_t, int, gregset_t);
+   typedef int (*int_fnP_thread_t_i)(thread_t, int);
+   typedef int (*int_fnP_thread_t)(thread_t);
+
+   typedef int (*int_fnP_cond_tP_mutex_tP_timestruc_tP)(cond_t *cv, mutex_t *mx, timestruc_t *abst);
+   typedef int (*int_fnP_cond_tP_mutex_tP)(cond_t *cv, mutex_t *mx);
+
+   // typedef for missing API in libc
+   typedef int (*int_fnP_mutex_tP_i_vP)(mutex_t *, int, void *);
+   typedef int (*int_fnP_mutex_tP)(mutex_t *);
+   typedef int (*int_fnP_cond_tP_i_vP)(cond_t *cv, int scope, void *arg);
+   typedef int (*int_fnP_cond_tP)(cond_t *cv);
+};
+#endif
+
+// checking for nanness
+#ifdef SOLARIS
+#ifdef SPARC
+inline int g_isnan(float  f) { return isnanf(f); }
+#else
+// isnanf() broken on Intel Solaris use isnand()
+inline int g_isnan(float  f) { return isnand(f); }
+#endif
+
+inline int g_isnan(double f) { return isnand(f); }
+#elif LINUX
+inline int g_isnan(float  f) { return isnanf(f); }
+inline int g_isnan(double f) { return isnan(f); }
+#else
+#error "missing platform-specific definition here"
+#endif
+
+// Checking for finiteness
+
+inline int g_isfinite(jfloat  f)                 { return finite(f); }
+inline int g_isfinite(jdouble f)                 { return finite(f); }
+
+
+// Wide characters
+
+inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); }
+
+// Portability macros
+#define PRAGMA_INTERFACE
+#define PRAGMA_IMPLEMENTATION
+#define PRAGMA_IMPLEMENTATION_(arg)
+
+// Formatting.
+#ifdef _LP64
+#define FORMAT64_MODIFIER "l"
+#else // !_LP64
+#define FORMAT64_MODIFIER "ll"
+#endif // _LP64
+
+#define offset_of(klass,field) offsetof(klass,field)
+
+#ifndef USE_LIBRARY_BASED_TLS_ONLY
+#define THREAD_LOCAL_DECL __thread
+#endif
+
+// Inlining support
+#define NOINLINE
+#define ALWAYSINLINE inline __attribute__((always_inline))
+
+// Alignment
+#define ATTRIBUTE_ALIGNED(x) __attribute__((aligned(x)))
+
+#endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_SOLSTUDIO_HPP
--- a/src/hotspot/share/utilities/globalDefinitions_sparcWorks.hpp	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,264 +0,0 @@
-/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_SPARCWORKS_HPP
-#define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_SPARCWORKS_HPP
-
-#include "jni.h"
-
-// This file holds compiler-dependent includes,
-// globally used constants & types, class (forward)
-// declarations and a few frequently used utility functions.
-
-
-# include <ctype.h>
-# include <string.h>
-# include <strings.h>     // for bsd'isms
-# include <stdarg.h>
-# include <stddef.h>      // for offsetof
-# include <stdio.h>
-# include <stdlib.h>
-# include <wchar.h>
-# include <stdarg.h>
-#ifdef SOLARIS
-# include <ieeefp.h>
-#endif
-# include <math.h>
-# include <time.h>
-# include <fcntl.h>
-# include <dlfcn.h>
-# include <pthread.h>
-#ifdef SOLARIS
-# include <thread.h>
-#endif
-# include <limits.h>
-# include <errno.h>
-#ifdef SOLARIS
-# include <sys/trap.h>
-# include <sys/regset.h>
-# include <sys/procset.h>
-# include <ucontext.h>
-# include <setjmp.h>
-#endif
-# ifdef SOLARIS_MUTATOR_LIBTHREAD
-# include <sys/procfs.h>
-# endif
-
-#include <inttypes.h>
-
-// Solaris 8 doesn't provide definitions of these
-#ifdef SOLARIS
-#ifndef PRIdPTR
-#if defined(_LP64)
-#define PRIdPTR                 "ld"
-#define PRIuPTR                 "lu"
-#define PRIxPTR                 "lx"
-#else
-#define PRIdPTR                 "d"
-#define PRIuPTR                 "u"
-#define PRIxPTR                 "x"
-#endif
-#endif
-#endif
-
-#ifdef LINUX
-# include <signal.h>
-# include <ucontext.h>
-# include <sys/time.h>
-#endif
-
-
-// 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures
-// When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in
-// system header files.  On 32-bit architectures, there is no problem.
-// On 64-bit architectures, defining NULL as a 32-bit constant can cause
-// problems with varargs functions: C++ integral promotion rules say for
-// varargs, we pass the argument 0 as an int.  So, if NULL was passed to a
-// varargs function it will remain 32-bits.  Depending on the calling
-// convention of the machine, if the argument is passed on the stack then
-// only 32-bits of the "NULL" pointer may be initialized to zero.  The
-// other 32-bits will be garbage.  If the varargs function is expecting a
-// pointer when it extracts the argument, then we have a problem.
-//
-// Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0.
-//
-// Note: this fix doesn't work well on Linux because NULL will be overwritten
-// whenever a system header file is included. Linux handles NULL correctly
-// through a special type '__null'.
-#ifdef SOLARIS
-#ifdef _LP64
-#undef NULL
-#define NULL 0L
-#else
-#ifndef NULL
-#define NULL 0
-#endif
-#endif
-#endif
-
-// NULL vs NULL_WORD:
-// On Linux NULL is defined as a special type '__null'. Assigning __null to
-// integer variable will cause gcc warning. Use NULL_WORD in places where a
-// pointer is stored as integer value. On some platforms, sizeof(intptr_t) >
-// sizeof(void*), so here we want something which is integer type, but has the
-// same size as a pointer.
-#ifdef LINUX
-  #ifdef _LP64
-    #define NULL_WORD  0L
-  #else
-    // Cast 0 to intptr_t rather than int32_t since they are not the same type
-    // on some platforms.
-    #define NULL_WORD  ((intptr_t)0)
-  #endif
-#else
-  #define NULL_WORD  NULL
-#endif
-
-#ifndef LINUX
-// Compiler-specific primitive types
-typedef unsigned short     uint16_t;
-#ifndef _UINT32_T
-#define _UINT32_T
-typedef unsigned int       uint32_t;
-#endif
-#if !defined(_SYS_INT_TYPES_H)
-#ifndef _UINT64_T
-#define _UINT64_T
-typedef unsigned long long uint64_t;
-#endif
-// %%%% how to access definition of intptr_t portably in 5.5 onward?
-typedef int                     intptr_t;
-typedef unsigned int            uintptr_t;
-// If this gets an error, figure out a symbol XXX that implies the
-// prior definition of intptr_t, and add "&& !defined(XXX)" above.
-#endif
-#endif
-
-// On solaris 8, UINTPTR_MAX is defined as empty.
-// Everywhere else it's an actual value.
-#if UINTPTR_MAX - 1 == -1
-#undef UINTPTR_MAX
-#ifdef _LP64
-#define UINTPTR_MAX UINT64_MAX
-#else
-#define UINTPTR_MAX UINT32_MAX
-#endif /* ifdef _LP64 */
-#endif
-
-// Additional Java basic types
-
-typedef unsigned char      jubyte;
-typedef unsigned short     jushort;
-typedef unsigned int       juint;
-typedef unsigned long long julong;
-
-
-#ifdef SOLARIS
-// ANSI C++ fixes
-// NOTE:In the ANSI committee's continuing attempt to make each version
-// of C++ incompatible with the previous version, you can no longer cast
-// pointers to functions without specifying linkage unless you want to get
-// warnings.
-//
-// This also means that pointers to functions can no longer be "hidden"
-// in opaque types like void * because at the invokation point warnings
-// will be generated. While this makes perfect sense from a type safety
-// point of view it causes a lot of warnings on old code using C header
-// files. Here are some typedefs to make the job of silencing warnings
-// a bit easier.
-//
-// The final kick in the teeth is that you can only have extern "C" linkage
-// specified at file scope. So these typedefs are here rather than in the
-// .hpp for the class (os:Solaris usually) that needs them.
-
-extern "C" {
-   typedef int (*int_fnP_thread_t_iP_uP_stack_tP_gregset_t)(thread_t, int*, unsigned *, stack_t*, gregset_t);
-   typedef int (*int_fnP_thread_t_i_gregset_t)(thread_t, int, gregset_t);
-   typedef int (*int_fnP_thread_t_i)(thread_t, int);
-   typedef int (*int_fnP_thread_t)(thread_t);
-
-   typedef int (*int_fnP_cond_tP_mutex_tP_timestruc_tP)(cond_t *cv, mutex_t *mx, timestruc_t *abst);
-   typedef int (*int_fnP_cond_tP_mutex_tP)(cond_t *cv, mutex_t *mx);
-
-   // typedef for missing API in libc
-   typedef int (*int_fnP_mutex_tP_i_vP)(mutex_t *, int, void *);
-   typedef int (*int_fnP_mutex_tP)(mutex_t *);
-   typedef int (*int_fnP_cond_tP_i_vP)(cond_t *cv, int scope, void *arg);
-   typedef int (*int_fnP_cond_tP)(cond_t *cv);
-};
-#endif
-
-// checking for nanness
-#ifdef SOLARIS
-#ifdef SPARC
-inline int g_isnan(float  f) { return isnanf(f); }
-#else
-// isnanf() broken on Intel Solaris use isnand()
-inline int g_isnan(float  f) { return isnand(f); }
-#endif
-
-inline int g_isnan(double f) { return isnand(f); }
-#elif LINUX
-inline int g_isnan(float  f) { return isnanf(f); }
-inline int g_isnan(double f) { return isnan(f); }
-#else
-#error "missing platform-specific definition here"
-#endif
-
-// Checking for finiteness
-
-inline int g_isfinite(jfloat  f)                 { return finite(f); }
-inline int g_isfinite(jdouble f)                 { return finite(f); }
-
-
-// Wide characters
-
-inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); }
-
-// Portability macros
-#define PRAGMA_INTERFACE
-#define PRAGMA_IMPLEMENTATION
-#define PRAGMA_IMPLEMENTATION_(arg)
-
-// Formatting.
-#ifdef _LP64
-#define FORMAT64_MODIFIER "l"
-#else // !_LP64
-#define FORMAT64_MODIFIER "ll"
-#endif // _LP64
-
-#define offset_of(klass,field) offsetof(klass,field)
-
-#ifndef USE_LIBRARY_BASED_TLS_ONLY
-#define THREAD_LOCAL_DECL __thread
-#endif
-
-// Inlining support
-#define NOINLINE
-#define ALWAYSINLINE inline __attribute__((always_inline))
-
-// Alignment
-#define ATTRIBUTE_ALIGNED(x) __attribute__((aligned(x)))
-
-#endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_SPARCWORKS_HPP
--- a/src/hotspot/share/utilities/vmError.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/hotspot/share/utilities/vmError.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -47,7 +47,6 @@
 #include "utilities/debug.hpp"
 #include "utilities/decoder.hpp"
 #include "utilities/defaultStream.hpp"
-#include "utilities/errorReporter.hpp"
 #include "utilities/events.hpp"
 #include "utilities/vmError.hpp"
 #include "utilities/macros.hpp"
@@ -1287,7 +1286,6 @@
   // then save detailed information in log file (verbose = true).
   static bool out_done = false;         // done printing to standard out
   static bool log_done = false;         // done saving error log
-  static bool transmit_report_done = false; // done error reporting
 
   if (SuppressFatalErrorMessage) {
       os::abort(CreateCoredumpOnCrash);
@@ -1433,9 +1431,6 @@
       } else {
         out.print_raw_cr("# Can not save log file, dump to screen..");
         log.set_fd(defaultStream::output_fd());
-        /* Error reporting currently needs dumpfile.
-         * Maybe implement direct streaming in the future.*/
-        transmit_report_done = true;
       }
     }
 
@@ -1444,20 +1439,6 @@
     _current_step = 0;
     _current_step_info = "";
 
-    // Run error reporting to determine whether or not to report the crash.
-    if (!transmit_report_done && should_report_bug(_id)) {
-      transmit_report_done = true;
-      const int fd2 = ::dup(log.fd());
-      if (fd2 != -1) {
-        FILE* const hs_err = ::fdopen(fd2, "r");
-        if (NULL != hs_err) {
-          ErrorReporter er;
-          er.call(hs_err, buffer, O_BUFLEN);
-          ::fclose(hs_err);
-        }
-      }
-    }
-
     if (log.fd() != defaultStream::output_fd()) {
       close(log.fd());
     }
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Fri Sep 07 15:46:39 2018 -0700
@@ -450,7 +450,7 @@
      * independently of any {@code Lookup} object.
      * <p>
      * If the desired member is {@code protected}, the usual JVM rules apply,
-     * including the requirement that the lookup class must be either be in the
+     * including the requirement that the lookup class must either be in the
      * same package as the desired member, or must inherit that member.
      * (See the Java Virtual Machine Specification, sections 4.9.2, 5.4.3.5, and 6.4.)
      * In addition, if the desired member is a non-static field or method
--- a/src/java.base/share/classes/java/net/URLClassLoader.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/java/net/URLClassLoader.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -111,11 +111,6 @@
      */
     public URLClassLoader(URL[] urls, ClassLoader parent) {
         super(parent);
-        // this is to make the stack depth consistent with 1.1
-        SecurityManager security = System.getSecurityManager();
-        if (security != null) {
-            security.checkCreateClassLoader();
-        }
         this.acc = AccessController.getContext();
         this.ucp = new URLClassPath(urls, acc);
     }
@@ -123,11 +118,6 @@
     URLClassLoader(String name, URL[] urls, ClassLoader parent,
                    AccessControlContext acc) {
         super(name, parent);
-        // this is to make the stack depth consistent with 1.1
-        SecurityManager security = System.getSecurityManager();
-        if (security != null) {
-            security.checkCreateClassLoader();
-        }
         this.acc = acc;
         this.ucp = new URLClassPath(urls, acc);
     }
@@ -156,22 +146,12 @@
      */
     public URLClassLoader(URL[] urls) {
         super();
-        // this is to make the stack depth consistent with 1.1
-        SecurityManager security = System.getSecurityManager();
-        if (security != null) {
-            security.checkCreateClassLoader();
-        }
         this.acc = AccessController.getContext();
         this.ucp = new URLClassPath(urls, acc);
     }
 
     URLClassLoader(URL[] urls, AccessControlContext acc) {
         super();
-        // this is to make the stack depth consistent with 1.1
-        SecurityManager security = System.getSecurityManager();
-        if (security != null) {
-            security.checkCreateClassLoader();
-        }
         this.acc = acc;
         this.ucp = new URLClassPath(urls, acc);
     }
@@ -201,11 +181,6 @@
     public URLClassLoader(URL[] urls, ClassLoader parent,
                           URLStreamHandlerFactory factory) {
         super(parent);
-        // this is to make the stack depth consistent with 1.1
-        SecurityManager security = System.getSecurityManager();
-        if (security != null) {
-            security.checkCreateClassLoader();
-        }
         this.acc = AccessController.getContext();
         this.ucp = new URLClassPath(urls, factory, acc);
     }
@@ -238,11 +213,6 @@
                           URL[] urls,
                           ClassLoader parent) {
         super(name, parent);
-        // this is to make the stack depth consistent with 1.1
-        SecurityManager security = System.getSecurityManager();
-        if (security != null) {
-            security.checkCreateClassLoader();
-        }
         this.acc = AccessController.getContext();
         this.ucp = new URLClassPath(urls, acc);
     }
@@ -273,11 +243,6 @@
     public URLClassLoader(String name, URL[] urls, ClassLoader parent,
                           URLStreamHandlerFactory factory) {
         super(name, parent);
-        // this is to make the stack depth consistent with 1.1
-        SecurityManager security = System.getSecurityManager();
-        if (security != null) {
-            security.checkCreateClassLoader();
-        }
         this.acc = AccessController.getContext();
         this.ucp = new URLClassPath(urls, factory, acc);
     }
--- a/src/java.base/share/classes/java/nio/Buffer.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/java/nio/Buffer.java	Fri Sep 07 15:46:39 2018 -0700
@@ -693,13 +693,6 @@
         return mark;
     }
 
-    final void truncate() {                             // package-private
-        mark = -1;
-        position = 0;
-        limit = 0;
-        capacity = 0;
-    }
-
     final void discardMark() {                          // package-private
         mark = -1;
     }
--- a/src/java.base/share/classes/java/nio/charset/Charset-X-Coder.java.template	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/java/nio/charset/Charset-X-Coder.java.template	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -189,10 +189,12 @@
                    $replType$ replacement)
     {
         this.charset = cs;
-        if (average$ItypesPerOtype$ <= 0.0f)
+        // Use !(a > 0.0f) rather than (a <= 0.0f) to exclude NaN values
+        if (!(average$ItypesPerOtype$ > 0.0f))
             throw new IllegalArgumentException("Non-positive "
                                                + "average$ItypesPerOtype$");
-        if (max$ItypesPerOtype$ <= 0.0f)
+        // Use !(a > 0.0f) rather than (a <= 0.0f) to exclude NaN values
+        if (!(max$ItypesPerOtype$ > 0.0f))
             throw new IllegalArgumentException("Non-positive "
                                                + "max$ItypesPerOtype$");
         if (average$ItypesPerOtype$ > max$ItypesPerOtype$)
--- a/src/java.base/share/classes/java/nio/file/attribute/PosixFileAttributeView.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/java/nio/file/attribute/PosixFileAttributeView.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -50,7 +50,7 @@
  *
  * <p> The {@link PosixFileAttributes#permissions() permissions} attribute is a
  * set of access permissions. This file attribute view provides access to the nine
- * permission defined by the {@link PosixFilePermission} class.
+ * permission bits defined by the {@link PosixFilePermission} class.
  * These nine permission bits determine the <em>read</em>, <em>write</em>, and
  * <em>execute</em> access for the file owner, group, and others (others
  * meaning identities other than the owner and members of the group). Some
@@ -126,7 +126,7 @@
  * </pre>
  *
  * <p> When the access permissions are set at file creation time then the actual
- * value of the permissions may differ that the value of the attribute object.
+ * value of the permissions may differ from the value of the attribute object.
  * The reasons for this are implementation specific. On UNIX systems, for
  * example, a process has a <em>umask</em> that impacts the permission bits
  * of newly created files. Where an implementation supports the setting of
--- a/src/java.base/share/classes/java/security/SecureClassLoader.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/java/security/SecureClassLoader.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -42,12 +42,6 @@
  * @since 1.2
  */
 public class SecureClassLoader extends ClassLoader {
-    /*
-     * If initialization succeed this is set to true and security checks will
-     * succeed. Otherwise the object is not initialized and the object is
-     * useless.
-     */
-    private final boolean initialized;
 
     /*
      * Map that maps the CodeSource to a ProtectionDomain. The key is a
@@ -81,12 +75,6 @@
      */
     protected SecureClassLoader(ClassLoader parent) {
         super(parent);
-        // this is to make the stack depth consistent with 1.1
-        SecurityManager security = System.getSecurityManager();
-        if (security != null) {
-            security.checkCreateClassLoader();
-        }
-        initialized = true;
     }
 
     /**
@@ -104,12 +92,6 @@
      */
     protected SecureClassLoader() {
         super();
-        // this is to make the stack depth consistent with 1.1
-        SecurityManager security = System.getSecurityManager();
-        if (security != null) {
-            security.checkCreateClassLoader();
-        }
-        initialized = true;
     }
 
     /**
@@ -130,11 +112,6 @@
      */
     protected SecureClassLoader(String name, ClassLoader parent) {
         super(name, parent);
-        SecurityManager security = System.getSecurityManager();
-        if (security != null) {
-            security.checkCreateClassLoader();
-        }
-        initialized = true;
     }
 
     /**
@@ -220,7 +197,6 @@
      */
     protected PermissionCollection getPermissions(CodeSource codesource)
     {
-        check();
         return new Permissions(); // ProtectionDomain defers the binding
     }
 
@@ -260,15 +236,6 @@
         });
     }
 
-    /*
-     * Check to make sure the class loader has been initialized.
-     */
-    private void check() {
-        if (!initialized) {
-            throw new SecurityException("ClassLoader object not initialized");
-        }
-    }
-
     private static class CodeSourceKey {
         private final CodeSource cs;
 
--- a/src/java.base/share/classes/java/util/Calendar.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/java/util/Calendar.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -3326,7 +3326,9 @@
                 other.stamp[i] = stamp[i];
                 other.isSet[i] = isSet[i];
             }
-            other.zone = (TimeZone) zone.clone();
+            if (!sharedZone) {
+                other.zone = (TimeZone) zone.clone();
+            }
             return other;
         }
         catch (CloneNotSupportedException e) {
--- a/src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java	Fri Sep 07 15:46:39 2018 -0700
@@ -152,13 +152,6 @@
         synchronized (stateLock) {
             ensureOpen();
 
-            if (name == StandardSocketOptions.IP_TOS) {
-                ProtocolFamily family = Net.isIPv6Available() ?
-                    StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;
-                Net.setSocketOption(fd, family, name, value);
-                return this;
-            }
-
             if (name == StandardSocketOptions.SO_REUSEADDR && Net.useExclusiveBind()) {
                 // SO_REUSEADDR emulated when using exclusive bind
                 isReuseAddress = (Boolean)value;
@@ -200,7 +193,6 @@
             if (Net.isReusePortAvailable()) {
                 set.add(StandardSocketOptions.SO_REUSEPORT);
             }
-            set.add(StandardSocketOptions.IP_TOS);
             set.addAll(ExtendedSocketOptions.options(SOCK_STREAM));
             return Collections.unmodifiableSet(set);
         }
--- a/src/java.base/share/classes/sun/security/ssl/CertSignAlgsExtension.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/sun/security/ssl/CertSignAlgsExtension.java	Fri Sep 07 15:46:39 2018 -0700
@@ -191,12 +191,12 @@
             }
 
             // update the context
-            List<SignatureScheme> shemes =
+            List<SignatureScheme> schemes =
                     SignatureScheme.getSupportedAlgorithms(
                             shc.algorithmConstraints, shc.negotiatedProtocol,
                             spec.signatureSchemes);
-            shc.peerRequestedCertSignSchemes = shemes;
-            shc.handshakeSession.setPeerSupportedSignatureAlgorithms(shemes);
+            shc.peerRequestedCertSignSchemes = schemes;
+            shc.handshakeSession.setPeerSupportedSignatureAlgorithms(schemes);
 
             if (!shc.isResumption && shc.negotiatedProtocol.useTLS13PlusSpec()) {
                 if (shc.sslConfig.clientAuthType !=
@@ -337,12 +337,12 @@
             }
 
             // update the context
-            List<SignatureScheme> shemes =
+            List<SignatureScheme> schemes =
                     SignatureScheme.getSupportedAlgorithms(
                             chc.algorithmConstraints, chc.negotiatedProtocol,
                             spec.signatureSchemes);
-            chc.peerRequestedCertSignSchemes = shemes;
-            chc.handshakeSession.setPeerSupportedSignatureAlgorithms(shemes);
+            chc.peerRequestedCertSignSchemes = schemes;
+            chc.handshakeSession.setPeerSupportedSignatureAlgorithms(schemes);
         }
     }
 }
--- a/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1031,8 +1031,8 @@
                 // Don't select a signature scheme unless we will be able to
                 // produce a CertificateVerify message later
                 if (SignatureScheme.getPreferableAlgorithm(
-                    hc.peerRequestedSignatureSchemes,
-                    ss, hc.negotiatedProtocol) == null) {
+                        hc.peerRequestedSignatureSchemes,
+                        ss, hc.negotiatedProtocol) == null) {
 
                     if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
                         SSLLogger.warning(
--- a/src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java	Fri Sep 07 15:46:39 2018 -0700
@@ -50,7 +50,7 @@
         this.outputRecord = outputRecord;
     }
 
-    // Complete a handshakin message writing. Called by HandshakeMessage.
+    // Complete a handshaking message write. Called by HandshakeMessage.
     void complete() throws IOException {
         if (size() < 4) {       // 4: handshake message header size
             // internal_error alert will be triggered
--- a/src/java.base/share/classes/sun/security/ssl/PskKeyExchangeModesExtension.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/sun/security/ssl/PskKeyExchangeModesExtension.java	Fri Sep 07 15:46:39 2018 -0700
@@ -323,7 +323,7 @@
             // servers MUST abort the handshake.
             SSLExtensionSpec spec =
                 shc.handshakeExtensions.get(SSLExtension.CH_PRE_SHARED_KEY);
-            if (spec == null) {
+            if (spec != null) {
                 shc.conContext.fatal(Alert.HANDSHAKE_FAILURE,
                         "pre_shared_key key extension is offered " +
                         "without a psk_key_exchange_modes extension");
--- a/src/java.base/share/classes/sun/security/ssl/SSLCipher.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/sun/security/ssl/SSLCipher.java	Fri Sep 07 15:46:39 2018 -0700
@@ -379,10 +379,10 @@
     private final Map.Entry<WriteCipherGenerator,
             ProtocolVersion[]>[] writeCipherGenerators;
 
-    // Map of Ciphers listed in jdk.tls.KeyLimit
+    // Map of Ciphers listed in jdk.tls.keyLimits
     private static final HashMap<String, Long> cipherLimits = new HashMap<>();
 
-    // Keywords found on the jdk.tls.KeyLimit security property.
+    // Keywords found on the jdk.tls.keyLimits security property.
     final static String tag[] = {"KEYUPDATE"};
 
     static  {
@@ -407,7 +407,7 @@
                     index = 0;
                 } else {
                     if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
-                        SSLLogger.fine("jdk.net.keyLimits:  Unknown action:  " +
+                        SSLLogger.fine("jdk.tls.keyLimits:  Unknown action:  " +
                                 entry);
                     }
                     continue;
@@ -423,17 +423,18 @@
                         size = Long.parseLong(values[2]);
                     }
                     if (size < 1 || size > max) {
-                        throw new NumberFormatException("Length exceeded limits");
+                        throw new NumberFormatException(
+                            "Length exceeded limits");
                     }
                 } catch (NumberFormatException e) {
                     if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
-                        SSLLogger.fine("jdk.net.keyLimits:  " + e.getMessage() +
+                        SSLLogger.fine("jdk.tls.keyLimits:  " + e.getMessage() +
                                 ":  " +  entry);
                     }
                     continue;
                 }
                 if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
-                    SSLLogger.fine("jdk.net.keyLimits:  entry = " + entry +
+                    SSLLogger.fine("jdk.tls.keyLimits:  entry = " + entry +
                             ". " + values[0] + ":" + tag[index] + " = " + size);
                 }
                 cipherLimits.put(values[0] + ":" + tag[index], size);
--- a/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java	Fri Sep 07 15:46:39 2018 -0700
@@ -127,9 +127,7 @@
         }
 
         // See if the handshaker needs to report back some SSLException.
-        if (conContext.outputRecord.isEmpty()) {
-            checkTaskThrown();
-        }   // Otherwise, deliver cached records before throwing task exception.
+        checkTaskThrown();
 
         // check parameters
         checkParams(srcs, srcsOffset, srcsLength, dsts, dstsOffset, dstsLength);
@@ -896,18 +894,58 @@
         return true;
     }
 
+    /*
+     * Depending on whether the error was just a warning and the
+     * handshaker wasn't closed, or fatal and the handshaker is now
+     * null, report back the Exception that happened in the delegated
+     * task(s).
+     */
     private synchronized void checkTaskThrown() throws SSLException {
+
+        Exception exc = null;
+
+        // First check the handshake context.
         HandshakeContext hc = conContext.handshakeContext;
-        if (hc != null && hc.delegatedThrown != null) {
-            try {
-                throw getTaskThrown(hc.delegatedThrown);
-            } finally {
-                hc.delegatedThrown = null;
+        if ((hc != null) && (hc.delegatedThrown != null)) {
+            exc = hc.delegatedThrown;
+            hc.delegatedThrown = null;
+        }
+
+        /*
+         * hc.delegatedThrown and conContext.delegatedThrown are most likely
+         * the same, but it's possible we could have had a non-fatal
+         * exception and thus the new HandshakeContext is still valid
+         * (alert warning).  If so, then we may have a secondary exception
+         * waiting to be reported from the TransportContext, so we will
+         * need to clear that on a successive call.  Otherwise, clear it now.
+         */
+        if (conContext.delegatedThrown != null) {
+            if (exc != null) {
+                // hc object comparison
+                if (conContext.delegatedThrown == exc) {
+                    // clear if/only if both are the same
+                    conContext.delegatedThrown = null;
+                } // otherwise report the hc delegatedThrown
+            } else {
+                // Nothing waiting in HandshakeContext, but one is in the
+                // TransportContext.
+                exc = conContext.delegatedThrown;
+                conContext.delegatedThrown = null;
             }
         }
 
-        if (conContext.isBroken && conContext.closeReason != null) {
-            throw getTaskThrown(conContext.closeReason);
+        // Anything to report?
+        if (exc == null) {
+            return;
+        }
+
+        // If it wasn't a RuntimeException/SSLException, need to wrap it.
+        if (exc instanceof SSLException) {
+            throw (SSLException)exc;
+        } else if (exc instanceof RuntimeException) {
+            throw (RuntimeException)exc;
+        } else {
+            throw getTaskThrown(exc);
         }
     }
 
@@ -963,20 +1001,41 @@
                 } catch (PrivilegedActionException pae) {
                     // Get the handshake context again in case the
                     // handshaking has completed.
+                    Exception reportedException = pae.getException();
+
+                    // Report to both the TransportContext...
+                    if (engine.conContext.delegatedThrown == null) {
+                        engine.conContext.delegatedThrown = reportedException;
+                    }
+
+                    // ...and the HandshakeContext in case condition
+                    // wasn't fatal and the handshakeContext is still
+                    // around.
                     hc = engine.conContext.handshakeContext;
                     if (hc != null) {
-                        hc.delegatedThrown = pae.getException();
+                        hc.delegatedThrown = reportedException;
                     } else if (engine.conContext.closeReason != null) {
+                        // Update the reason in case there was a previous.
                         engine.conContext.closeReason =
-                                getTaskThrown(pae.getException());
+                                getTaskThrown(reportedException);
                     }
                 } catch (RuntimeException rte) {
                     // Get the handshake context again in case the
                     // handshaking has completed.
+
+                    // Report to both the TransportContext...
+                    if (engine.conContext.delegatedThrown == null) {
+                        engine.conContext.delegatedThrown = rte;
+                    }
+
+                    // ...and the HandshakeContext in case condition
+                    // wasn't fatal and the handshakeContext is still
+                    // around.
                     hc = engine.conContext.handshakeContext;
                     if (hc != null) {
                         hc.delegatedThrown = rte;
                     } else if (engine.conContext.closeReason != null) {
+                        // Update the reason in case there was a previous.
                         engine.conContext.closeReason = rte;
                     }
                 }
@@ -1000,13 +1059,6 @@
             @Override
             public Void run() throws Exception {
                 while (!context.delegatedActions.isEmpty()) {
-                    // Report back the task SSLException
-                    if (context.delegatedThrown != null) {
-                        Exception delegatedThrown = context.delegatedThrown;
-                        context.delegatedThrown = null;
-                        throw getTaskThrown(delegatedThrown);
-                    }
-
                     Map.Entry<Byte, ByteBuffer> me =
                             context.delegatedActions.poll();
                     if (me != null) {
--- a/src/java.base/share/classes/sun/security/ssl/SSLTransport.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/sun/security/ssl/SSLTransport.java	Fri Sep 07 15:46:39 2018 -0700
@@ -167,9 +167,10 @@
             if (plainText == null) {
                 plainText = Plaintext.PLAINTEXT_NULL;
             } else {
-                // File the destination buffers.
-                if (dsts != null && dstsLength > 0 &&
-                    plainText.contentType == ContentType.APPLICATION_DATA.id) {
+                // Fill the destination buffers.
+                if ((dsts != null) && (dstsLength > 0) &&
+                        (plainText.contentType ==
+                            ContentType.APPLICATION_DATA.id)) {
 
                     ByteBuffer fragment = plainText.fragment;
                     int remains = fragment.remaining();
--- a/src/java.base/share/classes/sun/security/ssl/ServerHello.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/sun/security/ssl/ServerHello.java	Fri Sep 07 15:46:39 2018 -0700
@@ -40,6 +40,7 @@
 import javax.crypto.spec.IvParameterSpec;
 import javax.net.ssl.SSLException;
 import javax.net.ssl.SSLHandshakeException;
+import javax.net.ssl.SSLProtocolException;
 import sun.security.ssl.CipherSuite.KeyExchange;
 import sun.security.ssl.ClientHello.ClientHelloMessage;
 import sun.security.ssl.SSLCipher.SSLReadCipher;
@@ -139,8 +140,11 @@
 
             this.serverRandom = new RandomCookie(m);
             this.sessionId = new SessionId(Record.getBytes8(m));
-            sessionId.checkLength(serverVersion.id);
-
+            try {
+                sessionId.checkLength(serverVersion.id);
+            } catch (SSLProtocolException ex) {
+                handshakeContext.conContext.fatal(Alert.ILLEGAL_PARAMETER, ex);
+            }
 
             int cipherSuiteId = Record.getInt16(m);
             this.cipherSuite = CipherSuite.valueOf(cipherSuiteId);
--- a/src/java.base/share/classes/sun/security/ssl/SignatureAlgorithmsExtension.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/sun/security/ssl/SignatureAlgorithmsExtension.java	Fri Sep 07 15:46:39 2018 -0700
@@ -362,16 +362,16 @@
                 // certificates and server key exchange), it MUST send the
                 // signature_algorithms extension, listing the algorithms it
                 // is willing to accept.
-                List<SignatureScheme> shemes = Arrays.asList(
+                List<SignatureScheme> schemes = Arrays.asList(
                         SignatureScheme.RSA_PKCS1_SHA1,
                         SignatureScheme.DSA_SHA1,
                         SignatureScheme.ECDSA_SHA1
                 );
 
-                shc.peerRequestedSignatureSchemes = shemes;
+                shc.peerRequestedSignatureSchemes = schemes;
                 if (shc.peerRequestedCertSignSchemes == null ||
-                    shc.peerRequestedCertSignSchemes.isEmpty()) {
-                        shc.peerRequestedCertSignSchemes = shemes;
+                        shc.peerRequestedCertSignSchemes.isEmpty()) {
+                    shc.peerRequestedCertSignSchemes = schemes;
                 }
 
                 // Use the default peer signature algorithms.
--- a/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java	Fri Sep 07 15:46:39 2018 -0700
@@ -403,8 +403,8 @@
 
         for (SignatureScheme ss : schemes) {
             if (ss.isAvailable &&
-            ss.handshakeSupportedProtocols.contains(version) &&
-            certScheme.keyAlgorithm.equalsIgnoreCase(ss.keyAlgorithm)) {
+                    ss.handshakeSupportedProtocols.contains(version) &&
+                    certScheme.keyAlgorithm.equalsIgnoreCase(ss.keyAlgorithm)) {
 
                 return ss;
             }
--- a/src/java.base/share/classes/sun/security/ssl/TransportContext.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/sun/security/ssl/TransportContext.java	Fri Sep 07 15:46:39 2018 -0700
@@ -63,6 +63,7 @@
     boolean                         isInputCloseNotified = false;
     boolean                         peerUserCanceled = false;
     Exception                       closeReason = null;
+    Exception                       delegatedThrown = null;
 
     // negotiated security parameters
     SSLSessionImpl                  conSession;
@@ -364,12 +365,12 @@
             }
         }
 
-        // terminal handshake context
+        // terminate the handshake context
         if (handshakeContext != null) {
             handshakeContext = null;
         }
 
-        // terminal the transport
+        // terminate the transport
         try {
             transport.shutdown();
         } catch (IOException ioe) {
--- a/src/java.base/share/classes/sun/security/ssl/X509Authentication.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/sun/security/ssl/X509Authentication.java	Fri Sep 07 15:46:39 2018 -0700
@@ -73,7 +73,7 @@
     }
 
     static X509Authentication valueOf(SignatureScheme signatureScheme) {
-        for (X509Authentication au: X509Authentication.values()) {
+        for (X509Authentication au : X509Authentication.values()) {
             if (au.keyType.equals(signatureScheme.keyAlgorithm)) {
                 return au;
             }
@@ -291,9 +291,9 @@
                         ((ECPublicKey)serverPublicKey).getParams();
                 NamedGroup namedGroup = NamedGroup.valueOf(params);
                 if ((namedGroup == null) ||
-                    (!SupportedGroups.isSupported(namedGroup)) ||
-                    ((shc.clientRequestedNamedGroups != null) &&
-                    !shc.clientRequestedNamedGroups.contains(namedGroup))) {
+                        (!SupportedGroups.isSupported(namedGroup)) ||
+                        ((shc.clientRequestedNamedGroups != null) &&
+                        !shc.clientRequestedNamedGroups.contains(namedGroup))) {
 
                     if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
                         SSLLogger.warning(
--- a/src/java.base/share/classes/sun/security/util/math/intpoly/IntegerPolynomial.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/classes/sun/security/util/math/intpoly/IntegerPolynomial.java	Fri Sep 07 15:46:39 2018 -0700
@@ -70,13 +70,28 @@
     protected final int bitsPerLimb;
     private final long[] posModLimbs;
 
-    // must work when a==r
+    /**
+     * Multiply an IntegerPolynomial representation (a) with a long (b) and
+     * store the result in an IntegerPolynomial representation (r). Requires
+     * that a.length == r.length == numLimbs. It is allowed for a and r to be
+     * the same array.
+     */
     protected abstract void multByInt(long[] a, long b, long[] r);
 
-    // must work when a==r
+    /**
+     * Multiply two IntegerPolynomial representations (a and b) and store the
+     * result in an IntegerPolynomial representation (r). Requires that
+     * a.length == b.length == r.length == numLimbs. It is allowed for a and r
+     * to be the same array.
+     */
     protected abstract void mult(long[] a, long[] b, long[] r);
 
-    // must work when a==r
+    /**
+     * Multiply an IntegerPolynomial representation (a) with itself and store
+     * the result in an IntegerPolynomialRepresentation (r). Requires that
+     * a.length == r.length == numLimbs. It is allowed for a and r
+     * to be the same array.
+     */
     protected abstract void square(long[] a, long[] r);
 
     IntegerPolynomial(int bitsPerLimb,
@@ -240,7 +255,9 @@
         carry(limbs, 0, limbs.length - 1);
     }
 
-    // carry out of the specified position and return the carry value
+    /**
+     * Carry out of the specified position and return the carry value.
+     */
     protected long carryOut(long[] limbs, int index) {
         long carry = carryValue(limbs[index]);
         limbs[index] -= (carry << bitsPerLimb);
@@ -261,9 +278,20 @@
         }
     }
 
+    /**
+     * Carry out of the last limb and reduce back in. This method will be
+     * called as part of the "finalReduce" operation that puts the
+     * representation into a fully-reduced form. It is representation-
+     * specific, because representations have different amounts of empty
+     * space in the high-order limb. Requires that limbs.length=numLimbs.
+     */
     protected abstract void finalCarryReduceLast(long[] limbs);
 
-    // Convert reduced limbs into a number between 0 and MODULUS-1
+    /**
+     * Convert reduced limbs into a number between 0 and MODULUS-1.
+     * Requires that limbs.length == numLimbs. This method only works if the
+     * modulus has at most three terms.
+     */
     protected void finalReduce(long[] limbs) {
 
         // This method works by doing several full carry/reduce operations.
@@ -313,8 +341,10 @@
 
     }
 
-    // v must be final reduced. I.e. all limbs in [0, bitsPerLimb)
-    // and value in [0, modulus)
+    /**
+     * Decode the value in v and store it in dst. Requires that v is final
+     * reduced. I.e. all limbs in [0, 2^bitsPerLimb) and value in [0, modulus).
+     */
     protected void decode(long[] v, byte[] dst, int offset, int length) {
 
         int nextLimbIndex = 0;
@@ -344,12 +374,25 @@
         }
     }
 
+    /**
+     * Add two IntegerPolynomial representations (a and b) and store the result
+     * in an IntegerPolynomialRepresentation (dst). Requires that
+     * a.length == b.length == dst.length. It is allowed for a and
+     * dst to be the same array.
+     */
     protected void addLimbs(long[] a, long[] b, long[] dst) {
         for (int i = 0; i < dst.length; i++) {
             dst[i] = a[i] + b[i];
         }
     }
 
+    /**
+     * Branch-free conditional swap of a and b. Requires that swap is 0 or 1,
+     * and that a.length == b.length. If swap==0, then the values of a and b
+     * will be unchanged. If swap==1, then the values of a and b will be
+     * swapped. The behavior is undefined if swap has any value other than
+     * 0 or 1.
+     */
     protected static void conditionalSwap(int swap, long[] a, long[] b) {
         int maskValue = 0 - swap;
         for (int i = 0; i < a.length; i++) {
@@ -359,6 +402,9 @@
         }
     }
 
+    /**
+     * Stores the reduced, little-endian value of limbs in result.
+     */
     protected void limbsToByteArray(long[] limbs, byte[] result) {
 
         long[] reducedLimbs = limbs.clone();
@@ -367,6 +413,11 @@
         decode(reducedLimbs, result, 0, result.length);
     }
 
+    /**
+     * Add the reduced number corresponding to limbs and other, and store
+     * the low-order bytes of the sum in result. Requires that
+     * limbs.length==other.length. The result array may have any length.
+     */
     protected void addLimbsModPowerTwo(long[] limbs, long[] other,
                                        byte[] result) {
 
Binary file src/java.base/share/lib/security/cacerts has changed
--- a/src/java.base/share/native/libjava/io_util.c	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/native/libjava/io_util.c	Fri Sep 07 15:46:39 2018 -0700
@@ -211,11 +211,7 @@
 
     n = getLastErrorString(buf, sizeof(buf));
     if (n > 0) {
-#ifdef WIN32
-        why = (*env)->NewStringUTF(env, buf);
-#else
         why = JNU_NewStringPlatform(env, buf);
-#endif
         CHECK_NULL(why);
     }
     x = JNU_NewObjectByName(env,
--- a/src/java.base/share/native/libjli/wildcard.c	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/share/native/libjli/wildcard.c	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -100,6 +100,14 @@
 #include <dirent.h>
 #endif /* Unix */
 
+#if defined(_AIX)
+  #define DIR DIR64
+  #define dirent dirent64
+  #define opendir opendir64
+  #define readdir readdir64
+  #define closedir closedir64
+#endif
+
 static int
 exists(const char* filename)
 {
--- a/src/java.base/solaris/native/libjvm_db/libjvm_db.c	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/solaris/native/libjvm_db/libjvm_db.c	Fri Sep 07 15:46:39 2018 -0700
@@ -85,7 +85,7 @@
   const char * typeName;           /* The type name containing the given field (example: "Klass") */
   const char * fieldName;          /* The field name within the type           (example: "_name") */
   uint64_t address;                /* Address of field; only used for static fields */
-                                   /* ("offset" can not be reused because of apparent SparcWorks compiler bug */
+                                   /* ("offset" can not be reused because of apparent solstudio compiler bug */
                                    /* in generation of initializer data) */
 } VMStructEntry;
 
--- a/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -58,6 +58,14 @@
 #include <procfs.h>
 #endif
 
+#if defined(_AIX)
+  #define DIR DIR64
+  #define dirent dirent64
+  #define opendir opendir64
+  #define readdir readdir64
+  #define closedir closedir64
+#endif
+
 /**
  * This file contains the implementation of the native ProcessHandleImpl
  * functions which are common to all Unix variants.
--- a/src/java.base/unix/native/libjava/TimeZone_md.c	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/unix/native/libjava/TimeZone_md.c	Fri Sep 07 15:46:39 2018 -0700
@@ -50,11 +50,6 @@
   } while((_result == -1) && (errno == EINTR)); \
 } while(0)
 
-#if defined(_ALLBSD_SOURCE)
-#define dirent64 dirent
-#define readdir64 readdir
-#endif
-
 #if !defined(__solaris__) || defined(__sparcv9) || defined(amd64)
 #define fileopen        fopen
 #define filegets        fgets
@@ -121,7 +116,7 @@
 {
     DIR *dirp = NULL;
     struct stat statbuf;
-    struct dirent64 *dp = NULL;
+    struct dirent *dp = NULL;
     char *pathname = NULL;
     int fd = -1;
     char *dbuf = NULL;
@@ -133,7 +128,7 @@
         return NULL;
     }
 
-    while ((dp = readdir64(dirp)) != NULL) {
+    while ((dp = readdir(dirp)) != NULL) {
         /*
          * Skip '.' and '..' (and possibly other .* files)
          */
--- a/src/java.base/unix/native/libjava/UnixFileSystem_md.c	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/unix/native/libjava/UnixFileSystem_md.c	Fri Sep 07 15:46:39 2018 -0700
@@ -55,8 +55,11 @@
     #define NAME_MAX MAXNAMLEN
   #endif
   #define DIR DIR64
+  #define dirent dirent64
   #define opendir opendir64
+  #define readdir readdir64
   #define closedir closedir64
+  #define stat stat64
 #endif
 
 #if defined(__solaris__) && !defined(NAME_MAX)
@@ -64,9 +67,6 @@
 #endif
 
 #if defined(_ALLBSD_SOURCE)
-  #define dirent64 dirent
-  #define readdir64 readdir
-  #define stat64 stat
   #ifndef MACOSX
     #define statvfs64 statvfs
   #endif
@@ -121,8 +121,8 @@
 static jboolean
 statMode(const char *path, int *mode)
 {
-    struct stat64 sb;
-    if (stat64(path, &sb) == 0) {
+    struct stat sb;
+    if (stat(path, &sb) == 0) {
         *mode = sb.st_mode;
         return JNI_TRUE;
     }
@@ -229,8 +229,8 @@
     jlong rv = 0;
 
     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
-        struct stat64 sb;
-        if (stat64(path, &sb) == 0) {
+        struct stat sb;
+        if (stat(path, &sb) == 0) {
 #if defined(_AIX)
             rv =  (jlong)sb.st_mtime * 1000;
             rv += (jlong)sb.st_mtime_n / 1000000;
@@ -254,8 +254,8 @@
     jlong rv = 0;
 
     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
-        struct stat64 sb;
-        if (stat64(path, &sb) == 0) {
+        struct stat sb;
+        if (stat(path, &sb) == 0) {
             rv = sb.st_size;
         }
     } END_PLATFORM_STRING(env, path);
@@ -311,7 +311,7 @@
                                  jobject file)
 {
     DIR *dir = NULL;
-    struct dirent64 *ptr;
+    struct dirent *ptr;
     int len, maxlen;
     jobjectArray rv, old;
     jclass str_class;
@@ -331,7 +331,7 @@
     if (rv == NULL) goto error;
 
     /* Scan the directory */
-    while ((ptr = readdir64(dir)) != NULL) {
+    while ((ptr = readdir(dir)) != NULL) {
         jstring name;
         if (!strcmp(ptr->d_name, ".") || !strcmp(ptr->d_name, ".."))
             continue;
@@ -408,9 +408,9 @@
     jboolean rv = JNI_FALSE;
 
     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
-        struct stat64 sb;
+        struct stat sb;
 
-        if (stat64(path, &sb) == 0) {
+        if (stat(path, &sb) == 0) {
             struct timeval tv[2];
 
             /* Preserve access time */
--- a/src/java.base/unix/native/libjava/childproc.c	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/unix/native/libjava/childproc.c	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -66,12 +66,12 @@
   /* AIX does not understand '/proc/self' - it requires the real process ID */
   #define FD_DIR aix_fd_dir
   #define DIR DIR64
+  #define dirent dirent64
   #define opendir opendir64
+  #define readdir readdir64
   #define closedir closedir64
 #elif defined(_ALLBSD_SOURCE)
   #define FD_DIR "/dev/fd"
-  #define dirent64 dirent
-  #define readdir64 readdir
 #else
   #define FD_DIR "/proc/self/fd"
 #endif
@@ -80,7 +80,7 @@
 closeDescriptors(void)
 {
     DIR *dp;
-    struct dirent64 *dirp;
+    struct dirent *dirp;
     int from_fd = FAIL_FILENO + 1;
 
     /* We're trying to close all file descriptors, but opendir() might
@@ -102,10 +102,7 @@
     if ((dp = opendir(FD_DIR)) == NULL)
         return 0;
 
-    /* We use readdir64 instead of readdir to work around Solaris bug
-     * 6395699: /proc/self/fd fails to report file descriptors >= 1024 on Solaris 9
-     */
-    while ((dirp = readdir64(dp)) != NULL) {
+    while ((dirp = readdir(dp)) != NULL) {
         int fd;
         if (isAsciiDigit(dirp->d_name[0]) &&
             (fd = strtol(dirp->d_name, NULL, 10)) >= from_fd + 2)
--- a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c	Fri Sep 07 15:46:39 2018 -0700
@@ -71,7 +71,6 @@
 #define open64 open
 #define fstat64 fstat
 #define lstat64 lstat
-#define dirent64 dirent
 #define readdir64 readdir
 #endif
 
@@ -83,7 +82,9 @@
 
 #if defined(_AIX)
   #define DIR DIR64
+  #define dirent dirent64
   #define opendir opendir64
+  #define readdir readdir64
   #define closedir closedir64
 #endif
 
@@ -729,10 +730,10 @@
 JNIEXPORT jbyteArray JNICALL
 Java_sun_nio_fs_UnixNativeDispatcher_readdir(JNIEnv* env, jclass this, jlong value) {
     DIR* dirp = jlong_to_ptr(value);
-    struct dirent64* ptr;
+    struct dirent* ptr;
 
     errno = 0;
-    ptr = readdir64(dirp);
+    ptr = readdir(dirp);
     if (ptr == NULL) {
         if (errno != 0) {
             throwUnixException(env, errno);
--- a/src/java.base/windows/native/libnet/Inet4AddressImpl.c	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/windows/native/libnet/Inet4AddressImpl.c	Fri Sep 07 15:46:39 2018 -0700
@@ -326,7 +326,7 @@
     ReplyBuffer = (VOID *)malloc(ReplySize);
     if (ReplyBuffer == NULL) {
         IcmpCloseHandle(hIcmpFile);
-        NET_ThrowNew(env, WSAGetLastError(), "Unable to allocate memory");
+        NET_ThrowNew(env, -1, "Unable to allocate memory");
         return JNI_FALSE;
     }
 
--- a/src/java.base/windows/native/libnet/Inet6AddressImpl.c	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/windows/native/libnet/Inet6AddressImpl.c	Fri Sep 07 15:46:39 2018 -0700
@@ -396,7 +396,7 @@
     ReplyBuffer = (VOID *)malloc(ReplySize);
     if (ReplyBuffer == NULL) {
         IcmpCloseHandle(hIcmpFile);
-        NET_ThrowNew(env, WSAGetLastError(), "Unable to allocate memory");
+        NET_ThrowNew(env, -1, "Unable to allocate memory");
         return JNI_FALSE;
     }
 
--- a/src/java.base/windows/native/libnet/SocketInputStream.c	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.base/windows/native/libnet/SocketInputStream.c	Fri Sep 07 15:46:39 2018 -0700
@@ -122,12 +122,13 @@
         (*env)->SetByteArrayRegion(env, data, off, nread, (jbyte *)bufP);
     } else {
         if (nread < 0) {
+            int err = WSAGetLastError();
             // Check if the socket has been closed since we last checked.
             // This could be a reason for recv failing.
             if ((*env)->GetIntField(env, fdObj, IO_fd_fdID) == -1) {
                 JNU_ThrowByName(env, "java/net/SocketException", "Socket closed");
             } else {
-                switch (WSAGetLastError()) {
+                switch (err) {
                     case WSAEINTR:
                         JNU_ThrowByName(env, "java/net/SocketException",
                             "socket closed");
--- a/src/java.desktop/share/native/libmlib_image/mlib_ImageLookUp_Bit.c	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.desktop/share/native/libmlib_image/mlib_ImageLookUp_Bit.c	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -259,18 +259,18 @@
       }
 
 #ifdef _LITTLE_ENDIAN
-      emask = (mlib_u32)((mlib_s32)(-1)) >> ((4 - (size - i)) * 8);
+      emask = (~(mlib_u32)0) >> ((4 - (size - i)) * 8);
 #else
-      emask = (mlib_s32)(-1) << ((4 - (size - i)) * 8);
+      emask = (~(mlib_u32)0) << ((4 - (size - i)) * 8);
 #endif /* _LITTLE_ENDIAN */
       ((mlib_u32*)da)[0] = (val1 & emask) | (((mlib_u32*)da)[0] &~ emask);
 
 #else /* _NO_LONGLONG */
 
 #ifdef _LITTLE_ENDIAN
-      mlib_u64 emask = (mlib_u64)((mlib_s64)(-1)) >> ((8 - (size - i)) * 8);
+      mlib_u64 emask = (~(mlib_u64)0) >> ((8 - (size - i)) * 8);
 #else
-      mlib_u64 emask = (mlib_s64)(-1) << ((8 - (size - i)) * 8);
+      mlib_u64 emask = (~(mlib_u64)0) << ((8 - (size - i)) * 8);
 #endif /* _LITTLE_ENDIAN */
 
       ((mlib_u64*)da)[0] = (((mlib_u64*)dd_array)[sa[0]] & emask) | (((mlib_u64*)da)[0] &~ emask);
@@ -395,9 +395,9 @@
       }
 
 #ifdef _LITTLE_ENDIAN
-      emask = (mlib_u32)((mlib_s32)(-1)) >> ((4 - (size - i)) * 8);
+      emask = (~(mlib_u32)0) >> ((4 - (size - i)) * 8);
 #else
-      emask = (mlib_s32)(-1) << ((4 - (size - i)) * 8);
+      emask = (~(mlib_u32)0) << ((4 - (size - i)) * 8);
 #endif /* _LITTLE_ENDIAN */
       ((mlib_u32*)da)[0] = (dd1 & emask) | (((mlib_u32*)da)[0] &~ emask);
 
@@ -413,9 +413,9 @@
       }
 
 #ifdef _LITTLE_ENDIAN
-      emask = (mlib_u64)((mlib_s64)(-1)) >> ((8 - (size - i)) * 8);
+      emask = (~(mlib_u64)0) >> ((8 - (size - i)) * 8);
 #else
-      emask = (mlib_s64)(-1) << ((8 - (size - i)) * 8);
+      emask = (~(mlib_u64)0) << ((8 - (size - i)) * 8);
 #endif /* _LITTLE_ENDIAN */
       ((mlib_u64*)da)[0] = (dd & emask) | (((mlib_u64*)da)[0] &~ emask);
 
@@ -565,9 +565,9 @@
       }
 
 #ifdef _LITTLE_ENDIAN
-      emask = (mlib_u32)((mlib_s32)(-1)) >> ((4 - (size - i)) * 8);
+      emask = (~(mlib_u32)0) >> ((4 - (size - i)) * 8);
 #else
-      emask = (mlib_s32)(-1) << ((4 - (size - i)) * 8);
+      emask = (~(mlib_u32)0) << ((4 - (size - i)) * 8);
 #endif /* _LITTLE_ENDIAN */
       da[0] = (dd & emask) | (da[0] &~ emask);
     }
--- a/src/java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -312,7 +312,8 @@
 
         if ((refEx != null) &&
             (refEx.hasMoreReferrals() ||
-             refEx.hasMoreReferralExceptions())) {
+             refEx.hasMoreReferralExceptions()
+                && !(errEx instanceof LimitExceededException))) {
 
             if (homeCtx.handleReferrals == LdapClient.LDAP_REF_THROW) {
                 throw (NamingException)(refEx.fillInStackTrace());
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Fri Sep 07 15:46:39 2018 -0700
@@ -5022,6 +5022,10 @@
             this.types = types;
         }
 
+        protected void reportIllegalSignature(Type t) {
+            throw new InvalidSignatureException(t);
+        }
+
         /**
          * Assemble signature of given type in string buffer.
          */
@@ -5056,7 +5060,7 @@
                     break;
                 case CLASS:
                     if (type.isCompound()) {
-                        throw new InvalidSignatureException(type);
+                        reportIllegalSignature(type);
                     }
                     append('L');
                     assembleClassSig(type);
@@ -5101,7 +5105,7 @@
                 }
                 case TYPEVAR:
                     if (((TypeVar)type).isCaptured()) {
-                        throw new InvalidSignatureException(type);
+                        reportIllegalSignature(type);
                     }
                     append('T');
                     append(type.tsym.name);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Fri Sep 07 15:46:39 2018 -0700
@@ -25,6 +25,9 @@
 
 package com.sun.tools.javac.comp;
 
+import com.sun.tools.javac.code.Types.SignatureGenerator.InvalidSignatureException;
+import com.sun.tools.javac.resources.CompilerProperties.Errors;
+import com.sun.tools.javac.resources.CompilerProperties.Fragments;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind;
@@ -2031,7 +2034,7 @@
                         owner.type != null ||
                         directlyEnclosingLambda() != null);
                 if (owner.type != null) {
-                    buf.append(typeSig(owner.type));
+                    buf.append(typeSig(owner.type, true));
                     buf.append(":");
                 }
 
@@ -2047,7 +2050,7 @@
                 //add captured locals info: type, name, order
                 for (Symbol fv : getSymbolMap(CAPTURED_VAR).keySet()) {
                     if (fv != self) {
-                        buf.append(typeSig(fv.type));
+                        buf.append(typeSig(fv.type, true));
                         buf.append(" ");
                         buf.append(fv.flatName());
                         buf.append(",");
@@ -2433,15 +2436,31 @@
      */
 
     private String typeSig(Type type) {
-        L2MSignatureGenerator sg = new L2MSignatureGenerator();
-        sg.assembleSig(type);
-        return sg.toString();
+        return typeSig(type, false);
+    }
+
+    private String typeSig(Type type, boolean allowIllegalSignature) {
+        try {
+            L2MSignatureGenerator sg = new L2MSignatureGenerator(allowIllegalSignature);
+            sg.assembleSig(type);
+            return sg.toString();
+        } catch (InvalidSignatureException ex) {
+            Symbol c = attrEnv.enclClass.sym;
+            log.error(Errors.CannotGenerateClass(c, Fragments.IllegalSignature(c, ex.type())));
+            return "<ERRONEOUS>";
+        }
     }
 
     private String classSig(Type type) {
-        L2MSignatureGenerator sg = new L2MSignatureGenerator();
-        sg.assembleClassSig(type);
-        return sg.toString();
+        try {
+            L2MSignatureGenerator sg = new L2MSignatureGenerator(false);
+            sg.assembleClassSig(type);
+            return sg.toString();
+        } catch (InvalidSignatureException ex) {
+            Symbol c = attrEnv.enclClass.sym;
+            log.error(Errors.CannotGenerateClass(c, Fragments.IllegalSignature(c, ex.type())));
+            return "<ERRONEOUS>";
+        }
     }
 
     /**
@@ -2454,8 +2473,22 @@
          */
         StringBuilder sb = new StringBuilder();
 
-        L2MSignatureGenerator() {
+        /**
+         * Are signatures incompatible with JVM spec allowed?
+         * Used by {@link LambdaTranslationContext#serializedLambdaDisambiguation()}.
+         */
+        boolean allowIllegalSignatures;
+
+        L2MSignatureGenerator(boolean allowIllegalSignatures) {
             super(types);
+            this.allowIllegalSignatures = allowIllegalSignatures;
+        }
+
+        @Override
+        protected void reportIllegalSignature(Type t) {
+            if (!allowIllegalSignatures) {
+                super.reportIllegalSignature(t);
+            }
         }
 
         @Override
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Fri Sep 07 15:46:39 2018 -0700
@@ -97,11 +97,8 @@
 import static javax.tools.StandardLocation.PLATFORM_CLASS_PATH;
 
 import static com.sun.tools.javac.main.Option.BOOT_CLASS_PATH;
-import static com.sun.tools.javac.main.Option.DJAVA_ENDORSED_DIRS;
-import static com.sun.tools.javac.main.Option.DJAVA_EXT_DIRS;
 import static com.sun.tools.javac.main.Option.ENDORSEDDIRS;
 import static com.sun.tools.javac.main.Option.EXTDIRS;
-import static com.sun.tools.javac.main.Option.XBOOTCLASSPATH;
 import static com.sun.tools.javac.main.Option.XBOOTCLASSPATH_APPEND;
 import static com.sun.tools.javac.main.Option.XBOOTCLASSPATH_PREPEND;
 
@@ -1533,7 +1530,62 @@
             return true;
         }
 
+        /**
+         * Initializes the module table, based on a string containing the composition
+         * of a series of command-line options.
+         * At most one pattern to initialize a series of modules can be given.
+         * At most one module-specific search path per module can be given.
+         *
+         * @param value a series of values, separated by NUL.
+         */
         void init(String value) {
+            Pattern moduleSpecificForm = Pattern.compile("([\\p{Alnum}$_.]+)=(.*)");
+            List<String> pathsForModules = new ArrayList<>();
+            String modulePattern = null;
+            for (String v : value.split("\0")) {
+                if (moduleSpecificForm.matcher(v).matches()) {
+                    pathsForModules.add(v);
+                } else {
+                    modulePattern = v;
+                }
+            }
+            // set the general module pattern first, if given
+            if (modulePattern != null) {
+                initFromPattern(modulePattern);
+            }
+            pathsForModules.forEach(this::initForModule);
+        }
+
+        /**
+         * Initializes a module-specific override, using {@code setPathsForModule}.
+         *
+         * @param value a string of the form: module-name=search-path
+         */
+        void initForModule(String value) {
+            int eq = value.indexOf('=');
+            String name = value.substring(0, eq);
+            List<Path> paths = new ArrayList<>();
+            for (String v : value.substring(eq + 1).split(File.pathSeparator)) {
+                try {
+                    paths.add(Paths.get(v));
+                } catch (InvalidPathException e) {
+                    throw new IllegalArgumentException("invalid path: " + v, e);
+                }
+            }
+            try {
+                setPathsForModule(name, paths);
+            } catch (IOException e) {
+                e.printStackTrace();
+                throw new IllegalArgumentException("cannot set path for module " + name, e);
+            }
+        }
+
+        /**
+         * Initializes the module table based on a custom option syntax.
+         *
+         * @param value the value such as may be given to a --module-source-path option
+         */
+        void initFromPattern(String value) {
             Collection<String> segments = new ArrayList<>();
             for (String s: value.split(File.pathSeparator)) {
                 expandBraces(s, segments);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1002,15 +1002,17 @@
 
     public void visitVarDef(JCVariableDecl tree) {
         VarSymbol v = tree.sym;
-        code.newLocal(v);
         if (tree.init != null) {
             checkStringConstant(tree.init.pos(), v.getConstValue());
             if (v.getConstValue() == null || varDebugInfo) {
                 Assert.check(code.isStatementStart());
+                code.newLocal(v);
                 genExpr(tree.init, v.erasure(types)).load();
                 items.makeLocalItem(v).store();
                 Assert.check(code.isStatementStart());
             }
+        } else {
+            code.newLocal(v);
         }
         checkDimension(tree.pos(), v.type);
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java	Fri Sep 07 15:46:39 2018 -0700
@@ -27,8 +27,11 @@
 
 import java.io.BufferedInputStream;
 import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
@@ -37,20 +40,28 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.net.MalformedURLException;
 import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
 import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.InvalidPathException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.MissingResourceException;
+import java.util.NoSuchElementException;
 import java.util.ResourceBundle;
 
 import javax.lang.model.SourceVersion;
@@ -59,7 +70,6 @@
 import javax.tools.FileObject;
 import javax.tools.ForwardingJavaFileManager;
 import javax.tools.JavaFileManager;
-import javax.tools.JavaFileManager.Location;
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
 import javax.tools.StandardJavaFileManager;
@@ -531,6 +541,10 @@
      * {@code findClass} to find classes in the in-memory cache.
      */
     private static class MemoryClassLoader extends ClassLoader {
+        /**
+         * The map of classes known to this class loader, indexed by
+         * {@link ClassLoader#name binary name}.
+         */
         private final Map<String, byte[]> map;
 
         MemoryClassLoader(Map<String, byte[]> map, ClassLoader parent) {
@@ -546,5 +560,117 @@
             }
             return defineClass(name, bytes, 0, bytes.length);
         }
+
+        @Override
+        public URL findResource(String name) {
+            String binaryName = toBinaryName(name);
+            if (binaryName == null || map.get(binaryName) == null) {
+                return null;
+            }
+
+            URLStreamHandler handler = this.handler;
+            if (handler == null) {
+                this.handler = handler = new MemoryURLStreamHandler();
+            }
+
+            try {
+                return new URL(PROTOCOL, null, -1, name, handler);
+            } catch (MalformedURLException e) {
+                return null;
+            }
+        }
+
+        @Override
+        public Enumeration<URL> findResources(String name) {
+            return new Enumeration<URL>() {
+                private URL next = findResource(name);
+
+                @Override
+                public boolean hasMoreElements() {
+                    return (next != null);
+                }
+
+                @Override
+                public URL nextElement() {
+                    if (next == null) {
+                        throw new NoSuchElementException();
+                    }
+                    URL u = next;
+                    next = null;
+                    return u;
+                }
+            };
+        }
+
+        /**
+         * Converts a "resource name" (as used in the getResource* methods)
+         * to a binary name if the name identifies a class, or null otherwise.
+         * @param name the resource name
+         * @return the binary name
+         */
+        private String toBinaryName(String name) {
+            if (!name.endsWith(".class")) {
+                return null;
+            }
+            return name.substring(0, name.length() - DOT_CLASS_LENGTH).replace('/', '.');
+        }
+
+        private static final int DOT_CLASS_LENGTH = ".class".length();
+        private final String PROTOCOL = "sourcelauncher-" + getClass().getSimpleName() + hashCode();
+        private URLStreamHandler handler;
+
+        /**
+         * A URLStreamHandler for use with URLs returned by MemoryClassLoader.getResource.
+         */
+        private class MemoryURLStreamHandler extends URLStreamHandler {
+            @Override
+            public URLConnection openConnection(URL u) {
+                if (!u.getProtocol().equalsIgnoreCase(PROTOCOL)) {
+                    throw new IllegalArgumentException(u.toString());
+                }
+                return new MemoryURLConnection(u, map.get(toBinaryName(u.getPath())));
+            }
+
+        }
+
+        /**
+         * A URLConnection for use with URLs returned by MemoryClassLoader.getResource.
+         */
+        private static class MemoryURLConnection extends URLConnection {
+            private byte[] bytes;
+            private InputStream in;
+
+            MemoryURLConnection(URL u, byte[] bytes) {
+                super(u);
+                this.bytes = bytes;
+            }
+
+            @Override
+            public void connect() throws IOException {
+                if (!connected) {
+                    if (bytes == null) {
+                        throw new FileNotFoundException(getURL().getPath());
+                    }
+                    in = new ByteArrayInputStream(bytes);
+                    connected = true;
+                }
+            }
+
+            @Override
+            public InputStream getInputStream() throws IOException {
+                connect();
+                return in;
+            }
+
+            @Override
+            public long getContentLengthLong() {
+                return bytes.length;
+            }
+
+            @Override
+            public String getContentType() {
+                return "application/octet-stream";
+            }
+        }
     }
 }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Fri Sep 07 15:46:39 2018 -0700
@@ -182,7 +182,48 @@
 
     SOURCE_PATH("--source-path -sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER),
 
-    MODULE_SOURCE_PATH("--module-source-path", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER),
+    MODULE_SOURCE_PATH("--module-source-path", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER) {
+        // The deferred filemanager diagnostics mechanism assumes a single value per option,
+        // but --module-source-path-module can be used multiple times, once in the old form
+        // and once per module in the new form.  Therefore we compose an overall value for the
+        // option containing the individual values given on the command line, separated by NULL.
+        // The standard file manager code knows to split apart the NULL-separated components.
+        @Override
+        public void process(OptionHelper helper, String option, String arg) throws InvalidValueException {
+            if (arg.isEmpty()) {
+                throw helper.newInvalidValueException(Errors.NoValueForOption(option));
+            }
+            Pattern moduleSpecificForm = getPattern();
+            String prev = helper.get(MODULE_SOURCE_PATH);
+            if (prev == null) {
+                super.process(helper, option, arg);
+            } else  if (moduleSpecificForm.matcher(arg).matches()) {
+                String argModule = arg.substring(0, arg.indexOf('='));
+                boolean isRepeated = Arrays.stream(prev.split("\0"))
+                        .filter(s -> moduleSpecificForm.matcher(s).matches())
+                        .map(s -> s.substring(0, s.indexOf('=')))
+                        .anyMatch(s -> s.equals(argModule));
+                if (isRepeated) {
+                    throw helper.newInvalidValueException(Errors.RepeatedValueForModuleSourcePath(argModule));
+                } else {
+                    super.process(helper, option, prev + '\0' + arg);
+                }
+            } else {
+                boolean isPresent = Arrays.stream(prev.split("\0"))
+                        .anyMatch(s -> !moduleSpecificForm.matcher(s).matches());
+                if (isPresent) {
+                    throw helper.newInvalidValueException(Errors.MultipleValuesForModuleSourcePath);
+                } else {
+                    super.process(helper, option, prev + '\0' + arg);
+                }
+            }
+        }
+
+        @Override
+        public Pattern getPattern() {
+            return Pattern.compile("([\\p{Alnum}$_.]+)=(.*)");
+        }
+    },
 
     MODULE_PATH("--module-path -p", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER),
 
@@ -194,7 +235,7 @@
         // The deferred filemanager diagnostics mechanism assumes a single value per option,
         // but --patch-module can be used multiple times, once per module. Therefore we compose
         // a value for the option containing the last value specified for each module, and separate
-        // the the module=path pairs by an invalid path character, NULL.
+        // the module=path pairs by an invalid path character, NULL.
         // The standard file manager code knows to split apart the NULL-separated components.
         @Override
         public void process(OptionHelper helper, String option, String arg) throws InvalidValueException {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Sep 07 15:46:39 2018 -0700
@@ -3417,7 +3417,14 @@
 
 # 0: string
 compiler.err.repeated.value.for.patch.module=\
-    --patch-module specified more than once for {0}
+    --patch-module specified more than once for module {0}
+
+# 0: string
+compiler.err.repeated.value.for.module.source.path=\
+    --module-source-path specified more than once for module {0}
+
+compiler.err.multiple.values.for.module.source.path=\
+    --module-source-path specified more than once with a pattern argument
 
 # 0: string
 compiler.err.unmatched.quote=\
--- a/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHKeyAgreement.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHKeyAgreement.java	Fri Sep 07 15:46:39 2018 -0700
@@ -186,7 +186,7 @@
             throw new IllegalStateException("Not initialized correctly");
         }
         int secretLen = this.secret.length;
-        if (offset + secretLen > sharedSecret.length) {
+        if (secretLen > sharedSecret.length - offset) {
             throw new ShortBufferException("Need " + secretLen
                 + " bytes, only " + (sharedSecret.length - offset)
                 + " available");
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java	Fri Sep 07 15:46:39 2018 -0700
@@ -197,11 +197,11 @@
     // pattern of, for example, a double and the vtbl is vanishingly
     // small.)
     //    1. The first word of the object (should handle MSVC++ as
-    //    well as the SparcWorks compilers with compatibility set to
+    //    well as the solstudio compilers with compatibility set to
     //    v5.0 or greater)
     //    2. and 3. The last two Address-aligned words of the part of
     //    the object defined by its topmost polymorphic superclass.
-    //    This should handle the SparcWorks compilers, v4.2 or
+    //    This should handle the solstudio compilers, v4.2 or
     //    earlier, as well as any other compilers which place the vptr
     //    at the end of the user-defined fields of the first base
     //    class with virtual functions.
--- a/src/jdk.internal.ed/share/classes/jdk/internal/editor/external/ExternalEditor.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/jdk.internal.ed/share/classes/jdk/internal/editor/external/ExternalEditor.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,6 +40,7 @@
 import java.util.Scanner;
 import java.util.function.Consumer;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
 import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE;
 import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
@@ -188,8 +189,8 @@
     }
 
     private void saveFile() {
-        try {
-            saveHandler.accept(Files.lines(tmpfile).collect(Collectors.joining("\n", "", "\n")));
+        try (Stream<String> lines = Files.lines(tmpfile)) {
+            saveHandler.accept(lines.collect(Collectors.joining("\n", "", "\n")));
         } catch (IOException ex) {
             errorHandler.accept("Failure in read edit file: " + ex.getMessage());
         }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js	Fri Sep 07 15:46:39 2018 -0700
@@ -32,11 +32,16 @@
 var highlight = "<span class=\"resultHighlight\">$&</span>";
 var camelCaseRegexp = "";
 var secondaryMatcher = "";
+function escapeHtml(str) {
+    return str.replace(/</g, "&lt;").replace(/>/g, "&gt;");
+}
 function getHighlightedText(item) {
-    var ccMatcher = new RegExp(camelCaseRegexp);
-    var label = item.replace(ccMatcher, highlight);
-    if (label === item) {
-        label = item.replace(secondaryMatcher, highlight);
+    var ccMatcher = new RegExp(escapeHtml(camelCaseRegexp));
+    var escapedItem = escapeHtml(item);
+    var label = escapedItem.replace(ccMatcher, highlight);
+    if (label === escapedItem) {
+        var secMatcher = new RegExp(escapeHtml(secondaryMatcher.source), "i");
+        label = escapedItem.replace(secMatcher, highlight);
     }
     return label;
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css	Fri Sep 07 15:46:39 2018 -0700
@@ -447,28 +447,28 @@
     margin:0px;
     white-space:pre;
 }
+.constantsSummary caption a:link, .constantsSummary caption a:visited,
+.useSummary caption a:link, .useSummary caption a:visited {
+    color:#1f389c;
+}
 .overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link,
-.constantsSummary caption a:link, .deprecatedSummary caption a:link,
+.deprecatedSummary caption a:link,
 .requiresSummary caption a:link, .packagesSummary caption a:link, .providesSummary caption a:link,
 .usesSummary caption a:link,
 .overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover,
-.constantsSummary caption a:hover, .deprecatedSummary caption a:hover,
+.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover,
 .requiresSummary caption a:hover, .packagesSummary caption a:hover, .providesSummary caption a:hover,
 .usesSummary caption a:hover,
 .overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active,
-.constantsSummary caption a:active, .deprecatedSummary caption a:active,
+.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active,
 .requiresSummary caption a:active, .packagesSummary caption a:active, .providesSummary caption a:active,
 .usesSummary caption a:active,
 .overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited,
-.constantsSummary caption a:visited, .deprecatedSummary caption a:visited,
+.deprecatedSummary caption a:visited,
 .requiresSummary caption a:visited, .packagesSummary caption a:visited, .providesSummary caption a:visited,
 .usesSummary caption a:visited {
     color:#FFFFFF;
 }
-.useSummary caption a:link, .useSummary caption a:hover, .useSummary caption a:active,
-.useSummary caption a:visited {
-    color:#1f389c;
-}
 .overviewSummary caption span, .memberSummary caption span, .typeSummary caption span,
 .useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span,
 .requiresSummary caption span, .packagesSummary caption span, .providesSummary caption span,
--- a/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_es_VE.properties	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_es_VE.properties	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 # 
-# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -37,4 +37,4 @@
 
 VEB=Bs
 VEF=Bs.F.
-
+VES=Bs.S.
--- a/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c	Fri Sep 07 15:46:39 2018 -0700
@@ -74,9 +74,12 @@
 
 #endif /* _ALLBSD_SOURCE */
 
-#if defined(_ALLBSD_SOURCE)
-  #define dirent64 dirent
-  #define readdir64 readdir
+#if defined(_AIX)
+  #define DIR DIR64
+  #define dirent dirent64
+  #define opendir opendir64
+  #define readdir readdir64
+  #define closedir closedir64
 #endif
 
 // true = get available swap in bytes
@@ -423,7 +426,7 @@
     return (100);
 #else /* solaris/linux */
     DIR *dirp;
-    struct dirent64* dentp;
+    struct dirent* dentp;
     jlong fds = 0;
 
 #if defined(_AIX)
@@ -443,7 +446,7 @@
 
     // iterate through directory entries, skipping '.' and '..'
     // each entry represents an open file descriptor.
-    while ((dentp = readdir64(dirp)) != NULL) {
+    while ((dentp = readdir(dirp)) != NULL) {
         if (isdigit(dentp->d_name[0])) {
             fds++;
         }
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java	Fri Sep 07 15:46:39 2018 -0700
@@ -317,7 +317,7 @@
                 if (inode == null)
                     return null;
                 e = new Entry(inode.name, inode.isdir);  // pseudo directory
-                e.method = METHOD_STORED;         // STORED for dir
+                e.method = METHOD_STORED;                // STORED for dir
                 e.mtime = e.atime = e.ctime = zfsDefaultTimeStamp;
             }
         } finally {
@@ -1087,9 +1087,8 @@
             if (pos + CENHDR + nlen > limit) {
                 zerror("invalid CEN header (bad header size)");
             }
-            IndexNode inode = new IndexNode(cen, pos + CENHDR, nlen, pos);
+            IndexNode inode = new IndexNode(cen, nlen, pos);
             inodes.put(inode, inode);
-
             // skip ext and comment
             pos += (CENHDR + nlen + elen + clen);
         }
@@ -1173,9 +1172,15 @@
                 size = 16;
         }
         // read loc, use the original loc.elen/nlen
-        if (readFullyAt(buf, 0, LOCHDR , locoff) != LOCHDR)
+        //
+        // an extra byte after loc is read, which should be the first byte of the
+        // 'name' field of the loc. if this byte is '/', which means the original
+        // entry has an absolute path in original zip/jar file, the e.writeLOC()
+        // is used to output the loc, in which the leading "/" will be removed
+        if (readFullyAt(buf, 0, LOCHDR + 1 , locoff) != LOCHDR + 1)
             throw new ZipException("loc: reading failed");
-        if (updateHeader) {
+
+        if (updateHeader || LOCNAM(buf) > 0 && buf[LOCHDR] == '/') {
             locoff += LOCHDR + LOCNAM(buf) + LOCEXT(buf);  // skip header
             size += e.csize;
             written = e.writeLOC(os) + size;
@@ -1275,6 +1280,10 @@
                     if (inode.pos == -1) {
                         continue;               // pseudo directory node
                     }
+                    if (inode.name.length == 1 && inode.name[0] == '/') {
+                        continue;               // no root '/' directory even it
+                                                // exits in original zip/jar file.
+                    }
                     e = Entry.readCEN(this, inode);
                     try {
                         written += copyLOCEntry(e, false, os, written, buf);
@@ -1796,15 +1805,20 @@
             this.pos = pos;
         }
 
-        // constructor for cenInit()
-        IndexNode(byte[] cen, int noff, int nlen, int pos) {
+        // constructor for cenInit() (1) remove tailing '/' (2) pad leading '/'
+        IndexNode(byte[] cen, int nlen, int pos) {
+            int noff = pos + CENHDR;
             if (cen[noff + nlen - 1] == '/') {
                 isdir = true;
                 nlen--;
             }
-            name = new byte[nlen + 1];
-            System.arraycopy(cen, pos + CENHDR, name, 1, nlen);
-            name[0] = '/';
+            if (nlen > 0 && cen[noff] == '/') {
+                name = Arrays.copyOfRange(cen, noff, noff + nlen);
+            } else {
+                name = new byte[nlen + 1];
+                System.arraycopy(cen, noff, name, 1, nlen);
+                name[0] = '/';
+            }
             name(name);
             this.pos = pos;
         }
@@ -2505,7 +2519,12 @@
     private void buildNodeTree() throws IOException {
         beginWrite();
         try {
-            IndexNode root = new IndexNode(ROOTPATH, true);
+            IndexNode root = inodes.get(LOOKUPKEY.as(ROOTPATH));
+            if (root == null) {
+                root = new IndexNode(ROOTPATH, true);
+            } else {
+                inodes.remove(root);
+            }
             IndexNode[] nodes = inodes.keySet().toArray(new IndexNode[0]);
             inodes.put(root, root);
             ParentLookup lookup = new ParentLookup();
--- a/test/hotspot/jtreg/ProblemList-graal.txt	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/ProblemList-graal.txt	Fri Sep 07 15:46:39 2018 -0700
@@ -147,11 +147,6 @@
 
 vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/TestDescription.java         8051349   generic-all
 
-vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/TestDescription.java         8209585   generic-all
-vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/TestDescription.java         8209585   generic-all
-vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/TestDescription.java         8209585   generic-all
-vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/TestDescription.java         8209585   generic-all
-
 runtime/appcds/cacheObject/ArchivedModuleCompareTest.java                          8209534   generic-all
 runtime/appcds/cacheObject/ArchivedModuleComboTest.java                            8209534   generic-all
 
--- a/test/hotspot/jtreg/ProblemList.txt	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/ProblemList.txt	Fri Sep 07 15:46:39 2018 -0700
@@ -84,7 +84,6 @@
 runtime/CompressedOops/UseCompressedOops.java 8079353 generic-all
 runtime/RedefineTests/RedefineRunningMethods.java 8208778 macosx-x64
 runtime/SharedArchiveFile/SASymbolTableTest.java 8193639 solaris-all
-runtime/MemberName/MemberNameLeak.java 8209844 generic-all
 
 #############################################################################
 
--- a/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java	Fri Sep 07 15:46:39 2018 -0700
@@ -65,7 +65,7 @@
         "-XX:MetaspaceSize=4m", "-XX:MaxMetaspaceSize=16m", "-XX:InitialCodeCacheSize=512k",
         "-XX:ReservedCodeCacheSize=4m", "-XX:ThreadStackSize=512", "-XX:VMThreadStackSize=512",
         "-XX:CompilerThreadStackSize=512", "-XX:ParallelGCThreads=1", "-XX:CICompilerCount=2",
-        "-Xcomp", "-XX:CICrashAt=1", "-XX:+DumpReplayDataOnError", "-XX:-TransmitErrorReport",
+        "-Xcomp", "-XX:CICrashAt=1", "-XX:+DumpReplayDataOnError",
         "-XX:+PreferInterpreterNativeStubs", "-XX:+PrintCompilation", REPLAY_FILE_OPTION};
     private static final String[] REPLAY_OPTIONS = new String[]{DISABLE_COREDUMP_ON_CRASH,
         "-XX:+ReplayCompiles", REPLAY_FILE_OPTION};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/floatingpoint/TestFloatSyncJNIArgs.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2015, 2016 SAP SE. All rights reserved.
+ * Copyright (c) 2018 Red Hat, Inc. 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
+ * @bug 8207838
+ * @summary Regression test for passing float args to a synchronized jni function.
+ *
+ *
+ * @run main/othervm/native compiler.floatingpoint.TestFloatSyncJNIArgs
+ */
+
+package compiler.floatingpoint;
+
+public class TestFloatSyncJNIArgs {
+    static {
+        try {
+            System.loadLibrary("TestFloatSyncJNIArgs");
+        } catch (UnsatisfiedLinkError e) {
+            System.out.println("could not load native lib: " + e);
+        }
+    }
+
+    private static final int numberOfThreads = 8;
+
+    static volatile Error testFailed = null;
+
+    public synchronized static native float combine15floats(
+        float f1, float f2, float f3, float f4,
+        float f5, float f6, float f7, float f8,
+        float f9, float f10, float f11, float f12,
+        float f13, float f14, float f15);
+
+    public synchronized static native double combine15doubles(
+        double d1, double d2, double d3, double d4,
+        double d5, double d6, double d7, double d8,
+        double d9, double d10, double d11, double d12,
+        double d13, double d14, double d15);
+
+    static void test() throws Exception {
+        Thread[] threads = new Thread[numberOfThreads];
+
+        for (int i = 0; i < numberOfThreads; i++) {
+            threads[i] = new Thread(() -> {
+                for (int j = 0; j < 10000; j++) {
+                    float f = combine15floats(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f,
+                                              9, 10, 11, 12, 13, 14, 15);
+                    if (f != 81720.0f) {
+                        testFailed = new Error("jni function didn't combine 15 float args properly: " + f);
+                        throw testFailed;
+                    }
+                }
+            });
+        }
+        for (int i = 0; i < numberOfThreads; i++) {
+            threads[i].start();
+        }
+        for (int i = 0; i < numberOfThreads; i++) {
+            threads[i].join();
+        }
+        if (testFailed != null) {
+            throw testFailed;
+        }
+
+        for (int i = 0; i < numberOfThreads; i++) {
+            threads[i] = new Thread(() -> {
+                for (int j = 0; j < 10000; j++) {
+                    double d = combine15doubles(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
+                                                9, 10, 11, 12, 13, 14, 15);
+                    if (d != 81720.0) {
+                        testFailed = new Error("jni function didn't combine 15 double args properly: " + d);
+                        throw testFailed;
+                    }
+                }
+            });
+        }
+        for (int i = 0; i < numberOfThreads; i++) {
+            threads[i].start();
+        }
+        for (int i = 0; i < numberOfThreads; i++) {
+            threads[i].join();
+        }
+        if (testFailed != null) {
+            throw testFailed;
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        for (int i = 0; i < 200; ++i) {
+            test();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/floatingpoint/libTestFloatSyncJNIArgs.c	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2018 Red Hat, Inc. 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>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Fletcher checksum. This is a nonlinear function which detects both */
+/* missing or otherwise incorrect arguments and arguments in the wrong */
+/* order. */
+static jfloat fcombine(jfloat f[], int len) {
+  int i;
+  jfloat sum = 0, sum_of_sums = 0;
+  for (i = 0; i < len; i++) {
+    sum += f[i];
+    sum_of_sums += sum;
+  }
+  return sum + sum_of_sums * sum;
+}
+
+static jdouble combine(jdouble f[], int len) {
+  int i;
+  double sum = 0, sum_of_sums = 0;
+  for (i = 0; i < len; i++) {
+    sum += f[i];
+    sum_of_sums += sum;
+  }
+  return sum + sum_of_sums * sum;
+}
+
+JNIEXPORT jfloat JNICALL Java_compiler_floatingpoint_TestFloatSyncJNIArgs_combine15floats
+  (JNIEnv *env, jclass cls,
+   jfloat  f1, jfloat  f2, jfloat  f3, jfloat  f4,
+   jfloat  f5, jfloat  f6, jfloat  f7, jfloat  f8,
+   jfloat  f9, jfloat f10, jfloat f11, jfloat f12,
+   jfloat f13, jfloat f14, jfloat f15) {
+
+  jfloat f[15];
+  f[0] = f1; f[1] = f2; f[2] = f3; f[3] = f4; f[4] = f5;
+  f[5] = f6; f[6] = f7; f[7] = f8; f[8] = f9; f[9] = f10;
+  f[10] = f11; f[11] = f12; f[12] = f13; f[13] = f14; f[14] = f15;
+
+  return fcombine(f, sizeof f / sizeof f[0]);
+}
+
+JNIEXPORT jdouble JNICALL Java_compiler_floatingpoint_TestFloatSyncJNIArgs_combine15doubles
+  (JNIEnv *env, jclass cls,
+   jdouble  f1, jdouble  f2, jdouble  f3, jdouble  f4,
+   jdouble  f5, jdouble  f6, jdouble  f7, jdouble  f8,
+   jdouble  f9, jdouble f10, jdouble f11, jdouble f12,
+   jdouble f13, jdouble f14, jdouble f15) {
+
+  jdouble f[15];
+  f[0] = f1; f[1] = f2; f[2] = f3; f[3] = f4; f[4] = f5;
+  f[5] = f6; f[6] = f7; f[7] = f8; f[8] = f9; f[9] = f10;
+  f[10] = f11; f[11] = f12; f[12] = f13; f[13] = f14; f[14] = f15;
+
+  return combine(f, sizeof f / sizeof f[0]);
+}
+
+
+#ifdef __cplusplus
+}
+#endif
--- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -47,6 +47,7 @@
  *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame
  *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2
  *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse
+ *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3
  *                   -XX:+DoEscapeAnalysis -XX:-UseCounterDecay
  *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=true
  *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false
@@ -58,6 +59,7 @@
  *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame
  *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2
  *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse
+ *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3
  *                   -XX:+DoEscapeAnalysis -XX:-UseCounterDecay
  *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=false
  *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false
@@ -69,6 +71,7 @@
  *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame
  *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2
  *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse
+ *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3
  *                   -XX:+DoEscapeAnalysis -XX:-UseCounterDecay
  *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=true
  *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true
@@ -80,6 +83,7 @@
  *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame
  *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2
  *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse
+ *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3
  *                   -XX:+DoEscapeAnalysis -XX:-UseCounterDecay
  *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=false
  *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true
@@ -107,8 +111,11 @@
     private static final int COMPILE_THRESHOLD;
     private static final Method MATERIALIZED_METHOD;
     private static final Method NOT_MATERIALIZED_METHOD;
+    private static final Method FRAME3_METHOD;
     private static final ResolvedJavaMethod MATERIALIZED_RESOLVED;
     private static final ResolvedJavaMethod NOT_MATERIALIZED_RESOLVED;
+    private static final ResolvedJavaMethod FRAME2_RESOLVED;
+    private static final ResolvedJavaMethod FRAME3_RESOLVED;
     private static final boolean MATERIALIZE_FIRST;
 
     static {
@@ -120,13 +127,15 @@
                     String.class, int.class);
             method2 = MaterializeVirtualObjectTest.class.getDeclaredMethod("testFrame2",
                     String.class, int.class);
+            FRAME3_METHOD = MaterializeVirtualObjectTest.class.getDeclaredMethod("testFrame3",
+                    Helper.class, int.class);
         } catch (NoSuchMethodException e) {
             throw new Error("Can't get executable for test method", e);
         }
         ResolvedJavaMethod resolved1;
-        ResolvedJavaMethod resolved2;
         resolved1 = CTVMUtilities.getResolvedMethod(method1);
-        resolved2 = CTVMUtilities.getResolvedMethod(method2);
+        FRAME2_RESOLVED = CTVMUtilities.getResolvedMethod(method2);
+        FRAME3_RESOLVED = CTVMUtilities.getResolvedMethod(FRAME3_METHOD);
         INVALIDATE = Boolean.getBoolean(
                 "compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate");
         COMPILE_THRESHOLD = WB.getBooleanVMFlag("TieredCompilation")
@@ -134,8 +143,8 @@
                 : CompilerWhiteBoxTest.THRESHOLD * 2;
         MATERIALIZE_FIRST = Boolean.getBoolean(
                 "compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst");
-        MATERIALIZED_RESOLVED = MATERIALIZE_FIRST ? resolved1 : resolved2;
-        NOT_MATERIALIZED_RESOLVED = MATERIALIZE_FIRST ? resolved2 : resolved1;
+        MATERIALIZED_RESOLVED = MATERIALIZE_FIRST ? resolved1 : FRAME2_RESOLVED;
+        NOT_MATERIALIZED_RESOLVED = MATERIALIZE_FIRST ? FRAME2_RESOLVED : resolved1;
         MATERIALIZED_METHOD = MATERIALIZE_FIRST ? method1 : method2;
         NOT_MATERIALIZED_METHOD = MATERIALIZE_FIRST ? method2 : method1;
     }
@@ -171,6 +180,16 @@
         Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD),
                 getName() + " : not materialized method not compiled");
         testFrame("someString", /* materialize */ CompilerWhiteBoxTest.THRESHOLD);
+
+        // run second test types
+        for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) {
+            testFrame("someString", i);
+        }
+        Asserts.assertTrue(WB.isMethodCompiled(MATERIALIZED_METHOD), getName()
+                + " : materialized method not compiled");
+        Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD),
+                getName() + " : not materialized method not compiled");
+        testFrame("someString", /* materialize */ CompilerWhiteBoxTest.THRESHOLD + 1);
     }
 
     private void testFrame(String str, int iteration) {
@@ -178,13 +197,25 @@
         testFrame2(str, iteration);
         Asserts.assertTrue((helper.string != null) && (this != null)
                 && (helper != null), String.format("%s : some locals are null", getName()));
-     }
+    }
 
     private void testFrame2(String str, int iteration) {
         Helper helper = new Helper(str);
+        Helper helper2 = new Helper("bar");
+        testFrame3(helper, iteration);
+        Asserts.assertTrue((helper.string != null) && (this != null) && helper.string == str
+                && (helper != null), String.format("%s : some locals are null", getName()));
+        Asserts.assertTrue((helper2.string != null) && (this != null)
+                && (helper2 != null), String.format("%s : some locals are null", getName()));
+    }
+
+    private void testFrame3(Helper outerHelper, int iteration) {
+        Helper innerHelper = new Helper("foo");
         recurse(2, iteration);
-        Asserts.assertTrue((helper.string != null) && (this != null)
-                && (helper != null), String.format("%s : some locals are null", getName()));
+        Asserts.assertTrue((innerHelper.string != null) && (this != null)
+                && (innerHelper != null), String.format("%s : some locals are null", getName()));
+        Asserts.assertTrue((outerHelper.string != null) && (this != null)
+                && (outerHelper != null), String.format("%s : some locals are null", getName()));
     }
 
     private void recurse(int depth, int iteration) {
@@ -198,6 +229,48 @@
         }
     }
 
+    private void checkStructure(boolean materialize) {
+        boolean[] framesSeen = new boolean[2];
+        Object[] helpers = new Object[1];
+        CompilerToVMHelper.iterateFrames(
+            new ResolvedJavaMethod[] {FRAME3_RESOLVED},
+            null, /* any */
+            0,
+            f -> {
+                if (!framesSeen[1]) {
+                    Asserts.assertTrue(f.isMethod(FRAME3_RESOLVED),
+                            "Expected testFrame3 first");
+                    framesSeen[1] = true;
+                    Asserts.assertTrue(f.getLocal(0) != null, "this should not be null");
+                    Asserts.assertTrue(f.getLocal(1) != null, "outerHelper should not be null");
+                    Asserts.assertTrue(f.getLocal(3) != null, "innerHelper should not be null");
+                    Asserts.assertEQ(((Helper) f.getLocal(3)).string, "foo", "innerHelper.string should be foo");
+                    helpers[0] = f.getLocal(1);
+                    if (materialize) {
+                        f.materializeVirtualObjects(false);
+                    }
+                    return null; //continue
+                } else {
+                    Asserts.assertFalse(framesSeen[0], "frame3 can not have been seen");
+                    Asserts.assertTrue(f.isMethod(FRAME2_RESOLVED),
+                            "Expected testFrame2 second");
+                    framesSeen[0] = true;
+                    Asserts.assertTrue(f.getLocal(0) != null, "this should not be null");
+                    Asserts.assertTrue(f.getLocal(1) != null, "str should not be null");
+                    Asserts.assertTrue(f.getLocal(3) != null, "helper should not be null");
+                    Asserts.assertTrue(f.getLocal(4) != null, "helper2 should not be null");
+                    Asserts.assertEQ(((Helper) f.getLocal(3)).string, f.getLocal(1), "helper.string should be the same as str");
+                    Asserts.assertEQ(((Helper) f.getLocal(4)).string, "bar", "helper2.string should be foo");
+                    if (!materialize) {
+                        Asserts.assertEQ(f.getLocal(3), helpers[0], "helper should be the same as frame3's outerHelper");
+                    }
+                    return f; // stop
+                }
+            });
+        Asserts.assertTrue(framesSeen[1], "frame3 should have been seen");
+        Asserts.assertTrue(framesSeen[0], "frame2 should have been seen");
+    }
+
     private void check(int iteration) {
         // Materialize virtual objects on last invocation
         if (iteration == COMPILE_THRESHOLD) {
@@ -244,6 +317,9 @@
             // check that not materialized frame wasn't deoptimized
             Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD), getName()
                     + " : not materialized method has unexpected compiled status");
+        } else if (iteration == COMPILE_THRESHOLD + 1) {
+            checkStructure(false);
+            checkStructure(true);
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/TestNoPerfCounter.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+/* @test TestNoPerfCounter
+ * @bug 8210265
+ * @requires vm.gc=="null"
+ * @library /test/lib /
+ * @summary Tests that disabling perf counters does not crash the VM
+ * @run main/othervm -XX:-UsePerfData TestNoPerfCounter
+ */
+
+public class TestNoPerfCounter {
+    public static void main(String[] args) throws Exception {
+        // Nothing to do
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/TestPolicyNamePerfCounter.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+import static jdk.test.lib.Asserts.*;
+import gc.testlibrary.PerfCounter;
+import gc.testlibrary.PerfCounters;
+
+
+/* @test TestPolicyNamePerfCounter
+ * @bug 8210192
+ * @requires vm.gc=="null"
+ * @library /test/lib /
+ * @summary Tests that sun.gc.policy.name returns expected values for different GCs.
+ * @modules java.base/jdk.internal.misc
+ *          java.compiler
+ *          java.management/sun.management
+ *          jdk.internal.jvmstat/sun.jvmstat.monitor
+ * @run main/othervm -XX:+UsePerfData -XX:+UseSerialGC TestPolicyNamePerfCounter Copy:MSC
+ * @run main/othervm -XX:+UsePerfData -XX:+UseParallelGC TestPolicyNamePerfCounter ParScav:MSC
+ * @run main/othervm -XX:+UsePerfData -XX:+UseG1GC TestPolicyNamePerfCounter GarbageFirst
+ */
+
+/* @test TestPolicyNamePerfCounterCMS
+ * @bug 8210192
+ * @comment Graal does not support CMS
+ * @requires vm.gc=="null" & !vm.graal.enabled
+ * @library /test/lib /
+ * @summary Tests that sun.gc.policy.name returns expected values for different GCs.
+ * @modules java.base/jdk.internal.misc
+ *          java.compiler
+ *          java.management/sun.management
+ *          jdk.internal.jvmstat/sun.jvmstat.monitor
+ * @run main/othervm -XX:+UsePerfData -XX:+UseConcMarkSweepGC TestPolicyNamePerfCounter ParNew:CMS
+ */
+
+public class TestPolicyNamePerfCounter {
+    public static void main(String[] args) throws Exception {
+        if (args.length != 1) {
+            throw new IllegalArgumentException("Expected 1 arg: <expectedName>");
+        }
+        assertEQ(PerfCounters.findByName("sun.gc.policy.name").value(), args[0]);
+    }
+}
--- a/test/hotspot/jtreg/gc/testlibrary/PerfCounter.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/gc/testlibrary/PerfCounter.java	Fri Sep 07 15:46:39 2018 -0700
@@ -41,6 +41,15 @@
     }
 
     /**
+     * Returns the value of this performance counter as an Object.
+     *
+     * @return The value of this performance counter
+     */
+    public Object value() {
+        return monitor.getValue();
+    }
+
+    /**
      * Returns the value of this performance counter as a long.
      *
      * @return The long value of this performance counter
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/BoolReturn/JNIBooleanTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2018 SAP SE. 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
+ * @bug 8209637
+ * @summary [s390x] Interpreter doesn't call result handler after native calls
+ * @author Volker Simonis
+ *
+ * @run main/othervm/native -XX:-UseOnStackReplacement -Xbatch JNIBooleanTest 50000
+ * @run main/othervm/native -Xint JNIBooleanTest 256
+ */
+
+import java.lang.reflect.Method;
+
+public class JNIBooleanTest {
+  static native boolean foo(byte b);
+
+  static boolean bar(byte b) {
+    return foo(b);
+  }
+
+  public static void main(String args[]) throws Exception {
+    int count = args.length > 0 ? Integer.parseInt(args[0]) : 50_000;
+    byte b = 0;
+    for (int i = 0; i < count; i++) {
+      boolean bool = foo(b);
+      if ((b == 0 && bool) || (b != 0 && !bool)) {
+        throw new RuntimeException("Error: foo(" + b + ") = " + bool + " in iteration " + i);
+      }
+      b++;
+    }
+
+    b = 0;
+    for (int i = 0; i < count; i++) {
+      boolean bool = bar(b);
+      if ((b == 0 && bool) || (b != 0 && !bool)) {
+        throw new RuntimeException("Error: bar(" + b + ") = " + bool + " in iteration " + i);
+      }
+      b++;
+    }
+
+    Method foo = JNIBooleanTest.class.getDeclaredMethod("foo", byte.class);
+
+    b = 0;
+    for (int i = 0; i < count; i++) {
+      boolean bool = ((Boolean)foo.invoke(null, b)).booleanValue();
+      if ((b == 0 && bool) || (b != 0 && !bool)) {
+        throw new RuntimeException("Error: foo(" + b + ") = " + bool + " in iteration " + i + " (reflective)");
+      }
+      b++;
+    }
+
+    Method bar = JNIBooleanTest.class.getDeclaredMethod("bar", byte.class);
+
+    b = 0;
+    for (int i = 0; i < count; i++) {
+      boolean bool = ((Boolean)bar.invoke(null, b)).booleanValue();
+      if ((b == 0 && bool) || (b != 0 && !bool)) {
+        throw new RuntimeException("Error: bar(" + b + ") = " + bool + " in iteration " + i + " (reflective)");
+      }
+      b++;
+    }
+  }
+
+  static {
+    System.loadLibrary("JNIBooleanTest");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/BoolReturn/libJNIBooleanTest.c	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2018 SAP SE. 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"
+
+JNIEXPORT jboolean JNICALL
+Java_JNIBooleanTest_foo(JNIEnv *env, jclass cls, jbyte b) {
+  jboolean old = b;
+  return old;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/Dictionary/CleanProtectionDomain.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @summary Verifies the creation and cleaup of entries in the Protection Domain Table
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main CleanProtectionDomain
+ */
+
+import java.security.ProtectionDomain;
+import jdk.test.lib.compiler.InMemoryJavaCompiler;
+import jdk.internal.misc.Unsafe;
+import static jdk.test.lib.Asserts.*;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import sun.hotspot.WhiteBox;
+
+public class CleanProtectionDomain {
+
+  public static void main(String args[]) throws Exception {
+    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+                                  "-Xlog:protectiondomain+table=debug",
+                                  "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
+                                  "-XX:+WhiteBoxAPI",
+                                  "-Xbootclasspath/a:.",
+                                  Test.class.getName());
+    OutputAnalyzer output = new OutputAnalyzer(pb.start());
+    output.shouldContain("protection domain added");
+    output.shouldContain("protection domain unlinked");
+    output.shouldHaveExitValue(0);
+  }
+
+  static class Test {
+    public static void test() throws Exception {
+      Unsafe unsafe = Unsafe.getUnsafe();
+      TestClassLoader classloader = new TestClassLoader();
+      ProtectionDomain pd = new ProtectionDomain(null, null);
+      byte klassbuf[] = InMemoryJavaCompiler.compile("TestClass", "class TestClass { }");
+      Class klass = unsafe.defineClass(null, klassbuf, 0, klassbuf.length, classloader, pd);
+    }
+
+    public static void main(String[] args) throws Exception {
+      WhiteBox wb = WhiteBox.getWhiteBox();
+      int removedCountOrig =  wb.protectionDomainRemovedCount();
+      int removedCount;
+
+      test();
+
+      System.gc();
+      // Wait until ServiceThread cleans ProtectionDomain table.
+      // When the TestClassLoader is unloaded by GC, at least one
+      // ProtectionDomainCacheEntry will be eligible for removal.
+      do {
+        removedCount = wb.protectionDomainRemovedCount();
+      } while (removedCountOrig == removedCount);
+    }
+
+    private static class TestClassLoader extends ClassLoader {
+      public TestClassLoader() {
+        super();
+      }
+    }
+  }
+}
--- a/test/hotspot/jtreg/runtime/ErrorHandling/CreateCoredumpOnCrash.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/ErrorHandling/CreateCoredumpOnCrash.java	Fri Sep 07 15:46:39 2018 -0700
@@ -57,7 +57,7 @@
     public static OutputAnalyzer runTest(String option) throws Exception {
         return new OutputAnalyzer(
             ProcessTools.createJavaProcessBuilder(
-            "-Xmx128m", "-XX:-TransmitErrorReport", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", option, Crasher.class.getName())
+            "-Xmx128m", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", option, Crasher.class.getName())
             .start());
     }
 }
--- a/test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java	Fri Sep 07 15:46:39 2018 -0700
@@ -43,7 +43,7 @@
         // The -XX:ErrorHandlerTest=N option requires debug bits.
         return new OutputAnalyzer(
             ProcessTools.createJavaProcessBuilder(
-            "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=" + testcase)
+            "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=" + testcase)
             .start());
     }
 
--- a/test/hotspot/jtreg/runtime/ErrorHandling/ProblematicFrameTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/ErrorHandling/ProblematicFrameTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -47,7 +47,7 @@
 
     public static void main(String[] args) throws Exception {
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-            "-Xmx64m", "-XX:-TransmitErrorReport", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-CreateCoredumpOnCrash", Crasher.class.getName());
+            "-Xmx64m", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-CreateCoredumpOnCrash", Crasher.class.getName());
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
         output.shouldNotContain("Exception in thread");
         output.shouldNotMatch("error occurred during error reporting \\(printing problematic frame\\)");
--- a/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java	Fri Sep 07 15:46:39 2018 -0700
@@ -41,7 +41,6 @@
         String msg = "Test Succeeded";
 
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-           "-XX:-TransmitErrorReport",
            "-XX:-CreateCoredumpOnCrash",
            "-XX:ErrorHandlerTest=12", // trigger potential SEGV
            "-XX:OnError=echo " + msg,
--- a/test/hotspot/jtreg/runtime/MemberName/MemberNameLeak.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/MemberName/MemberNameLeak.java	Fri Sep 07 15:46:39 2018 -0700
@@ -34,7 +34,7 @@
 import java.lang.invoke.*;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
-
+import sun.hotspot.WhiteBox;
 import sun.hotspot.code.Compiler;
 
 public class MemberNameLeak {
@@ -44,6 +44,9 @@
 
       public static void main(String[] args) throws Throwable {
         Leak leak = new Leak();
+        WhiteBox wb = WhiteBox.getWhiteBox();
+        int removedCountOrig =  wb.resolvedMethodRemovedCount();
+        int removedCount;
 
         for (int i = 0; i < 10; i++) {
           MethodHandles.Lookup lookup = MethodHandles.lookup();
@@ -54,6 +57,11 @@
         }
 
         System.gc();  // make mh unused
+
+        // Wait until ServiceThread cleans ResolvedMethod table
+        do {
+          removedCount = wb.resolvedMethodRemovedCount();
+        } while (removedCountOrig == removedCount);
       }
     }
 
@@ -61,6 +69,8 @@
        // Run this Leak class with logging
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
                                       "-Xlog:membername+table=trace",
+                                      "-XX:+WhiteBoxAPI",
+                                      "-Xbootclasspath/a:.",
                                       gc, Leak.class.getName());
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
         output.shouldContain("ResolvedMethod entry added for MemberNameLeak$Leak.callMe()V");
--- a/test/hotspot/jtreg/runtime/Metaspace/FragmentMetaspace.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/Metaspace/FragmentMetaspace.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -26,7 +26,7 @@
  * @library /runtime/testlibrary
  * @modules java.base/jdk.internal.misc
  * @modules java.compiler
- * @run main/othervm/timeout=200 -Xmx300m FragmentMetaspace
+ * @run main/othervm/timeout=200 -Xmx1g FragmentMetaspace
  */
 
 import java.io.IOException;
@@ -42,8 +42,8 @@
     public static Class<?> c;
 
     public static void main(String... args) {
-        runGrowing(Long.valueOf(System.getProperty("time", "80000")),
-            Integer.valueOf(System.getProperty("iterations", "200")));
+        runGrowing(Long.valueOf(System.getProperty("time", "40000")),
+            Integer.valueOf(System.getProperty("iterations", "100")));
         // try to clean up and unload classes to decrease
         // class verification time in debug vm
         System.gc();
@@ -68,6 +68,9 @@
                 gcl = null;
             } catch (IOException | InstantiationException | IllegalAccessException ex) {
                 throw new RuntimeException(ex);
+            } catch (OutOfMemoryError oome) {
+                System.out.println("javac failed with OOM; ignored.");
+                return;
             }
         }
     }
--- a/test/hotspot/jtreg/runtime/RedefineTests/ModifyAnonymous.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/RedefineTests/ModifyAnonymous.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,9 @@
  * @run main/othervm -javaagent:redefineagent.jar ModifyAnonymous
  */
 
+import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.PrintWriter;
 import java.lang.RuntimeException;
 import java.lang.instrument.ClassDefinition;
@@ -107,12 +109,39 @@
     }
 
     static void runTest() {
+        PrintWriter pw;
+        String logName = System.getProperty("test.classes") +
+            File.separator + "loadedClasses.log";
+        // Create a log file to capture the names of the classes in the
+        // allLoadedClasses array. The log file is for assisting in debugging
+        // in case a null class is encountered in the allLoadedClasses array.
+        try {
+            pw = new PrintWriter(new FileOutputStream(
+                new File(logName), true));
+        } catch (FileNotFoundException e) {
+            throw new RuntimeException("Could not write loaded classes to log", e);
+        }
         while (!done) {
             Class[] allLoadedClasses = inst.getAllLoadedClasses();
-            for (Class clazz : allLoadedClasses) {
+            int len = allLoadedClasses.length;
+            pw.println("    allLoadedClasses length: " + len);
+            for (int idx = 0; idx < len; idx++) {
+                Class cls = allLoadedClasses[idx];
+                pw.println("    " + idx + " " +
+                    ((cls != null) ? cls.getName() : "null"));
+            }
+            for (int idx = 0; idx < len; idx++) {
+                Class clazz = allLoadedClasses[idx];
+                if (clazz == null) {
+                    pw.flush();
+                    pw.close();
+                    throw new RuntimeException("null class encountered");
+                }
                 final String name = clazz.getName();
                 if (name.contains("$$Lambda$") && name.contains("App")) {
                     if (inst.isModifiableClass(clazz)) {
+                        pw.flush();
+                        pw.close();
                         throw new RuntimeException ("Class should not be modifiable");
                     }
                     // Try to modify them anyway.
@@ -133,12 +162,16 @@
                         System.out.println("PASSED: expecting UnmodifiableClassException");
                         t.printStackTrace();
                     } catch(java.lang.ClassNotFoundException e) {
+                        pw.flush();
+                        pw.close();
                         throw new RuntimeException ("ClassNotFoundException thrown");
                     }
                     done = true;
                 }
             }
         }
+        pw.flush();
+        pw.close();
     }
 
     public static void main(String argv[]) throws InterruptedException, RuntimeException {
--- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency1.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency1.java	Fri Sep 07 15:46:39 2018 -0700
@@ -50,7 +50,6 @@
                   "-Xbootclasspath/a:.",
                   "-XX:+UnlockDiagnosticVMOptions",
                   "-XX:+WhiteBoxAPI",
-                  "-XX:-TransmitErrorReport",
                   "-XX:-CreateCoredumpOnCrash",
                   "-Xmx128m",
                   "AssertSafepointCheckConsistency1",
--- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency2.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency2.java	Fri Sep 07 15:46:39 2018 -0700
@@ -50,7 +50,6 @@
                   "-Xbootclasspath/a:.",
                   "-XX:+UnlockDiagnosticVMOptions",
                   "-XX:+WhiteBoxAPI",
-                  "-XX:-TransmitErrorReport",
                   "-XX:-CreateCoredumpOnCrash",
                   "-Xmx128m",
                   "AssertSafepointCheckConsistency2",
--- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency3.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency3.java	Fri Sep 07 15:46:39 2018 -0700
@@ -50,7 +50,6 @@
                   "-Xbootclasspath/a:.",
                   "-XX:+UnlockDiagnosticVMOptions",
                   "-XX:+WhiteBoxAPI",
-                  "-XX:-TransmitErrorReport",
                   "-XX:-CreateCoredumpOnCrash",
                   "-Xmx32m",
                   "AssertSafepointCheckConsistency3",
--- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency4.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency4.java	Fri Sep 07 15:46:39 2018 -0700
@@ -50,7 +50,6 @@
                "-Xbootclasspath/a:.",
                "-XX:+UnlockDiagnosticVMOptions",
                "-XX:+WhiteBoxAPI",
-               "-XX:-TransmitErrorReport",
                "-XX:-CreateCoredumpOnCrash",
                "-Xmx32m",
                "AssertSafepointCheckConsistency4",
--- a/test/hotspot/jtreg/runtime/Thread/ThreadPriorities.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/Thread/ThreadPriorities.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -30,7 +30,8 @@
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  *          java.management
- * @run main ThreadPriorities
+ * @comment Use othervm mode so that we don't capture unrelated threads created by other tests
+ * @run main/othervm ThreadPriorities
  */
 
 import java.util.ArrayList;
@@ -75,7 +76,7 @@
                 JDKToolFinder.getJDKTool("jstack"),
                 String.valueOf(ProcessTools.getProcessId()));
 
-        String[] output = new OutputAnalyzer(pb.start()).getOutput().split("\\n+");
+        String[] output = new OutputAnalyzer(pb.start()).getOutput().split("\\R");
 
         Pattern pattern = Pattern.compile(
                 "\\\"Priority=(\\d+)\\\".* prio=(\\d+).*");
@@ -93,8 +94,20 @@
         barrier.await(); // 2nd
         barrier.reset();
 
-        assertEquals(matches, NUMBER_OF_JAVA_PRIORITIES);
-        assertTrue(failed.isEmpty(), failed.size() + ":" + failed);
+        boolean success = false;
+        try {
+            assertEquals(matches, NUMBER_OF_JAVA_PRIORITIES);
+            assertTrue(failed.isEmpty(), failed.size() + ":" + failed);
+            success = true;
+        }
+        finally {
+            if (!success) {
+                System.out.println("Failure detected - dumping jstack output:");
+                for (String line : output) {
+                    System.out.println(line);
+                }
+            }
+        }
     }
 }
 
--- a/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java	Fri Sep 07 15:46:39 2018 -0700
@@ -48,7 +48,6 @@
                 true,
                 "-Xmx128m",
                 "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
-                "-XX:-TransmitErrorReport",
                 "-XX:-CreateCoredumpOnCrash",
                 "-XX:-InlineUnsafeOps", // The compiler intrinsics doesn't have the assert
                 DummyClassWithMainRangeCheck.class.getName());
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddModules.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddModules.java	Fri Sep 07 15:46:39 2018 -0700
@@ -25,7 +25,7 @@
 /**
  * @test
  * @requires vm.cds
- * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/appcds
+ * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules jdk.compiler
  *          jdk.jartool/sun.tools.jar
  *          jdk.jlink
@@ -39,7 +39,6 @@
 import java.nio.file.Paths;
 
 import jdk.test.lib.process.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 
 public class AddModules {
 
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddOpens.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddOpens.java	Fri Sep 07 15:46:39 2018 -0700
@@ -25,7 +25,7 @@
 /**
  * @test
  * @requires vm.cds
- * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/appcds
+ * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules jdk.compiler
  *          jdk.jartool/sun.tools.jar
  *          jdk.jlink
@@ -39,7 +39,6 @@
 import java.nio.file.Paths;
 
 import jdk.test.lib.process.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 
 public class AddOpens {
 
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddReads.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddReads.java	Fri Sep 07 15:46:39 2018 -0700
@@ -39,7 +39,6 @@
 import java.nio.file.Paths;
 
 import jdk.test.lib.process.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.Asserts;
 
 public class AddReads {
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ExportModule.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ExportModule.java	Fri Sep 07 15:46:39 2018 -0700
@@ -40,7 +40,6 @@
 
 import jdk.test.lib.compiler.CompilerUtils;
 import jdk.test.lib.process.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.Asserts;
 
 public class ExportModule {
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/MainModuleOnly.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/MainModuleOnly.java	Fri Sep 07 15:46:39 2018 -0700
@@ -25,7 +25,7 @@
 /**
  * @test
  * @requires vm.cds
- * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/appcds
+ * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules jdk.compiler
  *          jdk.jartool/sun.tools.jar
  *          jdk.jlink
@@ -41,7 +41,6 @@
 
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.Platform;
-import jdk.testlibrary.ProcessTools;
 
 public class MainModuleOnly {
 
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP.java	Fri Sep 07 15:46:39 2018 -0700
@@ -25,7 +25,7 @@
 /**
  * @test
  * @requires vm.cds
- * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/appcds
+ * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules jdk.compiler
  *          jdk.jartool/sun.tools.jar
  *          jdk.jlink
@@ -40,7 +40,6 @@
 import java.nio.file.Paths;
 
 import jdk.test.lib.process.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 
 public class ModulePathAndCP {
 
--- a/test/hotspot/jtreg/runtime/appcds/sharedStrings/IncompatibleOptions.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/appcds/sharedStrings/IncompatibleOptions.java	Fri Sep 07 15:46:39 2018 -0700
@@ -41,6 +41,7 @@
 import jdk.test.lib.process.OutputAnalyzer;
 
 import sun.hotspot.code.Compiler;
+import sun.hotspot.gc.GC;
 
 public class IncompatibleOptions {
     static final String COOPS_DUMP_WARNING =
@@ -63,7 +64,7 @@
 
         // Uncompressed OOPs
         testDump(1, "-XX:+UseG1GC", "-XX:-UseCompressedOops", COOPS_DUMP_WARNING, true);
-        if (Platform.isLinux() && Platform.isX64()) {
+        if (GC.Z.isSupported()) { // ZGC is included in build.
             testDump(1, "-XX:+UnlockExperimentalVMOptions", "-XX:+UseZGC", COOPS_DUMP_WARNING, true);
         }
 
--- a/test/hotspot/jtreg/runtime/memory/ReserveMemory.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/memory/ReserveMemory.java	Fri Sep 07 15:46:39 2018 -0700
@@ -55,7 +55,6 @@
           "-Xbootclasspath/a:.",
           "-XX:+UnlockDiagnosticVMOptions",
           "-XX:+WhiteBoxAPI",
-          "-XX:-TransmitErrorReport",
           "-XX:-CreateCoredumpOnCrash",
           "-Xmx128m",
           "ReserveMemory",
--- a/test/hotspot/jtreg/runtime/testlibrary/GeneratedClassLoader.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/runtime/testlibrary/GeneratedClassLoader.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,6 +22,7 @@
  */
 
 import java.io.DataInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileWriter;
@@ -145,10 +146,17 @@
             pw.append(src);
             pw.flush();
         }
-        int exitcode = javac.run(null, null, null, file.getCanonicalPath());
+        ByteArrayOutputStream err = new ByteArrayOutputStream();
+        int exitcode = javac.run(null, null, err, file.getCanonicalPath());
         if (exitcode != 0) {
-            throw new RuntimeException("javac failure when compiling: " +
-                    file.getCanonicalPath());
+            // Print Error
+            System.err.print(err);
+            if (err.toString().contains("java.lang.OutOfMemoryError: Java heap space")) {
+              throw new OutOfMemoryError("javac failed with resources exhausted");
+            } else {
+              throw new RuntimeException("javac failure when compiling: " +
+                      file.getCanonicalPath());
+            }
         } else {
             if (deleteFiles) {
                 file.delete();
--- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitor.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitor.java	Fri Sep 07 15:46:39 2018 -0700
@@ -188,6 +188,28 @@
     throw new RuntimeException("Could not set the sampler");
   }
 
+  public static Frame[] allocateAndCheckFrames() {
+    if (!eventStorageIsEmpty()) {
+      throw new RuntimeException("Statistics should be null to begin with.");
+    }
+
+    // Put sampling rate to 100k to ensure samples are collected.
+    setSamplingInterval(100 * 1024);
+
+    enableSamplingEvents();
+
+    List<Frame> frameList = allocate();
+    frameList.add(new Frame("allocateAndCheckFrames", "()[LMyPackage/Frame;", "HeapMonitor.java",
+          201));
+    Frame[] frames = frameList.toArray(new Frame[0]);
+
+    if (!obtainedEvents(frames) && !garbageContains(frames)) {
+      throw new RuntimeException("No expected events were found.");
+    }
+
+    return frames;
+  }
+
   public native static int sampledEvents();
   public native static boolean obtainedEvents(Frame[] frames, boolean checkLines);
   public native static boolean garbageContains(Frame[] frames, boolean checkLines);
--- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorGCTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorGCTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -40,23 +40,7 @@
  */
 public class HeapMonitorGCTest {
   public static void main(String[] args) {
-    if (!HeapMonitor.eventStorageIsEmpty()) {
-      throw new RuntimeException("Statistics should be null to begin with.");
-    }
-
-    // Put sampling rate to 100k to ensure samples are collected.
-    HeapMonitor.setSamplingInterval(100 * 1024);
-
-    HeapMonitor.enableSamplingEvents();
-
-    List<Frame> frameList = HeapMonitor.allocate();
-    frameList.add(new Frame("main", "([Ljava/lang/String;)V", "HeapMonitorGCTest.java", 52));
-    Frame[] frames = frameList.toArray(new Frame[0]);
-
-    if (!HeapMonitor.obtainedEvents(frames)
-        && !HeapMonitor.garbageContains(frames)) {
-      throw new RuntimeException("No expected events were found.");
-    }
+    Frame[] frames = HeapMonitor.allocateAndCheckFrames();
 
     HeapMonitor.forceGarbageCollection();
 
--- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -24,8 +24,6 @@
 
 package MyPackage;
 
-import java.util.List;
-
 /**
  * @test
  * @summary Verifies the JVMTI Heap Monitor API
@@ -44,22 +42,7 @@
       HeapMonitor.setAllocationIterations(Integer.parseInt(args[0]));
     }
 
-    // Put sampling rate to 100k to ensure samples are collected.
-    HeapMonitor.setSamplingInterval(100 * 1024);
-
-    if (!HeapMonitor.eventStorageIsEmpty()) {
-      throw new RuntimeException("Storage is not empty at test start...");
-    }
-
-    HeapMonitor.enableSamplingEvents();
-    List<Frame> frameList = HeapMonitor.allocate();
-    frameList.add(new Frame("main", "([Ljava/lang/String;)V", "HeapMonitorTest.java", 55));
-
-    Frame[] frames = frameList.toArray(new Frame[0]);
-    if (!HeapMonitor.obtainedEvents(frames)
-        && !HeapMonitor.garbageContains(frames)) {
-      throw new RuntimeException("Events not found with the right frames.");
-    }
+    HeapMonitor.allocateAndCheckFrames();
 
     HeapMonitor.disableSamplingEvents();
     HeapMonitor.resetEventStorage();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/jvmti/VMEvent/MyPackage/VMEventRecursionTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, Google 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 MyPackage;
+
+/**
+ * @test
+ * @summary Verifies that a VM event callback does not recurse if a VM object is allocated during callback.
+ * @compile VMEventRecursionTest.java
+ * @run main/othervm/native -agentlib:VMEventTest MyPackage.VMEventRecursionTest
+ */
+public class VMEventRecursionTest implements Cloneable {
+    // Implement a simple clone. A call will provoke a JVMTI event for VM allocations, which tries to
+    // call this again.
+    public Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }
+
+    public static void main(String[] args) {
+        VMEventRecursionTest obj = new VMEventRecursionTest();
+        try {
+            obj.clone();
+        } catch(CloneNotSupportedException e) {
+            // NOP.
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/jvmti/VMEvent/libVMEventTest.c	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, Google 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 <string.h>
+#include "jvmti.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef JNI_ENV_ARG
+
+#ifdef __cplusplus
+#define JNI_ENV_ARG(x)
+#define JNI_ENV_ARGS2(x, y) y
+#define JNI_ENV_ARGS3(x, y, z) y, z
+#define JNI_ENV_ARGS4(x, y, z, w) y, z, w
+#define JNI_ENV_PTR(x) x
+#else
+#define JNI_ENV_ARG(x) x
+#define JNI_ENV_ARGS2(x,y) x, y
+#define JNI_ENV_ARGS3(x, y, z) x, y, z
+#define JNI_ENV_ARGS4(x, y, z, w) x, y, z, w
+#define JNI_ENV_PTR(x) (*x)
+#endif
+
+#endif
+
+extern JNIEXPORT void JNICALL VMObjectAlloc(jvmtiEnv *jvmti,
+                                            JNIEnv* jni,
+                                            jthread thread,
+                                            jobject object,
+                                            jclass klass,
+                                            jlong size) {
+  char *signature = NULL;
+  jvmtiError error = (*jvmti)->GetClassSignature(jvmti, klass, &signature, NULL);
+
+  if (error != JVMTI_ERROR_NONE || signature == NULL) {
+    JNI_ENV_PTR(jni)->FatalError(
+        JNI_ENV_ARGS2(jni, "Failed during the GetClassSignature call"));
+  }
+
+  // If it is our test class, call clone now.
+  if (!strcmp(signature, "LMyPackage/VMEventRecursionTest;")) {
+    jmethodID clone_method =
+        JNI_ENV_PTR(jni)->GetMethodID(JNI_ENV_ARGS4(jni, klass, "clone", "()Ljava/lang/Object;"));
+
+    if (JNI_ENV_PTR(jni)->ExceptionOccurred(JNI_ENV_ARG(jni))) {
+      JNI_ENV_PTR(jni)->FatalError(
+          JNI_ENV_ARGS2(jni, "Failed during the GetMethodID call"));
+    }
+
+    JNI_ENV_PTR(jni)->CallObjectMethod(JNI_ENV_ARGS3(jni, object, clone_method));
+
+    if (JNI_ENV_PTR(jni)->ExceptionOccurred(JNI_ENV_ARG(jni))) {
+      JNI_ENV_PTR(jni)->FatalError(
+          JNI_ENV_ARGS2(jni, "Failed during the CallObjectMethod call"));
+    }
+  }
+}
+
+extern JNIEXPORT void JNICALL OnVMInit(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread) {
+  (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, NULL);
+}
+
+extern JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options,
+                                           void *reserved) {
+  jvmtiEnv *jvmti;
+  jvmtiEventCallbacks callbacks;
+  jvmtiCapabilities caps;
+
+  if ((*jvm)->GetEnv(jvm, (void **) (&jvmti), JVMTI_VERSION) != JNI_OK) {
+    return JNI_ERR;
+  }
+
+  memset(&callbacks, 0, sizeof(callbacks));
+  callbacks.VMObjectAlloc = &VMObjectAlloc;
+  callbacks.VMInit = &OnVMInit;
+
+  memset(&caps, 0, sizeof(caps));
+  caps.can_generate_vm_object_alloc_events = 1;
+  (*jvmti)->AddCapabilities(jvmti, &caps);
+
+  (*jvmti)->SetEventCallbacks(jvmti, &callbacks, sizeof(jvmtiEventCallbacks));
+  (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL);
+  return 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
--- a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java	Fri Sep 07 15:46:39 2018 -0700
@@ -87,7 +87,7 @@
 
     static void test(String type) throws Throwable {
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-XX:+CreateCoredumpOnCrash",
-                "-XX:MaxMetaspaceSize=64m", "-XX:+CrashOnOutOfMemoryError", "-XX:-TransmitErrorReport",
+                "-XX:MaxMetaspaceSize=64m", "-XX:+CrashOnOutOfMemoryError",
                 TestJmapCore.class.getName(), type);
 
         boolean useDefaultUlimit = useDefaultUlimit();
--- a/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/libdefine.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/libdefine.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -31,24 +31,10 @@
 
 #define REFERENCES_ARRAY_SIZE 10000000
 
-#ifndef JNI_ENV_ARG
-
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x, y) x , y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
-
 #ifndef _Included_gc_g1_unloading_unloading_classloaders_JNIClassloader
 #define _Included_gc_g1_unloading_unloading_classloaders_JNIClassloader
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /*
  * Class:     gc_g1_unloading_unloading_classloaders_JNIClassloader
@@ -58,10 +44,10 @@
 JNIEXPORT jclass JNICALL Java_gc_g1_unloading_classloaders_JNIClassloader_loadThroughJNI0 (JNIEnv * env,
                                          jclass clazz, jstring className, jobject classLoader, jbyteArray bytecode) {
 
-  const char * classNameChar = JNI_ENV_PTR(env)->GetStringUTFChars(JNI_ENV_ARG(env, className), NULL);
-  jbyte * arrayContent = JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, bytecode), NULL);
-  jsize bytecodeLength = JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, bytecode));
-  jclass returnValue = JNI_ENV_PTR(env)->DefineClass(JNI_ENV_ARG(env, classNameChar), classLoader, arrayContent, bytecodeLength);
+  const char * classNameChar = env->GetStringUTFChars(className, NULL);
+  jbyte * arrayContent = env->GetByteArrayElements(bytecode, NULL);
+  jsize bytecodeLength = env->GetArrayLength(bytecode);
+  jclass returnValue = env->DefineClass(classNameChar, classLoader, arrayContent, bytecodeLength);
   if (!returnValue) {
     printf("ERROR: DefineClass call returned NULL by some reason. Classloading failed.\n");
   }
@@ -81,25 +67,25 @@
     jvmtiError err;
     jvmtiCapabilities caps;
     jvmtiClassDefinition classDef;
-    jint jint_err = JNI_ENV_PTR(env)->GetJavaVM(JNI_ENV_ARG(env, &jvm));
+    jint jint_err = env->GetJavaVM(&jvm);
     if (jint_err) {
         printf("GetJavaVM returned nonzero: %d", jint_err);
         return STATUS_FAILED;
     }
 
-    jint_err = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **)&jvmti), JVMTI_VERSION_1_0);
+    jint_err = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_0);
     if (jint_err) {
         printf("GetEnv returned nonzero: %d", jint_err);
         return STATUS_FAILED;
     }
 
-    err = JNI_ENV_PTR(jvmti)->GetPotentialCapabilities(JNI_ENV_ARG(jvmti, &caps));
+    err = jvmti->GetPotentialCapabilities(&caps);
     if (err != JVMTI_ERROR_NONE) {
         printf("(GetPotentialCapabilities) unexpected error: %d\n",err);
         return JNI_ERR;
     }
 
-    err = JNI_ENV_PTR(jvmti)->AddCapabilities(JNI_ENV_ARG(jvmti, &caps));
+    err = jvmti->AddCapabilities(&caps);
     if (err != JVMTI_ERROR_NONE) {
         printf("(AddCapabilities) unexpected error: %d\n", err);
         return JNI_ERR;
@@ -112,16 +98,16 @@
 
     classDef.klass = redefCls;
     classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, classBytes));
+        env->GetArrayLength(classBytes);
     classDef.class_bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, classBytes),
+        env->GetByteArrayElements(classBytes,
             NULL);
 
     if (fl == 2) {
         printf(">>>>>>>> Invoke RedefineClasses():\n");
         printf("\tnew class byte count=%d\n", classDef.class_byte_count);
     }
-    err = JNI_ENV_PTR(jvmti)->RedefineClasses(JNI_ENV_ARG(jvmti, 1), &classDef);
+    err = jvmti->RedefineClasses(1, &classDef);
     if (err != JVMTI_ERROR_NONE) {
         printf("%s: Failed to call RedefineClasses():\n", __FILE__);
         printf("\tthe function returned error %d\n", err);
@@ -145,7 +131,7 @@
 JNIEXPORT jint JNICALL Java_gc_g1_unloading_keepref_JNIGlobalRefHolder_keepGlobalJNIReference
   (JNIEnv * env, jclass clazz, jobject obj) {
     int returnValue;
-    referencesArray[firstFreeIndex] = JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env, obj));
+    referencesArray[firstFreeIndex] = env->NewGlobalRef(obj);
     printf("checkpoint1 %d \n", firstFreeIndex);
     returnValue = firstFreeIndex;
     firstFreeIndex++;
@@ -159,7 +145,7 @@
  */
 JNIEXPORT void JNICALL Java_gc_g1_unloading_keepref_JNIGlobalRefHolder_deleteGlobalJNIReference
   (JNIEnv * env, jclass clazz, jint index) {
-    JNI_ENV_PTR(env)->DeleteGlobalRef(JNI_ENV_ARG(env, referencesArray[index]));
+    env->DeleteGlobalRef(referencesArray[index]);
 }
 
 
@@ -185,10 +171,6 @@
     waitMethod = env->GetMethodID(objectClazz, "wait", "()V");
     env->CallVoidMethod(syncObject, waitMethod);
     printf("checkpoint2 \n");
-  }
-
-
-#ifdef __cplusplus
+}
 }
 #endif
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001.java	Fri Sep 07 15:46:39 2018 -0700
@@ -50,9 +50,9 @@
  * To check up on the method, a debugger,
  * upon getting new set for ClassPrepareEvent,
  * suspends VM with the method VirtualMachine.suspend(),
- * gets the List of geduggee's threads calling VM.allThreads(),
+ * gets the List of debuggee's threads calling VM.allThreads(),
  * invokes the method EventSet.resume(), and
- * gets another List of geduggee's threads.
+ * gets another List of debuggee's threads.
  * The debugger then compares values of
  * each thread's suspendCount from first and second Lists.
  *
@@ -63,6 +63,13 @@
  *   making special clases loaded and prepared to create the Events
  * - Upon getting the Events,
  *   the debugger performs the check required.
+ * - The debugger informs the debuggee when it completes
+ *   each test case, so it will wait before hitting
+ *   communication breakpoints.
+ *   This prevents the breakpoint SUSPEND_ALL policy
+ *   disrupting the first test case check for
+ *   SUSPEND_NONE, if the debuggee gets ahead of
+ *   the debugger processing.
  */
 
 public class resume001 extends TestDebuggerType1 {
@@ -233,6 +240,7 @@
 
                      default: throw new Failure("** default case 1 **");
                 }
+                informDebuggeeTestCase(i);
             }
 
             display("......--> vm.resume()");
@@ -261,5 +269,22 @@
             throw new Failure("** FAILURE to set up ClassPrepareRequest **");
         }
     }
-
+    /**
+     * Inform debuggee which thread test the debugger has completed.
+     * Used for synchronization, so the debuggee does not move too quickly.
+     * @param testCase index of just completed test
+     */
+    void informDebuggeeTestCase(int testCase) {
+        try {
+            ((ClassType)debuggeeClass)
+                .setValue(debuggeeClass.fieldByName("testCase"),
+                          vm.mirrorOf(testCase));
+        } catch (InvalidTypeException ite) {
+            throw new Failure("** FAILURE setting testCase  **");
+        } catch (ClassNotLoadedException cnle) {
+            throw new Failure("** FAILURE notifying debuggee  **");
+        } catch (VMDisconnectedException e) {
+            throw new Failure("** FAILURE debuggee connection **");
+        }
+    }
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001a.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001a.java	Fri Sep 07 15:46:39 2018 -0700
@@ -33,7 +33,7 @@
 
 public class resume001a {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
 
     static final int PASSED = 0;
     static final int FAILED = 2;
@@ -57,6 +57,7 @@
 
     static int exitCode = PASSED;
 
+    static int testCase    = -1;
     static int instruction = 1;
     static int end         = 0;
                                    //    static int quit        = 0;
@@ -100,6 +101,10 @@
 
                 case 0:
                 TestClass2 obj2 = new TestClass2();
+                // Wait for debugger to complete the first test case
+                // before advancing to the first breakpoint
+                waitForTestCase(0);
+
                 break;
 
                 case 1:
@@ -119,6 +124,16 @@
         log1("debuggee exits");
         System.exit(exitCode + PASS_BASE);
     }
+    // Synchronize with debugger progression.
+    static void waitForTestCase(int t) {
+        while (testCase < t) {
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                // ignored
+            }
+        }
+    }
 }
 
 class TestClass2 {
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java	Fri Sep 07 15:46:39 2018 -0700
@@ -48,9 +48,9 @@
  * To check up on the method, a debugger,                       <BR>
  * upon getting new set for the EventSet,                       <BR>
  * suspends VM with the method VirtualMachine.suspend(),        <BR>
- * gets the List of geduggee's threads calling VM.allThreads(), <BR>
+ * gets the List of debuggee's threads calling VM.allThreads(), <BR>
  * invokes the method EventSet.resume(), and                    <BR>
- * gets another List of geduggee's threads.                     <BR>
+ * gets another List of debuggee's threads.                     <BR>
  * The debugger then compares values of                         <BR>
  * each thread's suspendCount from first and second Lists.      <BR>
  * <BR>
@@ -87,12 +87,12 @@
 
 public class resume002 {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
     static final int PASSED = 0;
     static final int FAILED = 2;
     static final int PASS_BASE = 95;
 
-    //----------------------------------------------------- templete parameters
+    //----------------------------------------------------- template parameters
     static final String
     sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume002 ",
     sHeader2 = "--> debugger: ",
@@ -503,6 +503,7 @@
 
             log2("......--> vm.resume()");
             vm.resume();
+            informDebuggeeTestCase(i);
             //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         }
         log1("    TESTING ENDS");
@@ -642,5 +643,22 @@
             throw new JDITestRuntimeException("** FAILURE to set up AccessWatchpointRequest **");
         }
     }
-
+    /**
+     * Inform debuggee which thread test the debugger has completed.
+     * Used for synchronization, so the debuggee does not move too quickly.
+     * @param testCase index of just completed test
+     */
+    void informDebuggeeTestCase(int testCase) {
+        try {
+            ((ClassType)debuggeeClass)
+                .setValue(debuggeeClass.fieldByName("testCase"),
+                          vm.mirrorOf(testCase));
+        } catch (InvalidTypeException ite) {
+            throw new Failure("** FAILURE setting testCase  **");
+        } catch (ClassNotLoadedException cnle) {
+            throw new Failure("** FAILURE notifying debuggee  **");
+        } catch (VMDisconnectedException e) {
+            throw new Failure("** FAILURE debuggee connection **");
+        }
+    }
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002a.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002a.java	Fri Sep 07 15:46:39 2018 -0700
@@ -33,7 +33,7 @@
 
 public class resume002a {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
 
     static final int PASSED = 0;
     static final int FAILED = 2;
@@ -41,6 +41,7 @@
 
     static ArgumentHandler argHandler;
     static Log log;
+    static int testCase    = -1;
 
     //--------------------------------------------------   log procedures
 
@@ -98,8 +99,12 @@
 
     //------------------------------------------------------  section tested
 
-                    case 0: resume002aTestClass.method();
-                            break;
+                    case 0:
+                        resume002aTestClass.method();
+                        // Wait for debugger to complete the first test case
+                        // before advancing to the first breakpoint
+                        waitForTestCase(0);
+                        break;
 
                     case 1: resume002aTestClass.method();
                             break;
@@ -118,6 +123,17 @@
         log1("debuggee exits");
         System.exit(exitCode + PASS_BASE);
     }
+    // Synchronize with debugger progression.
+    static void waitForTestCase(int t) {
+        while (testCase < t) {
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                // ignored
+            }
+        }
+    }
+
 }
 
 class resume002aTestClass {
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java	Fri Sep 07 15:46:39 2018 -0700
@@ -48,9 +48,9 @@
  * To check up on the method, a debugger,                       <BR>
  * upon getting new set for the EventSet,                       <BR>
  * suspends VM with the method VirtualMachine.suspend(),        <BR>
- * gets the List of geduggee's threads calling VM.allThreads(), <BR>
+ * gets the List of debuggee's threads calling VM.allThreads(), <BR>
  * invokes the method EventSet.resume(), and                    <BR>
- * gets another List of geduggee's threads.                     <BR>
+ * gets another List of debuggee's threads.                     <BR>
  * The debugger then compares values of                         <BR>
  * each thread's suspendCount from first and second Lists.      <BR>
  * <BR>
@@ -87,12 +87,12 @@
 
 public class resume003 {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
     static final int PASSED = 0;
     static final int FAILED = 2;
     static final int PASS_BASE = 95;
 
-    //----------------------------------------------------- templete parameters
+    //----------------------------------------------------- template parameters
     static final String
     sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume003 ",
     sHeader2 = "--> debugger: ",
@@ -503,6 +503,8 @@
 
             log2("......--> vm.resume()");
             vm.resume();
+            informDebuggeeTestCase(i);
+
             //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         }
         log1("    TESTING ENDS");
@@ -642,5 +644,22 @@
             throw new JDITestRuntimeException("** FAILURE to set up ModificationWatchpointRequest **");
         }
     }
-
+    /**
+     * Inform debuggee which thread test the debugger has completed.
+     * Used for synchronization, so the debuggee does not move too quickly.
+     * @param testCase index of just completed test
+     */
+    void informDebuggeeTestCase(int testCase) {
+        try {
+            ((ClassType)debuggeeClass)
+                .setValue(debuggeeClass.fieldByName("testCase"),
+                          vm.mirrorOf(testCase));
+        } catch (InvalidTypeException ite) {
+            throw new Failure("** FAILURE setting testCase  **");
+        } catch (ClassNotLoadedException cnle) {
+            throw new Failure("** FAILURE notifying debuggee  **");
+        } catch (VMDisconnectedException e) {
+            throw new Failure("** FAILURE debuggee connection **");
+        }
+    }
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003a.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003a.java	Fri Sep 07 15:46:39 2018 -0700
@@ -33,7 +33,8 @@
 
 public class resume003a {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
+    static int testCase    = -1;
 
     static final int PASSED = 0;
     static final int FAILED = 2;
@@ -98,8 +99,12 @@
 
     //------------------------------------------------------  section tested
 
-                    case 0: resume003aTestClass.method();
-                            break;
+                    case 0:
+                        resume003aTestClass.method();
+                        // Wait for debugger to complete the first test case
+                        // before advancing to the first breakpoint
+                        waitForTestCase(0);
+                        break;
 
                     case 1: resume003aTestClass.method();
                             break;
@@ -118,6 +123,16 @@
         log1("debuggee exits");
         System.exit(exitCode + PASS_BASE);
     }
+    // Synchronize with debugger progression.
+    static void waitForTestCase(int t) {
+        while (testCase < t) {
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                // ignored
+            }
+        }
+    }
 }
 
 class resume003aTestClass {
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java	Fri Sep 07 15:46:39 2018 -0700
@@ -48,9 +48,9 @@
  * To check up on the method, a debugger,                       <BR>
  * upon getting new set for the EventSet,                       <BR>
  * suspends VM with the method VirtualMachine.suspend(),        <BR>
- * gets the List of geduggee's threads calling VM.allThreads(), <BR>
+ * gets the List of debuggee's threads calling VM.allThreads(), <BR>
  * invokes the method EventSet.resume(), and                    <BR>
- * gets another List of geduggee's threads.                     <BR>
+ * gets another List of debuggee's threads.                     <BR>
  * The debugger then compares values of                         <BR>
  * each thread's suspendCount from first and second Lists.      <BR>
  * <BR>
@@ -87,12 +87,12 @@
 
 public class resume004 {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
     static final int PASSED = 0;
     static final int FAILED = 2;
     static final int PASS_BASE = 95;
 
-    //----------------------------------------------------- templete parameters
+    //----------------------------------------------------- template parameters
     static final String
     sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume004 ",
     sHeader2 = "--> debugger: ",
@@ -493,6 +493,7 @@
 
                   default: throw new JDITestRuntimeException("** default case 1 **");
                 }
+                informDebuggeeTestCase(i);
             }
 
             log2("......--> vm.resume()");
@@ -638,5 +639,22 @@
             throw new JDITestRuntimeException("** FAILURE to set up BreakpointRequest **");
         }
     }
-
+    /**
+     * Inform debuggee which thread test the debugger has completed.
+     * Used for synchronization, so the debuggee does not move too quickly.
+     * @param testCase index of just completed test
+     */
+    void informDebuggeeTestCase(int testCase) {
+        try {
+            ((ClassType)debuggeeClass)
+                .setValue(debuggeeClass.fieldByName("testCase"),
+                          vm.mirrorOf(testCase));
+        } catch (InvalidTypeException ite) {
+            throw new Failure("** FAILURE setting testCase  **");
+        } catch (ClassNotLoadedException cnle) {
+            throw new Failure("** FAILURE notifying debuggee  **");
+        } catch (VMDisconnectedException e) {
+            throw new Failure("** FAILURE debuggee connection **");
+        }
+    }
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004a.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004a.java	Fri Sep 07 15:46:39 2018 -0700
@@ -33,7 +33,8 @@
 
 public class resume004a {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
+    static int testCase    = -1;
 
     static final int PASSED = 0;
     static final int FAILED = 2;
@@ -98,8 +99,10 @@
 
     //------------------------------------------------------  section tested
 
-                    case 0: resume004aTestClass.method();
-                            break;
+                    case 0:
+                        resume004aTestClass.method();
+                        waitForTestCase(0);
+                        break;
 
                     case 1: resume004aTestClass.method();
                             break;
@@ -118,6 +121,16 @@
         log1("debuggee exits");
         System.exit(exitCode + PASS_BASE);
     }
+    // Synchronize with debugger progression.
+    static void waitForTestCase(int t) {
+        while (testCase < t) {
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                // ignored
+            }
+        }
+    }
 }
 
 class resume004aTestClass {
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java	Fri Sep 07 15:46:39 2018 -0700
@@ -48,9 +48,9 @@
  * To check up on the method, a debugger,                       <BR>
  * upon getting new set for the EventSet,                       <BR>
  * suspends VM with the method VirtualMachine.suspend(),        <BR>
- * gets the List of geduggee's threads calling VM.allThreads(), <BR>
+ * gets the List of debuggee's threads calling VM.allThreads(), <BR>
  * invokes the method EventSet.resume(), and                    <BR>
- * gets another List of geduggee's threads.                     <BR>
+ * gets another List of debuggee's threads.                     <BR>
  * The debugger then compares values of                         <BR>
  * each thread's suspendCount from first and second Lists.      <BR>
  * <BR>
@@ -87,12 +87,12 @@
 
 public class resume005 {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
     static final int PASSED = 0;
     static final int FAILED = 2;
     static final int PASS_BASE = 95;
 
-    //----------------------------------------------------- templete parameters
+    //----------------------------------------------------- template parameters
     static final String
     sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume005 ",
     sHeader2 = "--> debugger: ",
@@ -493,6 +493,7 @@
 
                   default: throw new JDITestRuntimeException("** default case 1 **");
                 }
+                informDebuggeeTestCase(i);
             }
 
             log2("......--> vm.resume()");
@@ -634,5 +635,22 @@
             throw new JDITestRuntimeException("** FAILURE to set up ExceptionRequest **");
         }
     }
-
+    /**
+     * Inform debuggee which thread test the debugger has completed.
+     * Used for synchronization, so the debuggee does not move too quickly.
+     * @param testCase index of just completed test
+     */
+    void informDebuggeeTestCase(int testCase) {
+        try {
+            ((ClassType)debuggeeClass)
+                .setValue(debuggeeClass.fieldByName("testCase"),
+                          vm.mirrorOf(testCase));
+        } catch (InvalidTypeException ite) {
+            throw new Failure("** FAILURE setting testCase  **");
+        } catch (ClassNotLoadedException cnle) {
+            throw new Failure("** FAILURE notifying debuggee  **");
+        } catch (VMDisconnectedException e) {
+            throw new Failure("** FAILURE debuggee connection **");
+        }
+    }
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005a.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005a.java	Fri Sep 07 15:46:39 2018 -0700
@@ -33,7 +33,8 @@
 
 public class resume005a {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
+    static int testCase    = -1;
 
     static final int PASSED = 0;
     static final int FAILED = 2;
@@ -98,8 +99,10 @@
 
     //------------------------------------------------------  section tested
 
-                    case 0: resume005aTestClass.method();
-                            break;
+                    case 0:
+                        resume005aTestClass.method();
+                        waitForTestCase(0);
+                        break;
 
                     case 1: resume005aTestClass.method();
                             break;
@@ -122,7 +125,16 @@
     public static void nullMethod() {
         throw new NullPointerException("test");
     }
-
+    // Synchronize with debugger progression.
+    static void waitForTestCase(int t) {
+        while (testCase < t) {
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                // ignored
+            }
+        }
+    }
 }
 
 class resume005aTestClass {
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java	Fri Sep 07 15:46:39 2018 -0700
@@ -48,9 +48,9 @@
  * To check up on the method, a debugger,                       <BR>
  * upon getting new set for the EventSet,                       <BR>
  * suspends VM with the method VirtualMachine.suspend(),        <BR>
- * gets the List of geduggee's threads calling VM.allThreads(), <BR>
+ * gets the List of debuggee's threads calling VM.allThreads(), <BR>
  * invokes the method EventSet.resume(), and                    <BR>
- * gets another List of geduggee's threads.                     <BR>
+ * gets another List of debuggee's threads.                     <BR>
  * The debugger then compares values of                         <BR>
  * each thread's suspendCount from first and second Lists.      <BR>
  * <BR>
@@ -87,12 +87,12 @@
 
 public class resume006 {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
     static final int PASSED = 0;
     static final int FAILED = 2;
     static final int PASS_BASE = 95;
 
-    //----------------------------------------------------- templete parameters
+    //----------------------------------------------------- template parameters
     static final String
     sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume006 ",
     sHeader2 = "--> debugger: ",
@@ -495,6 +495,7 @@
 
             log2("......--> vm.resume()");
             vm.resume();
+            informDebuggeeTestCase(i);
             //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         }
         log1("    TESTING ENDS");
@@ -632,5 +633,22 @@
             throw new JDITestRuntimeException("** FAILURE to set up MethodEntryRequest **");
         }
     }
-
+    /**
+     * Inform debuggee which thread test the debugger has completed.
+     * Used for synchronization, so the debuggee does not move too quickly.
+     * @param testCase index of just completed test
+     */
+    void informDebuggeeTestCase(int testCase) {
+        try {
+            ((ClassType)debuggeeClass)
+                .setValue(debuggeeClass.fieldByName("testCase"),
+                          vm.mirrorOf(testCase));
+        } catch (InvalidTypeException ite) {
+            throw new Failure("** FAILURE setting testCase  **");
+        } catch (ClassNotLoadedException cnle) {
+            throw new Failure("** FAILURE notifying debuggee  **");
+        } catch (VMDisconnectedException e) {
+            throw new Failure("** FAILURE debuggee connection **");
+        }
+    }
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006a.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006a.java	Fri Sep 07 15:46:39 2018 -0700
@@ -33,7 +33,7 @@
 
 public class resume006a {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
 
     static final int PASSED = 0;
     static final int FAILED = 2;
@@ -41,6 +41,7 @@
 
     static ArgumentHandler argHandler;
     static Log log;
+    static int testCase    = -1;
 
     //--------------------------------------------------   log procedures
 
@@ -98,8 +99,12 @@
 
     //------------------------------------------------------  section tested
 
-                    case 0: resume006aTestClass.method();
-                            break;
+                    case 0:
+                        resume006aTestClass.method();
+                        // Wait for debugger to complete the first test case
+                        // before advancing to the next breakpoint
+                        waitForTestCase(0);
+                        break;
 
                     case 1: resume006aTestClass.method();
                             break;
@@ -118,7 +123,16 @@
         log1("debuggee exits");
         System.exit(exitCode + PASS_BASE);
     }
-
+    // Synchronize with debugger progression.
+    static void waitForTestCase(int t) {
+        while (testCase < t) {
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                // ignored
+            }
+        }
+    }
 }
 
 class resume006aTestClass {
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java	Fri Sep 07 15:46:39 2018 -0700
@@ -48,9 +48,9 @@
  * To check up on the method, a debugger,                       <BR>
  * upon getting new set for the EventSet,                       <BR>
  * suspends VM with the method VirtualMachine.suspend(),        <BR>
- * gets the List of geduggee's threads calling VM.allThreads(), <BR>
+ * gets the List of debuggee's threads calling VM.allThreads(), <BR>
  * invokes the method EventSet.resume(), and                    <BR>
- * gets another List of geduggee's threads.                     <BR>
+ * gets another List of debuggee's threads.                     <BR>
  * The debugger then compares values of                         <BR>
  * each thread's suspendCount from first and second Lists.      <BR>
  * <BR>
@@ -87,12 +87,12 @@
 
 public class resume007 {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
     static final int PASSED = Consts.TEST_PASSED;
     static final int FAILED = Consts.TEST_FAILED;
     static final int PASS_BASE = Consts.JCK_STATUS_BASE;
 
-    //----------------------------------------------------- templete parameters
+    //----------------------------------------------------- template parameters
     static final String
     sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume007 ",
     sHeader2 = "--> debugger: ",
@@ -490,6 +490,7 @@
 
                   default: throw new JDITestRuntimeException("** default case 1 **");
                 }
+                informDebuggeeTestCase(i);
             }
 
             log2("......--> vm.resume()");
@@ -631,5 +632,22 @@
             throw new JDITestRuntimeException("** FAILURE to set up MethodExitRequest **");
         }
     }
-
+    /**
+     * Inform debuggee which thread test the debugger has completed.
+     * Used for synchronization, so the debuggee does not move too quickly.
+     * @param testCase index of just completed test
+     */
+    void informDebuggeeTestCase(int testCase) {
+        try {
+            ((ClassType)debuggeeClass)
+                .setValue(debuggeeClass.fieldByName("testCase"),
+                          vm.mirrorOf(testCase));
+        } catch (InvalidTypeException ite) {
+            throw new Failure("** FAILURE setting testCase  **");
+        } catch (ClassNotLoadedException cnle) {
+            throw new Failure("** FAILURE notifying debuggee  **");
+        } catch (VMDisconnectedException e) {
+            throw new Failure("** FAILURE debuggee connection **");
+        }
+    }
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007a.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007a.java	Fri Sep 07 15:46:39 2018 -0700
@@ -33,7 +33,8 @@
 
 public class resume007a {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
+    static int testCase    = -1;
 
     static final int PASSED = 0;
     static final int FAILED = 2;
@@ -98,8 +99,10 @@
 
     //------------------------------------------------------  section tested
 
-                    case 0: resume007aTestClass.method();
-                            break;
+                    case 0:
+                        resume007aTestClass.method();
+                        waitForTestCase(0);
+                        break;
 
                     case 1: resume007aTestClass.method();
                             break;
@@ -118,7 +121,16 @@
         log1("debuggee exits");
         System.exit(exitCode + PASS_BASE);
     }
-
+    // Synchronize with debugger progression.
+    static void waitForTestCase(int t) {
+        while (testCase < t) {
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                // ignored
+            }
+        }
+    }
 }
 
 class resume007aTestClass {
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008.java	Fri Sep 07 15:46:39 2018 -0700
@@ -50,9 +50,9 @@
  * To check up on the method, a debugger,
  * upon getting new set for the EventSet,
  * suspends VM with the method VirtualMachine.suspend(),
- * gets the List of geduggee's threads calling VM.allThreads(),
+ * gets the List of debuggee's threads calling VM.allThreads(),
  * invokes the method EventSet.resume(), and
- * gets another List of geduggee's threads.
+ * gets another List of debuggee's threads.
  * The debugger then compares values of
  * each thread's suspendCount from first and second Lists.
  *
@@ -63,6 +63,13 @@
  *   to be resulting in the event.
  * - Upon getting new event, the debugger
  *   performs the check corresponding to the event.
+ * - The debugger informs the debuggee when it completes
+ *   each test case, so it will wait before hitting
+ *   communication breakpoints.
+ *   This prevents the breakpoint SUSPEND_ALL policy
+ *   disrupting the first test case check for
+ *   SUSPEND_NONE, if the debuggee gets ahead of
+ *   the debugger processing.
  */
 
 public class resume008 extends TestDebuggerType1 {
@@ -124,7 +131,9 @@
             }
 
             display("......waiting for new ThreadStartEvent : " + i);
-            EventSet eventSet = eventHandler.waitForRequestedEventSet(new EventRequest[]{eventRequest}, waitTime, true);
+            EventSet eventSet = eventHandler
+                .waitForRequestedEventSet(new EventRequest[]{eventRequest},
+                                          waitTime, true);
 
             EventIterator eventIterator = eventSet.eventIterator();
             Event newEvent = eventIterator.nextEvent();
@@ -134,7 +143,8 @@
             } else {
 
                 String property = (String) newEvent.request().getProperty("number");
-                display("       got new ThreadStartEvent with propety 'number' == " + property);
+                display("       got new ThreadStartEvent with propety 'number' == "
+                        + property);
 
                 display("......checking up on EventSet.resume()");
                 display("......--> vm.suspend();");
@@ -144,7 +154,8 @@
 
                 Map<String, Integer> suspendsCounts1 = new HashMap<String, Integer>();
                 for (ThreadReference threadReference : vm.allThreads()) {
-                    suspendsCounts1.put(threadReference.name(), threadReference.suspendCount());
+                    suspendsCounts1.put(threadReference.name(),
+                                        threadReference.suspendCount());
                 }
                 display(suspendsCounts1.toString());
 
@@ -154,7 +165,8 @@
                 display("        getting : Map<String, Integer> suspendsCounts2");
                 Map<String, Integer> suspendsCounts2 = new HashMap<String, Integer>();
                 for (ThreadReference threadReference : vm.allThreads()) {
-                    suspendsCounts2.put(threadReference.name(), threadReference.suspendCount());
+                    suspendsCounts2.put(threadReference.name(),
+                                        threadReference.suspendCount());
                 }
                 display(suspendsCounts2.toString());
 
@@ -163,85 +175,90 @@
 
                 switch (policy) {
 
-                  case SUSPEND_NONE   :
-                       display("        case SUSPEND_NONE");
-                       for (String threadName : suspendsCounts1.keySet()) {
-                           display("        checking " + threadName);
-                           if (!suspendsCounts2.containsKey(threadName)) {
-                               complain("ERROR: couldn't get ThreadReference for " + threadName);
-                               testExitCode = TEST_FAILED;
-                               break;
-                           }
-                           int count1 = suspendsCounts1.get(threadName);
-                           int count2 = suspendsCounts2.get(threadName);
-                           if (count1 != count2) {
-                               complain("ERROR: suspendCounts don't match for : " + threadName);
-                               complain("before resuming : " + count1);
-                               complain("after  resuming : " + count2);
-                               testExitCode = TEST_FAILED;
-                               break;
-                           }
-                       }
-                       break;
+                case SUSPEND_NONE   :
+                    display("        case SUSPEND_NONE");
+                    for (String threadName : suspendsCounts1.keySet()) {
+                        display("        checking " + threadName);
+                        if (!suspendsCounts2.containsKey(threadName)) {
+                            complain("ERROR: couldn't get ThreadReference for "
+                                     + threadName);
+                            testExitCode = TEST_FAILED;
+                            break;
+                        }
+                        int count1 = suspendsCounts1.get(threadName);
+                        int count2 = suspendsCounts2.get(threadName);
+                        if (count1 != count2) {
+                            complain("ERROR: suspendCounts don't match for : "
+                                     + threadName);
+                            complain("before resuming : " + count1);
+                            complain("after  resuming : " + count2);
+                            testExitCode = TEST_FAILED;
+                            break;
+                        }
+                    }
+                    break;
 
-                  case SUSPEND_THREAD :
-                       display("        case SUSPEND_THREAD");
-                       for (String threadName : suspendsCounts1.keySet()) {
-                           display("checking " + threadName);
-                           if (!suspendsCounts2.containsKey(threadName)) {
-                               complain("ERROR: couldn't get ThreadReference for " + threadName);
-                               testExitCode = TEST_FAILED;
-                               break;
-                           }
-                           int count1 = suspendsCounts1.get(threadName);
-                           int count2 = suspendsCounts2.get(threadName);
-                           String eventThreadName = ((ThreadStartEvent)newEvent).thread().name();
-                           int expectedValue = count2 + (eventThreadName.equals(threadName) ? 1 : 0);
-                           if (count1 != expectedValue) {
-                               complain("ERROR: suspendCounts don't match for : " + threadName);
-                               complain("before resuming : " + count1);
-                               complain("after  resuming : " + count2);
-                               testExitCode = TEST_FAILED;
-                               break;
-                           }
-                       }
-                       break;
-
-                    case SUSPEND_ALL    :
+                case SUSPEND_THREAD :
+                    display("        case SUSPEND_THREAD");
+                    for (String threadName : suspendsCounts1.keySet()) {
+                        display("checking " + threadName);
+                        if (!suspendsCounts2.containsKey(threadName)) {
+                            complain("ERROR: couldn't get ThreadReference for "
+                                     + threadName);
+                            testExitCode = TEST_FAILED;
+                            break;
+                        }
+                        int count1 = suspendsCounts1.get(threadName);
+                        int count2 = suspendsCounts2.get(threadName);
+                        String eventThreadName = ((ThreadStartEvent)newEvent)
+                            .thread().name();
+                        int expectedValue = count2 +
+                            (eventThreadName.equals(threadName) ? 1 : 0);
+                        if (count1 != expectedValue) {
+                            complain("ERROR: suspendCounts don't match for : "
+                                     + threadName);
+                            complain("before resuming : " + count1);
+                            complain("after  resuming : " + count2);
+                            testExitCode = TEST_FAILED;
+                            break;
+                        }
+                    }
+                    break;
 
-                        display("        case SUSPEND_ALL");
-                        for (String threadName : suspendsCounts1.keySet()) {
-                            display("checking " + threadName);
+                case SUSPEND_ALL    :
+                    display("        case SUSPEND_ALL");
+                    for (String threadName : suspendsCounts1.keySet()) {
+                        display("checking " + threadName);
+                        if (!newEvent.request().equals(eventRequest))
+                            break;
+                        if (!suspendsCounts2.containsKey(threadName)) {
+                            complain("ERROR: couldn't get ThreadReference for "
+                                     + threadName);
+                            testExitCode = TEST_FAILED;
+                            break;
+                        }
+                        int count1 = suspendsCounts1.get(threadName);
+                        int count2 = suspendsCounts2.get(threadName);
+                        if (count1 != count2 + 1) {
+                            complain("ERROR: suspendCounts don't match for : "
+                                     + threadName);
+                            complain("before resuming : " + count1);
+                            complain("after  resuming : " + count2);
+                            testExitCode = TEST_FAILED;
+                            break;
+                        }
+                    }
+                    break;
+                default: throw new Failure("** default case 1 **");
+                }
+                informDebuggeeTestCase(i);
 
-                            if (!newEvent.request().equals(eventRequest))
-                                break;
-                            if (!suspendsCounts2.containsKey(threadName)) {
-                                complain("ERROR: couldn't get ThreadReference for " + threadName);
-                                testExitCode = TEST_FAILED;
-                                break;
-                            }
-                            int count1 = suspendsCounts1.get(threadName);
-                            int count2 = suspendsCounts2.get(threadName);
-                            if (count1 != count2 + 1) {
-                                complain("ERROR: suspendCounts don't match for : " + threadName);
-                                complain("before resuming : " + count1);
-                                complain("after  resuming : " + count2);
-                                testExitCode = TEST_FAILED;
-                                break;
-                            }
-                        }
-                        break;
-
-                     default: throw new Failure("** default case 1 **");
-                }
             }
-
             display("......--> vm.resume()");
             vm.resume();
         }
         return;
     }
-
     private ThreadStartRequest settingThreadStartRequest(int suspendPolicy,
                                                          String property) {
         try {
@@ -254,5 +271,22 @@
             throw new Failure("** FAILURE to set up ThreadStartRequest **");
         }
     }
-
+    /**
+     * Inform debuggee which thread test the debugger has completed.
+     * Used for synchronization, so the debuggee does not move too quickly.
+     * @param testCase index of just completed test
+     */
+    void informDebuggeeTestCase(int testCase) {
+        try {
+            ((ClassType)debuggeeClass)
+                .setValue(debuggeeClass.fieldByName("testCase"),
+                          vm.mirrorOf(testCase));
+        } catch (InvalidTypeException ite) {
+            throw new Failure("** FAILURE setting testCase  **");
+        } catch (ClassNotLoadedException cnle) {
+            throw new Failure("** FAILURE notifying debuggee  **");
+        } catch (VMDisconnectedException e) {
+            throw new Failure("** FAILURE debuggee connection **");
+        }
+    }
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008a.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008a.java	Fri Sep 07 15:46:39 2018 -0700
@@ -33,7 +33,7 @@
 
 public class resume008a {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
 
     static final int PASSED = 0;
     static final int FAILED = 2;
@@ -62,6 +62,7 @@
 
     static int exitCode = PASSED;
 
+    static int testCase    = -1;
     static int instruction = 1;
     static int end         = 0;
                                    //    static int quit        = 0;
@@ -70,6 +71,7 @@
 
     static int lineForComm = 2;
 
+    // Debugger sets a breakpoint here to track debuggee
     private static void methodForCommunication() {
         int i1 = instruction;
         int i2 = i1;
@@ -85,47 +87,38 @@
         log1("debuggee started!");
 
         label0:
-            for (int i = 0; ; i++) {
-
-                if (instruction > maxInstr) {
-                    logErr("ERROR: unexpected instruction: " + instruction);
-                    exitCode = FAILED;
-                    break ;
-                }
-
-                switch (i) {
-
+        for (int i = 0; ; i++) {
+            if (instruction > maxInstr) {
+                logErr("ERROR: unexpected instruction: " + instruction);
+                exitCode = FAILED;
+                break ;
+            }
+            switch (i) {
     //------------------------------------------------------  section tested
-
-                    case 0:
-                            thread0 = new Threadresume008a("thread0");
-                            methodForCommunication();
-
-                            threadStart(thread0);
-
-                            thread1 = new Threadresume008a("thread1");
-                            methodForCommunication();
-                            break;
-
-                    case 1:
-                            threadStart(thread1);
-
-                            thread2 = new Threadresume008a("thread2");
-                            methodForCommunication();
-                            break;
-
-                    case 2:
-                            threadStart(thread2);
-
-    //-------------------------------------------------    standard end section
-
-                    default:
-                                instruction = end;
-                                methodForCommunication();
-                                break label0;
-                }
+            case 0:
+                thread0 = new Threadresume008a("thread0");
+                methodForCommunication();
+                threadStart(thread0);
+                thread1 = new Threadresume008a("thread1");
+                // Wait for debugger to complete the first test case
+                // before advancing to the first breakpoint
+                waitForTestCase(0);
+                methodForCommunication();
+                break;
+            case 1:
+                threadStart(thread1);
+                thread2 = new Threadresume008a("thread2");
+                methodForCommunication();
+                break;
+            case 2:
+                threadStart(thread2);
+            //-------------------------------------------------    standard end section
+            default:
+                instruction = end;
+                methodForCommunication();
+                break label0;
             }
-
+        }
         log1("debuggee exits");
         System.exit(exitCode + PASS_BASE);
     }
@@ -145,24 +138,29 @@
         }
         return PASSED;
     }
-
+    // Synchronize with debugger progression.
+    static void waitForTestCase(int t) {
+        while (testCase < t) {
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                // ignored
+            }
+        }
+    }
     static class Threadresume008a extends Thread {
-
         String tName = null;
-
         public Threadresume008a(String threadName) {
             super(threadName);
             tName = threadName;
         }
-
         public void run() {
             log1("  'run': enter  :: threadName == " + tName);
             synchronized (waitnotifyObj) {
-                    waitnotifyObj.notify();
+                waitnotifyObj.notify();
             }
             log1("  'run': exit   :: threadName == " + tName);
             return;
         }
     }
-
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009.java	Fri Sep 07 15:46:39 2018 -0700
@@ -50,9 +50,9 @@
  * To check up on the method, a debugger,
  * upon getting new set for the EventSet,
  * suspends VM with the method VirtualMachine.suspend(),
- * gets the List of geduggee's threads calling VM.allThreads(),
+ * gets the List of debuggee's threads calling VM.allThreads(),
  * invokes the method EventSet.resume(), and
- * gets another List of geduggee's threads.
+ * gets another List of debuggee's threads.
  * The debugger then compares values of
  * each thread's suspendCount from first and second Lists.
  *
@@ -63,6 +63,13 @@
  *   to be resulting in the event.
  * - Upon getting new event, the debugger
  *   performs the check corresponding to the event.
+ * - The debugger informs the debuggee when it completes
+ *   each test case, so it will wait before hitting
+ *   communication breakpoints.
+ *   This prevents the breakpoint SUSPEND_ALL policy
+ *   disrupting the first test case check for
+ *   SUSPEND_NONE, if the debuggee gets ahead of
+ *   the debugger processing.
  */
 
 public class resume009 extends TestDebuggerType1 {
@@ -233,6 +240,7 @@
 
                      default: throw new Failure("** default case 1 **");
                 }
+                informDebuggeeTestCase(i);
             }
 
             display("......--> vm.resume()");
@@ -253,5 +261,22 @@
             throw new Failure("** FAILURE to set up ThreadDeathRequest **");
         }
     }
-
+    /**
+     * Inform debuggee which thread test the debugger has completed.
+     * Used for synchronization, so the debuggee does not move too quickly.
+     * @param testCase index of just completed test
+     */
+    void informDebuggeeTestCase(int testCase) {
+        try {
+            ((ClassType)debuggeeClass)
+                .setValue(debuggeeClass.fieldByName("testCase"),
+                          vm.mirrorOf(testCase));
+        } catch (InvalidTypeException ite) {
+            throw new Failure("** FAILURE setting testCase  **");
+        } catch (ClassNotLoadedException cnle) {
+            throw new Failure("** FAILURE notifying debuggee  **");
+        } catch (VMDisconnectedException e) {
+            throw new Failure("** FAILURE debuggee connection **");
+        }
+    }
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009a.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009a.java	Fri Sep 07 15:46:39 2018 -0700
@@ -33,7 +33,7 @@
 
 public class resume009a {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
 
     static final int PASSED = 0;
     static final int FAILED = 2;
@@ -62,6 +62,7 @@
 
     static int exitCode = PASSED;
 
+    static int testCase    = -1;
     static int instruction = 1;
     static int end         = 0;
                                    //    static int quit        = 0;
@@ -104,6 +105,9 @@
                             threadRun(thread0);
 
                             thread1 = new Threadresume009a("thread1");
+                            // Wait for debugger to complete the first test case
+                            // before advancing to the first breakpoint
+                            waitForTestCase(0);
                             methodForCommunication();
                             break;
 
@@ -152,6 +156,16 @@
         }
         return PASSED;
     }
+    // Synchronize with debugger progression.
+    static void waitForTestCase(int t) {
+        while (testCase < t) {
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                // ignored
+            }
+        }
+    }
 
     static class Threadresume009a extends Thread {
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java	Fri Sep 07 15:46:39 2018 -0700
@@ -48,9 +48,9 @@
  * To check up on the method, a debugger,                       <BR>
  * upon getting new set for the EventSet,                       <BR>
  * suspends VM with the method VirtualMachine.suspend(),        <BR>
- * gets the List of geduggee's threads calling VM.allThreads(), <BR>
+ * gets the List of debuggee's threads calling VM.allThreads(), <BR>
  * invokes the method EventSet.resume(), and                    <BR>
- * gets another List of geduggee's threads.                     <BR>
+ * gets another List of debuggee's threads.                     <BR>
  * The debugger then compares values of                         <BR>
  * each thread's suspendCount from first and second Lists.      <BR>
  * <BR>
@@ -87,12 +87,12 @@
 
 public class resume010 {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
     static final int PASSED = 0;
     static final int FAILED = 2;
     static final int PASS_BASE = 95;
 
-    //----------------------------------------------------- templete parameters
+    //----------------------------------------------------- template parameters
     static final String
     sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume010 ",
     sHeader2 = "--> debugger: ",
@@ -488,6 +488,7 @@
                     default:
                         throw new JDITestRuntimeException("** default case 1 **");
                 }
+                informDebuggeeTestCase(i);
             }
 
             log2("......--> vm.resume()");
@@ -627,5 +628,22 @@
             throw new JDITestRuntimeException("** FAILURE to set up StepRequest **");
         }
     }
-
+    /**
+     * Inform debuggee which thread test the debugger has completed.
+     * Used for synchronization, so the debuggee does not move too quickly.
+     * @param testCase index of just completed test
+     */
+    void informDebuggeeTestCase(int testCase) {
+        try {
+            ((ClassType)debuggeeClass)
+                .setValue(debuggeeClass.fieldByName("testCase"),
+                          vm.mirrorOf(testCase));
+        } catch (InvalidTypeException ite) {
+            throw new Failure("** FAILURE setting testCase  **");
+        } catch (ClassNotLoadedException cnle) {
+            throw new Failure("** FAILURE notifying debuggee  **");
+        } catch (VMDisconnectedException e) {
+            throw new Failure("** FAILURE debuggee connection **");
+        }
+    }
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010a.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010a.java	Fri Sep 07 15:46:39 2018 -0700
@@ -33,7 +33,7 @@
 
 public class resume010a {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
 
     static final int PASSED = 0;
     static final int FAILED = 2;
@@ -60,6 +60,7 @@
 
     static int exitCode = PASSED;
 
+    static int testCase    = -1;
     static int instruction = 1;
     static int end         = 0;
                                    //    static int quit        = 0;
@@ -98,8 +99,12 @@
 
     //------------------------------------------------------  section tested
 
-                    case 0: resume010aTestClass.method();
-                            break;
+                    case 0:
+                        resume010aTestClass.method();
+                        // Wait for debugger to complete the first test case
+                        // before advancing to the first breakpoint
+                        waitForTestCase(0);
+                        break;
 
                     case 1: resume010aTestClass.method();
                             break;
@@ -117,7 +122,16 @@
 
         System.exit(exitCode + PASS_BASE);
     }
-
+    // Synchronize with debugger progression.
+    static void waitForTestCase(int t) {
+        while (testCase < t) {
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                // ignored
+            }
+        }
+    }
 }
 class resume010aTestClass {
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn004/libforceEarlyReturn004a.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn004/libforceEarlyReturn004a.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -23,25 +23,8 @@
 
 #include "jni.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_PTR
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG_2(x, y) y
-#define JNI_ENV_ARG_3(x, y, z) y, z
-#define JNI_ENV_ARG_4(x, y, z, a) y, z, a
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG_2(x,y) x, y
-#define JNI_ENV_ARG_3(x, y, z) x, y, z
-#define JNI_ENV_ARG_4(x, y, z, a) x, y, z, a
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 int always_true = 1;
 
@@ -50,9 +33,9 @@
 {
     int dummy_counter = 0;
     // notify another thread that thread in native method
-    jclass klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, object));
-    jfieldID field = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG_4(env, klass, "threadInNative", "Z"));
-    JNI_ENV_PTR(env)->SetBooleanField(JNI_ENV_ARG_4(env, object, field, 1));
+    jclass klass = env->GetObjectClass(object);
+    jfieldID field = env->GetFieldID(klass, "threadInNative", "Z");
+    env->SetBooleanField(object, field, 1);
 
     // execute infinite loop to be sure that thread in native method
     while(always_true)
@@ -66,6 +49,4 @@
     return dummy_counter >= 0 ? 0 : 1;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn005/libforceEarlyReturn005a.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/forceEarlyReturn/forceEarlyReturn005/libforceEarlyReturn005a.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -24,37 +24,22 @@
 #include "jni.h"
 #include "nsk_tools.cpp"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_PTR
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG_2(x, y) y
-#define JNI_ENV_ARG_3(x,y,z) y, z
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG_2(x,y) x, y
-#define JNI_ENV_ARG_3(x,y,z) x, y, z
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 JNIEXPORT void JNICALL
 Java_nsk_jdi_ThreadReference_forceEarlyReturn_forceEarlyReturn005_forceEarlyReturn005a_nativeJNIMonitorEnter(JNIEnv *env, jobject classObject, jobject object)
 {
-        jint success  = JNI_ENV_PTR(env)->MonitorEnter(JNI_ENV_ARG_2(env, object));
+        jint success  = env->MonitorEnter(object);
 
         if(success != 0)
         {
                 NSK_COMPLAIN1("MonitorEnter return non-zero: %d\n", success);
 
-                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "MonitorEnter return non-zero"));
+                env->ThrowNew(
+                    env->FindClass("nsk/share/TestJNIError"),
+                    "MonitorEnter return non-zero");
         }
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/libforceEarlyReturn002a.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/libforceEarlyReturn002a.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -23,25 +23,8 @@
 
 #include "jni.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_PTR
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG_2(x, y) y
-#define JNI_ENV_ARG_3(x, y, z) y, z
-#define JNI_ENV_ARG_4(x, y, z, a) y, z, a
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG_2(x,y) x, y
-#define JNI_ENV_ARG_3(x, y, z) x, y, z
-#define JNI_ENV_ARG_4(x, y, z, a) x, y, z, a
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 int always_true = 1;
 
@@ -50,9 +33,9 @@
 {
     int dummy_counter = 0;
     // notify another thread that thread in native method
-    jclass klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, object));
-    jfieldID field = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG_4(env, klass, "threadInNative", "Z"));
-    JNI_ENV_PTR(env)->SetBooleanField(JNI_ENV_ARG_4(env, object, field, 1));
+    jclass klass = env->GetObjectClass(object);
+    jfieldID field = env->GetFieldID(klass, "threadInNative", "Z");
+    env->SetBooleanField(object, field, 1);
 
     // execute infinite loop to be sure that thread in native method
     while(always_true)
@@ -66,6 +49,4 @@
     return dummy_counter >= 0 ? 0 : 1;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAllThreads/allthr001/allthr001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAllThreads/allthr001/allthr001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -28,21 +28,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED  0
 #define STATUS_FAILED  2
@@ -70,11 +57,9 @@
     jclass thrClass;
     jmethodID cid;
     jthread res;
-    thrClass = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-         "java/lang/Thread"));
-    cid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, thrClass),
-        "<init>", "()V");
-    res = JNI_ENV_PTR(env)->NewObject(JNI_ENV_ARG(env, thrClass), cid);
+    thrClass = env->FindClass("java/lang/Thread");
+    cid = env->GetMethodID(thrClass, "<init>", "()V");
+    res = env->NewObject(thrClass, cid);
     return res;
 }
 
@@ -143,8 +128,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -313,6 +297,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAllThreads/allthr002/allthr002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAllThreads/allthr002/allthr002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -116,6 +102,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize001/argsize001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize001/argsize001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -26,21 +26,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -54,10 +41,9 @@
     jint ret_size;
 
     if (stat) {
-        mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cl),
-            name, sig);
+        mid = env->GetStaticMethodID(cl, name, sig);
     } else {
-        mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cl), name, sig);
+        mid = env->GetMethodID(cl, name, sig);
     }
     if (mid == NULL) {
         printf("Name = %s, sig = %s: mid = 0\n", name, sig);
@@ -89,8 +75,7 @@
 jint  Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
     jint res;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -114,6 +99,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize002/argsize002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize002/argsize002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -89,7 +75,7 @@
         return STATUS_FAILED;
     }
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls), "<init>", "()V");
+    mid = env->GetMethodID(cls, "<init>", "()V");
     if (mid == NULL) {
         printf("Cannot get method ID for \"<init>\"!\n");
         return STATUS_FAILED;
@@ -115,8 +101,7 @@
         result = STATUS_FAILED;
     }
 
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-        "check", "()I");
+    mid = env->GetStaticMethodID(cls, "check", "()I");
     if (mid == NULL) {
         printf("Cannot get method ID for \"check\"!\n");
         return STATUS_FAILED;
@@ -139,6 +124,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAvailableProcessors/getavailproc001/getavailproc001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAvailableProcessors/getavailproc001/getavailproc001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -28,9 +28,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -185,6 +183,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes001/bytecodes001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes001/bytecodes001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -87,8 +74,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -142,10 +128,10 @@
     }
 
     if (meth_tab[meth_ind].stat == JNI_TRUE) {
-        mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cl),
+        mid = env->GetStaticMethodID(cl,
             meth_tab[meth_ind].name, meth_tab[meth_ind].sig);
     } else {
-        mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cl),
+        mid = env->GetMethodID(cl,
             meth_tab[meth_ind].name, meth_tab[meth_ind].sig);
     }
     if (mid == NULL) {
@@ -194,6 +180,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes002/bytecodes002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes002/bytecodes002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -70,8 +57,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -123,8 +109,7 @@
         return STATUS_FAILED;
     }
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls),
-        "<init>", "()V");
+    mid = env->GetMethodID(cls, "<init>", "()V");
     if (mid == NULL) {
         printf("Cannot get method ID for \"<init>\"!\n");
         return STATUS_FAILED;
@@ -166,8 +151,7 @@
         result = STATUS_FAILED;
     }
 
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-        "check", "()I");
+    mid = env->GetStaticMethodID(cls, "check", "()I");
     if (mid == NULL) {
         printf("Cannot get method ID for \"check\"!\n");
         return STATUS_FAILED;
@@ -190,6 +174,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes003/bytecodes003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes003/bytecodes003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -366,8 +353,7 @@
             name = NULL;
             msig = NULL;
             bytecodes = NULL;
-            err = jvmti_env->GetMethodName(methods[i],
-                &name, &msig, NULL);
+            err = jvmti_env->GetMethodName(methods[i], &name, &msig, NULL);
             if (err != JVMTI_ERROR_NONE) {
                 printf("(GetMethodName) unexpected error: %s (%d)\n",
                        TranslateError(err), err);
@@ -446,8 +432,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -535,6 +520,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCapabilities/getcaps001/getcaps001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCapabilities/getcaps001/getcaps001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -104,6 +90,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCapabilities/getcaps002/getcaps002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCapabilities/getcaps002/getcaps002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -28,9 +28,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -325,6 +323,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld005/getclfld005.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld005/getclfld005.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -126,6 +112,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld006/getclfld006.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld006/getclfld006.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -112,6 +98,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld007/getclfld007.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld007/getclfld007.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -128,8 +115,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -201,6 +187,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr001/getclsldr001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr001/getclsldr001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -115,6 +101,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr002/getclsldr002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr002/getclsldr002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -121,6 +107,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr003/getclsldr003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr003/getclsldr003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -109,8 +95,7 @@
         printf(">>> %s - 0x%p\n", sig, classloader);
     }
 
-    if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, classloader),
-            cl) != JNI_TRUE) {
+    if (env->IsSameObject(classloader, cl) != JNI_TRUE) {
         printf("(%s) unexpected class loader\n", sig);
         result = STATUS_FAILED;
     }
@@ -121,6 +106,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss001/clsldrclss001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss001/clsldrclss001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -134,6 +120,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss002/clsldrclss002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss002/clsldrclss002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "agent_common.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ========================================================================== */
 
@@ -229,6 +227,4 @@
 
 /* ========================================================================== */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd005/getclmthd005.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd005/getclmthd005.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -126,6 +112,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd006/getclmthd006.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd006/getclmthd006.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -112,6 +98,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd007/getclmthd007.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd007/getclmthd007.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -140,8 +127,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -224,6 +210,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf004/getclmdf004.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf004/getclmdf004.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -115,6 +101,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf005/getclmdf005.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf005/getclmdf005.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -74,8 +61,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -137,6 +123,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf006/getclmdf006.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf006/getclmdf006.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -78,8 +65,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -138,6 +124,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf007/getclmdf007.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf007/getclmdf007.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -78,8 +65,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -160,6 +146,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig004/getclsig004.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig004/getclsig004.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -80,8 +67,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -125,6 +111,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig005/getclsig005.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig005/getclsig005.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -69,8 +56,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -139,6 +125,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig006/getclsig006.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig006/getclsig006.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -31,9 +31,7 @@
 #include "JVMTITools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 #define CLS_NUM 5 /* overall number of tested classes */
 
@@ -145,6 +143,4 @@
     return JNI_OK;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat005/getclstat005.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat005/getclstat005.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -115,6 +101,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat006/getclstat006.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat006/getclstat006.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -77,8 +64,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -120,6 +106,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat007/getclstat007.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat007/getclstat007.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -155,6 +141,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentContendedMonitor/contmon001/contmon001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentContendedMonitor/contmon001/contmon001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -65,8 +52,7 @@
     jvmtiError err;
     jint res;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -123,8 +109,7 @@
         printf("(GetCurrentContendedMonitor#%d) unexpected error: %s (%d)\n",
                point, TranslateError(err), err);
         result = STATUS_FAILED;
-    } else if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, lock), mon)
-                == JNI_FALSE) {
+    } else if (env->IsSameObject(lock, mon) == JNI_FALSE) {
         printf("(IsSameObject#%d) unexpected monitor object: 0x%p\n",
                point, mon);
         result = STATUS_FAILED;
@@ -135,6 +120,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentContendedMonitor/contmon002/contmon002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentContendedMonitor/contmon002/contmon002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -65,8 +52,7 @@
     jint res;
     jvmtiError err;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -133,6 +119,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentContendedMonitor/contmon003/contmon003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentContendedMonitor/contmon003/contmon003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -70,8 +57,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -155,6 +141,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentThreadCpuTime/curthrcputime001/curthrcputime001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentThreadCpuTime/curthrcputime001/curthrcputime001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -28,9 +28,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -376,6 +374,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentThreadCpuTimerInfo/curthrtimerinfo001/curthrtimerinfo001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentThreadCpuTimerInfo/curthrtimerinfo001/curthrtimerinfo001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -28,9 +28,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -298,6 +296,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetEnv/GetEnv001/GetEnv001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetEnv/GetEnv001/GetEnv001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -29,9 +29,7 @@
 #include <jvmti_tools.h>
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -152,6 +150,4 @@
     return JNI_OK;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetEnvironmentLocalStorage/getenvstor001/getenvstor001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetEnvironmentLocalStorage/getenvstor001/getenvstor001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -28,9 +28,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -186,6 +184,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetErrorName/geterrname001/geterrname001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetErrorName/geterrname001/geterrname001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "agent_common.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ========================================================================== */
 
@@ -316,6 +314,4 @@
 
 /* ========================================================================== */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetErrorName/geterrname002/geterrname002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetErrorName/geterrname002/geterrname002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -26,9 +26,7 @@
 #include "agent_common.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ========================================================================== */
 
@@ -103,6 +101,4 @@
 
 /* ========================================================================== */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetExtensionEvents/extevents001/extevents001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetExtensionEvents/extevents001/extevents001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 
 /* min and max values defined in jvmtiParamTypes */
@@ -292,6 +290,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetExtensionFunctions/extfuncs001/extfuncs001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetExtensionFunctions/extfuncs001/extfuncs001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* min and max values defined in jvmtiParamTypes */
 #define PARAM_TYPE_MIN_VALUE 101
@@ -303,6 +301,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl001/getfldecl001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl001/getfldecl001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x,y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x,y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -69,8 +56,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -94,11 +80,9 @@
     }
 
     if (i == 0) {
-        fid = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG(env, cls1),
-            fields[i], "I");
+        fid = env->GetStaticFieldID(cls1, fields[i], "I");
     } else {
-        fid = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG(env, cls1),
-            fields[i], "I");
+        fid = env->GetFieldID(cls1, fields[i], "I");
     }
     if (fid == NULL) {
         printf("(%d) cannot get field ID for %s:\"I\"\n", i, fields[i]);
@@ -126,8 +110,7 @@
         printf(">>> %d -- %s: \"%s\"\n", i, fields[i], sig);
     }
 
-    if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, cls2),
-            declaringClass) != JNI_TRUE) {
+    if (env->IsSameObject(cls2, declaringClass) != JNI_TRUE) {
         printf("(%d) unexpected declaringClass: %s\n", i, sig);
         result = STATUS_FAILED;
     }
@@ -139,6 +122,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl002/getfldecl002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl002/getfldecl002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x,y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x,y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -69,8 +56,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -94,11 +80,9 @@
     }
 
     if (i == 0) {
-        fid = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG(env, cls1),
-            fields[i], "I");
+        fid = env->GetStaticFieldID(cls1, fields[i], "I");
     } else {
-        fid = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG(env, cls1),
-            fields[i], "I");
+        fid = env->GetFieldID(cls1, fields[i], "I");
     }
     if (fid == NULL) {
         printf("(%d) cannot get field ID for %s:\"I\"\n", i, fields[i]);
@@ -126,8 +110,7 @@
         printf(">>> %d -- %s: \"%s\"\n", i, fields[i], sig);
     }
 
-    if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, cls2),
-            declaringClass) != JNI_TRUE) {
+    if (env->IsSameObject(cls2, declaringClass) != JNI_TRUE) {
         printf("(%d) unexpected declaringClass: %s\n", i, sig);
         result = STATUS_FAILED;
     }
@@ -137,6 +120,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl004/getfldecl004.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl004/getfldecl004.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -88,8 +75,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -113,11 +99,9 @@
     }
 
     if (fields[i].is_static == JNI_TRUE) {
-        fid = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG(env, cls1),
-            fields[i].name, fields[i].sig);
+        fid = env->GetStaticFieldID(cls1, fields[i].name, fields[i].sig);
     } else {
-        fid = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG(env, cls1),
-            fields[i].name, fields[i].sig);
+        fid = env->GetFieldID(cls1, fields[i].name, fields[i].sig);
     }
     if (fid == NULL) {
         printf("(%d) cannot get field ID for %s:\"%s\"\n",
@@ -146,8 +130,7 @@
         printf(">>> %d -- %s: \"%s\"\n", i, fields[i].name, sig);
     }
 
-    if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, cls2),
-            declaringClass) != JNI_TRUE) {
+    if (env->IsSameObject(cls2, declaringClass) != JNI_TRUE) {
         printf("(%d) unexpected declaringClass: %s\n", i, sig);
         result = STATUS_FAILED;
     }
@@ -157,6 +140,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf003/getfldmdf003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf003/getfldmdf003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -89,7 +75,7 @@
         return STATUS_FAILED;
     }
 
-    fid = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG(env, cls), "fld", "I");
+    fid = env->GetFieldID(cls, "fld", "I");
     if (fid == NULL) {
         printf("Cannot get field ID!\n");
         return STATUS_FAILED;
@@ -132,6 +118,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf004/getfldmdf004.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf004/getfldmdf004.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -138,8 +125,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -178,11 +164,9 @@
     }
 
     if (fields[i].is_static == JNI_TRUE) {
-        fid = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG(env, cls),
-            fields[i].name, fields[i].sig);
+        fid = env->GetStaticFieldID(cls, fields[i].name, fields[i].sig);
     } else {
-        fid = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG(env, cls),
-            fields[i].name, fields[i].sig);
+        fid = env->GetFieldID(cls, fields[i].name, fields[i].sig);
     }
     if (fid == NULL) {
         printf("(%d) cannot get field ID for %s:\"%s\"\n",
@@ -218,6 +202,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm003/getfldnm003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm003/getfldnm003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -89,7 +75,7 @@
         return STATUS_FAILED;
     }
 
-    field = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG(env, cls), "fld", "I");
+    field = env->GetFieldID(cls, "fld", "I");
     if (field == NULL) {
         printf("Cannot get field ID!\n");
         return STATUS_FAILED;
@@ -180,6 +166,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm004/getfldnm004.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm004/getfldnm004.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -28,21 +28,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -98,8 +85,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -123,11 +109,11 @@
 
     for (i = 0; i < sizeof(fields)/sizeof(field_info); i++) {
         if (fields[i].is_static == JNI_TRUE) {
-            fid = JNI_ENV_PTR(env)->GetStaticFieldID(
-                JNI_ENV_ARG(env, clazz), fields[i].name, fields[i].sig);
+            fid = env->GetStaticFieldID(
+                clazz, fields[i].name, fields[i].sig);
         } else {
-            fid = JNI_ENV_PTR(env)->GetFieldID(
-                JNI_ENV_ARG(env, clazz), fields[i].name, fields[i].sig);
+            fid = env->GetFieldID(
+                clazz, fields[i].name, fields[i].sig);
         }
         if (fid == NULL) {
             printf("(%" PRIuPTR ") cannot get field ID for %s:\"%s\"\n",
@@ -160,6 +146,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm005/getfldnm005.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm005/getfldnm005.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -31,9 +31,7 @@
 #include "JVMTITools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 #define FLDS_NUM 12 /* overall number of tested fields */
 
@@ -202,6 +200,4 @@
     return JNI_OK;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameCount/framecnt001/framecnt001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameCount/framecnt001/framecnt001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -65,8 +52,7 @@
     jvmtiError err;
     jint res;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -141,6 +127,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameCount/framecnt002/framecnt002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameCount/framecnt002/framecnt002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -63,8 +50,7 @@
 jint  Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
     jint res;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -99,6 +85,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameCount/framecnt003/framecnt003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameCount/framecnt003/framecnt003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -63,8 +50,7 @@
 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
     jint res;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -93,6 +79,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameLocation/frameloc001/frameloc001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameLocation/frameloc001/frameloc001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -62,8 +49,7 @@
     char *meth, *sig, *generic;
     jboolean isOk = JNI_FALSE;
 
-    err = jvmti_env->GetMethodName(exp_mid,
-        &meth, &sig, &generic);
+    err = jvmti_env->GetMethodName(exp_mid, &meth, &sig, &generic);
     if (err != JVMTI_ERROR_NONE) {
         printf("(GetMethodName) unexpected error: %s (%d)\n",
                TranslateError(err), err);
@@ -115,8 +101,7 @@
     jint res;
     jvmtiError err;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -177,8 +162,7 @@
         return;
     }
 
-    mid1 = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, klass),
-        "meth01", "(I)V");
+    mid1 = env->GetMethodID(klass, "meth01", "(I)V");
     if (mid1 == NULL) {
         printf("Cannot get jmethodID for method \"meth01\"\n");
         result = STATUS_FAILED;
@@ -205,7 +189,7 @@
         return JNI_TRUE;
     }
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, klass), "run", "()V");
+    mid = env->GetMethodID(klass, "run", "()V");
     if (mid == NULL) {
         printf("Cannot get jmethodID for method \"run\"\n");
         result = STATUS_FAILED;
@@ -241,6 +225,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameLocation/frameloc002/frameloc002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameLocation/frameloc002/frameloc002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -28,21 +28,8 @@
 #include "jni_tools.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -79,8 +66,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -175,6 +161,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameLocation/frameloc003/frameloc003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameLocation/frameloc003/frameloc003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -70,8 +57,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -181,6 +167,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf005/getintrf005.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf005/getintrf005.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -126,6 +112,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf006/getintrf006.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf006/getintrf006.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -112,6 +98,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf007/getintrf007.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf007/getintrf007.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -112,8 +99,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -182,6 +168,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt001/getjlocfmt001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt001/getjlocfmt001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "agent_common.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ========================================================================== */
 
@@ -224,6 +222,4 @@
 
 /* ========================================================================== */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt002/getjlocfmt002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt002/getjlocfmt002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -26,9 +26,7 @@
 #include "agent_common.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ========================================================================== */
 
@@ -97,6 +95,4 @@
 
 /* ========================================================================== */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab001/getjniftab001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab001/getjniftab001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -32,19 +32,8 @@
 #include "JVMTITools.h"
 #include "native_thread.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
-#ifndef JNI_ENV_ARG
-  #ifdef __cplusplus
-    #define JNI_ENV_ARG(x, y) y
-    #define JNI_ENV_PTR(x) x
-  #else
-    #define JNI_ENV_ARG(x, y) x, y
-    #define JNI_ENV_PTR(x) (*x)
-  #endif
-#endif
 
 #ifndef JNI_ENV_ARG1
   #ifdef __cplusplus
@@ -95,16 +84,14 @@
         result = STATUS_FAILED;
         printf("(%s,%d): TEST FAILED: failed to get original JNI function table: %s\n",
             __FILE__, __LINE__, TranslateError(err));
-        JNI_ENV_PTR(env)->FatalError(JNI_ENV_ARG(env,
-            "failed to get original JNI function table"));
+        env->FatalError("failed to get original JNI function table");
     }
     if ((err = jvmti->GetJNIFunctionTable(&redir_jni_functions)) !=
             JVMTI_ERROR_NONE) {
         result = STATUS_FAILED;
         printf("(%s,%d): TEST FAILED: failed to get redirected JNI function table: %s\n",
             __FILE__, __LINE__, TranslateError(err));
-        JNI_ENV_PTR(env)->FatalError(JNI_ENV_ARG(env,
-            "failed to get redirected JNI function table"));
+        env->FatalError("failed to get redirected JNI function table");
     }
     if (verbose)
         printf("doRedirect: the JNI function table obtained successfully\n");
@@ -118,8 +105,7 @@
         result = STATUS_FAILED;
         printf("(%s,%d): TEST FAILED: failed to get new JNI function table: %s\n",
             __FILE__, __LINE__, TranslateError(err));
-        JNI_ENV_PTR(env)->FatalError(JNI_ENV_ARG(env,
-            "failed to get new JNI function table"));
+        env->FatalError("failed to get new JNI function table");
     }
 
     if (verbose)
@@ -136,8 +122,7 @@
         result = STATUS_FAILED;
         printf("(%s,%d): TEST FAILED: failed to restore original JNI function table: %s\n",
             __FILE__, __LINE__, TranslateError(err));
-        JNI_ENV_PTR(env)->FatalError(JNI_ENV_ARG(env,
-            "failed to restore original JNI function table"));
+        env->FatalError("failed to restore original JNI function table");
     }
     if (verbose)
         printf("doRestore: the original JNI function table is restored successfully\n");
@@ -155,8 +140,7 @@
         result = STATUS_FAILED;
         printf("(%s,%d): TEST FAILED: failed to get modified JNI function table: %s\n",
             __FILE__, __LINE__, TranslateError(err));
-        JNI_ENV_PTR(env)->FatalError(JNI_ENV_ARG(env,
-            "failed to get modified JNI function table"));
+        env->FatalError("failed to get modified JNI function table");
     }
     if (verbose)
         printf("checkRedir: the JNI function table obtained successfully\n\tcalling GetVersion() ...\n");
@@ -222,8 +206,7 @@
     if (verbose)
         printf("verbose mode on\n");
 
-    res = JNI_ENV_PTR(jvm)->
-        GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("(%s,%d): Failed to call GetEnv\n", __FILE__, __LINE__);
         return JNI_ERR;
@@ -232,6 +215,4 @@
     return JNI_OK;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab002/getjniftab002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab002/getjniftab002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,19 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
-#ifndef JNI_ENV_ARG
-  #ifdef __cplusplus
-    #define JNI_ENV_ARG(x, y) y
-    #define JNI_ENV_PTR(x) x
-  #else
-    #define JNI_ENV_ARG(x, y) x, y
-    #define JNI_ENV_PTR(x) (*x)
-  #endif
-#endif
 
 #ifndef JNI_ENV_ARG1
   #ifdef __cplusplus
@@ -100,9 +89,7 @@
        only since JDK 1.2 */
     if (verbose)
         printf("\nb) Checking the function with the detached thread ...\n\ndetaching the main thread ...\n");
-    if ((err =
-            JNI_ENV_PTR(vm)->DetachCurrentThread(
-                JNI_ENV_ARG1(vm))) != 0)
+    if ((err = vm->DetachCurrentThread(JNI_ENV_ARG1(vm))) != 0)
         printf("(%s,%d): Warning: DetachCurrentThread() returns: %d\n\
 \tcheck with the detached main thread skipped\n",
             __FILE__, __LINE__, err);
@@ -111,9 +98,7 @@
 
         if (verbose)
             printf("\nattaching the main thread back ...\n");
-        if ((err =
-                JNI_ENV_PTR(vm)->AttachCurrentThread(
-                    JNI_ENV_ARG(vm, (void **) &nextEnv), (void *) 0)) != 0) {
+        if ((err = vm->AttachCurrentThread((void **) &nextEnv, (void *) 0)) != 0) {
             printf("(%s,%d): TEST FAILURE: waitingThread: AttachCurrentThread() returns: %d\n",
                 __FILE__, __LINE__, err);
             return STATUS_FAILED;
@@ -143,8 +128,7 @@
     if (verbose)
         printf("verbose mode on\n");
 
-    res = JNI_ENV_PTR(jvm)->
-        GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("(%s,%d): Failed to call GetEnv\n", __FILE__, __LINE__);
         return JNI_ERR;
@@ -155,6 +139,4 @@
     return JNI_OK;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab001/linetab001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab001/linetab001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -76,11 +63,9 @@
     jvmtiLineNumberEntry *exp_table = meth_tab[meth_ind].table;
 
     if (stat) {
-        mid = JNI_ENV_PTR(env)->
-            GetStaticMethodID(JNI_ENV_ARG(env, cl), name, sig);
+        mid = env->GetStaticMethodID(cl, name, sig);
     } else {
-        mid = JNI_ENV_PTR(env)->
-            GetMethodID(JNI_ENV_ARG(env, cl), name, sig);
+        mid = env->GetMethodID(cl, name, sig);
     }
     if (mid == NULL) {
         printf("Name = %s, sig = %s: mid = NULL\n", name, sig);
@@ -146,8 +131,7 @@
     jvmtiError err;
     jint res;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -188,6 +172,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab002/linetab002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab002/linetab002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -70,8 +57,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -121,7 +107,7 @@
         return result;
     }
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls), "<init>", "()V");
+    mid = env->GetMethodID(cls, "<init>", "()V");
     if (mid == NULL) {
         printf("Cannot get method ID!\n");
         return STATUS_FAILED;
@@ -164,6 +150,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab003/linetab003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab003/linetab003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -70,8 +57,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -122,7 +108,7 @@
         return result;
     }
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls), "meth", "()I");
+    mid = env->GetMethodID(cls, "meth", "()I");
     if (mid == NULL) {
         printf("Cannot get method ID!\n");
         return STATUS_FAILED;
@@ -153,6 +139,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss001/loadedclss001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss001/loadedclss001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -115,6 +101,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss002/loadedclss002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss002/loadedclss002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "agent_common.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ========================================================================== */
 
@@ -168,6 +166,4 @@
 
 /* ========================================================================== */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariable/getlocal001/getlocal001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariable/getlocal001/getlocal001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,31 +27,11 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#define JNI_EARG(x)
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#define JNI_EARG(x) x
-#endif
-
-#endif
 
 #ifndef JNI_EARG
 
-#ifdef __cplusplus
-#define JNI_EARG(x)
-#else
-#define JNI_EARG(x) x
-#endif
 
 #endif
 
@@ -190,15 +170,14 @@
                 result = STATUS_FAILED;
                 continue;
             }
-            fid = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG(env, cls),
-                 "fld", "I");
+            fid = env->GetFieldID(cls, "fld", "I");
             if (fid == NULL) {
                 printf("Cannot find ID for \"fld\" field of meth03\n");
-                JNI_ENV_PTR(env)->ExceptionClear(JNI_EARG(env));
+                env->ExceptionClear();
                 result = STATUS_FAILED;
                 continue;
             }
-            fldVal = JNI_ENV_PTR(env)->GetIntField(JNI_ENV_ARG(env, ob1), fid);
+            fldVal = env->GetIntField(ob1, fid);
         } else if (strcmp(table[i].name, "ob2") == 0) {
             err = jvmti_env->GetLocalObject(thr, depth,
                 table[i].slot, &ob2);
@@ -207,8 +186,7 @@
                        TranslateError(err), err);
                 result = STATUS_FAILED;
             }
-            JNI_ENV_PTR(env)->GetIntArrayRegion(JNI_ENV_ARG(env, (jintArray) ob2),
-                0, 10, arr);
+            env->GetIntArrayRegion((jintArray) ob2, 0, 10, arr);
         }
     }
     if ((fldVal != 17) || (arr[2] != 8)) {
@@ -423,8 +401,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -482,25 +459,19 @@
 
     fval = f;
     dval = d;
-    mid1 = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls),
-        "meth01", "()D");
-    mid2 = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls),
-        "meth02", "(I)V");
-    mid3 = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-        "meth03", "(Lnsk/jvmti/GetLocalVariable/getlocal001;)V");
-    mid4 = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-        "meth04", "(IJSDCFBZ)V");
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-         "checkPoint", "()V");
+    mid1 = env->GetMethodID(cls, "meth01", "()D");
+    mid2 = env->GetMethodID(cls, "meth02", "(I)V");
+    mid3 = env->GetStaticMethodID(cls, "meth03", "(Lnsk/jvmti/GetLocalVariable/getlocal001;)V");
+    mid4 = env->GetStaticMethodID(cls, "meth04", "(IJSDCFBZ)V");
+    mid = env->GetStaticMethodID(cls, "checkPoint", "()V");
     if (mid == 0 || mid1 == 0 || mid2 == 0 || mid3 == 0 || mid4 == 0) {
         printf("Cannot find Method ID for a method\n");
-        JNI_ENV_PTR(env)->ExceptionDescribe(JNI_EARG(env));
-        JNI_ENV_PTR(env)->ExceptionClear(JNI_EARG(env));
+        env->ExceptionDescribe();
+        env->ExceptionClear();
         result = STATUS_FAILED;
         return;
     }
-    err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
-        JVMTI_EVENT_METHOD_EXIT, NULL);
+    err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, NULL);
     if (err != JVMTI_ERROR_NONE) {
         printf("Failed to enable METHOD_EXIT event: %s (%d)\n",
                TranslateError(err), err);
@@ -526,6 +497,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariable/getlocal002/getlocal002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariable/getlocal002/getlocal002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -146,8 +133,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -204,7 +190,7 @@
     if (!caps.can_access_local_variables ||
         !caps.can_generate_method_exit_events) return;
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls), "meth01", "()D");
+    mid = env->GetMethodID(cls, "meth01", "()D");
     if (mid == NULL) {
         printf("Cannot find Method ID for meth01\n");
         result = STATUS_FAILED;
@@ -233,8 +219,7 @@
         return;
     }
 
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-        "meth02", "()V");
+    mid = env->GetStaticMethodID(cls, "meth02", "()V");
     if (mid == NULL) {
         printf("Cannot find Method ID for meth02\n");
         result = STATUS_FAILED;
@@ -287,6 +272,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab001/localtab001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab001/localtab001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED  0
 #define STATUS_FAILED  2
@@ -115,9 +102,9 @@
     jvmtiLocalVariableEntry *exp_table = meth_tab[meth_ind].table;
 
     if (stat) {
-        mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cl), name, sig);
+        mid = env->GetStaticMethodID(cl, name, sig);
     } else {
-        mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cl), name, sig);
+        mid = env->GetMethodID(cl, name, sig);
     }
     if (mid == NULL) {
         printf("Name = %s, sig = %s: mid = NULL\n", name, sig);
@@ -206,8 +193,7 @@
     jint res;
     jvmtiError err;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -257,6 +243,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab002/localtab002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab002/localtab002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -70,8 +57,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -119,7 +105,7 @@
 
     if (!caps.can_access_local_variables) return result;
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls), "<init>", "()V");
+    mid = env->GetMethodID(cls, "<init>", "()V");
     if (mid == NULL) {
         printf("Cannot get method ID for \"<init>\"!\n");
         return STATUS_FAILED;
@@ -155,8 +141,7 @@
         result = STATUS_FAILED;
     }
 
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-        "check", "()I");
+    mid = env->GetStaticMethodID(cls, "check", "()I");
     if (mid == NULL) {
         printf("Cannot get method ID for \"check\"!\n");
         return STATUS_FAILED;
@@ -179,6 +164,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab003/localtab003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab003/localtab003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -70,8 +57,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -120,7 +106,7 @@
 
     if (!caps.can_access_local_variables) return result;
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls), "meth", "()I");
+    mid = env->GetMethodID(cls, "meth", "()I");
     if (mid == NULL) {
         printf("Cannot get method ID!\n");
         return STATUS_FAILED;
@@ -154,6 +140,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab004/localtab004.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab004/localtab004.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -30,9 +30,7 @@
 #include "JVMTITools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 #define METH_NUM 3 /* overall number of methods */
 
@@ -221,6 +219,4 @@
     return JNI_OK;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab005/localtab005.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab005/localtab005.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -30,9 +30,7 @@
 #include "JVMTITools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 #define METH_NUM 3 /* overall number of methods */
 
@@ -242,6 +240,4 @@
     return JNI_OK;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMaxLocals/maxloc001/maxloc001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMaxLocals/maxloc001/maxloc001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -55,9 +42,9 @@
     jint ret_loc;
 
     if (stat) {
-        mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cl), name, sig);
+        mid = env->GetStaticMethodID(cl, name, sig);
     } else {
-        mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cl), name, sig);
+        mid = env->GetMethodID(cl, name, sig);
     }
     if (mid == NULL) {
         printf("Name = %s, sig = %s: mid = 0\n", name, sig);
@@ -89,8 +76,7 @@
 jint  Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
     jint res;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -108,16 +94,12 @@
     checkMeth(env, cls, "meth_stat", "(ILjava/lang/String;)[F", 1, 3);
     checkMeth(env, cls, "meth_1", "(C)C", 0, 4);
     checkMeth(env, cls, "meth_2", "(FF)F", 0, 6);
-    clsId = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/GetMaxLocals/maxloc001a"));
+    clsId = env->FindClass("nsk/jvmti/GetMaxLocals/maxloc001a");
     checkMeth(env, clsId, "meth_new", "()Lnsk/jvmti/GetMaxLocals/maxloc001;", 0, 3);
     checkMeth(env, clsId, "meth_abs", "()V", 0, 0);
-    clsId = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/GetMaxLocals/maxloc001$Inn"));
+    clsId = env->FindClass("nsk/jvmti/GetMaxLocals/maxloc001$Inn");
     checkMeth(env, clsId, "meth_inn", "(Ljava/lang/String;)V", 0, 2);
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMaxLocals/maxloc002/maxloc002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMaxLocals/maxloc002/maxloc002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -89,7 +75,7 @@
         return STATUS_FAILED;
     }
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls), "<init>", "()V");
+    mid = env->GetMethodID(cls, "<init>", "()V");
     if (mid == NULL) {
         printf("Cannot get method ID for \"<init>\"!\n");
         return STATUS_FAILED;
@@ -115,8 +101,7 @@
         result = STATUS_FAILED;
     }
 
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-        "check", "()I");
+    mid = env->GetStaticMethodID(cls, "check", "()I");
     if (mid == NULL) {
         printf("Cannot get method ID for \"check\"!\n");
         return STATUS_FAILED;
@@ -139,6 +124,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls001/declcls001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls001/declcls001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED  0
 #define STATUS_FAILED  2
@@ -56,12 +43,11 @@
     char *cl_sig, *generic;
     jclass cl, ret_decl_cl;
 
-    cl = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, cl_name));
+    cl = env->FindClass(cl_name);
     if (stat) {
-        mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cl),
-            name, sig);
+        mid = env->GetStaticMethodID(cl, name, sig);
     } else {
-        mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cl), name, sig);
+        mid = env->GetMethodID(cl, name, sig);
     }
     if (mid == NULL) {
         printf("%s.%s%s: mid = NULL\n", cl_name, name, sig);
@@ -108,8 +94,7 @@
 jint  Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
     jint res;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -139,6 +124,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls002/declcls002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls002/declcls002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -89,8 +75,7 @@
         return STATUS_FAILED;
     }
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls),
-        "<init>", "()V");
+    mid = env->GetMethodID(cls, "<init>", "()V");
     if (mid == NULL) {
         printf("Cannot get method ID!\n");
         return STATUS_FAILED;
@@ -123,6 +108,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls003/declcls003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls003/declcls003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -66,8 +53,8 @@
         printf(">>> checking: %s.%s%s\n", name, meth, sig);
     }
 
-    cl = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, name));
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cl), meth, sig);
+    cl = env->FindClass(name);
+    mid = env->GetMethodID(cl, meth, sig);
     if (mid == NULL) {
         printf("%s.%s%s: mid = NULL\n", name, meth, sig);
         result = STATUS_FAILED;
@@ -122,8 +109,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -153,6 +139,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodLocation/methloc001/methloc001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodLocation/methloc001/methloc001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -25,21 +25,8 @@
 #include "jvmti.h"
 #include "agent_common.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED  0
 #define STATUS_FAILED  2
@@ -68,10 +55,9 @@
     jlocation exp_end = meth_tab[meth_ind].end;
 
     if (stat) {
-        mid = JNI_ENV_PTR(env)->
-            GetStaticMethodID(JNI_ENV_ARG(env, cl), name, sig);
+        mid = env->GetStaticMethodID(cl, name, sig);
     } else {
-        mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cl), name, sig);
+        mid = env->GetMethodID(cl, name, sig);
     }
     if (mid == NULL) {
         printf("Name = %s, sig = %s: mid = NULL\n", name, sig);
@@ -116,8 +102,7 @@
 jint  Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
     jint res;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -133,6 +118,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodLocation/methloc002/methloc002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodLocation/methloc002/methloc002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -90,7 +76,7 @@
         return STATUS_FAILED;
     }
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls), "<init>", "()V");
+    mid = env->GetMethodID(cls, "<init>", "()V");
     if (mid == NULL) {
         printf("Cannot get method ID for \"<init>\"!\n");
         return STATUS_FAILED;
@@ -126,8 +112,7 @@
         result = STATUS_FAILED;
     }
 
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-        "check", "()I");
+    mid = env->GetStaticMethodID(cls, "check", "()I");
     if (mid == NULL) {
         printf("Cannot get method ID for \"check\"!\n");
         return STATUS_FAILED;
@@ -150,6 +135,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodModifiers/methmod001/methmod001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodModifiers/methmod001/methmod001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -81,10 +68,9 @@
     jint modifiers;
 
     if (stat) {
-        mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cl),
-            name, sig);
+        mid = env->GetStaticMethodID(cl, name, sig);
     } else {
-        mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cl), name, sig);
+        mid = env->GetMethodID(cl, name, sig);
     }
     if (mid == NULL) {
         printf("Cannot find MethodID for \"%s%s\"\n", name, sig);
@@ -155,8 +141,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -188,19 +173,13 @@
     checkMeth(jvmti, env, cls, "meth_1", "(C)C", 0,  ACC_PRIVATE);
     checkMeth(jvmti, env, cls, "meth_2", "(FF)F", 0,  ACC_STRICT);
     checkMeth(jvmti, env, cls, "check", "()I", 1,  ACC_NATIVE |  ACC_STATIC);
-    clsId = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/GetMethodModifiers/methmod001a"));
-    checkMeth(jvmti, env, clsId, "meth_new",
-        "()Lnsk/jvmti/GetMethodModifiers/methmod001;", 0,  ACC_SYNCHRONIZED);
+    clsId = env->FindClass("nsk/jvmti/GetMethodModifiers/methmod001a");
+    checkMeth(jvmti, env, clsId, "meth_new", "()Lnsk/jvmti/GetMethodModifiers/methmod001;", 0,  ACC_SYNCHRONIZED);
     checkMeth(jvmti, env, clsId, "meth_abs", "()V", 0,  ACC_ABSTRACT);
-    clsId = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/GetMethodModifiers/methmod001$Inn"));
-    checkMeth(jvmti, env, clsId, "meth_inn", "(Ljava/lang/String;)V",
-        0, ACC_PUBLIC |  ACC_SYNCHRONIZED |  ACC_FINAL);
+    clsId = env->FindClass("nsk/jvmti/GetMethodModifiers/methmod001$Inn");
+    checkMeth(jvmti, env, clsId, "meth_inn", "(Ljava/lang/String;)V", 0, ACC_PUBLIC |  ACC_SYNCHRONIZED |  ACC_FINAL);
 
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodModifiers/methmod002/methmod002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodModifiers/methmod002/methmod002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -89,8 +75,7 @@
         return STATUS_FAILED;
     }
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls),
-        "<init>", "()V");
+    mid = env->GetMethodID(cls, "<init>", "()V");
     if (mid == NULL) {
         printf("Cannot get method ID!\n");
         return STATUS_FAILED;
@@ -123,6 +108,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname001/methname001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname001/methname001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -59,10 +46,9 @@
     char *ret_name, *ret_sig, *generic;
 
     if (stat) {
-        mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cl),
-            name, sig);
+        mid = env->GetStaticMethodID(cl, name, sig);
     } else {
-        mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cl), name, sig);
+        mid = env->GetMethodID(cl, name, sig);
     }
     if (mid == NULL) {
         printf("Cannot find MethodID for \"%s%s\"\n", name, sig);
@@ -133,8 +119,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -166,17 +151,12 @@
     checkMeth(jvmti, env, cls, "<init>", "()V", 0);
     checkMeth(jvmti, env, cls, "meth_1", "(C)C", 0);
     checkMeth(jvmti, env, cls, "meth_1", "(CC)C", 0);
-    clsId = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/GetMethodName/methname001a"));
-    checkMeth(jvmti, env, clsId, "meth_new",
-        "()Lnsk/jvmti/GetMethodName/methname001;", 0);
-    clsId = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/GetMethodName/methname001$Inn"));
+    clsId = env->FindClass("nsk/jvmti/GetMethodName/methname001a");
+    checkMeth(jvmti, env, clsId, "meth_new", "()Lnsk/jvmti/GetMethodName/methname001;", 0);
+    clsId = env->FindClass("nsk/jvmti/GetMethodName/methname001$Inn");
     checkMeth(jvmti, env, clsId, "meth_inn", "(Ljava/lang/String;)V", 0);
 
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname002/methname002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname002/methname002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -89,8 +75,7 @@
         return STATUS_FAILED;
     }
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls),
-        "<init>", "()V");
+    mid = env->GetMethodID(cls, "<init>", "()V");
     if (mid == NULL) {
         printf("Cannot get method ID!\n");
         return STATUS_FAILED;
@@ -171,6 +156,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname003/methname003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname003/methname003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -31,9 +31,7 @@
 #include "JVMTITools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* number of tested methods in particular class */
 #define METH_NUM 2
@@ -201,6 +199,4 @@
     return JNI_OK;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectHashCode/objhashcode001/objhashcode001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectHashCode/objhashcode001/objhashcode001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -210,6 +208,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage001/objmonusage001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage001/objmonusage001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x,y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x,y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -70,8 +57,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -159,8 +145,7 @@
         }
     }
 
-    if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, owner),
-            inf.owner) != JNI_TRUE) {
+    if (!env->IsSameObject(owner, inf.owner)) {
         jvmti->GetThreadInfo(inf.owner, &tinf);
         printf("(%d) unexpected owner: %s (0x%p)\n", i, tinf.name, inf.owner);
         result = STATUS_FAILED;
@@ -184,6 +169,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage002/objmonusage002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage002/objmonusage002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -70,8 +57,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -145,6 +131,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage003/objmonusage003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage003/objmonusage003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -71,8 +58,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -149,8 +135,7 @@
         }
     }
 
-    if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, owner),
-            inf.owner) != JNI_TRUE) {
+    if (!env->IsSameObject(owner, inf.owner)) {
         printf("(%d) unexpected owner: 0x%p\n", count, inf.owner);
         result = STATUS_FAILED;
     }
@@ -173,6 +158,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage004/objmonusage004.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage004/objmonusage004.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -71,8 +58,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -149,8 +135,7 @@
         }
     }
 
-    if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, owner),
-            inf.owner) != JNI_TRUE) {
+    if (!env->IsSameObject(owner, inf.owner)) {
         printf("(%d) unexpected owner: 0x%p\n", count, inf.owner);
         result = STATUS_FAILED;
     }
@@ -173,6 +158,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage005/objmonusage005.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage005/objmonusage005.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -65,8 +52,7 @@
     jint res;
     jvmtiError err;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -121,6 +107,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage006/objmonusage006.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage006/objmonusage006.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -65,8 +52,7 @@
     jint res;
     jvmtiError err;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -121,6 +107,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectSize/objsize001/objsize001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectSize/objsize001/objsize001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -208,6 +206,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectsWithTags/objwithtags001/objwithtags001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectsWithTags/objwithtags001/objwithtags001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -472,6 +470,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf001/ownmoninf001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf001/ownmoninf001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -65,8 +52,7 @@
     jint res;
     jvmtiError err;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -139,8 +125,7 @@
     if ((monitors = getInfo(env, point, thr, 1)) == NULL) {
         return;
     }
-    if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, lock), monitors[0])
-            == JNI_FALSE) {
+    if (!env->IsSameObject(lock, monitors[0])) {
         result = STATUS_FAILED;
         printf("Point %d: not expected monitor: 0x%p\n", point, monitors[0]);
     }
@@ -153,19 +138,12 @@
     if ((monitors = getInfo(env, point, thr, 2)) == NULL) {
         return;
     }
-    if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, lock1), monitors[0])
-            == JNI_FALSE &&
-            JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, lock2), monitors[0])
-            == JNI_FALSE) {
+    if (!env->IsSameObject(lock1, monitors[0]) && !env->IsSameObject(lock2, monitors[0])) {
         result = STATUS_FAILED;
         printf("Point %d: not expected monitor: 0x%p\n", point, monitors[0]);
     }
-    if ((JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, lock1), monitors[1])
-            == JNI_FALSE &&
-            JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, lock2), monitors[1])
-            == JNI_FALSE) ||
-            JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, monitors[0]),
-                 monitors[1]) == JNI_TRUE) {
+    if ((!env->IsSameObject(lock1, monitors[1]) && !env->IsSameObject(lock2, monitors[1]))
+        || env->IsSameObject(monitors[0], monitors[1])) {
         result = STATUS_FAILED;
         printf("Point %d: not expected monitor: 0x%p\n", point, monitors[1]);
     }
@@ -176,6 +154,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf002/ownmoninf002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf002/ownmoninf002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -65,8 +52,7 @@
     jint res;
     jvmtiError err;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -124,6 +110,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf003/ownmoninf003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf003/ownmoninf003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -70,8 +57,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -160,6 +146,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPhase/getphase001/getphase001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPhase/getphase001/getphase001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -26,9 +26,7 @@
 #include "agent_common.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ========================================================================== */
 
@@ -384,6 +382,4 @@
 
 /* ========================================================================== */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPhase/getphase002/getphase002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPhase/getphase002/getphase002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -26,9 +26,7 @@
 #include "agent_common.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ========================================================================== */
 
@@ -97,6 +95,4 @@
 
 /* ========================================================================== */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPotentialCapabilities/getpotcaps001/getpotcaps001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPotentialCapabilities/getpotcaps001/getpotcaps001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -28,9 +28,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -260,6 +258,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex001/srcdebugex001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex001/srcdebugex001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define STATUS_FAILED 2
 #define PASSED 0
@@ -65,8 +52,7 @@
     jvmtiError err;
     jint res;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -138,6 +124,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex002/srcdebugex002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex002/srcdebugex002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define STATUS_FAILED 2
 #define PASSED 0
@@ -65,8 +52,7 @@
     jvmtiError err;
     jint res;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -149,6 +135,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex003/srcdebugex003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex003/srcdebugex003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define STATUS_FAILED 2
 #define PASSED 0
@@ -67,8 +54,7 @@
     jvmtiError err;
     jint res;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -144,6 +130,4 @@
     return (result);
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn004/getsrcfn004.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn004/getsrcfn004.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -70,8 +57,7 @@
         printdump = JNI_TRUE;
     }
 
-    code = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    code = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (code != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -150,6 +136,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn005/getsrcfn005.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn005/getsrcfn005.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -70,8 +57,7 @@
         printdump = JNI_TRUE;
     }
 
-    code = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    code = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (code != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -136,6 +122,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn006/getsrcfn006.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn006/getsrcfn006.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -76,8 +63,7 @@
         printdump = JNI_TRUE;
     }
 
-    code = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    code = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (code != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -145,6 +131,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr001/getstacktr001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr001/getstacktr001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -66,7 +53,7 @@
      "([Ljava/lang/String;)V"}
 };
 
-#define NUMBER_OF_FRAMES ((int) (sizeof(frames)/sizeof(frame_info)))
+#define NUMBER_OF_STACK_FRAMES ((int) (sizeof(frames)/sizeof(frame_info)))
 
 #ifdef STATIC_BUILD
 JNIEXPORT jint JNICALL Agent_OnLoad_getstacktr001(JavaVM *jvm, char *options, void *reserved) {
@@ -86,8 +73,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -100,9 +86,8 @@
 Java_nsk_jvmti_GetStackTrace_getstacktr001_chain(JNIEnv *env, jclass cls) {
     jmethodID mid;
 
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-        "dummy", "()V");
-    JNI_ENV_PTR(env)->CallStaticVoidMethod(JNI_ENV_ARG(env, cls), mid);
+    mid = env->GetStaticMethodID(cls, "dummy", "()V");
+    env->CallStaticVoidMethod(cls, mid);
 
     return result;
 }
@@ -110,7 +95,7 @@
 JNIEXPORT void JNICALL
 Java_nsk_jvmti_GetStackTrace_getstacktr001_check(JNIEnv *env, jclass cls, jthread thread) {
     jvmtiError err;
-    jvmtiFrameInfo f[NUMBER_OF_FRAMES + 1];
+    jvmtiFrameInfo f[NUMBER_OF_STACK_FRAMES + 1];
     jclass callerClass;
     char *sigClass, *name, *sig, *generic;
     jint i, count;
@@ -122,16 +107,16 @@
     }
 
     err = jvmti->GetStackTrace(thread, 0,
-        NUMBER_OF_FRAMES + 1, f, &count);
+        NUMBER_OF_STACK_FRAMES + 1, f, &count);
     if (err != JVMTI_ERROR_NONE) {
         printf("(GetStackTrace) unexpected error: %s (%d)\n",
                TranslateError(err), err);
         result = STATUS_FAILED;
         return;
     }
-    if (count != NUMBER_OF_FRAMES) {
+    if (count != NUMBER_OF_STACK_FRAMES) {
         printf("Wrong number of frames: %d, expected: %d\n",
-               count, NUMBER_OF_FRAMES);
+               count, NUMBER_OF_STACK_FRAMES);
         result = STATUS_FAILED;
     }
     for (i = 0; i < count; i++) {
@@ -166,7 +151,7 @@
             printf(">>>   method: \"%s%s\"\n", name, sig);
             printf(">>>   %d ... done\n", i);
         }
-        if (i < NUMBER_OF_FRAMES) {
+        if (i < NUMBER_OF_STACK_FRAMES) {
             if (sigClass == NULL || strcmp(sigClass, frames[i].cls) != 0) {
                 printf("(frame#%d) wrong class sig: \"%s\", expected: \"%s\"\n",
                        i, sigClass, frames[i].cls);
@@ -186,6 +171,4 @@
     }
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr002/getstacktr002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr002/getstacktr002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -136,6 +122,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr003/getstacktr003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr003/getstacktr003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -63,7 +50,7 @@
     {"Lnsk/jvmti/GetStackTrace/getstacktr003$TestThread;", "run", "()V"},
 };
 
-#define NUMBER_OF_FRAMES ((int) (sizeof(frames)/sizeof(frame_info)))
+#define NUMBER_OF_STACK_FRAMES ((int) (sizeof(frames)/sizeof(frame_info)))
 #define MAX_NUMBER_OF_FRAMES 32
 
 #ifdef STATIC_BUILD
@@ -85,8 +72,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -124,12 +110,11 @@
 Java_nsk_jvmti_GetStackTrace_getstacktr003_chain(JNIEnv *env, jclass cls) {
     jmethodID mid;
 
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-        "dummy", "()V");
+    mid = env->GetStaticMethodID(cls, "dummy", "()V");
     if (mid == NULL) {
         printf("Could not find method ID for dummy()V!\n");
     } else {
-        JNI_ENV_PTR(env)->CallStaticVoidMethod(JNI_ENV_ARG(env, cls), mid);
+        env->CallStaticVoidMethod(cls, mid);
     }
 
     return;
@@ -168,9 +153,9 @@
         result = STATUS_FAILED;
         return result;
     }
-    if (count < NUMBER_OF_FRAMES) {
+    if (count < NUMBER_OF_STACK_FRAMES) {
         printf("Number of frames: %d is less then expected: %d\n",
-               count, NUMBER_OF_FRAMES);
+               count, NUMBER_OF_STACK_FRAMES);
         result = STATUS_FAILED;
     }
     for (i = 0; i < count; i++) {
@@ -206,20 +191,20 @@
             printf(">>>   method: \"%s%s\"\n", name, sig);
             printf(">>>   %d ... done\n", i);
         }
-        if (i < NUMBER_OF_FRAMES) {
-            if (sigClass == NULL || strcmp(sigClass, frames[NUMBER_OF_FRAMES-1-i].cls) != 0) {
+        if (i < NUMBER_OF_STACK_FRAMES) {
+            if (sigClass == NULL || strcmp(sigClass, frames[NUMBER_OF_STACK_FRAMES-1-i].cls) != 0) {
                 printf("(frame#%d) wrong class sig: \"%s\", expected: \"%s\"\n",
-                       NUMBER_OF_FRAMES-1-i, sigClass, frames[NUMBER_OF_FRAMES-1-i].cls);
+                       NUMBER_OF_STACK_FRAMES-1-i, sigClass, frames[NUMBER_OF_STACK_FRAMES-1-i].cls);
                 result = STATUS_FAILED;
             }
-            if (name == NULL || strcmp(name, frames[NUMBER_OF_FRAMES-1-i].name) != 0) {
+            if (name == NULL || strcmp(name, frames[NUMBER_OF_STACK_FRAMES-1-i].name) != 0) {
                 printf("(frame#%d) wrong method name: \"%s\", expected: \"%s\"\n",
-                       NUMBER_OF_FRAMES-1-i, name, frames[NUMBER_OF_FRAMES-1-i].name);
+                       NUMBER_OF_STACK_FRAMES-1-i, name, frames[NUMBER_OF_STACK_FRAMES-1-i].name);
                 result = STATUS_FAILED;
             }
-            if (sig == NULL || strcmp(sig, frames[NUMBER_OF_FRAMES-1-i].sig) != 0) {
+            if (sig == NULL || strcmp(sig, frames[NUMBER_OF_STACK_FRAMES-1-i].sig) != 0) {
                 printf("(frame#%d) wrong method sig: \"%s\", expected: \"%s\"\n",
-                       NUMBER_OF_FRAMES-1-i, sig, frames[NUMBER_OF_FRAMES-1-i].sig);
+                       NUMBER_OF_STACK_FRAMES-1-i, sig, frames[NUMBER_OF_STACK_FRAMES-1-i].sig);
                 result = STATUS_FAILED;
             }
         }
@@ -235,6 +220,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr004/getstacktr004.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr004/getstacktr004.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -67,26 +54,26 @@
     {"Lnsk/jvmti/GetStackTrace/getstacktr004$TestThread;", "run", "()V"},
 };
 
-#define NUMBER_OF_FRAMES ((int) (sizeof(frames)/sizeof(frame_info)))
+#define NUMBER_OF_STACK_FRAMES ((int) (sizeof(frames)/sizeof(frame_info)))
 
 void check(jvmtiEnv *jvmti_env, jthread thr) {
     jvmtiError err;
-    jvmtiFrameInfo f[NUMBER_OF_FRAMES + 1];
+    jvmtiFrameInfo f[NUMBER_OF_STACK_FRAMES + 1];
     jclass callerClass;
     char *sigClass, *name, *sig, *generic;
     jint i, count;
 
     err = jvmti_env->GetStackTrace(thr,
-        0, NUMBER_OF_FRAMES + 1, f, &count);
+        0, NUMBER_OF_STACK_FRAMES + 1, f, &count);
     if (err != JVMTI_ERROR_NONE) {
         printf("(GetStackTrace) unexpected error: %s (%d)\n",
                TranslateError(err), err);
         result = STATUS_FAILED;
         return;
     }
-    if (count != NUMBER_OF_FRAMES) {
+    if (count != NUMBER_OF_STACK_FRAMES) {
         printf("Wrong frame count, expected: %d, actual: %d\n",
-               NUMBER_OF_FRAMES, count);
+               NUMBER_OF_STACK_FRAMES, count);
         result = STATUS_FAILED;
     }
 
@@ -125,7 +112,7 @@
             printf(">>>   class:  \"%s\"\n", sigClass);
             printf(">>>   method: \"%s%s\"\n", name, sig);
         }
-        if (i < NUMBER_OF_FRAMES) {
+        if (i < NUMBER_OF_STACK_FRAMES) {
             if (sigClass == NULL || strcmp(sigClass, frames[i].cls) != 0) {
                 printf("(frame#%d) wrong class sig: \"%s\", expected: \"%s\"\n",
                        i, sigClass, frames[i].cls);
@@ -174,8 +161,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -231,8 +217,7 @@
         return;
     }
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz),
-         "checkPoint", "()V");
+    mid = env->GetMethodID(clazz, "checkPoint", "()V");
     if (mid == NULL) {
         printf("Cannot find Method ID for method checkPoint\n");
         result = STATUS_FAILED;
@@ -260,6 +245,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr005/getstacktr005.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr005/getstacktr005.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -66,26 +53,26 @@
     {"Lnsk/jvmti/GetStackTrace/getstacktr005$TestThread;", "run", "()V"},
 };
 
-#define NUMBER_OF_FRAMES ((int) (sizeof(frames)/sizeof(frame_info)))
+#define NUMBER_OF_STACK_FRAMES ((int) (sizeof(frames)/sizeof(frame_info)))
 
 void check(jvmtiEnv *jvmti_env, jthread thr) {
     jvmtiError err;
-    jvmtiFrameInfo f[NUMBER_OF_FRAMES + 1];
+    jvmtiFrameInfo f[NUMBER_OF_STACK_FRAMES + 1];
     jclass callerClass;
     char *sigClass, *name, *sig, *generic;
     jint i, count;
 
     err = jvmti_env->GetStackTrace(thr,
-        0, NUMBER_OF_FRAMES + 1, f, &count);
+        0, NUMBER_OF_STACK_FRAMES + 1, f, &count);
     if (err != JVMTI_ERROR_NONE) {
         printf("(GetStackTrace) unexpected error: %s (%d)\n",
                TranslateError(err), err);
         result = STATUS_FAILED;
         return;
     }
-    if (count != NUMBER_OF_FRAMES) {
+    if (count != NUMBER_OF_STACK_FRAMES) {
         printf("Wrong frame count, expected: %d, actual: %d\n",
-               NUMBER_OF_FRAMES, count);
+               NUMBER_OF_STACK_FRAMES, count);
         result = STATUS_FAILED;
     }
 
@@ -124,7 +111,7 @@
             printf(">>>   class:  \"%s\"\n", sigClass);
             printf(">>>   method: \"%s%s\"\n", name, sig);
         }
-        if (i < NUMBER_OF_FRAMES) {
+        if (i < NUMBER_OF_STACK_FRAMES) {
             if (sigClass == NULL || strcmp(sigClass, frames[i].cls) != 0) {
                 printf("(frame#%d) wrong class sig: \"%s\", expected: \"%s\"\n",
                        i, sigClass, frames[i].cls);
@@ -167,9 +154,9 @@
         return;
     }
 
-    if (frameCount != NUMBER_OF_FRAMES + 1) {
+    if (frameCount != NUMBER_OF_STACK_FRAMES + 1) {
         printf("(bp) wrong frame count, expected: %d, actual: %d\n",
-               NUMBER_OF_FRAMES + 1, frameCount);
+               NUMBER_OF_STACK_FRAMES + 1, frameCount);
         result = STATUS_FAILED;
     }
 
@@ -223,8 +210,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -283,8 +269,7 @@
         return;
     }
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz),
-         "checkPoint", "()V");
+    mid = env->GetMethodID(clazz, "checkPoint", "()V");
     if (mid == NULL) {
         printf("Cannot find Method ID for method checkPoint\n");
         result = STATUS_FAILED;
@@ -312,6 +297,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr006/getstacktr006.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr006/getstacktr006.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -66,26 +53,26 @@
     {"Lnsk/jvmti/GetStackTrace/getstacktr006$TestThread;", "run", "()V"},
 };
 
-#define NUMBER_OF_FRAMES ((int) (sizeof(frames)/sizeof(frame_info)))
+#define NUMBER_OF_STACK_FRAMES ((int) (sizeof(frames)/sizeof(frame_info)))
 
 void check(jvmtiEnv *jvmti_env, jthread thr) {
     jvmtiError err;
-    jvmtiFrameInfo f[NUMBER_OF_FRAMES + 1];
+    jvmtiFrameInfo f[NUMBER_OF_STACK_FRAMES + 1];
     jclass callerClass;
     char *sigClass, *name, *sig, *generic;
     jint i, count;
 
     err = jvmti_env->GetStackTrace(thr,
-        0, NUMBER_OF_FRAMES + 1, f, &count);
+        0, NUMBER_OF_STACK_FRAMES + 1, f, &count);
     if (err != JVMTI_ERROR_NONE) {
         printf("(GetStackTrace) unexpected error: %s (%d)\n",
                TranslateError(err), err);
         result = STATUS_FAILED;
         return;
     }
-    if (count != NUMBER_OF_FRAMES) {
+    if (count != NUMBER_OF_STACK_FRAMES) {
         printf("Wrong frame count, expected: %d, actual: %d\n",
-               NUMBER_OF_FRAMES, count);
+               NUMBER_OF_STACK_FRAMES, count);
         result = STATUS_FAILED;
     }
 
@@ -124,7 +111,7 @@
             printf(">>>   class:  \"%s\"\n", sigClass);
             printf(">>>   method: \"%s%s\"\n", name, sig);
         }
-        if (i < NUMBER_OF_FRAMES) {
+        if (i < NUMBER_OF_STACK_FRAMES) {
             if (sigClass == NULL || strcmp(sigClass, frames[i].cls) != 0) {
                 printf("(frame#%d) wrong class sig: \"%s\", expected: \"%s\"\n",
                        i, sigClass, frames[i].cls);
@@ -229,8 +216,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -290,8 +276,7 @@
         return;
     }
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz),
-         "checkPoint", "()V");
+    mid = env->GetMethodID(clazz, "checkPoint", "()V");
     if (mid == NULL) {
         printf("Cannot find Method ID for method checkPoint\n");
         result = STATUS_FAILED;
@@ -320,6 +305,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr007/getstacktr007.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr007/getstacktr007.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,26 +55,26 @@
     {"Lnsk/jvmti/GetStackTrace/getstacktr007$TestThread;", "run", "()V"},
 };
 
-#define NUMBER_OF_FRAMES ((int) (sizeof(frames)/sizeof(frame_info)))
+#define NUMBER_OF_STACK_FRAMES ((int) (sizeof(frames)/sizeof(frame_info)))
 
 void check(jvmtiEnv *jvmti_env, jthread thr) {
     jvmtiError err;
-    jvmtiFrameInfo f[NUMBER_OF_FRAMES + 1];
+    jvmtiFrameInfo f[NUMBER_OF_STACK_FRAMES + 1];
     jclass callerClass;
     char *sigClass, *name, *sig, *generic;
     jint i, count;
 
     err = jvmti_env->GetStackTrace(thr,
-        0, NUMBER_OF_FRAMES + 1, f, &count);
+        0, NUMBER_OF_STACK_FRAMES + 1, f, &count);
     if (err != JVMTI_ERROR_NONE) {
         printf("(GetStackTrace) unexpected error: %s (%d)\n",
                TranslateError(err), err);
         result = STATUS_FAILED;
         return;
     }
-    if (count != NUMBER_OF_FRAMES) {
+    if (count != NUMBER_OF_STACK_FRAMES) {
         printf("Wrong frame count, expected: %d, actual: %d\n",
-               NUMBER_OF_FRAMES, count);
+               NUMBER_OF_STACK_FRAMES, count);
         result = STATUS_FAILED;
     }
 
@@ -126,7 +113,7 @@
             printf(">>>   class:  \"%s\"\n", sigClass);
             printf(">>>   method: \"%s%s\"\n", name, sig);
         }
-        if (i < NUMBER_OF_FRAMES) {
+        if (i < NUMBER_OF_STACK_FRAMES) {
             if (sigClass == NULL || strcmp(sigClass, frames[i].cls) != 0) {
                 printf("(frame#%d) wrong class sig: \"%s\", expected: \"%s\"\n",
                        i, sigClass, frames[i].cls);
@@ -183,10 +170,8 @@
 
     classDef.klass = klass;
     classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG((JNIEnv *)env, classBytes));
-    classDef.class_bytes = (unsigned char*)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG((JNIEnv *)env,
-            classBytes), NULL);
+        env->GetArrayLength(classBytes);
+    classDef.class_bytes = (unsigned char*) env->GetByteArrayElements(classBytes, NULL);
 
     err = jvmti->RedefineClasses(1, &classDef);
     if (err != JVMTI_ERROR_NONE) {
@@ -195,7 +180,7 @@
         result = STATUS_FAILED;
         return;
     }
-    JNI_ENV_PTR(env)->DeleteGlobalRef(JNI_ENV_ARG((JNIEnv *)env, classBytes));
+    env->DeleteGlobalRef(classBytes);
     classBytes = NULL;
 
     check(jvmti_env, thr);
@@ -220,8 +205,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -278,10 +262,9 @@
         return;
     }
 
-    classBytes = (jbyteArray) JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env, bytes));
+    classBytes = (jbyteArray) env->NewGlobalRef(bytes);
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz),
-         "checkPoint", "()V");
+    mid = env->GetMethodID(clazz, "checkPoint", "()V");
     if (mid == NULL) {
         printf("Cannot find Method ID for method checkPoint\n");
         result = STATUS_FAILED;
@@ -310,6 +293,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr008/getstacktr008.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr008/getstacktr008.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -72,11 +59,11 @@
     {"Lnsk/jvmti/GetStackTrace/getstacktr008$TestThread;", "run", "()V"},
 };
 
-#define NUMBER_OF_FRAMES ((int) (sizeof(frames)/sizeof(frame_info)))
+#define NUMBER_OF_STACK_FRAMES ((int) (sizeof(frames)/sizeof(frame_info)))
 
 void check(jvmtiEnv *jvmti_env, jthread thr, int offset, const char *note) {
     jvmtiError err;
-    jvmtiFrameInfo f[NUMBER_OF_FRAMES + 1];
+    jvmtiFrameInfo f[NUMBER_OF_STACK_FRAMES + 1];
     jclass callerClass;
     char *sigClass, *name, *sig, *generic;
     jint i, count;
@@ -86,7 +73,7 @@
     }
 
     err = jvmti_env->GetStackTrace(thr,
-        0, NUMBER_OF_FRAMES + 1, f, &count);
+        0, NUMBER_OF_STACK_FRAMES + 1, f, &count);
     if (err != JVMTI_ERROR_NONE) {
         printf("(%s, GetStackTrace) unexpected error: %s (%d)\n",
                note, TranslateError(err), err);
@@ -98,9 +85,9 @@
             printf(">>>   frame count: %d\n", count);
     }
 
-    if (count != (jint)(NUMBER_OF_FRAMES - offset)) {
+    if (count != (jint)(NUMBER_OF_STACK_FRAMES - offset)) {
         printf("(%s) wrong frame count, expected: %d, actual: %d\n",
-               note, NUMBER_OF_FRAMES, count);
+               note, NUMBER_OF_STACK_FRAMES, count);
         result = STATUS_FAILED;
     }
     for (i = 0; i < count; i++) {
@@ -135,7 +122,7 @@
             printf(">>>   class:  \"%s\"\n", sigClass);
             printf(">>>   method: \"%s%s\"\n", name, sig);
         }
-        if (i < NUMBER_OF_FRAMES) {
+        if (i < NUMBER_OF_STACK_FRAMES) {
             if (sigClass == NULL ||
                     strcmp(sigClass, frames[i + offset].cls) != 0) {
                 printf("(%s, frame#%d) wrong class sig: \"%s\",\n",
@@ -250,11 +237,8 @@
             printf(">>> redefining class ...\n");
         }
         classDef.klass = klass;
-        classDef.class_byte_count =
-            JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG((JNIEnv *)env, classBytes));
-        classDef.class_bytes = (unsigned char*)
-            JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG((JNIEnv *)env,
-                classBytes), NULL);
+        classDef.class_byte_count = env->GetArrayLength(classBytes);
+        classDef.class_bytes = (unsigned char*) env->GetByteArrayElements(classBytes, NULL);
         err = jvmti->RedefineClasses(1, &classDef);
         if (err != JVMTI_ERROR_NONE) {
             printf("(RedefineClasses) unexpected error: %s (%d)\n",
@@ -262,7 +246,7 @@
             result = STATUS_FAILED;
             return;
         }
-        JNI_ENV_PTR(env)->DeleteGlobalRef(JNI_ENV_ARG((JNIEnv *)env, classBytes));
+        env->DeleteGlobalRef(classBytes);
         classBytes = NULL;
         check(jvmti_env, thread, 2, "swap");
     }
@@ -287,8 +271,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -344,32 +327,30 @@
         return;
     }
 
-    testedThread = JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env, thr));
+    testedThread = env->NewGlobalRef(thr);
 
     if (!caps.can_generate_breakpoint_events ||
             !caps.can_generate_single_step_events) {
         return;
     }
 
-    classBytes = (jbyteArray) JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env, bytes));
+    classBytes = (jbyteArray) env->NewGlobalRef(bytes);
 
-    clazz = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, thr));
+    clazz = env->GetObjectClass(thr);
     if (clazz == NULL) {
         printf("Cannot get the class of thread object\n");
         result = STATUS_FAILED;
         return;
     }
 
-    mid_checkPoint = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, clazz),
-        "checkPoint", "()V");
+    mid_checkPoint = env->GetStaticMethodID(clazz, "checkPoint", "()V");
     if (mid_checkPoint == NULL) {
         printf("Cannot find Method ID for method \"checkPoint\"\n");
         result = STATUS_FAILED;
         return;
     }
 
-    mid_chain4 = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, clazz),
-        "chain4", "()V");
+    mid_chain4 = env->GetStaticMethodID(clazz, "chain4", "()V");
     if (mid_chain4 == NULL) {
         printf("Cannot find Method ID for method \"chain4\"\n");
         result = STATUS_FAILED;
@@ -395,8 +376,7 @@
 JNIEXPORT void JNICALL
 Java_nsk_jvmti_GetStackTrace_getstacktr008_nativeChain(JNIEnv *env, jclass cls) {
     if (mid_chain4 != NULL) {
-        JNI_ENV_PTR(env)->CallStaticVoidMethod(JNI_ENV_ARG(env, cls),
-            mid_chain4);
+        env->CallStaticVoidMethod(cls, mid_chain4);
     }
     check(jvmti, testedThread, 3, "native");
 }
@@ -406,6 +386,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr009/getstacktr009.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr009/getstacktr009.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -119,6 +105,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops001/getsysprops001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops001/getsysprops001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -144,6 +142,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops002/getsysprops002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops002/getsysprops002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -176,6 +174,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop001/getsysprop001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop001/getsysprop001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -157,6 +155,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop002/getsysprop002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop002/getsysprop002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -156,6 +154,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTag/gettag001/gettag001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTag/gettag001/gettag001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -180,6 +178,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime001/thrcputime001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime001/thrcputime001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -28,9 +28,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -376,6 +374,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime002/thrcputime002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime002/thrcputime002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -28,9 +28,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -404,6 +402,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTimerInfo/thrtimerinfo001/thrtimerinfo001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTimerInfo/thrtimerinfo001/thrtimerinfo001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -28,9 +28,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -298,6 +296,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupChildren/getthrdgrpchld001/getthrdgrpchld001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupChildren/getthrdgrpchld001/getthrdgrpchld001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -432,6 +430,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo001/thrgrpinfo001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo001/thrgrpinfo001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -70,8 +57,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -117,8 +103,7 @@
         result = STATUS_FAILED;
     }
 
-    if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, parent),
-            inf.parent) != JNI_TRUE) {
+    if (!env->IsSameObject(parent, inf.parent)) {
         printf("(%d) parent is not the same\n", stage);
         result = STATUS_FAILED;
     }
@@ -143,6 +128,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo002/thrgrpinfo002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo002/thrgrpinfo002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -127,6 +113,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadInfo/thrinfo001/thrinfo001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadInfo/thrinfo001/thrinfo001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED  0
 #define STATUS_FAILED  2
@@ -75,8 +62,7 @@
 jint  Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
     jint res;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -112,8 +98,7 @@
            threads[ind].name, threads[ind].is_daemon, inf.is_daemon);
         result = STATUS_FAILED;
     }
-    if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, group),
-            inf.thread_group) != JNI_TRUE) {
+    if (!env->IsSameObject(group, inf.thread_group)) {
         printf("Thread %s: invalid thread group\n", threads[ind].name);
         result = STATUS_FAILED;
     }
@@ -123,6 +108,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadInfo/thrinfo002/thrinfo002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadInfo/thrinfo002/thrinfo002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -113,8 +99,7 @@
            "main", 0, inf.is_daemon);
         result = STATUS_FAILED;
     }
-    if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, group),
-            inf.thread_group) != JNI_TRUE) {
+    if (!env->IsSameObject(group, inf.thread_group)) {
         printf("Thread %s: invalid thread group\n", "main");
         result = STATUS_FAILED;
     }
@@ -132,6 +117,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadLocalStorage/getthrdstor001/getthrdstor001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadLocalStorage/getthrdstor001/getthrdstor001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,9 +27,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -138,6 +136,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat001/thrstat001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat001/thrstat001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED  0
 #define STATUS_FAILED  2
@@ -117,7 +104,7 @@
         result = STATUS_FAILED;
     }
     if (thrInfo.name != NULL && strcmp(thrInfo.name, "thr1") == 0) {
-        thr_ptr = JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG((JNIEnv *)env, thread));
+        thr_ptr = env->NewGlobalRef(thread);
         if (printdump == JNI_TRUE) {
             printf(">>> ThreadStart: \"%s\", 0x%p\n", thrInfo.name, thr_ptr);
         }
@@ -244,8 +231,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->
-        GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -437,6 +423,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat002/thrstat002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat002/thrstat002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED  0
 #define STATUS_FAILED  2
@@ -102,7 +89,7 @@
         result = STATUS_FAILED;
     }
     if (thrInfo.name != NULL && strcmp(thrInfo.name, "thr1") == 0) {
-        thr_ptr = JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG((JNIEnv *)env, thread));
+        thr_ptr = env->NewGlobalRef(thread);
         if (printdump == JNI_TRUE) {
             printf(">>> ThreadStart: \"%s\", 0x%p\n", thrInfo.name, thr_ptr);
         }
@@ -135,8 +122,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv !\n");
         return JNI_ERR;
@@ -376,6 +362,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat003/thrstat003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat003/thrstat003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -81,8 +68,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -170,6 +156,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat004/thrstat004.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat004/thrstat004.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -111,6 +97,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat005/thrstat005.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat005/thrstat005.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -33,21 +33,8 @@
 #include "JVMTITools.h"
 #endif
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define THREAD_STATE_MASK ~(JVMTI_THREAD_STATE_SUSPENDED \
                             | JVMTI_THREAD_STATE_INTERRUPTED \
@@ -113,7 +100,7 @@
     jvmtiError error;
     jint res;
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &g_ppJvmtiEnv), JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &g_ppJvmtiEnv, JVMTI_VERSION_1_1);
     if ( res != JNI_OK || ! g_ppJvmtiEnv ) {
         printf("Agent_OnLoad: Error: GetEnv returned error or NULL\n");
         return JNI_ERR;
@@ -171,6 +158,4 @@
     return JNI_FALSE;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTime/gettime001/gettime001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTime/gettime001/gettime001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -28,9 +28,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -215,6 +213,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTimerInfo/timerinfo001/timerinfo001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTimerInfo/timerinfo001/timerinfo001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -28,9 +28,7 @@
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /* ============================================================================= */
 
@@ -232,6 +230,4 @@
 
 /* ============================================================================= */
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp001/topthrgrp001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp001/topthrgrp001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -134,6 +120,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp002/topthrgrp002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp002/topthrgrp002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-        JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -116,6 +102,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetVersionNumber/getvern001/getvern001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetVersionNumber/getvern001/getvern001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -27,21 +27,8 @@
 #include "agent_common.h"
 #include "JVMTITools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x,y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x,y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -68,8 +55,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->
-        GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), JVMTI_VERSION_1_1);
+    res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
     if (res != JNI_OK || jvmti == NULL) {
         printf("Wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -117,6 +103,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/TestDescription.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/TestDescription.java	Fri Sep 07 15:46:39 2018 -0700
@@ -32,13 +32,12 @@
  *     This JVMTI test is for SP02 scenario of "time sampling profiling" area.
  *     This test checks that JVMTI methods GetFrameCount() and GetStackTrace()
  *     return expected number of stack frames for each kind of thread.
- *     Threads are supended/resumed individually by SuspendThread() and ResumeThread().
- *     Checked statements:
+ *     Threads are suspended/resumed individually by SuspendThread() and ResumeThread().
+ *     Checked statements for suspended threads:
  *         - number of stack frames returned by GetFramesCount() and GetStackTrace()
- *           are not less than expected minimal stack depth.
+ *           are not less than expected minimal stack depth
  *         - number of stack frames returned by GetFrameCount() should be equal to
- *           or less than frames number returned by successive call to GetStackTrace()
- *         - for suspended thread these numbers should be strictly equal
+ *           frames number returned by successive call to GetStackTrace()
  *     Tested threads:
  *         Running             - running in Java method
  *         Entering            - entering monitor in synchronized block
@@ -48,11 +47,10 @@
  *         RunningNative       - running in native method
  *     Testcases:
  *         - start threads
- *         - check stack frames of not suspended threads
  *         - suspend each threads
  *         - check stack frames of suspended threads
  *         - resume each threads
- *         - check stack frames of resumed threads
+
  * COMMENTS
  *     Fixed according to test bug:
  *     6405644 TEST_BUG: no proper sync with agent thread in sp02t001/sp02t003
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/sp02t001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/sp02t001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -64,7 +64,7 @@
 
 /* testcase(s) */
 static int prepare();
-static int checkThreads(int suspended, const char* kind);
+static int checkSuspendedThreads();
 static int suspendThreadsIndividually(int suspend);
 static int clean();
 
@@ -87,20 +87,14 @@
             nsk_jvmti_setFailStatus();
             return;
         }
-
-        /* testcase #1: check not suspended threads */
-        NSK_DISPLAY0("Testcase #1: check stack frames of not suspended threads\n");
-        if (!checkThreads(NSK_FALSE, "not suspended"))
-            return;
-
         /* suspend threads */
         NSK_DISPLAY0("Suspend each thread\n");
         if (!suspendThreadsIndividually(NSK_TRUE))
             return;
 
-        /* testcase #2: check suspended threads */
-        NSK_DISPLAY0("Testcase #2: check stack frames of suspended threads\n");
-        if (!checkThreads(NSK_TRUE, "suspended"))
+        /* check suspended threads */
+        NSK_DISPLAY0("Check stack frames of suspended threads\n");
+        if (!checkSuspendedThreads())
             return;
 
         /* resume threads */
@@ -108,11 +102,6 @@
         if (!suspendThreadsIndividually(NSK_FALSE))
             return;
 
-        /* testcase #3: check resumed threads */
-        NSK_DISPLAY0("Testcase #3: check stack frames of resumed threads\n");
-        if (!checkThreads(NSK_FALSE, "resumed"))
-            return;
-
         /* clean date: delete threads references */
         NSK_DISPLAY0("Clean data\n");
         if (!clean()) {
@@ -237,12 +226,11 @@
  *    - invoke getFrameCount() for each thread
  *    - check if frameCount is not less than minimal stack depth
  *    - invoke getStackTrace() for each thread
- *    - check if stack depth is not less than frameCount
- *    - for suspended thread check if stack depth is equal to frameCount
+ *    - check if stack depth is equal to frameCount
  *
  * Returns NSK_TRUE if test may continue; or NSK_FALSE for test break.
  */
-static int checkThreads(int suspended, const char* kind) {
+static int checkSuspendedThreads() {
     int i;
 
     /* check each thread */
@@ -276,35 +264,23 @@
 
         /* check frame count */
         if (frameCount < threadsDesc[i].minDepth) {
-            NSK_COMPLAIN5("Too few frameCount of %s thread #%d (%s):\n"
+            NSK_COMPLAIN4("Too few frameCount of suspended thread #%d (%s):\n"
                             "#   got frameCount:   %d\n"
                             "#   expected minimum: %d\n",
-                            kind, i, threadsDesc[i].threadName,
+                            i, threadsDesc[i].threadName,
                             (int)frameCount, threadsDesc[i].minDepth);
             nsk_jvmti_setFailStatus();
         }
 
-        /* check if stack size is not less than frameCount */
-        if (frameStackSize < frameCount) {
-            NSK_COMPLAIN5("Too small stack of %s thread #%d (%s):\n"
+        if (frameStackSize != frameCount) {
+            NSK_COMPLAIN4("Different frames count for suspended thread #%d (%s):\n"
                             "#   getStackTrace(): %d\n"
                             "#   getFrameCount(): %d\n",
-                            kind, i, threadsDesc[i].threadName,
+                            i, threadsDesc[i].threadName,
                             (int)frameStackSize, (int)frameCount);
             nsk_jvmti_setFailStatus();
         }
 
-        /* for suspended thread: check if stack size is equal to frameCount */
-        if (suspended) {
-            if (frameStackSize != frameCount) {
-                NSK_COMPLAIN5("Different frames count for %s thread #%d (%s):\n"
-                                "#   getStackTrace(): %d\n"
-                                "#   getFrameCount(): %d\n",
-                                kind, i, threadsDesc[i].threadName,
-                                (int)frameStackSize, (int)frameCount);
-                nsk_jvmti_setFailStatus();
-            }
-        }
     }
 
     /* test may continue */
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/TestDescription.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/TestDescription.java	Fri Sep 07 15:46:39 2018 -0700
@@ -32,10 +32,10 @@
  *     This JVMTI test is for SP02 scenario of "time sampling profiling" area.
  *     This test checks that JVMTI methods GetStackTrace() returns expected list
  *     of stack frames including frame for tested method.
- *     Threads are supended/resumed individually by SuspendThread() and ResumeThread().
+ *     Threads are suspended/resumed individually by SuspendThread() and ResumeThread().
  *     Checked statements:
- *         - number of stack frames returned by GetFramesCount() should be equal or
- *           less than number returned by successive call to GetStackTrace()
+ *         - for suspended threads number of stack frames returned by GetFrameCount()
+  *          should be equal to frames number returned by successive call to GetStackTrace()
  *         - list of stack frames returned by GetStackTrace() should include
  *           frame for tested method
  *     Tested threads:
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/sp02t002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/sp02t002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -268,8 +268,8 @@
 /**
  * Testcase: check tested threads
  *    - call GetFrameCount() and getStackTrace()
- *    - compare numbers of stack frame returned
- *    - find stck frane with expected methodID
+ *    - for suspended thread compare number of stack frames returned
+ *    - find stack frames with expected methodID
  *
  * Returns NSK_TRUE if test may continue; or NSK_FALSE for test break.
  */
@@ -306,13 +306,14 @@
 
         NSK_DISPLAY1("    stack depth: %d\n", (int)frameStackSize);
 
-        /* check stack size */
-        if (frameStackSize < frameCount) {
-            NSK_COMPLAIN5("Too small stack of %s thread #%d (%s):\n"
-                            "#   got ctack frames:  %d\n"
-                            "#   got framesCount:   %d\n",
-                            kind, i, threadsDesc[i].threadName,
-                            (int)frameStackSize, (int)frameCount);
+        /*  Only check for suspended threads: running threads might have different
+            frames between stack grabbing calls. */
+        if (suspended && (frameStackSize != frameCount)) {
+            NSK_COMPLAIN5("Different frames count for %s thread #%d (%s):\n"
+                          "#   getStackTrace(): %d\n"
+                          "#   getFrameCount(): %d\n",
+                          kind, i, threadsDesc[i].threadName,
+                          (int)frameStackSize, (int)frameCount);
             nsk_jvmti_setFailStatus();
         }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/TestDescription.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/TestDescription.java	Fri Sep 07 15:46:39 2018 -0700
@@ -32,20 +32,15 @@
  *     This JVMTI test is for SP06 scenario of "time sampling profiling" area.
  *     This test checks that JVMTI methods GetStackTrace() returns expected list
  *     of stack frames including frame for tested method even for compiled methods.
- *     The test provokes compilation of tested methods by intensivelly calling
- *     them in a loop and then invokes GenarateEvents() to receive all
+ *     The test provokes compilation of tested methods by intensively calling
+ *     them in a loop and then invokes GenerateEvents() to receive all
  *     COMPILED_METHOD_LOAD events and mark compiled methods.
- *     Threads are supended/resumed individually by SuspendThread() and ResumeThread().
- *     Checked statements:
- *         - number of stack frames returned by GetFramesCount() should be equal or
- *           less than number returned by successive call to GetStackTrace()
- *         - list of stack frames returned by GetStackTrace() should include
- *           frame for tested method
- *     Checked statements:
- *         - stack frame info returned by GetFrameLocation() equals to the
- *           corresponding frame info returmned by GetStackTrace()
- *         - both GetFrameLocation() and GetStackTrace() include frame info
- *           for expected tested method
+ *     Threads are suspended/resumed individually by SuspendThread() and ResumeThread().
+ *     Checked statements for suspended threads:
+ *         - number of stack frames returned by GetFramesCount() and GetStackTrace()
+ *           are not less than expected minimal stack depth
+ *         - for suspended threads the number of stack frames returned by GetFrameCount()
+ *           should be equal to frames number returned by successive call to GetStackTrace()
  *     Tested threads:
  *         Running             - running in Java method
  *         Entering            - entering monitor in synchronized block
@@ -57,11 +52,9 @@
  *         - run threads and provoke methods compilation
  *         - enable events
  *         - call GenerateEvents() and mark compiled methods
- *         - check stack frames of not suspended threads
  *         - suspend each threads
  *         - check stack frames of suspended threads
  *         - resume each threads
- *         - check stack frames of resumed threads
  * COMMENTS
  *     This test is similar to 'sp02t002' but for compiled methods.
  *     Test fixed due to test bug:
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/sp06t001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/sp06t001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -81,7 +81,7 @@
 /* testcase(s) */
 static int prepare();
 static int generateEvents();
-static int checkThreads(int suspended, const char* kind);
+static int checkSuspendedThreads();
 static int suspendThreadsIndividually(int suspend);
 static int clean();
 
@@ -107,26 +107,18 @@
         if (!generateEvents())
             return;
 
-        NSK_DISPLAY0("Testcase #1: check stack frames of not suspended threads\n");
-        if (!checkThreads(NSK_FALSE, "not suspended"))
-            return;
-
         NSK_DISPLAY0("Suspend each thread\n");
         if (!suspendThreadsIndividually(NSK_TRUE))
             return;
 
-        NSK_DISPLAY0("Testcase #2: check stack frames of suspended threads\n");
-        if (!checkThreads(NSK_TRUE, "suspended"))
+        NSK_DISPLAY0("Check stack frames of suspended threads\n");
+        if (!checkSuspendedThreads())
             return;
 
         NSK_DISPLAY0("Resume each thread\n");
         if (!suspendThreadsIndividually(NSK_FALSE))
             return;
 
-        NSK_DISPLAY0("Testcase #3: check stack frames of resumed threads\n");
-        if (!checkThreads(NSK_FALSE, "resumed"))
-            return;
-
         NSK_DISPLAY0("Clean data\n");
         if (!clean()) {
             nsk_jvmti_setFailStatus();
@@ -290,12 +282,11 @@
  *    - invoke getFrameCount() for each thread
  *    - check if frameCount is not less than minimal stack depth
  *    - invoke getStackTrace() for each thread
- *    - check if stack depth is not less than frameCount
- *    - for suspended thread check if stack depth is equal to frameCount
+ *    - check if stack depth is equal to frameCount
  *
  * Returns NSK_TRUE if test may continue; or NSK_FALSE for test break.
  */
-static int checkThreads(int suspended, const char* kind0) {
+static int checkSuspendedThreads() {
     char kind[256] = "";
     int i;
 
@@ -308,7 +299,6 @@
 
         /* make proper kind */
         strcpy(kind, threadsDesc[i].methodCompiled ? "compiled " : "not compiled ");
-        strcat(kind, kind0);
         NSK_DISPLAY2("  thread #%d (%s):\n", i, threadsDesc[i].threadName);
 
         /* get frame count */
@@ -341,9 +331,8 @@
             nsk_jvmti_setFailStatus();
         }
 
-        /* check if stack size is not less than frameCount */
-        if (frameStackSize < frameCount) {
-            NSK_COMPLAIN5("Too small stack of %s thread #%d (%s):\n"
+        if (frameStackSize != frameCount) {
+            NSK_COMPLAIN5("Different frames count for %s thread #%d (%s):\n"
                             "#   getStackTrace(): %d\n"
                             "#   getFrameCount(): %d\n",
                             kind, i, threadsDesc[i].threadName,
@@ -351,17 +340,6 @@
             nsk_jvmti_setFailStatus();
         }
 
-        /* for suspended thread: check if stack size is equal to frameCount */
-        if (suspended) {
-            if (frameStackSize != frameCount) {
-                NSK_COMPLAIN5("Different frames count for %s thread #%d (%s):\n"
-                                "#   getStackTrace(): %d\n"
-                                "#   getFrameCount(): %d\n",
-                                kind, i, threadsDesc[i].threadName,
-                                (int)frameStackSize, (int)frameCount);
-                nsk_jvmti_setFailStatus();
-            }
-        }
     }
 
     /* test may continue */
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/TestDescription.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/TestDescription.java	Fri Sep 07 15:46:39 2018 -0700
@@ -32,20 +32,15 @@
  *     This JVMTI test is for SP06 scenario of "time sampling profiling" area.
  *     This test checks that JVMTI methods GetStackTrace() returns expected list
  *     of stack frames including frame for tested method even for compiled methods.
- *     The test provokes compilation of tested methods by intensivelly calling
- *     them in a loop and then invokes GenarateEvents() to receive all
+ *     The test provokes compilation of tested methods by intensively calling
+ *     them in a loop and then invokes GenerateEvents() to receive all
  *     COMPILED_METHOD_LOAD events and mark compiled methods.
- *     Threads are supended/resumed individually by SuspendThread() and ResumeThread().
+ *     Threads are suspended/resumed individually by SuspendThread() and ResumeThread().
  *     Checked statements:
- *         - number of stack frames returned by GetFramesCount() should be equal or
- *           less than number returned by successive call to GetStackTrace()
+ *         - for suspended threads number of stack frames returned by GetFrameCount()
+ *           should be equal to frames number returned by successive call to GetStackTrace()
  *         - list of stack frames returned by GetStackTrace() should include
  *           frame for tested method
- *     Checked statements:
- *         - stack frame info returned by GetFrameLocation() equals to the
- *           corresponding frame info returmned by GetStackTrace()
- *         - both GetFrameLocation() and GetStackTrace() include frame info
- *           for expected tested method
  *     Tested threads:
  *         Running             - running in Java method
  *         Entering            - entering monitor in synchronized block
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/sp06t002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/sp06t002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -289,8 +289,8 @@
 /**
  * Testcase: check tested threads.
  *    - call GetFrameCount() and getStackTrace()
- *    - compare numbers of stack frame returned
- *    - find stck frane with expected methodID
+ *    - for suspended thread compare number of stack frames returned
+ *    - find stack frames with expected methodID
  *
  * Returns NSK_TRUE if test may continue; or NSK_FALSE for test break.
  */
@@ -331,13 +331,14 @@
 
         NSK_DISPLAY1("    stack depth: %d\n", (int)frameStackSize);
 
-        /* check stack size */
-        if (frameStackSize < frameCount) {
-            NSK_COMPLAIN5("Too small stack of %s thread #%d (%s):\n"
-                            "#   got ctack frames:  %d\n"
-                            "#   got framesCount:   %d\n",
-                            kind, i, threadsDesc[i].threadName,
-                            (int)frameStackSize, (int)frameCount);
+        /*  Only check for suspended threads: running threads might have different
+            frames between stack grabbing calls. */
+        if (suspended && (frameStackSize != frameCount)) {
+            NSK_COMPLAIN5("Different frames count for %s thread #%d (%s):\n"
+                          "#   getStackTrace(): %d\n"
+                          "#   getFrameCount(): %d\n",
+                          kind, i, threadsDesc[i].threadName,
+                          (int)frameStackSize, (int)frameCount);
             nsk_jvmti_setFailStatus();
         }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref001/followref001.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref001/followref001.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -71,7 +71,7 @@
 static const jlong ROOT_OBJECT_TAG  = 10;
 static const jlong CHAIN_OBJECT_TAG = 100;
 
-static jvmtiHeapCallbacks heapCallbacks = {};
+static jvmtiHeapCallbacks heapCallbacks;
 
 /* This array has to be up-to-date with the jvmtiHeapReferenceKind enum */
 static const char* ref_kind_str[28] = {
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref002/followref002.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref002/followref002.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -69,7 +69,7 @@
 static jlong rootObjectTag  = 10;
 static jlong chainObjectTag = 100;
 
-static jvmtiHeapCallbacks heapCallbacks = {};
+static jvmtiHeapCallbacks heapCallbacks;
 
 static const char* ref_kind_str[28] = {
    "unknown_0",
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref003/followref003.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref003/followref003.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -94,7 +94,7 @@
 #define DUMMY_STRING_ARR_SLOT  11
 
 
-static jvmtiHeapCallbacks heapCallbacks = {};
+static jvmtiHeapCallbacks heapCallbacks;
 
 static const char* ref_kind_str[28] = {
    "unknown_0",
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Jdb.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Jdb.java	Fri Sep 07 15:46:39 2018 -0700
@@ -399,8 +399,14 @@
      * @param count number of prompt instances to wait for.
      */
     public String[] receiveReply(int startPos, boolean compoundPromptOnly, int count) {
-
-        int found = waitForPrompt(startPos, compoundPromptOnly, count);
+        nsk.share.Failure e = null;
+        try {
+            waitForPrompt(startPos, compoundPromptOnly, count);
+        } catch (nsk.share.Failure nsf) {
+            e = nsf;
+            launcher.getLog().display("receiveReply FAILED due to \"" + e + "\".");
+            launcher.getLog().display("Pending reply output follows:");
+        }
 
         String reply = stdoutBuffer.substring(startPos, stdoutBuffer.length());
         String[] replyArr = toStringArray(reply);
@@ -410,6 +416,7 @@
             launcher.getLog().display("reply[" + i + "]: " + replyArr[i]);
         }
 
+        if (e != null) throw e;
         return replyArr;
     }
 
@@ -443,7 +450,7 @@
         long max = getLauncher().getJdbArgumentHandler().getWaitTime() * 60 * 1000;  // maximum time to wait.
 
         if (count <= 0) {
-            throw new TestBug("Wrong number of promts count in Jdb.waitForPrompt(): " + count);
+            throw new TestBug("Wrong number of prompts count in Jdb.waitForPrompt(): " + count);
         }
 
         Object dummy = new Object();
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/MonitorEnterExecutor.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/MonitorEnterExecutor.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -23,45 +23,34 @@
 #include "jni.h"
 #include "nsk_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_PTR
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG_2(x, y) y
-#define JNI_ENV_ARG_3(x,y, z) y, z
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG_2(x,y) x, y
-#define JNI_ENV_ARG_3(x,y, z) x, y, z
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 JNIEXPORT void JNICALL
 Java_nsk_share_jdi_MonitorEnterExecutor_nativeJNIMonitorEnter(JNIEnv *env, jobject thisObject)
 {
         jint success;
 
-        success  = JNI_ENV_PTR(env)->MonitorEnter(JNI_ENV_ARG_2(env, thisObject));
+        success  = env->MonitorEnter(thisObject);
 
         if(success != 0)
         {
                 NSK_COMPLAIN1("MonitorEnter return non-zero: %d\n", success);
 
-                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "MonitorEnter return non-zero"));
+                env->ThrowNew(
+                    env->FindClass("nsk/share/TestJNIError"),
+                    "MonitorEnter return non-zero");
         }
 
-        success  = JNI_ENV_PTR(env)->MonitorExit(JNI_ENV_ARG_2(env, thisObject));
+        success  = env->MonitorExit(thisObject);
 
         if(success != 0)
         {
                 NSK_COMPLAIN1("MonitorExit return non-zero: %d\n", success);
 
-                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "MonitorExit return non-zero"));
+                env->ThrowNew(
+                    env->FindClass("nsk/share/TestJNIError"),
+                    "MonitorExit return non-zero");
         }
 }
 
@@ -70,22 +59,26 @@
 {
         jint success;
 
-        success  = JNI_ENV_PTR(env)->MonitorEnter(JNI_ENV_ARG_2(env, thisObject));
+        success  = env->MonitorEnter(thisObject);
 
         if(success != 0)
         {
                 NSK_COMPLAIN1("MonitorEnter return non-zero: %d\n", success);
 
-                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "MonitorEnter return non-zero"));
+                env->ThrowNew(
+                    env->FindClass("nsk/share/TestJNIError"),
+                    "MonitorEnter return non-zero");
         }
 
-        success  = JNI_ENV_PTR(env)->MonitorExit(JNI_ENV_ARG_2(env, thisObject));
+        success  = env->MonitorExit(thisObject);
 
         if(success != 0)
         {
                 NSK_COMPLAIN1("MonitorExit return non-zero: %d\n", success);
 
-                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "MonitorExit return non-zero"));
+                env->ThrowNew(
+                    env->FindClass("nsk/share/TestJNIError"),
+                    "MonitorExit return non-zero");
         }
 }
 
@@ -94,25 +87,27 @@
 {
         jint success;
 
-        success  = JNI_ENV_PTR(env)->MonitorEnter(JNI_ENV_ARG_2(env, thisObject));
+        success  = env->MonitorEnter(thisObject);
 
         if(success != 0)
         {
                 NSK_COMPLAIN1("MonitorEnter return non-zero: %d\n", success);
 
-                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "MonitorEnter return non-zero"));
+                env->ThrowNew(
+                    env->FindClass("nsk/share/TestJNIError"),
+                    "MonitorEnter return non-zero");
         }
 
-        success  = JNI_ENV_PTR(env)->MonitorExit(JNI_ENV_ARG_2(env, thisObject));
+        success  = env->MonitorExit(thisObject);
 
         if(success != 0)
         {
                 NSK_COMPLAIN1("MonitorExit return non-zero: %d\n", success);
 
-                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "MonitorExit return non-zero"));
+                env->ThrowNew(
+                    env->FindClass("nsk/share/TestJNIError"),
+                    "MonitorExit return non-zero");
         }
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/jni/JNIreferences.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jni/JNIreferences.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -24,25 +24,8 @@
 #include <stdlib.h>
 #include "nsk_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_PTR
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG_2(x, y) y
-#define JNI_ENV_ARG_3(x, y, z) y, z
-#define JNI_ENV_ARG_4(x, y, z, a) y, z, a
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG_2(x,y) x, y
-#define JNI_ENV_ARG_3(x, y, z) x, y, z
-#define JNI_ENV_ARG_4(x, y, z, a) x, y, z, a
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 static jobject* globalReferences = NULL;
 static jweak* weakReferences = NULL;
@@ -76,13 +59,15 @@
 
                 if(reference == NULL)
                 {
-                        reference = JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG_2(env, object));
+                        reference = env->NewGlobalRef(object);
 
                         if(reference == NULL)
                         {
                                 NSK_COMPLAIN0("NewGlobalRef return NULL\n");
 
-                                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "NewGlobalRef return NULL"));
+                                env->ThrowNew(
+                                    env->FindClass("nsk/share/TestJNIError"),
+                                    "NewGlobalRef return NULL");
                         }
 
                         globalReferences[i] = reference;
@@ -106,10 +91,12 @@
         {
                 NSK_COMPLAIN1("globalReferences[%d] = NULL, possible wrong index is passed\n", index);
 
-                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestBug")), "Requested globalReferences[] element is NULL, possible wrong index is passed"));
+                env->ThrowNew(
+                    env->FindClass("nsk/share/TestBug"),
+                    "Requested globalReferences[] element is NULL, possible wrong index is passed");
         }
 
-        JNI_ENV_PTR(env)->DeleteGlobalRef(JNI_ENV_ARG_2(env, reference));
+        env->DeleteGlobalRef(reference);
 
         globalReferences[index] = NULL;
 }
@@ -119,23 +106,27 @@
 Java_nsk_share_ReferringObject_createJNILocalReferenceNative(JNIEnv *env,
         jobject thisObject, jobject object, jobject createWicket, jobject deleteWicket)
 {
-        jobject reference = JNI_ENV_PTR(env)->NewLocalRef(JNI_ENV_ARG_2(env, object));
+        jobject reference = env->NewLocalRef(object);
         jclass klass;
 
         if(reference == NULL)
         {
                 NSK_COMPLAIN0("NewLocalRef return NULL\n");
 
-                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "NewLocalRef return NULL"));
+                env->ThrowNew(
+                    env->FindClass("nsk/share/TestJNIError"),
+                    "NewLocalRef return NULL");
         }
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, createWicket));
+        klass = env->GetObjectClass(createWicket);
 
         // notify another thread that JNI local reference has been created
-        JNI_ENV_PTR(env)->CallVoidMethod(JNI_ENV_ARG_3(env, createWicket, JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG_4(env, klass, "unlock", "()V"))));
+        env->CallVoidMethod(createWicket,
+                            env->GetMethodID(klass, "unlock", "()V"));
 
         // wait till JNI local reference can be released (it will heppen then we will leave the method)
-        JNI_ENV_PTR(env)->CallVoidMethod(JNI_ENV_ARG_3(env, deleteWicket, JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG_4(env, klass, "waitFor", "()V"))));
+        env->CallVoidMethod(deleteWicket,
+                            env->GetMethodID(klass, "waitFor", "()V"));
 }
 
 JNIEXPORT jint JNICALL
@@ -168,13 +159,15 @@
 
                 if(reference == NULL)
                 {
-                        reference = JNI_ENV_PTR(env)->NewWeakGlobalRef(JNI_ENV_ARG_2(env, object));
+                        reference = env->NewWeakGlobalRef(object);
 
                         if(reference == NULL)
                         {
                                 NSK_COMPLAIN0("NewWeakGlobalRef return NULL\n");
 
-                                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "NewWeakGlobalRef return NULL"));
+                                env->ThrowNew(
+                                    env->FindClass("nsk/share/TestJNIError"),
+                                    "NewWeakGlobalRef return NULL");
                         }
 
                         weakReferences[i] = reference;
@@ -198,21 +191,23 @@
         {
                 NSK_COMPLAIN1("weakReferences[%d] = NULL, possible wrong index is passed\n", index);
 
-                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestBug")), "Requested weakReferences[] element is NULL, possible wrong index is passed"));
+                env->ThrowNew(
+                    env->FindClass("nsk/share/TestBug"),
+                    "Requested weakReferences[] element is NULL, possible wrong index is passed");
         }
 
-        if(JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG_3(env, reference, NULL)) == JNI_TRUE)
+        if(env->IsSameObject(reference, NULL) == JNI_TRUE)
         {
                 NSK_COMPLAIN0("TEST BUG: Weak reference was collected\n");
 
-                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestBug")), "TEST BUG: Weak reference was collected"));
+                env->ThrowNew(
+                    env->FindClass("nsk/share/TestBug"),
+                    "TEST BUG: Weak reference was collected");
         }
 
-        JNI_ENV_PTR(env)->DeleteWeakGlobalRef(JNI_ENV_ARG_2(env, reference));
+        env->DeleteWeakGlobalRef(reference);
 
         weakReferences[index] = NULL;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/libNativeMethodsTestThread.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/libNativeMethodsTestThread.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -23,36 +23,16 @@
 #include "jni.h"
 #include <stdlib.h>
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_PTR
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG_2(x, y) y
-#define JNI_ENV_ARG_3(x, y, z) y, z
-#define JNI_ENV_ARG_4(x, y, z, a) y, z, a
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG_2(x,y) x, y
-#define JNI_ENV_ARG_3(x, y, z) x, y, z
-#define JNI_ENV_ARG_4(x, y, z, a) x, y, z, a
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 static void logMessage(JNIEnv *env, jobject thisObject, jstring message)
 {
         jclass klass;
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
-        JNI_ENV_PTR(env)->CallVoidMethod(
-        JNI_ENV_ARG_4(
-                env,
-                thisObject,
-                JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG_4(env, klass, "log", "(Ljava/lang/String;)V")),
-                message));
+        klass = env->GetObjectClass(thisObject);
+        env->CallVoidMethod(thisObject,
+                            env->GetMethodID(klass, "log", "(Ljava/lang/String;)V"),
+                            message);
 }
 
 JNIEXPORT void JNICALL
@@ -71,15 +51,11 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedBooleanValue",
-                "Z"));
+        valueField = env->GetStaticFieldID(klass, "expectedBooleanValue", "Z");
 
-        return JNI_ENV_PTR(env)->GetStaticBooleanField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticBooleanField(klass, valueField);
 }
 
 JNIEXPORT jbyte JNICALL
@@ -91,15 +67,11 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedByteValue",
-                "B"));
+        valueField = env->GetStaticFieldID(klass, "expectedByteValue", "B");
 
-        return JNI_ENV_PTR(env)->GetStaticByteField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticByteField(klass, valueField);
 }
 
 JNIEXPORT jshort JNICALL
@@ -111,15 +83,11 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedShortValue",
-                "S"));
+        valueField = env->GetStaticFieldID(klass, "expectedShortValue", "S");
 
-        return JNI_ENV_PTR(env)->GetStaticShortField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticShortField(klass, valueField);
 }
 
 JNIEXPORT jchar JNICALL
@@ -131,15 +99,11 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedCharValue",
-                "C"));
+        valueField = env->GetStaticFieldID(klass, "expectedCharValue", "C");
 
-        return JNI_ENV_PTR(env)->GetStaticCharField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticCharField(klass, valueField);
 }
 
 JNIEXPORT jint JNICALL
@@ -151,15 +115,11 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedIntValue",
-                "I"));
+        valueField = env->GetStaticFieldID(klass, "expectedIntValue", "I");
 
-        return JNI_ENV_PTR(env)->GetStaticIntField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticIntField(klass, valueField);
 }
 
 JNIEXPORT jlong JNICALL
@@ -171,15 +131,11 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedLongValue",
-                "J"));
+        valueField = env->GetStaticFieldID(klass, "expectedLongValue", "J");
 
-        return JNI_ENV_PTR(env)->GetStaticLongField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticLongField(klass, valueField);
 }
 
 JNIEXPORT jfloat JNICALL
@@ -191,15 +147,11 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedFloatValue",
-                "F"));
+        valueField = env->GetStaticFieldID(klass, "expectedFloatValue", "F");
 
-        return JNI_ENV_PTR(env)->GetStaticFloatField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticFloatField(klass, valueField);
 }
 
 JNIEXPORT jdouble JNICALL
@@ -211,15 +163,11 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedDoubleValue",
-                "D"));
+        valueField = env->GetStaticFieldID(klass, "expectedDoubleValue", "D");
 
-        return JNI_ENV_PTR(env)->GetStaticDoubleField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticDoubleField(klass, valueField);
 }
 
 JNIEXPORT jobject JNICALL
@@ -231,15 +179,12 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedObjectArrayValue",
-                "[Ljava/lang/Object;"));
+        valueField = env->GetStaticFieldID(klass, "expectedObjectArrayValue",
+                                           "[Ljava/lang/Object;");
 
-        return JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticObjectField(klass, valueField);
 }
 
 JNIEXPORT jobject JNICALL
@@ -251,15 +196,12 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedStringValue",
-                "Ljava/lang/String;"));
+        valueField = env->GetStaticFieldID(klass, "expectedStringValue",
+                                           "Ljava/lang/String;");
 
-        return JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticObjectField(klass, valueField);
 }
 
 JNIEXPORT jobject JNICALL
@@ -271,15 +213,12 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedThreadValue",
-                "Ljava/lang/Thread;"));
+        valueField = env->GetStaticFieldID(klass, "expectedThreadValue",
+                                           "Ljava/lang/Thread;");
 
-        return JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticObjectField(klass, valueField);
 }
 
 JNIEXPORT jobject JNICALL
@@ -291,15 +230,12 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedThreadGroupValue",
-                "Ljava/lang/ThreadGroup;"));
+        valueField = env->GetStaticFieldID(klass, "expectedThreadGroupValue",
+                                           "Ljava/lang/ThreadGroup;");
 
-        return JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticObjectField(klass, valueField);
 }
 
 JNIEXPORT jobject JNICALL
@@ -311,15 +247,12 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedClassObjectValue",
-                "Ljava/lang/Class;"));
+        valueField = env->GetStaticFieldID(klass, "expectedClassObjectValue",
+                                           "Ljava/lang/Class;");
 
-        return JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticObjectField(klass, valueField);
 }
 
 JNIEXPORT jobject JNICALL
@@ -331,15 +264,12 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedClassLoaderValue",
-                "Ljava/lang/ClassLoader;"));
+        valueField = env->GetStaticFieldID(klass, "expectedClassLoaderValue",
+                                           "Ljava/lang/ClassLoader;");
 
-        return JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticObjectField(klass, valueField);
 }
 
 JNIEXPORT jobject JNICALL
@@ -351,15 +281,12 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedObjectValue",
-                "Ljava/lang/Object;"));
+        valueField = env->GetStaticFieldID(klass, "expectedObjectValue",
+                                           "Ljava/lang/Object;");
 
-        return JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticObjectField(klass, valueField);
 }
 
 JNIEXPORT jobject JNICALL
@@ -371,15 +298,12 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedBooleanWrapperValue",
-                "Ljava/lang/Boolean;"));
+        valueField = env->GetStaticFieldID(klass, "expectedBooleanWrapperValue",
+                                           "Ljava/lang/Boolean;");
 
-        return JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticObjectField(klass, valueField);
 }
 
 JNIEXPORT jobject JNICALL
@@ -391,15 +315,12 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedByteWrapperValue",
-                "Ljava/lang/Byte;"));
+        valueField = env->GetStaticFieldID(klass, "expectedByteWrapperValue",
+                                           "Ljava/lang/Byte;");
 
-        return JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticObjectField(klass, valueField);
 }
 
 JNIEXPORT jobject JNICALL
@@ -411,15 +332,12 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedShortWrapperValue",
-                "Ljava/lang/Short;"));
+        valueField = env->GetStaticFieldID(klass, "expectedShortWrapperValue",
+                                           "Ljava/lang/Short;");
 
-        return JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticObjectField(klass, valueField);
 }
 
 JNIEXPORT jobject JNICALL
@@ -431,15 +349,12 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedCharWrapperValue",
-                "Ljava/lang/Character;"));
+        valueField = env->GetStaticFieldID(klass, "expectedCharWrapperValue",
+                                           "Ljava/lang/Character;");
 
-        return JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticObjectField(klass, valueField);
 }
 
 JNIEXPORT jobject JNICALL
@@ -451,15 +366,12 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedIntWrapperValue",
-                "Ljava/lang/Integer;"));
+        valueField = env->GetStaticFieldID(klass, "expectedIntWrapperValue",
+                                           "Ljava/lang/Integer;");
 
-        return JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticObjectField(klass, valueField);
 }
 
 JNIEXPORT jobject JNICALL
@@ -471,15 +383,12 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedLongWrapperValue",
-                "Ljava/lang/Long;"));
+        valueField = env->GetStaticFieldID(klass, "expectedLongWrapperValue",
+                                           "Ljava/lang/Long;");
 
-        return JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticObjectField(klass, valueField);
 }
 
 JNIEXPORT jobject JNICALL
@@ -491,15 +400,12 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedFloatWrapperValue",
-                "Ljava/lang/Float;"));
+        valueField = env->GetStaticFieldID(klass, "expectedFloatWrapperValue",
+                                           "Ljava/lang/Float;");
 
-        return JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticObjectField(klass, valueField);
 }
 
 JNIEXPORT jobject JNICALL
@@ -511,17 +417,12 @@
 
         logMessage(env, thisObject, message);
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        valueField = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG_4(
-                env,
-                klass,
-                "expectedDoubleWrapperValue",
-                "Ljava/lang/Double;"));
+        valueField = env->GetStaticFieldID(klass, "expectedDoubleWrapperValue",
+                                           "Ljava/lang/Double;");
 
-        return JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG_3(env, klass, valueField));
+        return env->GetStaticObjectField(klass, valueField);
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_FollowRefObjects.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_FollowRefObjects.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -35,7 +35,7 @@
 
 int g_fakeUserData = 0;
 int g_userDataError = 0;
-jvmtiHeapCallbacks g_wrongHeapCallbacks = {};
+jvmtiHeapCallbacks g_wrongHeapCallbacks;
 
 /* This array has to be up-to-date with the jvmtiHeapReferenceKind enum */
 const char * const g_refKindStr[28] = {
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/locks/JNIMonitorLocker.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/locks/JNIMonitorLocker.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -23,25 +23,8 @@
 #include "jni.h"
 #include "nsk_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_PTR
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG_2(x, y) y
-#define JNI_ENV_ARG_3(x, y, z) y, z
-#define JNI_ENV_ARG_4(x, y, z, a) y, z, a
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG_2(x,y) x, y
-#define JNI_ENV_ARG_3(x, y, z) x, y, z
-#define JNI_ENV_ARG_4(x, y, z, a) x, y, z, a
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 JNIEXPORT void JNICALL
 Java_nsk_share_locks_JNIMonitorLocker_doLock(JNIEnv *env, jobject thisObject)
@@ -74,54 +57,60 @@
         // class for field 'inner'
         jclass deadlockLockerClass;
 
-        success = JNI_ENV_PTR(env)->MonitorEnter(JNI_ENV_ARG_2(env, thisObject));
+        success = env->MonitorEnter(thisObject);
 
         if(success != 0)
         {
                 NSK_COMPLAIN1("MonitorEnter return non-zero: %d\n", success);
 
-                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "MonitorEnter return non-zero"));
+                env->ThrowNew(
+                    env->FindClass("nsk/share/TestJNIError"),
+                    "MonitorEnter return non-zero");
         }
 
-        thisObjectClass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        thisObjectClass = env->GetObjectClass(thisObject);
 
         // step1.unlockAll()
-        field = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG_4(env, thisObjectClass, "step1", "Lnsk/share/Wicket;"));
+        field = env->GetFieldID(thisObjectClass, "step1", "Lnsk/share/Wicket;");
 
-        wicketObject = JNI_ENV_PTR(env)->GetObjectField(JNI_ENV_ARG_3(env, thisObject, field));
-        wicketClass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, wicketObject));
+        wicketObject = env->GetObjectField(thisObject, field);
+        wicketClass = env->GetObjectClass(wicketObject);
 
-        JNI_ENV_PTR(env)->CallVoidMethod(JNI_ENV_ARG_3(env, wicketObject, JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG_4(env, wicketClass, "unlockAll", "()V"))));
+        env->CallVoidMethod(wicketObject,
+                            env->GetMethodID(wicketClass, "unlockAll", "()V"));
 
         // step2.waitFor()
-        field = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG_4(env, thisObjectClass, "step2", "Lnsk/share/Wicket;"));
-        wicketObject = JNI_ENV_PTR(env)->GetObjectField(JNI_ENV_ARG_3(env, thisObject, field));
+        field = env->GetFieldID(thisObjectClass, "step2", "Lnsk/share/Wicket;");
+        wicketObject = env->GetObjectField(thisObject, field);
 
-        JNI_ENV_PTR(env)->CallVoidMethod(JNI_ENV_ARG_3(env, wicketObject, JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG_4(env, wicketClass, "waitFor", "()V"))));
+        env->CallVoidMethod(wicketObject,
+                            env->GetMethodID(wicketClass, "waitFor", "()V"));
 
         // readyWicket.unlock()
-        field = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG_4(env, thisObjectClass, "readyWicket", "Lnsk/share/Wicket;"));
-        wicketObject = JNI_ENV_PTR(env)->GetObjectField(JNI_ENV_ARG_3(env, thisObject, field));
+        field = env->GetFieldID(thisObjectClass, "readyWicket", "Lnsk/share/Wicket;");
+        wicketObject = env->GetObjectField(thisObject, field);
 
-        JNI_ENV_PTR(env)->CallVoidMethod(JNI_ENV_ARG_3(env, wicketObject, JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG_4(env, wicketClass, "unlock", "()V"))));
+        env->CallVoidMethod(wicketObject,
+                            env->GetMethodID(wicketClass, "unlock", "()V"));
 
         // inner.lock()
-        field = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG_4(env, thisObjectClass, "inner", "Lnsk/share/locks/DeadlockLocker;"));
-        innerObject = JNI_ENV_PTR(env)->GetObjectField(JNI_ENV_ARG_3(env, thisObject, field));
-        deadlockLockerClass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, innerObject));
+        field = env->GetFieldID(thisObjectClass, "inner", "Lnsk/share/locks/DeadlockLocker;");
+        innerObject = env->GetObjectField(thisObject, field);
+        deadlockLockerClass = env->GetObjectClass(innerObject);
 
-        JNI_ENV_PTR(env)->CallVoidMethod(JNI_ENV_ARG_3(env, innerObject, JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG_4(env, deadlockLockerClass, "lock", "()V"))));
+        env->CallVoidMethod(innerObject,
+                            env->GetMethodID(deadlockLockerClass, "lock", "()V"));
 
-        success = JNI_ENV_PTR(env)->MonitorExit(JNI_ENV_ARG_2(env, thisObject));
+        success = env->MonitorExit(thisObject);
 
         if(success != 0)
         {
                 NSK_COMPLAIN1("MonitorExit return non-zero: %d\n", success);
 
-                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "MonitorExit return non-zero"));
+                env->ThrowNew(
+                    env->FindClass("nsk/share/TestJNIError"),
+                    "MonitorExit return non-zero");
         }
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/locks/LockingThread.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/locks/LockingThread.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -23,25 +23,8 @@
 #include "jni.h"
 #include "nsk_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_PTR
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG_2(x, y) y
-#define JNI_ENV_ARG_3(x, y, z) y, z
-#define JNI_ENV_ARG_4(x, y, z, a) y, z, a
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG_2(x,y) x, y
-#define JNI_ENV_ARG_3(x, y, z) x, y, z
-#define JNI_ENV_ARG_4(x, y, z, a) x, y, z, a
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 JNIEXPORT void JNICALL
 Java_nsk_share_locks_LockingThread_nativeJNIMonitorEnter(JNIEnv *env, jobject thisObject, jobject object)
@@ -49,29 +32,32 @@
         jint success;
         jclass klass;
 
-        success  = JNI_ENV_PTR(env)->MonitorEnter(JNI_ENV_ARG_2(env, object));
+        success  = env->MonitorEnter(object);
 
         if(success != 0)
         {
                 NSK_COMPLAIN1("MonitorEnter return non-zero: %d\n", success);
 
-                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "MonitorEnter return non-zero"));
+                env->ThrowNew(
+                    env->FindClass("nsk/share/TestJNIError"),
+                    "MonitorEnter return non-zero");
         }
 
-        klass = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG_2(env, thisObject));
+        klass = env->GetObjectClass(thisObject);
 
-        JNI_ENV_PTR(env)->CallVoidMethod(JNI_ENV_ARG_3(env, thisObject, JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG_4(env, klass, "createStackFrame", "()V"))));
+        env->CallVoidMethod(thisObject,
+                            env->GetMethodID(klass, "createStackFrame", "()V"));
 
-        success  = JNI_ENV_PTR(env)->MonitorExit(JNI_ENV_ARG_2(env, object));
+        success  = env->MonitorExit(object);
 
         if(success != 0)
         {
                 NSK_COMPLAIN1("MonitorExit return non-zero: %d\n", success);
 
-                JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG_3(env, JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG_2(env, "nsk/share/TestJNIError")), "MonitorExit return non-zero"));
+                env->ThrowNew(
+                    env->FindClass("nsk/share/TestJNIError"),
+                    "MonitorExit return non-zero");
         }
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/shared/redefineClasses.cpp	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/shared/redefineClasses.cpp	Fri Sep 07 15:46:39 2018 -0700
@@ -30,21 +30,8 @@
 #include "JVMTITools.h"
 #include "jvmti_tools.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
 
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
 
 static jvmtiEnv *test_jvmti = NULL;
 static jvmtiCapabilities caps;
@@ -126,6 +113,4 @@
     return Agent_Initialize(jvm, options, reserved);
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/jdk/ProblemList.txt	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/ProblemList.txt	Fri Sep 07 15:46:39 2018 -0700
@@ -840,8 +840,6 @@
 
 com/sun/jdi/RepStep.java                                        8043571 generic-all
 
-com/sun/jdi/GetLocalVariables4Test.sh                           8067354 windows-all
-
 com/sun/jdi/sde/SourceDebugExtensionTest.java                   8158066 windows-all
 
 com/sun/jdi/NashornPopFrameTest.java                            8187143 generic-all
--- a/test/jdk/com/oracle/security/ucrypto/TestAES.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/oracle/security/ucrypto/TestAES.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -39,6 +39,7 @@
 import javax.crypto.*;
 import javax.crypto.spec.*;
 
+import jdk.test.lib.OSVersion;
 import jdk.test.lib.Platform;
 import jdk.test.lib.Utils;
 
@@ -376,9 +377,6 @@
 
     // The cases on CFB128 mode have to be skipped on pre-S11.3.
     private static boolean isBadSolaris() {
-        return Platform.isSolaris()
-                && Platform.getOsVersionMajor() <= 5
-                && Platform.getOsVersionMinor() <= 11
-                && Utils.distro().compareTo("11.3") < 0;
+        return Platform.isSolaris() && OSVersion.current().compareTo(new OSVersion(11, 3)) < 0;
     }
 }
--- a/test/jdk/com/sun/jdi/ArrayLengthDumpTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/ArrayLengthDumpTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -90,7 +90,7 @@
 
     @Override
     protected void runCases() {
-        setBreakpoints(System.getProperty("test.src") + "/ArrayLengthDumpTest.java", 1);
+        setBreakpointsFromTestSource("ArrayLengthDumpTest.java", 1);
 
         // Run to breakpoint #1
         jdb.command(JdbCommand.run());
--- a/test/jdk/com/sun/jdi/BadAgentPath.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/BadAgentPath.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,18 +21,16 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.Utils;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 /* @test
  * @bug 8147456
  * @summary Check that providing a non-existing -agentpath gives a proper error.
  * @author Sharath Ballal
  *
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.management
- * @build jdk.testlibrary.*
  * @build BadAgentPath
  * @run driver BadAgentPath
  */
--- a/test/jdk/com/sun/jdi/BadHandshakeTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/BadHandshakeTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,12 +37,13 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import jdk.testlibrary.Utils;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 /* @test
  * @bug 6306165 6432567
  * @summary Check that a bad handshake doesn't cause a debuggee to abort
  * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @modules java.management
  *          jdk.jdi
--- a/test/jdk/com/sun/jdi/BreakpointWithFullGC.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/BreakpointWithFullGC.java	Fri Sep 07 15:46:39 2018 -0700
@@ -67,7 +67,7 @@
     }
 
     private BreakpointWithFullGC() {
-        super(new Jdb.LaunchOptions(DEBUGGEE_CLASS)
+        super(new LaunchOptions(DEBUGGEE_CLASS)
                      .addDebuggeeOptions(DEBUGGEE_OPTIONS));
     }
 
@@ -77,7 +77,7 @@
 
     @Override
     protected void runCases() {
-        setBreakpoints(System.getProperty("test.src") + "/BreakpointWithFullGC.java", 1);
+        setBreakpointsFromTestSource("BreakpointWithFullGC.java", 1);
 
         // get to the first loop breakpoint
         jdb.command(JdbCommand.run());
@@ -90,14 +90,14 @@
 
         jdb.contToExit(1);
 
-        new OutputAnalyzer(jdb.getJdbOutput())
+        new OutputAnalyzer(getJdbOutput())
                 // make sure we hit the first breakpoint at least once
                 .stdoutShouldMatch("System\\..*top of loop")
                 // make sure we hit the second breakpoint at least once
                 .stdoutShouldMatch("System\\..*bottom of loop")
                 // make sure we hit the last breakpoint
                 .stdoutShouldMatch("System\\..*end of test");
-        new OutputAnalyzer(jdb.getDebuggeeOutput())
+        new OutputAnalyzer(getDebuggeeOutput())
                 // check for error message due to thread ID change
                 .stderrShouldNotContain("Exception in thread \"event-handler\" java.lang.NullPointerException");
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/CatchAllTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4749692
+ * @summary REGRESSION: jdb rejects the syntax catch java.lang.IndexOutOfBoundsException
+ * @comment converted from test/jdk/com/sun/jdi/CatchAllTest.sh
+ *
+ * @library /test/lib
+ * @build CatchAllTest
+ * @run main/othervm CatchAllTest
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+class CatchAllTestTarg {
+    public void bar() {
+        System.out.println("bar");        // @1 breakpoint
+    }
+
+    public static void main(String[] args) {
+        CatchAllTestTarg my = new CatchAllTestTarg();
+        my.bar();
+    }
+}
+
+public class CatchAllTest extends JdbTest {
+    public static void main(String argv[]) {
+        new CatchAllTest().run();
+    }
+
+    private CatchAllTest() {
+        super(DEBUGGEE_CLASS);
+    }
+
+    private static final String DEBUGGEE_CLASS = CatchAllTestTarg.class.getName();
+
+    @Override
+    protected void runCases() {
+        setBreakpointsFromTestSource("CatchAllTest.java", 1);
+        // Run to breakpoint #1
+        jdb.command(JdbCommand.run());
+
+        final String IOOB = "java.lang.IndexOutOfBoundsException";
+        jdb.command(JdbCommand.catch_(IOOB));
+        jdb.command(JdbCommand.catch_(""));
+        jdb.command(JdbCommand.ignore(""));
+        jdb.command(JdbCommand.ignore(IOOB));
+        jdb.command(JdbCommand.catch_(JdbCommand.ExType.all, IOOB));
+        jdb.command(JdbCommand.ignore(JdbCommand.ExType.all, IOOB));
+        jdb.command(JdbCommand.catch_(JdbCommand.ExType.caught, IOOB));
+        jdb.command(JdbCommand.ignore(JdbCommand.ExType.caught, IOOB));
+        jdb.command(JdbCommand.catch_(JdbCommand.ExType.uncaught, IOOB));
+        jdb.command(JdbCommand.ignore(JdbCommand.ExType.uncaught, IOOB));
+
+        jdb.contToExit(1);
+
+        new OutputAnalyzer(getJdbOutput())
+                .shouldNotContain("Usage: catch")
+                .shouldNotContain("Usage: ignore");
+    }
+
+}
--- a/test/jdk/com/sun/jdi/CatchAllTest.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2014, 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
-#  @bug 4749692
-#  @summary REGRESSION: jdb rejects the syntax catch java.lang.IndexOutOfBoundsException
-#  @author Tim Bell
-#
-#  @key intermittent
-#  @run shell CatchAllTest.sh
-#
-classname=CatchAllTestTarg
-
-createJavaFile()
-{
-    cat <<EOF > $classname.java.1
-class $classname {
-    public void bar() {
-        System.out.println("bar");        // @1 breakpoint
-    }
-
-    public static void main(String[] args) {
-        CatchAllTestTarg my = new CatchAllTestTarg();
-        my.bar();
-    }
-}
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-   setBkpts @1
-   runToBkpt @1
-   cmd catch           java.lang.IndexOutOfBoundsException
-   cmd catch
-   cmd ignore
-   cmd ignore          java.lang.IndexOutOfBoundsException
-   cmd catch  all      java.lang.IndexOutOfBoundsException
-   cmd ignore all      java.lang.IndexOutOfBoundsException
-   cmd catch  caught   java.lang.IndexOutOfBoundsException
-   cmd ignore caught   java.lang.IndexOutOfBoundsException
-   cmd catch  uncaught java.lang.IndexOutOfBoundsException
-   cmd ignore uncaught java.lang.IndexOutOfBoundsException
-   cmd allowExit cont
-}
-
-mysetup()
-{
-    if [ -z "$TESTSRC" ] ; then
-        TESTSRC=.
-    fi
-
-    for ii in . $TESTSRC $TESTSRC/.. ; do
-        if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh
-            break
-        fi
-    done
-}
-
-
-# You could replace this next line with the contents
-# of ShellScaffold.sh and this script will run just the same.
-mysetup
-
-runit
-#
-jdbFailIfPresent "Usage: catch"
-jdbFailIfPresent "Usage: ignore"
-#
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/CatchCaughtTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4788864
+ * @summary TTY: 'catch caught' with no class pattern throws NullPointerException
+ * @comment converted from test/jdk/com/sun/jdi/CatchCaughtTest.sh
+ *
+ * @library /test/lib
+ * @build CatchCaughtTest
+ * @run main/othervm CatchCaughtTest
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+class CatchCaughtTestTarg {
+    public void bar() {
+        System.out.println("bar");        // @1 breakpoint
+    }
+
+    public static void main(String[] args) {
+        CatchCaughtTestTarg my = new CatchCaughtTestTarg();
+        my.bar();
+    }
+}
+
+public class CatchCaughtTest extends JdbTest {
+    public static void main(String argv[]) {
+        new CatchCaughtTest().run();
+    }
+
+    private CatchCaughtTest() {
+        super(DEBUGGEE_CLASS);
+    }
+
+    private static final String DEBUGGEE_CLASS = CatchCaughtTestTarg.class.getName();
+
+    @Override
+    protected void runCases() {
+        setBreakpointsFromTestSource("CatchCaughtTest.java", 1);
+        // Run to breakpoint #1
+        jdb.command(JdbCommand.run());
+
+        jdb.command(JdbCommand.catch_(JdbCommand.ExType.caught, ""));
+
+        jdb.contToExit(1);
+
+        new OutputAnalyzer(getJdbOutput())
+                .shouldNotContain("Internal exception")
+                .shouldContain("Usage: catch");
+    }
+
+}
--- a/test/jdk/com/sun/jdi/CatchCaughtTest.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2014, 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
-#  @bug 4788864
-#  @summary TTY: 'catch caught' with no class pattern throws NullPointerException
-#  @author Tim Bell
-#
-#  @key intermittent
-#  @run shell CatchCaughtTest.sh
-#
-classname=CatchCaughtTestTarg
-
-createJavaFile()
-{
-    cat <<EOF > $classname.java.1
-class $classname {
-    public void bar() {
-        System.out.println("bar");        // @1 breakpoint
-    }
-
-    public static void main(String[] args) {
-        CatchCaughtTestTarg my = new CatchCaughtTestTarg();
-        my.bar();
-    }
-}
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-   setBkpts @1
-   runToBkpt @1
-   cmd catch caught
-   cmd allowExit cont
-}
-
-mysetup()
-{
-    if [ -z "$TESTSRC" ] ; then
-        TESTSRC=.
-    fi
-
-    for ii in . $TESTSRC $TESTSRC/.. ; do
-        if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh
-            break
-        fi
-    done
-}
-
-
-# You could replace this next line with the contents
-# of ShellScaffold.sh and this script will run just the same.
-mysetup
-
-runit
-#
-jdbFailIfPresent "Internal exception"
-jdbFailIfNotPresent "Usage: catch"
-#
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/CommandCommentDelimiter.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2004, 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
+ * @bug 4507088
+ * @summary TTY: Add a comment delimiter to the jdb command set
+ * @comment converted from test/jdk/com/sun/jdi/CommandCommentDelimiter.sh
+ *
+ * @library /test/lib
+ * @build CommandCommentDelimiter
+ * @run main/othervm CommandCommentDelimiter
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+class CommandCommentDelimiterTarg {
+    public static void main(String args[]) {
+        System.out.print  ("Hello");
+        System.out.print  (", ");
+        System.out.print  ("world");
+        System.out.println("!");
+    }
+}
+
+
+public class CommandCommentDelimiter extends JdbTest {
+    public static void main(String argv[]) {
+        new CommandCommentDelimiter().run();
+    }
+
+    private CommandCommentDelimiter() {
+        super(DEBUGGEE_CLASS);
+    }
+
+    private static final String DEBUGGEE_CLASS = CommandCommentDelimiterTarg.class.getName();
+
+    @Override
+    protected void runCases() {
+        jdb.command(JdbCommand.stopIn(DEBUGGEE_CLASS, "main"));
+        jdb.command(JdbCommand.run());
+
+        jdb.command(JdbCommand.step());
+        jdb.command("#");
+        jdb.command("#foo");
+        jdb.command("3 #blah");
+        jdb.command("# connectors");
+        jdb.command(JdbCommand.step());
+
+        jdb.contToExit(1);
+
+        new OutputAnalyzer(getJdbOutput())
+                .shouldNotContain("Unrecognized command: '#'.  Try help...")
+                .shouldNotContain("Available connectors are");
+    }
+
+}
--- a/test/jdk/com/sun/jdi/CommandCommentDelimiter.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2014, 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
-#  @bug 4507088
-#  @summary TTY: Add a comment delimiter to the jdb command set
-#  @author Tim Bell
-#  @key intermittent
-#  @run shell CommandCommentDelimiter.sh
-#
-
-createJavaFile()
-{
-    cat <<EOF > $classname.java.1
-public class $classname {
-    public static void main(String args[]) {
-        System.out.print  ("Hello");
-        System.out.print  (", ");
-        System.out.print  ("world");
-        System.out.println("!");
-    }
-}
-
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-   #set -x
-   cmd stop in $classname.main
-   runToBkpt
-   cmd step
-   cmd \#
-   cmd \#foo
-   cmd 3 \#blah
-   cmd \# connectors
-   cmd step
-   cmd allowExit cont
-}
-
-mysetup()
-{
-    if [ -z "$TESTSRC" ] ; then
-        TESTSRC=.
-    fi
-
-    for ii in . $TESTSRC $TESTSRC/.. ; do
-        if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh
-            break
-        fi
-    done
-}
-
-# You could replace this next line with the contents
-# of ShellScaffold.sh and this script will run just the same.
-mysetup
-
-runit
-jdbFailIfPresent "Unrecognized command: '#'.  Try help..." 50
-jdbFailIfPresent "Available connectors are" 50
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/DeoptimizeWalk.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4525714
+ * @summary jtreg test PopAsynchronousTest fails in build 85 with -Xcomp
+ * @comment converted from test/jdk/com/sun/jdi/DeoptimizeWalk.sh
+ *
+ * @library /test/lib
+ * @compile -g DeoptimizeWalk.java
+ * @run main/othervm DeoptimizeWalk
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+/*
+ * The bug (JDK-4525714) is about failing PopAsynchronousTest test.
+ * This is another test of the same issue. The bug occurs when trying
+ * to walk the stack of a deoptimized thread. We can do this
+ * by running in -Xcomp mode and by doing a step which causes deopt,
+ * and then a 'where'. This will cause not all the frames to be shown.
+ */
+
+class DeoptimizeWalkTarg {
+    static public void main(String[] args) {
+        DeoptimizeWalkTarg mine = new DeoptimizeWalkTarg();
+        mine.a1(89);
+    }
+
+    public void a1(int p1) {
+        int v1 = 89;
+        System.out.println("a1" + v1);
+        a2(89);
+    }
+
+    public void a2(int pp) {
+        int v2 = 89;
+        System.out.println("a2" + v2);
+        a3(89);
+    }
+
+    public void a3(int pp) {
+        int v3 = 89;
+        System.out.println("a3");  //@ 1 breakpoint
+        a4(22);                  // it passes if this line is commented out
+        System.out.println("jj");
+    }
+
+    public void a4(int pp) {
+        int v4 = 90;
+        System.out.println("a4: @1 breakpoint here");
+    }
+}
+
+
+public class DeoptimizeWalk extends JdbTest {
+    public static void main(String argv[]) {
+        new DeoptimizeWalk().run();
+    }
+
+    private DeoptimizeWalk() {
+        super(new LaunchOptions(DEBUGGEE_CLASS)
+                .addDebuggeeOptions(DEBUGGEE_OPTIONS));
+    }
+
+    private static final String DEBUGGEE_CLASS = DeoptimizeWalkTarg.class.getName();
+    private static final String[] DEBUGGEE_OPTIONS = {"-Xcomp"};
+
+    @Override
+    protected void runCases() {
+        setBreakpointsFromTestSource("DeoptimizeWalk.java", 1);
+        jdb.command(JdbCommand.run());
+
+        jdb.command(JdbCommand.where(""));
+        jdb.command(JdbCommand.step());
+        jdb.command(JdbCommand.where(""));
+
+        jdb.contToExit(1);
+
+        new OutputAnalyzer(getJdbOutput())
+                .shouldContain(DEBUGGEE_CLASS + ".main");
+        new OutputAnalyzer(getDebuggeeOutput())
+                .shouldNotContain("Internal exception:");
+    }
+}
+
--- a/test/jdk/com/sun/jdi/DeoptimizeWalk.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2014, 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
-#  @bug 4525714
-#  @summary jtreg test PopAsynchronousTest fails in build 85 with -Xcomp
-#  @author Jim Holmlund/Swamy Venkataramanappa
-#  @key intermittent
-#  @run shell DeoptimizeWalk.sh
-
-#  This is another test of the same bug.  The bug occurs when trying
-#  to walk the stack of a deoptimized thread.  We can do this
-#  by running in -Xcomp mode and by doing a step which causes deopt,
-#  and then a 'where'.  This will cause not all the frames to be shown.
-
-compileOptions=-g
-
-echo "*********** This test only fails with -Xcomp ***************"
-createJavaFile()
-{
-    cat <<EOF > $1.java.1
-
-public class $1 {
-    static public void main(String[] args) {
-       $1 mine = new $1();
-       mine.a1(89);
-    }
-
-    public void a1(int p1) {
-      int v1 = 89;
-      System.out.println("a1" + v1);
-      a2(89);
-    }
-
-
-    public void a2(int pp) {
-      int v2 = 89;
-      System.out.println("a2" + v2);
-      a3(89);
-    }
-
-    public void a3(int pp) {
-      int v3 = 89;
-      System.out.println("a3");  //@ 1 breakpoint
-      a4(22);                  // it passes if this line is commented out
-      System.out.println("jj");
-    }
-
-    public void a4(int pp) {
-      int v4 = 90;
-      System.out.println("a4: @1 breakpoint here");
-    }
-}
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-    setBkpts @1
-    runToBkpt @1
-    cmd where
-    #cmd next
-    cmd step
-    cmd where
-}
-
-
-mysetup()
-{
-    if [ -z "$TESTSRC" ] ; then
-        TESTSRC=.
-    fi
-
-    for ii in . $TESTSRC $TESTSRC/.. ; do
-        if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh
-            break
-        fi
-    done
-}
-
-# You could replace this next line with the contents
-# of ShellScaffold.sh and this script will run just the same.
-mysetup
-
-runit
-jdbFailIfNotPresent "shtest\.main" 3
-debuggeeFailIfPresent "Internal exception:"
-pass
--- a/test/jdk/com/sun/jdi/DoubleAgentTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/DoubleAgentTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,8 +21,8 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Utils;
 
 /* @test
@@ -30,6 +30,7 @@
  * @summary Check that multiple -agentlib statements in command line fails
  *
  * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.management
  * @build jdk.testlibrary.*
  * @build DoubleAgentTest Exit0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/EvalArgs.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,290 @@
+/*
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4663146
+ * @summary Arguments match no method error
+ * @comment converted from test/jdk/com/sun/jdi/EvalArgs.sh
+ *
+ * @library /test/lib
+ * @build EvalArgs
+ * @run main/othervm EvalArgs
+ */
+
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+/*
+ * The bug is that, for example, if a String is passed
+ * as an arg to a func where an Object is expected,
+ * "Arguments match no method" error occurs. jdb doesn't notice that this is
+ * legal because String is an instance of Object.
+ */
+
+class EvalArgsTarg {
+
+    static jj1 myjj1;
+    static jj2 myjj2;
+    static oranges myoranges;
+    static boolean jjboolean = true;
+    static byte    jjbyte = 1;
+    static char    jjchar = 'a';
+    static double  jjdouble = 2.2;
+    static float   jjfloat = 3.1f;
+    static int     jjint = 4;
+    static long    jjlong = 5;
+    static short   jjshort = 6;
+    static int[]   jjintArray = {7, 8};
+    static float[] jjfloatArray = {9.1f, 10.2f};
+
+
+    public static void main(String args[]) {
+        myjj1 = new jj1();
+        myjj2 = new jj2();
+        myoranges = new oranges();
+
+        // prove that these work
+        System.out.println( ffjj1(myjj1));
+        System.out.println( ffjj1(myjj2));
+
+        System.out.println("EvalArgsTarg.ffoverload(EvalArgsTarg.jjboolean) = " +
+                            EvalArgsTarg.ffoverload(EvalArgsTarg.jjboolean));
+        System.out.println("EvalArgsTarg.ffoverload(EvalArgsTarg.jjbyte) = " +
+                            EvalArgsTarg.ffoverload(EvalArgsTarg.jjbyte));
+        System.out.println("EvalArgsTarg.ffoverload(EvalArgsTarg.jjchar) = " +
+                            EvalArgsTarg.ffoverload(EvalArgsTarg.jjchar));
+        System.out.println("EvalArgsTarg.ffoverload(EvalArgsTarg.jjdouble) = " +
+                            EvalArgsTarg.ffoverload(EvalArgsTarg.jjdouble));
+
+        //This doesn't even compile
+        //System.out.println( "ffintArray(jjfloatArray) = " + ffintArray(jjfloatArray));
+        gus();
+    }
+
+    static void gus() {
+        int x = 0;             // @1 breakpoint
+    }
+
+    public static String ffjj1(jj1 arg) {
+        return arg.me;
+    }
+
+    public static String ffjj2(jj2 arg) {
+        return arg.me;
+    }
+
+    static String ffboolean(boolean p1) {
+        return "ffbool: p1 = " + p1;
+    }
+
+    static String ffbyte(byte p1) {
+        return "ffbyte: p1 = " + p1;
+    }
+
+    static String ffchar(char p1) {
+        return "ffchar: p1 = " + p1;
+    }
+
+    static String ffdouble(double p1) {
+        return "ffdouble: p1 = " + p1;
+    }
+
+    static String fffloat(float p1) {
+        return "fffloat: p1 = " + p1;
+    }
+
+    static String ffint(int p1) {
+        return "ffint: p1 = " + p1;
+    }
+
+    static String fflong(long p1) {
+        return "fflong: p1 = " + p1;
+    }
+
+    static String ffshort(short p1) {
+        return "ffshort: p1 = " + p1;
+    }
+
+    static String ffintArray(int[] p1) {
+        return "ffintArray: p1 = " + p1;
+    }
+
+    // Overloaded funcs
+    public static String ffoverload(jj1 arg) {
+        return arg.me;
+    }
+
+    static String ffoverload(boolean p1) {
+        return "ffoverload: boolean p1 = " + p1;
+    }
+/***
+    static String ffoverload(byte p1) {
+        return "ffoverload: byte p1 = " + p1;
+    }
+***/
+    static String ffoverload(char p1) {
+        return "ffoverload: char p1 = " + p1;
+    }
+
+    static String ffoverload(double p1) {
+        return "ffoverload: double p1 = " + p1;
+    }
+
+    static String ffoverload(float p1) {
+        return "ffoverload: float p1 = " + p1;
+    }
+/***
+    static String ffoverload(int p1) {
+        return "ffoverload: int p1 = " + p1;
+    }
+***/
+    static String ffoverload(long p1) {
+        return "ffoverload: long p1 = " + p1;
+    }
+
+    static String ffoverload(short p1) {
+        return "ffoverload: short p1 = " + p1;
+    }
+
+    static String ffoverload(int[] p1) {
+        return "ffoverload: int array p1 = " + p1;
+    }
+
+    static class jj1 {
+        String me;
+        jj1() {
+            me = "jj1name";
+        }
+        public String toString() {
+            return me;
+        }
+
+    }
+
+    static class jj2 extends jj1 {
+        jj2() {
+            super();
+            me = "jj2name";
+        }
+    }
+
+    static class oranges {
+        oranges() {
+        }
+    }
+}
+
+public class EvalArgs extends JdbTest {
+    public static void main(String argv[]) {
+        new EvalArgs().run();
+    }
+
+    private EvalArgs() {
+        super(DEBUGGEE_CLASS);
+    }
+
+    private static final String DEBUGGEE_CLASS = EvalArgsTarg.class.getName();
+
+    @Override
+    protected void runCases() {
+        setBreakpointsFromTestSource("EvalArgs.java", 1);
+        // Run to breakpoint #1
+        jdb.command(JdbCommand.run());
+
+        final String argsMatchNoMethod = "Arguments match no method";
+        // verify that it works ok when arg types are the same as
+        // the param types
+        evalShouldNotContain("EvalArgsTarg.ffboolean(EvalArgsTarg.jjboolean)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffbyte(EvalArgsTarg.jjbyte)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffchar(EvalArgsTarg.jjchar)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffdouble(EvalArgsTarg.jjdouble)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.fffloat(EvalArgsTarg.jjfloat)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffint(EvalArgsTarg.jjint)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.fflong(EvalArgsTarg.jjlong)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffshort(EvalArgsTarg.jjshort)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffintArray(EvalArgsTarg.jjintArray)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffjj1(EvalArgsTarg.myjj1)", argsMatchNoMethod);
+
+        // Provide a visual break in the output
+        jdb.command(JdbCommand.print("1"));
+
+        // Verify mixing primitive types works ok
+        // These should work even though the arg types are
+        // not the same because there is only one
+        // method with each name.
+        evalShouldNotContain("EvalArgsTarg.ffbyte(EvalArgsTarg.jjint)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffchar(EvalArgsTarg.jjdouble)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffdouble(EvalArgsTarg.jjfloat)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.fffloat(EvalArgsTarg.jjshort)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffint(EvalArgsTarg.jjlong)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.fflong(EvalArgsTarg.jjchar)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffshort(EvalArgsTarg.jjbyte)", argsMatchNoMethod);
+
+        jdb.command(JdbCommand.print("1"));
+
+        //  Verify that passing a subclass object works
+        evalShouldNotContain("EvalArgsTarg.ffjj1(EvalArgsTarg.myjj2)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.myjj1.toString().equals(\"jj1name\")", argsMatchNoMethod);
+
+        jdb.command(JdbCommand.print("1"));
+
+        // Overloaded methods.  These should pass
+        // because there is an exact  match.
+        evalShouldNotContain("EvalArgsTarg.ffoverload(EvalArgsTarg.jjboolean)", argsMatchNoMethod);
+
+        evalShouldNotContain("EvalArgsTarg.ffoverload(EvalArgsTarg.jjchar)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffoverload(EvalArgsTarg.jjdouble)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffoverload(EvalArgsTarg.jjfloat)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffoverload(EvalArgsTarg.jjlong)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffoverload(EvalArgsTarg.jjshort)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffoverload(EvalArgsTarg.jjintArray)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffoverload(EvalArgsTarg.myjj1)", argsMatchNoMethod);
+        evalShouldNotContain("EvalArgsTarg.ffoverload(EvalArgsTarg.myjj2)", argsMatchNoMethod);
+
+        jdb.command(JdbCommand.print("1"));
+        jdb.command(JdbCommand.print("\"These should fail with msg Arguments match multiple methods\""));
+
+        // These overload calls should fail because there
+        // isn't an exact match and jdb isn't smart  enough
+        // to figure out which of several possibilities
+        // should be called
+        final String argsMatchMultipleMethods = "Arguments match multiple methods";
+        evalShouldContain("EvalArgsTarg.ffoverload(EvalArgsTarg.jjbyte)", argsMatchMultipleMethods);
+
+        evalShouldContain("EvalArgsTarg.ffoverload(EvalArgsTarg.jjint)", argsMatchMultipleMethods);
+
+        jdb.command(JdbCommand.print("1"));
+        jdb.command(JdbCommand.print("\"These should fail with InvalidTypeExceptions\""));
+
+        final String invalidTypeException = "InvalidTypeException";
+        evalShouldContain("EvalArgsTarg.ffboolean(EvalArgsTarg.jjbyte)", invalidTypeException);
+        evalShouldContain("EvalArgsTarg.ffintArray(EvalArgsTarg.jjint)", invalidTypeException);
+        evalShouldContain("EvalArgsTarg.ffintArray(EvalArgsTarg.jjfloatArray)", invalidTypeException);
+        evalShouldContain("EvalArgsTarg.ffjj2(EvalArgsTarg.myjj1)", invalidTypeException);
+        evalShouldContain("EvalArgsTarg.ffjj2(EvalArgsTarg.myoranges)", invalidTypeException);
+
+        jdb.contToExit(1);
+    }
+
+}
--- a/test/jdk/com/sun/jdi/EvalArgs.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,316 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2014, 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
-#  @bug 4663146
-#  @summary Arguments match no method error
-#  @author Jim Holmlund/Suvasis
-#
-#  @run shell/timeout=300 EvalArgs.sh
-
-#  The bug is that, for example, if a String is passed
-#  as an arg to a func where an Object is expected,
-#  the above error occurs.  jdb doesnt notice that this is
-#  legal because String is an instance of Object.
-
-
-# These are variables that can be set to control execution
-
-#pkg=untitled7
-classname=EvalArgs
-#compileOptions=-g
-#java="java_g"
-
-createJavaFile()
-{
-    cat <<EOF > $classname.java.1
-public class $classname {
-
-    static jj1 myjj1;
-    static jj2 myjj2;
-    static oranges myoranges;
-    static boolean jjboolean = true;
-    static byte    jjbyte = 1;
-    static char    jjchar = 'a';
-    static double  jjdouble = 2.2;
-    static float   jjfloat = 3.1f;
-    static int     jjint = 4;
-    static long    jjlong = 5;
-    static short   jjshort = 6;
-    static int[]   jjintArray = {7, 8};
-    static float[] jjfloatArray = {9.1f, 10.2f};
-
-
-    public static void main(String args[]) {
-        myjj1 = new jj1();
-        myjj2 = new jj2();
-        myoranges = new oranges();
-
-        // prove that these work
-        System.out.println( ffjj1(myjj1));
-        System.out.println( ffjj1(myjj2));
-
-        System.out.println("$classname.ffoverload($classname.jjboolean) = " +
-                            $classname.ffoverload($classname.jjboolean));
-        System.out.println("$classname.ffoverload($classname.jjbyte) = " +
-                            $classname.ffoverload($classname.jjbyte));
-        System.out.println("$classname.ffoverload($classname.jjchar) = " +
-                            $classname.ffoverload($classname.jjchar));
-        System.out.println("$classname.ffoverload($classname.jjdouble) = " +
-                            $classname.ffoverload($classname.jjdouble));
-
-
-        //This doesn't even compile
-        //System.out.println( "ffintArray(jjfloatArray) = " + ffintArray(jjfloatArray));
-        gus();
-    }
-
-    static void gus() {
-        int x = 0;             // @1 breakpoint
-    }
-
-    public static String ffjj1(jj1 arg) {
-        return arg.me;
-    }
-
-    public static String ffjj2(jj2 arg) {
-        return arg.me;
-    }
-
-    static String ffboolean(boolean p1) {
-        return "ffbool: p1 = " + p1;
-    }
-
-    static String ffbyte(byte p1) {
-        return "ffbyte: p1 = " + p1;
-    }
-
-    static String ffchar(char p1) {
-        return "ffchar: p1 = " + p1;
-    }
-
-    static String ffdouble(double p1) {
-        return "ffdouble: p1 = " + p1;
-    }
-
-    static String fffloat(float p1) {
-        return "fffloat: p1 = " + p1;
-    }
-
-    static String ffint(int p1) {
-        return "ffint: p1 = " + p1;
-    }
-
-    static String fflong(long p1) {
-        return "fflong: p1 = " + p1;
-    }
-
-    static String ffshort(short p1) {
-        return "ffshort: p1 = " + p1;
-    }
-
-    static String ffintArray(int[] p1) {
-        return "ffintArray: p1 = " + p1;
-    }
-
-    // Overloaded funcs
-    public static String ffoverload(jj1 arg) {
-        return arg.me;
-    }
-
-    static String ffoverload(boolean p1) {
-        return "ffoverload: boolean p1 = " + p1;
-    }
-/***
-    static String ffoverload(byte p1) {
-        return "ffoverload: byte p1 = " + p1;
-    }
-***/
-    static String ffoverload(char p1) {
-        return "ffoverload: char p1 = " + p1;
-    }
-
-    static String ffoverload(double p1) {
-        return "ffoverload: double p1 = " + p1;
-    }
-
-    static String ffoverload(float p1) {
-        return "ffoverload: float p1 = " + p1;
-    }
-/***
-    static String ffoverload(int p1) {
-        return "ffoverload: int p1 = " + p1;
-    }
-***/
-    static String ffoverload(long p1) {
-        return "ffoverload: long p1 = " + p1;
-    }
-
-    static String ffoverload(short p1) {
-        return "ffoverload: short p1 = " + p1;
-    }
-
-    static String ffoverload(int[] p1) {
-        return "ffoverload: int array p1 = " + p1;
-    }
-
-  static class jj1 {
-    String me;
-    jj1() {
-        me = "jj1name";
-    }
-    public String toString() {
-        return me;
-    }
-
-  }
-
-  static class jj2 extends jj1 {
-    jj2() {
-        super();
-        me = "jj2name";
-    }
-  }
-
-  static class oranges {
-    oranges() {
-    }
-  }
-}
-
-
-
-EOF
-}
-
-# drive jdb by sending cmds to it and examining its output
-dojdbCmds()
-{
-    setBkpts @1
-    runToBkpt @1
-
-    # verify that it works ok when arg types are the same as
-    # the param types
-    cmd eval "$classname.ffboolean($classname.jjboolean)"
-    cmd eval "$classname.ffbyte($classname.jjbyte)"
-    cmd eval "$classname.ffchar($classname.jjchar)"
-    cmd eval "$classname.ffdouble($classname.jjdouble)"
-    cmd eval "$classname.fffloat($classname.jjfloat)"
-    cmd eval "$classname.ffint($classname.jjint)"
-    cmd eval "$classname.fflong($classname.jjlong)"
-    cmd eval "$classname.ffshort($classname.jjshort)"
-    cmd eval "$classname.ffintArray($classname.jjintArray)"
-    cmd eval "$classname.ffjj1($classname.myjj1)"
-
-    # Provide a visual break in the output
-    cmd print 1
-
-    # Verify mixing primitive types works ok
-    # These should work even though the arg types are
-    # not the same because there is only one
-    # method with each name.
-    cmd eval "$classname.ffbyte($classname.jjint)"
-    cmd eval "$classname.ffchar($classname.jjdouble)"
-    cmd eval "$classname.ffdouble($classname.jjfloat)"
-    cmd eval "$classname.fffloat($classname.jjshort)"
-    cmd eval "$classname.ffint($classname.jjlong)"
-    cmd eval "$classname.fflong($classname.jjchar)"
-    cmd eval "$classname.ffshort($classname.jjbyte)"
-
-    cmd print 1
-
-    # Verify that passing a subclass object works
-    cmd eval "$classname.ffjj1($classname.myjj2)"
-    cmd eval "$classname.myjj1.toString().equals("jj1name")"
-
-    cmd print 1
-
-    # Overloaded methods.  These should pass
-    # because there is an exact  match.
-    cmd eval "$classname.ffoverload($classname.jjboolean)"
-
-    cmd eval "$classname.ffoverload($classname.jjchar)"
-    cmd eval "$classname.ffoverload($classname.jjdouble)"
-    cmd eval "$classname.ffoverload($classname.jjfloat)"
-    cmd eval "$classname.ffoverload($classname.jjlong)"
-    cmd eval "$classname.ffoverload($classname.jjshort)"
-    cmd eval "$classname.ffoverload($classname.jjintArray)"
-    cmd eval "$classname.ffoverload($classname.myjj1)"
-    cmd eval "$classname.ffoverload($classname.myjj2)"
-    jdbFailIfPresent "Arguments match no method"
-
-    cmd print 1
-    cmd print '"These should fail with msg Arguments match multiple methods"'
-
-    # These overload calls should fail because ther
-    # isn't an exact match and jdb isn't smart  enough
-    # to figure out which of several possibilities
-    # should be called
-    cmd eval "$classname.ffoverload($classname.jjbyte)"
-    jdbFailIfNotPresent "Arguments match multiple methods" 3
-
-    cmd eval "$classname.ffoverload($classname.jjint)"
-    jdbFailIfNotPresent "Arguments match multiple methods" 3
-
-    cmd print 1
-    cmd print '"These should fail with InvalidTypeExceptions"'
-
-    cmd eval "$classname.ffboolean($classname.jjbyte)"
-    jdbFailIfNotPresent "InvalidTypeException" 3
-
-    cmd eval "$classname.ffintArray($classname.jjint)"
-    jdbFailIfNotPresent "InvalidTypeException" 3
-
-    cmd eval "$classname.ffintArray($classname.jjfloatArray)"
-    jdbFailIfNotPresent "InvalidTypeException" 3
-
-    cmd eval "$classname.ffjj2($classname.myjj1)"
-    jdbFailIfNotPresent "InvalidTypeException" 3
-
-    cmd eval "$classname.ffjj2($classname.myoranges)"
-    jdbFailIfNotPresent "InvalidTypeException" 3
-}
-
-
-mysetup()
-{
-    if [ -z "$TESTSRC" ] ; then
-        TESTSRC=.
-    fi
-
-    for ii in . $TESTSRC $TESTSRC/.. ; do
-        if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh
-            break
-        fi
-    done
-}
-
-# You could replace this next line with the contents
-# of ShellScaffold.sh and this script will run just the same.
-mysetup
-
-runit
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/EvalArraysAsList.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8160024
+ * @summary jdb returns invalid argument count if first parameter to Arrays.asList is null
+ * @comment converted from test/jdk/com/sun/jdi/EvalArraysAsList.sh
+ *
+ * @library /test/lib
+ * @build EvalArraysAsList
+ * @run main/othervm EvalArraysAsList
+ */
+
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+/*
+ * The test checks if evaluation of the expression java.util.Arrays.asList(null, "a")
+ * works normally and does not throw an IllegalArgumentException.
+ */
+class EvalArraysAsListTarg {
+    public static void main(String[] args) {
+        java.util.List<Object> l = java.util.Arrays.asList(null, "a");
+        System.out.println("java.util.Arrays.asList(null, \"a\") returns: " + l);
+        return;    // @1 breakpoint
+    }
+}
+
+
+public class EvalArraysAsList extends JdbTest {
+    public static void main(String argv[]) {
+        new EvalArraysAsList().run();
+    }
+
+    private EvalArraysAsList() {
+        super(DEBUGGEE_CLASS);
+    }
+
+    private static final String DEBUGGEE_CLASS = EvalArraysAsListTarg.class.getName();
+
+    @Override
+    protected void runCases() {
+        setBreakpointsFromTestSource("EvalArraysAsList.java", 1);
+        // Run to breakpoint #1
+        jdb.command(JdbCommand.run());
+
+        final String illegalArgumentException = "IllegalArgumentException";
+
+        evalShouldNotContain("java.util.Arrays.asList(null, null)", illegalArgumentException);
+
+        evalShouldNotContain("java.util.Arrays.asList(null, \"a\")", illegalArgumentException);
+
+        evalShouldNotContain("java.util.Arrays.asList(\"a\", null)", illegalArgumentException);
+
+        jdb.contToExit(1);
+    }
+
+}
--- a/test/jdk/com/sun/jdi/EvalArraysAsList.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-#  @test
-#  @bug 8160024
-#  @summary jdb returns invalid argument count if first parameter to Arrays.asList is null
-#
-#  @run shell/timeout=300 EvalArraysAsList.sh
-#
-#  The test checks if evaluation of the expression java.util.Arrays.asList(null, "a")
-#  works normally and does not throw an IllegalArgumentException.
-
-classname=EvalArraysAsList
-
-createJavaFile()
-{
-    cat <<EOF > $classname.java.1
-public class $classname {
-    public static void main(String[] args) {
-        java.util.List<Object> l = java.util.Arrays.asList(null, "a");
-        System.out.println("java.util.Arrays.asList(null, \\"a\\") returns: " + l);
-        return;    // @1 breakpoint
-    }
-}
-EOF
-}
-
-# drive jdb by sending cmds to it and examining its output
-dojdbCmds()
-{
-    setBkpts @1
-    runToBkpt @1
-
-    cmd eval "java.util.Arrays.asList(null, null)"
-    jdbFailIfPresent "IllegalArgumentException" 3
-
-    cmd eval "java.util.Arrays.asList(null, \"a\")"
-    jdbFailIfPresent "IllegalArgumentException" 3
-
-    cmd eval "java.util.Arrays.asList(\"a\", null)"
-    jdbFailIfPresent "IllegalArgumentException" 3
-}
-
-
-mysetup()
-{
-    if [ -z "$TESTSRC" ] ; then
-        TESTSRC=.
-    fi
-
-    for ii in . $TESTSRC $TESTSRC/.. ; do
-        if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh
-            break
-        fi
-    done
-}
-
-# You could replace this next line with the contents
-# of ShellScaffold.sh and this script will run just the same.
-mysetup
-
-runit
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/EvalInterfaceStatic.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2014, 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
+ * @bug 8031195
+ * @summary JDB allows evaluation of calls to static interface methods
+ * @comment converted from test/jdk/com/sun/jdi/EvalInterfaceStatic.sh
+ *
+ * @library /test/lib
+ * @build EvalInterfaceStatic
+ * @run main/othervm EvalInterfaceStatic
+ */
+
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+/*
+ * The test exercises the ability to invoke static methods on interfaces.
+ * Static interface methods are a new feature added in JDK8.
+ *
+ * The test makes sure that it is possible to invoke an interface
+ * static method and that the static methods are not inherited by extending
+ * interfaces.
+ */
+interface EvalStaticInterfaces {
+    static String staticMethod1() {
+        return "base:staticMethod1";
+    }
+
+    static String staticMethod2() {
+        return "base:staticMethod2";
+    }
+
+    public static void main(String[] args) {
+        // prove that these work
+        System.out.println("base staticMethod1(): " + EvalStaticInterfaces.staticMethod1());
+        System.out.println("base staticMethod2(): " + EvalStaticInterfaces.staticMethod2());
+        System.out.println("overridden staticMethod2(): " + ExtendedEvalStaticInterfaces.staticMethod2());
+        System.out.println("base staticMethod3(): " + ExtendedEvalStaticInterfaces.staticMethod3());
+
+        gus();
+    }
+
+    static void gus() {
+        int x = 0;             // @1 breakpoint
+    }
+}
+
+interface ExtendedEvalStaticInterfaces extends EvalStaticInterfaces {
+    static String staticMethod2() {
+        return "extended:staticMethod2";
+    }
+
+    static String staticMethod3() {
+        return "extended:staticMethod3";
+    }
+}
+
+
+public class EvalInterfaceStatic extends JdbTest {
+    public static void main(String argv[]) {
+        new EvalInterfaceStatic().run();
+    }
+
+    private EvalInterfaceStatic() {
+        super(DEBUGGEE_CLASS);
+    }
+
+    private static final String DEBUGGEE_CLASS = EvalStaticInterfaces.class.getName();
+
+    @Override
+    protected void runCases() {
+        setBreakpointsFromTestSource("EvalInterfaceStatic.java", 1);
+        // Run to breakpoint #1
+        jdb.command(JdbCommand.run());
+
+        evalShouldContain("EvalStaticInterfaces.staticMethod1()", "base:staticMethod1");
+
+        evalShouldContain("EvalStaticInterfaces.staticMethod2()", "base:staticMethod2");
+
+        evalShouldNotContain("ExtendedEvalStaticInterfaces.staticMethod1()", "base:staticMethod1");
+
+        evalShouldContain("ExtendedEvalStaticInterfaces.staticMethod2()", "extended:staticMethod2");
+
+        evalShouldContain("ExtendedEvalStaticInterfaces.staticMethod3()", "extended:staticMethod3");
+
+        jdb.contToExit(1);
+    }
+
+}
--- a/test/jdk/com/sun/jdi/EvalInterfaceStatic.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2014, 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
-#  @bug 8031195
-#  @summary JDB allows evaluation of calls to static interface methods
-#  @author Jaroslav Bachorik
-#
-#  @run shell/timeout=300 EvalInterfaceStatic.sh
-
-#  The test exercises the ability to invoke static methods on interfaces.
-#  Static interface methods are a new feature added in JDK8.
-#
-#  The test makes sure that it is, at all, possible to invoke an interface
-#  static method and that the static methods are not inherited by extending
-#  interfaces.
-
-classname=EvalStaticInterfaces
-
-createJavaFile()
-{
-    cat <<EOF > $classname.java.1
-public interface $classname {
-    static String staticMethod1() {
-        return "base:staticMethod1";
-    }
-
-    static String staticMethod2() {
-        return "base:staticMethod2";
-    }
-
-    public static void main(String[] args) {
-        // prove that these work
-        System.out.println("base staticMethod1(): " + $classname.staticMethod1());
-        System.out.println("base staticMethod2(): " + $classname.staticMethod2());
-        System.out.println("overridden staticMethod2(): " + Extended$classname.staticMethod2());
-        System.out.println("base staticMethod3(): " + Extended$classname.staticMethod3());
-
-        gus();
-    }
-
-    static void gus() {
-        int x = 0;             // @1 breakpoint
-    }
-}
-
-interface Extended$classname extends $classname {
-    static String staticMethod2() {
-        return "extended:staticMethod2";
-    }
-
-    static String staticMethod3() {
-        return "extended:staticMethod3";
-    }
-}
-
-
-
-EOF
-}
-
-# drive jdb by sending cmds to it and examining its output
-dojdbCmds()
-{
-    setBkpts @1
-    runToBkpt @1
-
-    cmd eval "$classname.staticMethod1()"
-    jdbFailIfNotPresent "base:staticMethod1" 2
-
-    cmd eval "$classname.staticMethod2()"
-    jdbFailIfNotPresent "base:staticMethod2" 2
-
-    cmd eval "Extended$classname.staticMethod1()"
-    jdbFailIfPresent "base:staticMethod1" 2
-
-    cmd eval "Extended$classname.staticMethod2()"
-    jdbFailIfNotPresent "extended:staticMethod2" 2
-
-    cmd eval "Extended$classname.staticMethod3()"
-    jdbFailIfNotPresent "extended:staticMethod3" 2
-}
-
-
-mysetup()
-{
-    if [ -z "$TESTSRC" ] ; then
-        TESTSRC=.
-    fi
-
-    for ii in . $TESTSRC $TESTSRC/.. ; do
-        if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh
-            break
-        fi
-    done
-}
-
-# You could replace this next line with the contents
-# of ShellScaffold.sh and this script will run just the same.
-mysetup
-
-runit
-pass
--- a/test/jdk/com/sun/jdi/ExclusiveBind.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/ExclusiveBind.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
  * @summary Test that more than one debuggee cannot bind to same port
  *          at the same time.
  * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @modules java.management
  *          jdk.jdi
@@ -44,7 +45,7 @@
 import java.util.Iterator;
 import java.util.concurrent.TimeUnit;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Utils;
 
 public class ExclusiveBind {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/GetLocalVariables3Test.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4448658
+ * @summary javac produces the inconsistent variable debug in while loops.
+ * @comment converted from test/jdk/com/sun/jdi/GetLocalVariables3Test.sh
+ *
+ * @library /test/lib
+ * @compile -g GetLocalVariables3Test.java
+ * @run main/othervm GetLocalVariables3Test
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+
+class GetLocalVariables3Targ {
+    public static void main(String[] args) {
+        System.out.println("Howdy!");
+        int i = 1, j, k;
+        while ((j = i) > 0) {
+            k = j; i = k - 1;    // @1 breakpoint
+        }
+        System.out.println("Goodbye from GetLocalVariables3Targ!");
+    }
+}
+
+
+public class GetLocalVariables3Test extends JdbTest {
+    public static void main(String argv[]) {
+        new GetLocalVariables3Test().run();
+    }
+
+    private GetLocalVariables3Test() {
+        super(DEBUGGEE_CLASS);
+    }
+
+    private static final String DEBUGGEE_CLASS = GetLocalVariables3Targ.class.getName();
+
+    @Override
+    protected void runCases() {
+        setBreakpointsFromTestSource("GetLocalVariables3Test.java", 1);
+        // Run to breakpoint #1
+        jdb.command(JdbCommand.run());
+
+        jdb.command(JdbCommand.locals());
+
+        jdb.contToExit(1);
+
+        new OutputAnalyzer(getJdbOutput())
+                .shouldContain("j = 1");
+        new OutputAnalyzer(getDebuggeeOutput())
+                .shouldContain("Howdy")
+                .shouldContain("Goodbye from GetLocalVariables3Targ");
+    }
+
+}
--- a/test/jdk/com/sun/jdi/GetLocalVariables3Test.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2014, 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
-#  @bug 4448658
-#  @summary javac produces the inconsistent variable debug in while loops.
-#  @author Tim Bell
-#
-#  @run shell GetLocalVariables3Test.sh
-#
-classname=GetLocalVariables3Targ
-
-createJavaFile()
-{
-    cat <<EOF > $classname.java.1
-public class GetLocalVariables3Targ {
-    public static void main(String[] args) {
-        System.out.println("Howdy!");
-        int i = 1, j, k;
-        while ((j = i) > 0) {
-            k = j; i = k - 1;    // @1 breakpoint
-        }
-        System.out.println("Goodbye from GetLocalVariables3Targ!");
-    }
-}
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-   setBkpts @1
-   runToBkpt @1
-   cmd locals
-   cmd allowExit cont
-}
-
-mysetup()
-{
-    compileOptions="-g"
-    if [ -z "$TESTSRC" ] ; then
-        TESTSRC=.
-    fi
-
-    for ii in . $TESTSRC $TESTSRC/.. ; do
-        if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh
-            break
-        fi
-    done
-}
-
-mysetup
-
-runit
-jdbFailIfNotPresent "j = 1"
-debuggeeFailIfNotPresent "Howdy"
-debuggeeFailIfNotPresent "Goodbye from GetLocalVariables3Targ"
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/GetLocalVariables4Test.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4070747 4486859
+ * @summary Compiler fails to generate local var tbl entry for exception passed to catch
+ * @comment converted from test/jdk/com/sun/jdi/GetLocalVariables4Test.sh
+ *
+ * @library /test/lib
+ * @compile -g GetLocalVariables4Test.java
+ * @run main/othervm GetLocalVariables4Test
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+class GetLocalVariables4Targ {
+    public static void main(String[] args) {
+        System.out.println("Howdy!");
+        int i = 0;
+        try {
+            i = 16 / i;
+        } catch(Exception e) {
+            System.out.println("e should be visible");    // @1 breakpoint
+        }
+        System.out.println("Goodbye from GetLocalVariables4Targ!");
+    }
+}
+
+public class GetLocalVariables4Test extends JdbTest {
+    public static void main(String argv[]) {
+        new GetLocalVariables4Test().run();
+    }
+
+    private GetLocalVariables4Test() {
+        super(DEBUGGEE_CLASS);
+    }
+
+    private static final String DEBUGGEE_CLASS = GetLocalVariables4Targ.class.getName();
+
+    @Override
+    protected void runCases() {
+        setBreakpointsFromTestSource("GetLocalVariables4Test.java", 1);
+        // Run to breakpoint #1
+        jdb.command(JdbCommand.run());
+        jdb.command(JdbCommand.locals());
+        jdb.contToExit(1);
+
+        new OutputAnalyzer(getJdbOutput())
+                .shouldContain("e = instance of java.lang.ArithmeticException");
+        new OutputAnalyzer(getDebuggeeOutput())
+                .shouldContain("Howdy")
+                .shouldContain("Goodbye from GetLocalVariables4Targ");
+    }
+}
--- a/test/jdk/com/sun/jdi/GetLocalVariables4Test.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2014, 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
-#  @bug 4070747 4486859
-#  @summary Compiler fails to generate local var tbl entry for exception passed to catch
-#  @author Tim Bell
-#
-#  @run shell GetLocalVariables4Test.sh
-#
-classname=GetLocalVariables4Targ
-
-createJavaFile()
-{
-    cat <<EOF > $classname.java.1
-public class GetLocalVariables4Targ {
-    public static void main(String[] args) {
-        System.out.println("Howdy!");
-        int i = 0;
-        try {
-            i = 16 / i;
-        } catch(Exception e) {
-            System.out.println("e should be visible");    // @1 breakpoint
-        }
-        System.out.println("Goodbye from GetLocalVariables4Targ!");
-    }
-}
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-   setBkpts @1
-   runToBkpt @1
-   cmd locals
-   cmd allowExit cont
-}
-
-mysetup()
-{
-    compileOptions="-g"
-    if [ -z "$TESTSRC" ] ; then
-        TESTSRC=.
-    fi
-
-    for ii in . $TESTSRC $TESTSRC/.. ; do
-        if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh
-            break
-        fi
-    done
-}
-
-mysetup
-
-runit
-jdbFailIfNotPresent "e = instance of java.lang.ArithmeticException"
-debuggeeFailIfNotPresent "Howdy"
-debuggeeFailIfNotPresent "Goodbye from GetLocalVariables4Targ"
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/JdbArgTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4684386
+ * @summary TTY: jdb throws IllegalArumentException on cmd line args
+ * @comment converted from test/jdk/com/sun/jdi/JdbArgTest.sh
+ *
+ * @library /test/lib
+ * @run main/othervm JdbArgTest
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.Jdb;
+
+public class JdbArgTest {
+    public static void main(String argv[]) throws Exception {
+        try (Jdb jdb = new Jdb("Server", "0RBDebug", "subcontract,shutdown,transport")) {
+            jdb.waitForSimplePrompt(1, true);
+            jdb.quit();
+            new OutputAnalyzer(jdb.getJdbOutput())
+                    .shouldNotContain("IllegalArgumentException");
+        }
+    }
+}
--- a/test/jdk/com/sun/jdi/JdbArgTest.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 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
-#  @bug 4684386
-#  @summary TTY: jdb throws IllegalArumentException on cmd line args
-#  @author Jim/suvasis
-#  @run shell JdbArgTest.sh
-
-#Call this from anywhere to fail the test with an error message
-# usage: fail "reason why the test failed"
-fail() 
- { echo "The test failed :-("
-   echo "$*" 1>&2
-   echo "exit status was $status"
-   exit 1
- } #end of fail()
-
-#Call this from anywhere to pass the test with a message
-# usage: pass "reason why the test passed if applicable"
-pass() 
- { echo "The test passed!!!"
-   echo "$*" 1>&2
-   exit 0
- } #end of pass()
-
-# end of subroutines
-
-#Set appropriate jdk 
-
-if [ ! -z "${TESTJAVA}" ] ; then
-     jdk="$TESTJAVA"
-else
-     echo "--Error: TESTJAVA must be defined as the pathname of a jdk to test."
-     exit 1
-fi
-
-echo quit | \
-   $TESTJAVA/bin/jdb Server 0RBDebug subcontract,shutdown,transport 2>&1 | \
-   fgrep IllegalArgumentException > /dev/null 2<&1
-
-if [ $? = 1 ] ; then
-   pass " This test passed and jbd got no IllegalArgumentException"
-fi
-
-fail "FAILED: jdb got an IllegalArgumentException"
-
--- a/test/jdk/com/sun/jdi/JdbExprTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/JdbExprTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -67,7 +67,7 @@
 
     @Override
     protected void runCases() {
-        setBreakpoints(System.getProperty("test.src") + "/JdbExprTest.java", 1);
+        setBreakpointsFromTestSource("JdbExprTest.java", 1);
         // Run to breakpoint #1
         execCommand(JdbCommand.run())
                 .shouldContain("Breakpoint hit");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/JdbLockTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4847812
+ * @summary TTY: jdb lock command displays incorrect data
+ * @comment converted from test/jdk/com/sun/jdi/JdbLockTest.sh
+ *
+ * @library /test/lib
+ * @compile -g JdbLockTest.java
+ * @run main/othervm JdbLockTest
+ */
+
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+class JdbLockTestTarg {
+    static String jj = "jj";
+    public static void main(String args[]) {
+        synchronized(jj) {
+            sleeper xx = new sleeper();
+            xx.start();
+            // Give the sleeper a chance to run and get to
+            // the synchronized statement.
+            while(sleeper.started == 0) {
+                try {
+                    Thread.sleep(100);
+                } catch(InterruptedException ee) {
+                }
+            }
+            // At this bkpt, sleeper should be waiting on $classname.jj
+            System.out.println("Hello sailor");    // @1 breakpoint
+        }
+    }
+}
+
+class sleeper extends Thread {
+    public static int started = 0;
+    public void run() {
+        started = 1;
+        System.out.println("     sleeper starts sleeping");
+        synchronized(JdbLockTestTarg.jj) {
+            System.out.println("     sleeper got the lock");
+        }
+        System.out.println("     sleeper awakes");
+    }
+}
+
+public class JdbLockTest extends JdbTest {
+    public static void main(String argv[]) {
+        new JdbLockTest().run();
+    }
+
+    private JdbLockTest() {
+        super(DEBUGGEE_CLASS);
+    }
+
+    private static final String DEBUGGEE_CLASS = JdbLockTestTarg.class.getName();
+
+    @Override
+    protected void runCases() {
+        setBreakpointsFromTestSource("JdbLockTest.java", 1);
+        // Run to breakpoint #1
+        jdb.command(JdbCommand.run());
+
+        // This should say that main owns the lock
+        // and the sleeper thread is waiting for it.
+        execCommand(JdbCommand.lock("JdbLockTestTarg.jj"))
+                .shouldNotContain("Waiting thread: main");
+    }
+}
--- a/test/jdk/com/sun/jdi/JdbLockTest.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2003, 2014, 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
-#  @bug 4847812
-#  @summary TTY: jdb lock command displays incorrect data
-#  @author Jim Holmlund
-#  @run shell JdbLockTest.sh
-
-# These are variables that can be set to control execution
-
-#pkg=untitled7
-classname=JdbLockTest
-compileOptions=-g
-#java="java_g"
-
-createJavaFile()
-{
-    cat <<EOF > $classname.java.1
-public class $classname {
-    static String jj = "jj";
-    public static void main(String args[]) {
-        synchronized(jj) {
-            sleeper xx = new sleeper();
-            xx.start();
-            // Give the sleeper a chance to run and get to
-            // the synchronized statement.
-            while(sleeper.started == 0) {
-                try {
-                    Thread.sleep(100);
-                } catch(InterruptedException ee) {
-                }
-            }
-            // At this bkpt, sleeper should be waiting on $classname.jj
-            System.out.println("Hello sailor");    // @1 breakpoint
-        }
-    }
-}
-
-class sleeper extends Thread {
-    public static int started = 0;
-    public void run() {
-        started = 1;
-        System.out.println("     sleeper starts sleeping");
-        synchronized($classname.jj) {
-            System.out.println("     sleeper got the lock");
-        }
-        System.out.println("     sleeper awakes");
-    }
-}
-
-EOF
-}
-
-
-# drive jdb by sending cmds to it and examining its output
-dojdbCmds()
-{
-    setBkpts @1
-    runToBkpt @1
-    # This should say that main owns the lock
-    # and the sleeper thread is waiting for it.
-    cmd lock $classname.jj
-}
-
-
-mysetup()
-{
-    if [ -z "$TESTSRC" ] ; then
-        TESTSRC=.
-    fi
-
-    for ii in . $TESTSRC $TESTSRC/.. ; do
-        if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh
-            break
-        fi
-    done
-}
-
-# You could replace this next line with the contents
-# of ShellScaffold.sh and this script will run just the same.
-mysetup
-
-runit
-jdbFailIfPresent "Waiting thread: main"
-pass
--- a/test/jdk/com/sun/jdi/JdbMethodExitTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/JdbMethodExitTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -197,13 +197,13 @@
 
     @Override
     protected void runCases() {
-        setBreakpoints(System.getProperty("test.src") + "/JdbMethodExitTest.java", 1);
+        setBreakpointsFromTestSource("JdbMethodExitTest.java", 1);
 
         // test all possible return types
         execCommand(JdbCommand.run())
                 .shouldContain("Breakpoint hit");
         Integer threadId = Integer.parseInt(
-                new OutputAnalyzer(jdb.getDebuggeeOutput())
+                new OutputAnalyzer(getDebuggeeOutput())
                         .firstMatch("^threadid=(.*)$", 1));
         jdb.command(JdbCommand.untrace());
 
@@ -299,7 +299,7 @@
         new OutputAnalyzer(reply.stream().collect(Collectors.joining(lineSeparator)))
                 .shouldMatch("Method exited: .*JdbMethodExitTestTarg.traceExit1");
 
-        new OutputAnalyzer(jdb.getJdbOutput())
+        new OutputAnalyzer(getJdbOutput())
                 .shouldContain("Breakpoint hit");
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/JdbMissStep.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4762765
+ * @summary REGRESSION: jdb / jdi not stopping at some breakpoints and steps in j2sdk1.4.
+ * @comment converted from test/jdk/com/sun/jdi/JdbMissStep.sh
+ *
+ * @library /test/lib
+ * @compile -g JdbMissStep.java
+ * @run main/othervm JdbMissStep
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+class JdbMissStepTarg {
+
+    public static void main(String args[]) {
+        JdbMissStepTarg dbb = new JdbMissStepTarg();
+        System.out.println("ANSWER IS: " + dbb.getIntVal());
+        jj2 gus = new jj2();
+        System.out.println("ANSWER2 IS: " + gus.getIntVal());
+    }
+
+    static int statVal;
+    int intVal = 89;
+    public int getIntVal() {
+        return intVal;  //@ 1 breakpoint
+    }
+
+    static class jj2 {
+        static int statVal;
+        int intVal = 89;
+        public int getIntVal() {
+            return intVal;  //@1 breakpoint  line 20
+        }
+    }
+}
+
+public class JdbMissStep extends JdbTest {
+    public static void main(String argv[]) {
+        new JdbMissStep().run();
+    }
+
+    private JdbMissStep() {
+        super(DEBUGGEE_CLASS);
+    }
+
+    private static final String DEBUGGEE_CLASS = JdbMissStepTarg.class.getName();
+
+    @Override
+    protected void runCases() {
+        setBreakpoints(jdb, DEBUGGEE_CLASS + "$jj2", System.getProperty("test.src") + "/JdbMissStep.java", 1);
+
+        jdb.command(JdbCommand.run());
+        jdb.command(JdbCommand.step());
+
+        new OutputAnalyzer(jdb.getJdbOutput())
+                .shouldContain("Breakpoint hit");
+    }
+}
--- a/test/jdk/com/sun/jdi/JdbMissStep.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2014, 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
-#  @bug 4762765
-#  @summary REGRESSION: jdb / jdi not stopping at some breakpoints and steps in j2sdk1.4.
-#  @author Jim Holmlund
-#
-#  @key intermittent
-#  @run shell JdbMissStep.sh
-
-# These are variables that can be set to control execution
-
-#pkg=untitled7
-classname=JdbMissStep
-compileOptions=-g
-#java="java_g"
-
-createJavaFile()
-{
-    cat <<EOF > $classname.java.1
-public class $classname {
-   
-    public static void main(String args[]) {
-        $classname dbb = new $classname();
-        System.out.println("ANSWER IS: " + dbb.getIntVal());
-        jj2 gus = new jj2();
-        System.out.println("ANSWER2 IS: " + gus.getIntVal());
-    }
-
-    static int statVal;
-    int intVal = 89;
-    public int getIntVal() {
-        return intVal;  //@ 1 breakpoint
-    }
-
-  static class jj2 {
-    static int statVal;
-    int intVal = 89;
-    public int getIntVal() {
-        return intVal;  //@1 breakpoint  line 20
-    }
-  }
-}
-
-EOF
-}
-
-
-# drive jdb by sending cmds to it and examining its output
-dojdbCmds()
-{
-    cmd stop at $classname'$jj2:20'
-    runToBkpt
-    cmd step
-}
-
-
-mysetup()
-{
-    if [ -z "$TESTSRC" ] ; then
-        TESTSRC=.
-    fi
-
-    for ii in . $TESTSRC $TESTSRC/.. ; do
-        if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
-            break
-        fi
-    done
-}
-
-# You could replace this next line with the contents
-# of ShellScaffold.sh and this script will run just the same.
-mysetup
-
-runit
-jdbFailIfNotPresent "Breakpoint hit"
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/JdbVarargsTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4870984
+ * @summary JPDA: Add support for RFE 4856541 - varargs
+ * @comment converted from test/jdk/com/sun/jdi/JdbVarargsTest.sh
+ *
+ * @library /test/lib
+ * @run main/othervm JdbVarargsTest
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+class JdbVarargsTestTarg {
+
+    public static void main(String args[]) {
+        int ii = 0; // @1 breakpoint
+
+        // Call the varargs method so the bkpt will be hit
+        varString(new String[] {"a", "b"});
+    }
+
+    static String varString(String... ss) {
+        if (ss == null) {
+            return "-null-";
+        }
+        if (ss.length == 0) {
+            return "NONE";
+        }
+        String retVal = "";
+        for (int ii = 0; ii < ss.length; ii++) {
+            retVal += ss[ii];
+        }
+        return retVal;
+    }
+
+}
+
+public class JdbVarargsTest extends JdbTest {
+    public static void main(String argv[]) {
+        new JdbVarargsTest().run();
+    }
+
+    private JdbVarargsTest() {
+        super(DEBUGGEE_CLASS);
+    }
+
+    private static final String DEBUGGEE_CLASS = JdbVarargsTestTarg.class.getName();
+
+    @Override
+    protected void runCases() {
+        setBreakpointsFromTestSource("JdbVarargsTest.java", 1);
+        // Run to breakpoint #1
+        jdb.command(JdbCommand.run());
+
+        // check that 'methods' shows the ...
+        jdb.command(JdbCommand.methods(DEBUGGEE_CLASS));
+
+        // check that we can call with no args
+        jdb.command(JdbCommand.eval(DEBUGGEE_CLASS + ".varString();"));
+
+        // check that we can call with var args
+        jdb.command(JdbCommand.eval(DEBUGGEE_CLASS + ".varString(\"aa\", \"bb\");"));
+
+        // check that we can stop in ...
+        jdb.command(JdbCommand.stopIn(DEBUGGEE_CLASS, "varString(java.lang.String...)"));
+
+        jdb.command(JdbCommand.cont());
+
+        new OutputAnalyzer(jdb.getJdbOutput())
+                .shouldContain("NONE")
+                .shouldContain("aabb")
+                .shouldContain(DEBUGGEE_CLASS + " varString(java.lang.String...)")
+                .shouldMatch("Breakpoint hit:.*varString\\(\\)");
+    }
+}
--- a/test/jdk/com/sun/jdi/JdbVarargsTest.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2003, 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
-#  @bug 4870984
-#  @summary  JPDA: Add support for RFE 4856541 - varargs
-#
-#  @author jjh
-#
-#  @key intermittent
-#  @run shell JdbVarargsTest.sh
-
-classname=JdbVarargsTest
-createJavaFile()
-{
-    cat <<EOF > $classname.java.1
-public class $classname {
-   
-    public static void main(String args[]) {
-        int ii = 0; // @1 breakpoint
-
-        // Call the varargs method so the bkpt will be hit
-        varString(new String[] {"a", "b"});
-    }
-
-    static String varString(String... ss) {
-        if (ss == null) {
-            return "-null-";
-        }
-        if (ss.length == 0) {
-            return "NONE";
-        }
-        String retVal = "";
-        for (int ii = 0; ii < ss.length; ii++) {
-            retVal += ss[ii];
-        }
-        return retVal;
-    }
-
-}
-EOF
-}
-
-
-# drive jdb by sending cmds to it and examining its output
-dojdbCmds()
-{
-    setBkpts @1
-    runToBkpt @1
-
-    # check that 'methods' shows the ...
-    cmd methods "$classname"
-
-    # check that we can call with no args
-    cmd eval  "$classname.varString();"
-
-    # check that we can call with var args
-    cmd eval "$classname.varString(\"aa\", \"bb\");"
-    
-    # check that we can stop in ...
-    cmd stop in "$classname.varString(java.lang.String...)"
-    contToBkpt
-}
-
-
-mysetup()
-{
-    if [ -z "$TESTSRC" ] ; then
-        TESTSRC=.
-    fi
-
-    for ii in . $TESTSRC $TESTSRC/.. ; do
-        if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
-            break
-        fi
-    done
-}
-
-# You could replace this next line with the contents
-# of ShellScaffold.sh and this script will run just the same.
-mysetup
-
-runit
-jdbFailIfNotPresent "NONE"
-jdbFailIfNotPresent "aabb"
-jdbFailIfNotPresent "$classname varString\(java\.lang\.String\.\.\.\)"
-jdbFailIfNotPresent 'Breakpoint hit:.*varString\(\)'
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/MixedSuspendTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6224859
+ * @summary JDWP: Mixing application suspends and debugger suspends can cause hangs
+ * @comment converted from test/jdk/com/sun/jdi/MixedSuspendTest.sh
+ *
+ * @library /test/lib
+ * @run main/othervm MixedSuspendTest
+ */
+
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+class MixedSuspendTarg extends Thread {
+
+    static volatile boolean started = true;
+    static String lock = "startLock";
+
+    public static void main(String[] args){
+        System.out.println("Howdy from MixedSuspendTarg");
+
+        MixedSuspendTarg mytarg = new MixedSuspendTarg();
+
+        synchronized(lock) {
+            mytarg.start();
+            try {
+                lock.wait();
+            } catch(InterruptedException ee) {
+            }
+        }
+        mytarg.suspend();
+        bkpt();
+        System.out.println("Debuggee: resuming thread");
+
+        // If the bug occurs, this resume hangs in the back-end
+        mytarg.resume();
+        System.out.println("Debuggee: resumed thread");
+        synchronized(lock) {
+            started = false;
+        }
+        System.out.println("Debuggee: exitting, started = " + started);
+    }
+
+    public void run() {
+        synchronized(lock) {
+            lock.notifyAll();
+        }
+        while (true) {
+            synchronized(lock) {
+                if (!started) {
+                    break;
+                }
+                int i = 0;
+            }
+        }
+
+        System.out.println("Debuggee: end of thread");
+    }
+
+    static void bkpt() {
+        //System.out.println("bkpt reached, thread = " + this.getName());
+        int i = 0;   // @1 breakpoint
+    }
+}
+
+public class MixedSuspendTest extends JdbTest {
+    public static void main(String argv[]) {
+        new MixedSuspendTest().run();
+    }
+
+    private MixedSuspendTest() {
+        super(DEBUGGEE_CLASS);
+    }
+
+    private static final String DEBUGGEE_CLASS = MixedSuspendTarg.class.getName();
+
+    @Override
+    protected void runCases() {
+        setBreakpointsFromTestSource("MixedSuspendTest.java", 1);
+        jdb.command(JdbCommand.run());
+        jdb.command(JdbCommand.cont().allowExit());
+
+        // This test fails by timing out.
+    }
+}
--- a/test/jdk/com/sun/jdi/MixedSuspendTest.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2005, 2015, 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
-# @bug 6224859
-# @key intermittent
-# @summary JDWP: Mixing application suspends and debugger suspends can cause hangs
-# @author Jim Holmlund
-#
-# @run build TestScaffold VMConnection TargetListener TargetAdapter
-# @run shell MixedSuspendTest.sh
-
-classname=MixedSuspendTarg
-
-createJavaFile()
-{
-    cat <<EOF > $classname.java.1
-
-import java.util.*;
-
-public class $classname extends Thread {
-
-    static volatile boolean started = true;
-    static String lock = "startLock";
-
-    public static void main(String[] args){
-        System.out.println("Howdy from MixedSuspendTarg");
-
-        MixedSuspendTarg mytarg = new MixedSuspendTarg();
-
-        synchronized(lock) {
-            mytarg.start();
-            try {
-                lock.wait();
-            } catch(InterruptedException ee) {
-            }
-        }
-        mytarg.suspend();
-        bkpt();
-        System.out.println("Debuggee: resuming thread");
-
-        // If the bug occurs, this resume hangs in the back-end
-        mytarg.resume();
-        System.out.println("Debuggee: resumed thread");
-        synchronized(lock) {
-            started = false;
-        }
-        System.out.println("Debuggee: exitting, started = " + started);
-    }
-
-    public void run() {
-        synchronized(lock) {
-            lock.notifyAll();
-        }
-        while (true) {
-            synchronized(lock) {
-                if (!started) {
-                    break;
-                }
-                int i = 0;
-            }
-        }
-
-        System.out.println("Debuggee: end of thread");
-    }
-
-    static void bkpt() {
-        //System.out.println("bkpt reached, thread = " + this.getName());
-        int i = 0;   // @1 breakpoint
-    }
-}
-
-EOF
-}
-
-dojdbCmds()
-{
-    setBkpts @1
-    runToBkpt @1
-    cmd allowExit cont
-}
-
-
-mysetup()
-{
-    if [ -z "$TESTSRC" ] ; then
-        TESTSRC=.
-    fi
-
-    for ii in . $TESTSRC $TESTSRC/.. ; do
-        if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh
-            break
-        fi
-    done
-}
-
-# You could replace this next line with the contents
-# of ShellScaffold.sh and this script will run just the same.
-mysetup
-
-runit
-## This test fails by timing out.
-pass
--- a/test/jdk/com/sun/jdi/NoLaunchOptionTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/NoLaunchOptionTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,8 +22,8 @@
  */
 
 import static jdk.testlibrary.Asserts.assertFalse;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 /*
  * @test       NoLaunchOptionTest.java
@@ -32,6 +32,7 @@
  * @author     Tim Bell
  *
  * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @run compile -g NoLaunchOptionTest.java
  * @build jdk.testlibrary.* VMConnection
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/NotAField.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4467887 4913748
+ * @summary TTY: NullPointerException at com.sun.tools.jdi.MirrorImpl.validateMirrors
+ * @comment converted from test/jdk/com/sun/jdi/NotAField.sh
+ *
+ * @library /test/lib
+ * @run main/othervm NotAField
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+class NotAFieldTarg {
+    public static void main(String args[]) {
+        System.out.println("Hello, world!");
+    }
+}
+
+public class NotAField extends JdbTest {
+    public static void main(String argv[]) {
+        new NotAField().run();
+    }
+
+    private NotAField() {
+        super(DEBUGGEE_CLASS);
+    }
+
+    private static final String DEBUGGEE_CLASS = NotAFieldTarg.class.getName();
+
+    @Override
+    protected void runCases() {
+        jdb.command(JdbCommand.stopIn(DEBUGGEE_CLASS, "main"));
+        jdb.command(JdbCommand.run());
+
+        // This works:
+        jdb.command(JdbCommand.print("java.lang.Class.reflectionFactory.hashCode()"));
+        // This should result in a ParseException: ("No such field in ..."):
+        jdb.command(JdbCommand.print("java.lang.Class.reflectionFactory.hashCode"));
+        jdb.contToExit(1);
+
+        new OutputAnalyzer(jdb.getJdbOutput())
+                .shouldContain("com.sun.tools.example.debug.expr.ParseException");
+    }
+}
--- a/test/jdk/com/sun/jdi/NotAField.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2014, 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
-#  @bug 4467887 4913748
-#  @summary TTY: NullPointerException at
-#           com.sun.tools.jdi.MirrorImpl.validateMirrors
-#  @author Tim Bell
-#  @key intermittent
-#  @run shell NotAField.sh
-#
-
-createJavaFile()
-{
-    cat <<EOF > $classname.java.1
-public class $classname {
-    public static void main(String args[]) {
-        System.out.println("Hello, world!");
-    }
-}
-
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-   #set -x
-   cmd stop in $classname.main
-   runToBkpt
-   #This works:
-   cmd print "java.lang.Class.reflectionFactory.hashCode()"
-   #This should result in a ParseException: ("No such field in ..."):
-   cmd print "java.lang.Class.reflectionFactory.hashCode"
-   cmd allowExit cont
-}
-
-mysetup()
-{
-   if [ -z "${TESTJAVA}" ] ; then
-      # TESTJAVA is not set, so the test is running stand-alone.
-      # TESTJAVA holds the path to the root directory of the build of the JDK
-      # to be tested.  That is, any java files run explicitly in this shell
-      # should use TESTJAVA in the path to the java interpreter.
-      # So, we'll set this to the JDK spec'd on the command line.  If none
-      # is given on the command line, tell the user that and use a default.
-      # THIS IS THE JDK BEING TESTED.
-      if [ -n "$1" ] ; then
-             TESTJAVA=$1
-         else
-             TESTJAVA=$JAVA_HOME
-      fi
-      TESTSRC=.
-      TESTCLASSES=.
-   fi
-   echo "JDK under test is: $TESTJAVA"
-
-   if [ -z "$TESTSRC" ] ; then
-        TESTSRC=.
-   fi
-
-   if [ -r $TESTSRC/ShellScaffold.sh ] ; then
-        . $TESTSRC/ShellScaffold.sh 
-   elif [ -r $TESTSRC/../ShellScaffold.sh ] ; then
-        . $TESTSRC/../ShellScaffold.sh
-   fi
-}
-
-# You could replace this next line with the contents
-# of ShellScaffold.sh and this script will run just the same.
-mysetup
-
-runit
-jdbFailIfNotPresent "com.sun.tools.example.debug.expr.ParseException" 50
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/NullLocalVariable.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4690242 4695338
+ * @summary TTY: jdb throws NullPointerException when printing local variables
+ * @comment converted from test/jdk/com/sun/jdi/NullLocalVariable.sh
+ *
+ * @library /test/lib
+ * @compile -g NullLocalVariable.java
+ * @run main/othervm NullLocalVariable
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+class NullLocalVariableTarg {
+    public static final void main(String args[]) {
+        try {
+            System.out.println("hi!");               // @1 breakpoint
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            System.out.println("done");
+        }
+    }
+}
+
+public class NullLocalVariable extends JdbTest {
+    public static void main(String argv[]) {
+        new NullLocalVariable().run();
+    }
+
+    private NullLocalVariable() {
+        super(DEBUGGEE_CLASS);
+    }
+
+    private static final String DEBUGGEE_CLASS = NullLocalVariableTarg.class.getName();
+
+    @Override
+    protected void runCases() {
+        setBreakpointsFromTestSource("NullLocalVariable.java", 1);
+        // Run to breakpoint #1
+        jdb.command(JdbCommand.run());
+
+        jdb.command(JdbCommand.next());
+        jdb.command(JdbCommand.next());
+        jdb.command(JdbCommand.locals());
+        jdb.contToExit(1);
+
+        new OutputAnalyzer(getDebuggeeOutput())
+                .shouldNotContain("Internal exception");
+    }
+}
--- a/test/jdk/com/sun/jdi/NullLocalVariable.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2014, 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
-#  @bug 4690242 4695338
-#  @summary TTY: jdb throws NullPointerException when printing local variables
-#  @author Tim Bell
-#
-#  @run shell NullLocalVariable.sh
-#
-classname=badscope
-
-createJavaFile()
-{
-    cat <<EOF > $classname.java.1
-public class badscope {
-    public static final void main(String args[]) {
-        try {
-            System.out.println("hi!");               // @1 breakpoint
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            System.out.println("done");
-        }
-    }
-}
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-   #set -x
-   cmd stop at badscope:4   ; $sleepcmd
-   runToBkpt                ; $sleepcmd
-   cmd next                 ; $sleepcmd
-   cmd next                 ; $sleepcmd
-   cmd locals               ; $sleepcmd
-   cmd allowExit cont
-}
-
-mysetup()
-{
-    compileOptions=-g
-    if [ -z "$TESTSRC" ] ; then
-        TESTSRC=.
-    fi
-
-    for ii in . $TESTSRC $TESTSRC/.. ; do
-        if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh
-            break
-        fi
-    done
-}
-# You could replace this next line with the contents
-# of ShellScaffold.sh and this script will run just the same.
-mysetup
-
-runit
-jdbFailIfPresent "Internal exception" 50
-pass
--- a/test/jdk/com/sun/jdi/ProcessAttachTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/ProcessAttachTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -25,7 +25,7 @@
 import java.io.InputStream;
 import java.util.Map;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 import com.sun.jdi.Bootstrap;
 import com.sun.jdi.VirtualMachine;
@@ -39,6 +39,7 @@
  * @summary Unit test for ProcessAttachingConnector
  *
  * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.management
  *          jdk.jdi
  * @build jdk.testlibrary.* ProcessAttachTest
--- a/test/jdk/com/sun/jdi/RunToExit.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/RunToExit.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -24,10 +24,10 @@
 /* @test
  * @bug 4997445
  * @summary Test that with server=y, when VM runs to System.exit() no error happens
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.management
  *          jdk.jdi
- * @build jdk.testlibrary.* VMConnection RunToExit Exit0
+ * @build VMConnection RunToExit Exit0
  * @run driver RunToExit
  */
 import java.net.ServerSocket;
@@ -42,7 +42,7 @@
 import java.util.Iterator;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 public class RunToExit {
 
--- a/test/jdk/com/sun/jdi/SuspendNoFlagTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/SuspendNoFlagTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,15 +21,14 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 /* @test
  * @bug 4914611
  * @summary Test for JDWP: -agentlib:jdwp=suspend=n hanging
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.management
- * @build jdk.testlibrary.*
  * @compile -g HelloWorld.java
  * @run driver SuspendNoFlagTest
  */
--- a/test/jdk/com/sun/jdi/cds/CDSBreakpointTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/cds/CDSBreakpointTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,9 +29,8 @@
  * @modules jdk.jdi
  *          java.management
  *          jdk.jartool/sun.tools.jar
- * @library /lib/testlibrary
+ * @library /test/lib
  * @library ..
- * @build jdk.testlibrary.*
  * @build TestScaffold VMConnection TargetListener TargetAdapter
  * @build CDSJDITest
  * @run compile -g ../BreakpointTest.java
--- a/test/jdk/com/sun/jdi/cds/CDSDeleteAllBkptsTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/cds/CDSDeleteAllBkptsTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,9 +29,8 @@
  * @modules jdk.jdi
  *          java.management
  *          jdk.jartool/sun.tools.jar
- * @library /lib/testlibrary
+ * @library /test/lib
  * @library ..
- * @build jdk.testlibrary.*
  * @build TestScaffold VMConnection TargetListener TargetAdapter
  * @build CDSJDITest
  * @run compile -g ../DeleteAllBkptsTest.java
--- a/test/jdk/com/sun/jdi/cds/CDSFieldWatchpoints.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/cds/CDSFieldWatchpoints.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,9 +29,8 @@
  * @modules jdk.jdi
  *          java.management
  *          jdk.jartool/sun.tools.jar
- * @library /lib/testlibrary
+ * @library /test/lib
  * @library ..
- * @build jdk.testlibrary.*
  * @build TestScaffold VMConnection TargetListener TargetAdapter
  * @build CDSJDITest
  * @run compile -g ../FieldWatchpoints.java
--- a/test/jdk/com/sun/jdi/cds/CDSJDITest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/cds/CDSJDITest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -25,8 +25,8 @@
  * Helper superclass for launching JDI tests out of the CDS archive.
 */
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 import java.io.*;
 import java.util.ArrayList;
--- a/test/jdk/com/sun/jdi/lib/jdb/Jdb.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/lib/jdb/Jdb.java	Fri Sep 07 15:46:39 2018 -0700
@@ -33,87 +33,22 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import jdk.test.lib.JDKToolFinder;
-import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.Utils;
 import jdk.test.lib.process.StreamPumper;
 
-public class Jdb {
-
-    public static class LaunchOptions {
-        public final String debuggeeClass;
-        public final List<String> debuggeeOptions = new LinkedList<>();
-
-        public LaunchOptions(String debuggeeClass) {
-            this.debuggeeClass = debuggeeClass;
-        }
-        public LaunchOptions addDebuggeeOption(String option) {
-            debuggeeOptions.add(option);
-            return this;
-        }
-        public LaunchOptions addDebuggeeOptions(String[] options) {
-            debuggeeOptions.addAll(Arrays.asList(options));
-            return this;
+public class Jdb implements AutoCloseable {
+    public Jdb(String... args) {
+        ProcessBuilder pb = new ProcessBuilder(JDKToolFinder.getTestJDKTool("jdb"));
+        pb.command().addAll(Arrays.asList(args));
+        try {
+            jdb = pb.start();
+        } catch (IOException ex) {
+            throw new RuntimeException("failed to launch pdb", ex);
         }
-    }
-
-    public static Jdb launchLocal(LaunchOptions options) {
-        return new Jdb(options);
-    }
-
-    public static Jdb launchLocal(String debuggeeClass) {
-        return new Jdb(new LaunchOptions(debuggeeClass));
-    }
-
-    public Jdb(LaunchOptions options) {
-        /* run debuggee as:
-            java -agentlib:jdwp=transport=dt_socket,address=0,server=n,suspend=y <debuggeeClass>
-        it reports something like : Listening for transport dt_socket at address: 60810
-        after that connect jdb by:
-            jdb -connect com.sun.jdi.SocketAttach:port=60810
-        */
-        // launch debuggee
-        List<String> debuggeeArgs = new LinkedList<>();
-        // specify address=0 to automatically select free port
-        debuggeeArgs.add("-agentlib:jdwp=transport=dt_socket,address=0,server=y,suspend=y");
-        debuggeeArgs.addAll(options.debuggeeOptions);
-        debuggeeArgs.add(options.debuggeeClass);
-        ProcessBuilder pbDebuggee = ProcessTools.createJavaProcessBuilder(true, debuggeeArgs.toArray(new String[0]));
-
-        // debuggeeListen[0] - transport, debuggeeListen[1] - address
-        String[] debuggeeListen = new String[2];
-        Pattern listenRegexp = Pattern.compile("Listening for transport \\b(.+)\\b at address: \\b(\\d+)\\b");
         try {
-            debuggee = ProcessTools.startProcess("debuggee", pbDebuggee,
-                    s -> debuggeeOutput.add(s),  // output consumer
-                    s -> {  // warm-up predicate
-                        Matcher m = listenRegexp.matcher(s);
-                        if (!m.matches()) {
-                            return false;
-                        }
-                        debuggeeListen[0] = m.group(1);
-                        debuggeeListen[1] = m.group(2);
-                        return true;
-                    },
-                    30, TimeUnit.SECONDS);
-        } catch (IOException | InterruptedException | TimeoutException ex) {
-            throw new RuntimeException("failed to launch debuggee", ex);
-        }
-
-        // launch jdb
-        try {
-            ProcessBuilder pb = new ProcessBuilder(JDKToolFinder.getTestJDKTool("jdb"));
-            pb.command().add("-connect");
-            pb.command().add("com.sun.jdi.SocketAttach:port=" + debuggeeListen[1]);
-            System.out.println("Launching jdb:" + pb.command().stream().collect(Collectors.joining(" ")));
-            try {
-                jdb = pb.start();
-            } catch (IOException ex) {
-                throw new RuntimeException("failed to launch pdb", ex);
-            }
             StreamPumper stdout = new StreamPumper(jdb.getInputStream());
             StreamPumper stderr = new StreamPumper(jdb.getErrorStream());
 
@@ -125,19 +60,16 @@
 
             inputWriter = new PrintWriter(jdb.getOutputStream(), true);
         } catch (Throwable ex) {
-            // terminate debuggee if something went wrong
-            debuggee.destroy();
+            // terminate jdb if something went wrong
+            jdb.destroy();
             throw ex;
         }
     }
 
     private final Process jdb;
-    private final Process debuggee;
     private final OutputHandler outputHandler = new OutputHandler();
     private final PrintWriter inputWriter;
-    // contains all jdb output (to be used by getJdbOutput())
     private final List<String> jdbOutput = new LinkedList<>();
-    private final List<String> debuggeeOutput = new LinkedList<>();
 
     private static final String lineSeparator = System.getProperty("line.separator");
     // wait time before check jdb output (in ms)
@@ -145,8 +77,6 @@
     // max time to wait for  jdb output (in ms)
     private static long timeout = 60000;
 
-    // jdb prompt when debuggee is not started nor suspended after breakpoint
-    public static final String SIMPLE_PROMPT = "> ";
     // pattern for message of a breakpoint hit
     public static final String BREAKPOINT_HIT = "Breakpoint hit:";
     // pattern for message of an application exit
@@ -155,10 +85,15 @@
     public static final String APPLICATION_DISCONNECTED = "The application has been disconnected";
 
 
+    @Override
+    public void close() throws Exception {
+        shutdown();
+    }
+
     // waits until the process shutdown or crash
     public boolean waitFor(long timeout, TimeUnit unit) {
         try {
-            return jdb.waitFor(timeout, unit);
+            return jdb.waitFor(Utils.adjustTimeout(timeout), unit);
         } catch (InterruptedException e) {
             return false;
         }
@@ -177,18 +112,6 @@
                 }
             }
         }
-        // shutdown debuggee
-        if (debuggee.isAlive()) {
-            try {
-                debuggee.waitFor(10, TimeUnit.SECONDS);
-            } catch (InterruptedException e) {
-                // ignore
-            } finally {
-                if (debuggee.isAlive()) {
-                    debuggee.destroy();
-                }
-            }
-        }
     }
 
 
@@ -230,6 +153,16 @@
     private final String promptPattern = "[a-zA-Z0-9_-][a-zA-Z0-9_-]*\\[[1-9][0-9]*\\] [ >]*$";
     private final Pattern promptRegexp = Pattern.compile(promptPattern);
     public List<String> waitForPrompt(int lines, boolean allowExit) {
+        return waitForPrompt(lines, allowExit, promptRegexp);
+    }
+
+    // jdb prompt when debuggee is not started and is not suspended after breakpoint
+    private static final String SIMPLE_PROMPT = "> ";
+    public List<String> waitForSimplePrompt(int lines, boolean allowExit) {
+        return waitForPrompt(lines, allowExit, Pattern.compile(SIMPLE_PROMPT));
+    }
+
+    private List<String> waitForPrompt(int lines, boolean allowExit, Pattern promptRegexp) {
         long startTime = System.currentTimeMillis();
         while (System.currentTimeMillis() - startTime < timeout) {
             try {
@@ -332,11 +265,6 @@
         return jdbOutput.stream().collect(Collectors.joining(lineSeparator));
     }
 
-    // returns the whole debuggee output as a string
-    public String getDebuggeeOutput() {
-        return debuggeeOutput.stream().collect(Collectors.joining(lineSeparator));
-    }
-
     // handler for out/err of the pdb process
     private class OutputHandler extends OutputStream {
         // there are 2 buffers:
--- a/test/jdk/com/sun/jdi/lib/jdb/JdbCommand.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/lib/jdb/JdbCommand.java	Fri Sep 07 15:46:39 2018 -0700
@@ -120,7 +120,7 @@
     boolean allowExit = false;
 
     public JdbCommand(String cmd) {
-        this.cmd = cmd.endsWith(ls) ? cmd.substring(0, cmd.length() - 1) : cmd;
+        this.cmd = cmd;
     }
 
     public JdbCommand allowExit() {
@@ -129,8 +129,6 @@
     }
 
 
-    private static final String ls = System.getProperty("line.separator");
-
     public static JdbCommand run(String ... params) {
         return new JdbCommand("run " + Arrays.stream(params).collect(Collectors.joining(" ")));
     }
@@ -147,6 +145,28 @@
     public static JdbCommand stopAt(String targetClass, int lineNum) {
         return new JdbCommand("stop at " + targetClass + ":" + lineNum);
     }
+    public static JdbCommand stopIn(String targetClass, String methodName) {
+        return new JdbCommand("stop in " + targetClass + "." + methodName);
+    }
+
+    // exception type used by catch/ignore
+    public enum ExType{
+        uncaught,
+        caught,
+        all
+    }
+    public static JdbCommand catch_(String classId) {
+        return new JdbCommand("catch " + classId);
+    }
+    public static JdbCommand catch_(ExType eType, String classId) {
+        return catch_(eType.toString() + " " + classId);
+    }
+    public static JdbCommand ignore(String classId) {
+        return new JdbCommand("ignore " + classId);
+    }
+    public static JdbCommand ignore(ExType eType, String classId) {
+        return ignore(eType.toString() + " " + classId);
+    }
 
     public static JdbCommand step() {
         return new JdbCommand("step");
@@ -154,15 +174,37 @@
     public static JdbCommand stepUp() {
         return new JdbCommand("step up");
     }
+    public static JdbCommand next() {
+        return new JdbCommand("next");
+    }
 
+    // where [thread id] | all
+    public static JdbCommand where(String threadId) {
+        return new JdbCommand("where " + threadId);
+    }
+    public static JdbCommand eval(String expr) {
+        return new JdbCommand("eval " + expr);
+    }
     public static JdbCommand print(String expr) {
         return new JdbCommand("print " + expr);
     }
 
+    public static JdbCommand locals() {
+        return new JdbCommand("locals");
+    }
+
     public static JdbCommand set(String lvalue, String expr) {
         return new JdbCommand("set " + lvalue + " = " + expr);
     }
 
+    public static JdbCommand lock(String expr) {
+        return new JdbCommand("lock " + expr);
+    }
+
+    public static JdbCommand methods(String classId) {
+        return new JdbCommand("methods " + classId);
+    }
+
     // trace [go] methods [thread]
     //                           -- trace method entries and exits.
     //                           -- All threads are suspended unless 'go' is specified
@@ -192,4 +234,9 @@
     public static JdbCommand untrace() {
         return new JdbCommand("untrace");
     }
+
+    // watch [access|all] <class id>.<field name>
+    public static JdbCommand watch(String classId, String fieldName) {
+        return new JdbCommand("watch " + classId + "." + fieldName);
+    }
 }
--- a/test/jdk/com/sun/jdi/lib/jdb/JdbTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/jdi/lib/jdb/JdbTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -23,28 +23,64 @@
 
 package lib.jdb;
 
+import jdk.test.lib.Utils;
 import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 public abstract class JdbTest {
 
-    public JdbTest(Jdb.LaunchOptions jdbOptions) {
-        this.jdbOptions= jdbOptions;
-        debuggeeClass = jdbOptions.debuggeeClass;
+    public static class LaunchOptions {
+        public final String debuggeeClass;
+        public final List<String> debuggeeOptions = new LinkedList<>();
+
+        public LaunchOptions(String debuggeeClass) {
+            this.debuggeeClass = debuggeeClass;
+        }
+        public LaunchOptions addDebuggeeOption(String option) {
+            debuggeeOptions.add(option);
+            return this;
+        }
+        public LaunchOptions addDebuggeeOptions(String[] options) {
+            debuggeeOptions.addAll(Arrays.asList(options));
+            return this;
+        }
+    }
+
+    public JdbTest(LaunchOptions launchOptions) {
+        this.launchOptions= launchOptions;
+        debuggeeClass = launchOptions.debuggeeClass;
     }
     public JdbTest(String debuggeeClass) {
-        this(new Jdb.LaunchOptions(debuggeeClass));
+        this(new LaunchOptions(debuggeeClass));
     }
 
-    private final Jdb.LaunchOptions jdbOptions;
     protected Jdb jdb;
-    protected final String debuggeeClass;   // shortland for jdbOptions.debuggeeClass
+    protected Process debuggee;
+    private final List<String> debuggeeOutput = new LinkedList<>();
+    private final LaunchOptions launchOptions;
+    protected final String debuggeeClass;   // shortland for launchOptions.debuggeeClass
+
+    // returns the whole jdb output as a string
+    public String getJdbOutput() {
+        return jdb == null ? "" : jdb.getJdbOutput();
+    }
+
+    // returns the whole debuggee output as a string
+    public String getDebuggeeOutput() {
+        return debuggeeOutput.stream().collect(Collectors.joining(lineSeparator));
+    }
 
     public void run() {
         try {
@@ -56,10 +92,50 @@
     }
 
     protected void setup() {
-        jdb = Jdb.launchLocal(jdbOptions);
+        /* run debuggee as:
+            java -agentlib:jdwp=transport=dt_socket,address=0,server=n,suspend=y <debuggeeClass>
+        it reports something like : Listening for transport dt_socket at address: 60810
+        after that connect jdb by:
+            jdb -connect com.sun.jdi.SocketAttach:port=60810
+        */
+        // launch debuggee
+        List<String> debuggeeArgs = new LinkedList<>();
+        // specify address=0 to automatically select free port
+        debuggeeArgs.add("-agentlib:jdwp=transport=dt_socket,address=0,server=y,suspend=y");
+        debuggeeArgs.addAll(launchOptions.debuggeeOptions);
+        debuggeeArgs.add(launchOptions.debuggeeClass);
+        ProcessBuilder pbDebuggee = ProcessTools.createJavaProcessBuilder(true, debuggeeArgs.toArray(new String[0]));
+
+        // debuggeeListen[0] - transport, debuggeeListen[1] - address
+        String[] debuggeeListen = new String[2];
+        Pattern listenRegexp = Pattern.compile("Listening for transport \\b(.+)\\b at address: \\b(\\d+)\\b");
+        try {
+            debuggee = ProcessTools.startProcess("debuggee", pbDebuggee,
+                    s -> debuggeeOutput.add(s),  // output consumer
+                    s -> {  // warm-up predicate
+                        Matcher m = listenRegexp.matcher(s);
+                        if (!m.matches()) {
+                            return false;
+                        }
+                        debuggeeListen[0] = m.group(1);
+                        debuggeeListen[1] = m.group(2);
+                        return true;
+                    },
+                    30, TimeUnit.SECONDS);
+        } catch (IOException | InterruptedException | TimeoutException ex) {
+            throw new RuntimeException("failed to launch debuggee", ex);
+        }
+
+        // launch jdb
+        try {
+            jdb = new Jdb("-connect", "com.sun.jdi.SocketAttach:port=" + debuggeeListen[1]);
+        } catch (Throwable ex) {
+            // terminate debuggee if something went wrong
+            debuggee.destroy();
+            throw ex;
+        }
         // wait while jdb is initialized
         jdb.waitForPrompt(1, false);
-
     }
 
     protected abstract void runCases();
@@ -68,6 +144,18 @@
         if (jdb != null) {
             jdb.shutdown();
         }
+        // shutdown debuggee
+        if (debuggee != null && debuggee.isAlive()) {
+            try {
+                debuggee.waitFor(Utils.adjustTimeout(10), TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+                // ignore
+            } finally {
+                if (debuggee.isAlive()) {
+                    debuggee.destroy();
+                }
+            }
+        }
     }
 
     protected static final String lineSeparator = System.getProperty("line.separator");
@@ -109,12 +197,27 @@
         return bps.size();
     }
 
-    protected int setBreakpoints(String debuggeeSourcePath, int id) {
-        return setBreakpoints(jdb, debuggeeClass, debuggeeSourcePath, id);
+    // sets breakpoints to the lines parsed by {@code parseBreakpoints}
+    // from the file from test source directory.
+    // returns number of the breakpoints set.
+    protected int setBreakpointsFromTestSource(String debuggeeFileName, int id) {
+        return setBreakpoints(jdb, debuggeeClass, System.getProperty("test.src") + "/" + debuggeeFileName, id);
     }
 
     protected OutputAnalyzer execCommand(JdbCommand cmd) {
         List<String> reply = jdb.command(cmd);
         return new OutputAnalyzer(reply.stream().collect(Collectors.joining(lineSeparator)));
     }
+
+    // helpers for "eval" jdb command.
+    // executes "eval <expr>" and verifies output contains the specified text
+    protected void evalShouldContain(String expr, String expectedString) {
+        execCommand(JdbCommand.eval(expr))
+                .shouldContain(expectedString);
+    }
+    // executes "eval <expr>" and verifies output does not contain the specified text
+    protected void evalShouldNotContain(String expr, String unexpectedString) {
+        execCommand(JdbCommand.eval(expr))
+                .shouldNotContain(unexpectedString);
+    }
 }
--- a/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java	Fri Sep 07 15:46:39 2018 -0700
@@ -27,10 +27,9 @@
  * @author Staffan Larsen
  * @comment Graal does not support CMS
  * @requires !vm.graal.enabled
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules jdk.attach/sun.tools.attach
  *          jdk.management
- * @build jdk.testlibrary.*
  * @run main CheckOrigin
  */
 
@@ -44,7 +43,7 @@
 import java.io.PrintWriter;
 import java.lang.management.ManagementFactory;
 import java.util.Map;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 import sun.tools.attach.HotSpotVirtualMachine;
 
 public class CheckOrigin {
--- a/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
 import java.util.List;
 
 import jdk.test.lib.hprof.HprofParser;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 import com.sun.management.HotSpotDiagnosticMXBean;
 
--- a/test/jdk/com/sun/management/OperatingSystemMXBean/TestTotalSwap.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/management/OperatingSystemMXBean/TestTotalSwap.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,9 +28,8 @@
  * @author  Steve Bohne
  * @author  Jaroslav Bachorik
  *
- * @library /lib/testlibrary
+ * @library /test/lib
  *
- * @build TestTotalSwap jdk.testlibrary.*
  * @run main TestTotalSwap
  */
 
@@ -55,9 +54,9 @@
 import com.sun.management.OperatingSystemMXBean;
 import java.lang.management.*;
 
-import jdk.testlibrary.OSInfo;
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.Platform;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
 
 public class TestTotalSwap {
 
@@ -110,56 +109,48 @@
     }
 
     private static long getSwapSizeFromOs() throws Throwable {
-        OSInfo.OSType os = OSInfo.getOSType();
-
-        switch (os) {
+        if (Platform.isLinux()) {
             // total       used       free     shared    buffers     cached
             // Mem:    16533540864 13638467584 2895073280  534040576 1630248960 6236909568
             // -/+ buffers/cache: 5771309056 10762231808
             // Swap:   15999168512          0 15999168512
-
-            case LINUX: {
-                String swapSizeStr = ProcessTools.executeCommand("free", "-b")
-                                        .firstMatch("Swap:\\s+([0-9]+)\\s+.*", 1);
-                return Long.parseLong(swapSizeStr);
-            }
-            case SOLARIS: {
-                // swapfile             dev   swaplo blocks   free
-                // /dev/dsk/c0t0d0s1   136,1      16 1638608 1600528
-                OutputAnalyzer out= ProcessTools.executeCommand(
+            String swapSizeStr = ProcessTools.executeCommand("free", "-b")
+                                             .firstMatch("Swap:\\s+([0-9]+)\\s+.*", 1);
+            return Long.parseLong(swapSizeStr);
+        } else if (Platform.isSolaris()) {
+            // swapfile             dev   swaplo blocks   free
+            // /dev/dsk/c0t0d0s1   136,1      16 1638608 1600528
+            OutputAnalyzer out= ProcessTools.executeCommand(
                     "/usr/sbin/swap",
                     "-l"
-                );
+            );
 
-                long swapSize = 0;
+            long swapSize = 0;
 
-                for (String line : out.asLines()) {
-                    if (line.contains("swapfile")) continue;
+            for (String line : out.asLines()) {
+                if (line.contains("swapfile")) continue;
 
-                    String[] vals = line.split("\\s+");
-                    if (vals.length == 5) {
-                        swapSize += Long.parseLong(vals[3]) * 512; // size is reported in 512b blocks
-                    }
+                String[] vals = line.split("\\s+");
+                if (vals.length == 5) {
+                    swapSize += Long.parseLong(vals[3]) * 512; // size is reported in 512b blocks
                 }
+            }
 
-                return swapSize;
-            }
-            case MACOSX: {
-                // total = 8192.00M used = 7471.11M free = 720.89M (encrypted)
-                String swapSizeStr = ProcessTools.executeCommand(
+            return swapSize;
+        } else if (Platform.isOSX()) {
+            // total = 8192.00M used = 7471.11M free = 720.89M (encrypted)
+            String swapSizeStr = ProcessTools.executeCommand(
                     "/usr/sbin/sysctl",
                     "-n",
                     "vm.swapusage"
-                ).firstMatch("total\\s+=\\s+([0-9]+(\\.[0-9]+)?[Mm]?).*", 1);
-                if (swapSizeStr.toLowerCase().endsWith("m")) {
-                    swapSizeStr = swapSizeStr.substring(0, swapSizeStr.length() - 1);
-                    return (long)(Double.parseDouble(swapSizeStr) * 1024 * 1024); // size in MB
-                }
-                return (long)(Double.parseDouble(swapSizeStr) * 1024 * 1024);
+            ).firstMatch("total\\s+=\\s+([0-9]+(\\.[0-9]+)?[Mm]?).*", 1);
+            if (swapSizeStr.toLowerCase().endsWith("m")) {
+                swapSizeStr = swapSizeStr.substring(0, swapSizeStr.length() - 1);
+                return (long)(Double.parseDouble(swapSizeStr) * 1024 * 1024); // size in MB
             }
-            default: {
-                System.err.println("Unsupported operating system: " + os);
-            }
+            return (long)(Double.parseDouble(swapSizeStr) * 1024 * 1024);
+        } else {
+            System.err.println("Unsupported operating system: " + Platform.getOsName());
         }
 
         return -1;
--- a/test/jdk/com/sun/tools/attach/BasicTests.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/tools/attach/BasicTests.java	Fri Sep 07 15:46:39 2018 -0700
@@ -29,8 +29,8 @@
 import java.util.Properties;
 
 import jdk.test.lib.thread.ProcessThread;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 import com.sun.tools.attach.AgentInitializationException;
 import com.sun.tools.attach.AgentLoadException;
--- a/test/jdk/com/sun/tools/attach/PermissionTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/tools/attach/PermissionTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -25,8 +25,8 @@
 import com.sun.tools.attach.AttachNotSupportedException;
 import java.io.File;
 import jdk.test.lib.thread.ProcessThread;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 /*
  * @test
--- a/test/jdk/com/sun/tools/attach/ProviderTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/tools/attach/ProviderTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -22,9 +22,8 @@
  */
 
 import java.io.File;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import com.sun.tools.attach.VirtualMachine;
 import com.sun.tools.attach.spi.AttachProvider;
 
--- a/test/jdk/com/sun/tools/attach/RunnerUtil.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/tools/attach/RunnerUtil.java	Fri Sep 07 15:46:39 2018 -0700
@@ -27,7 +27,7 @@
 import java.util.Arrays;
 
 import jdk.test.lib.thread.ProcessThread;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Utils;
 
 /*
--- a/test/jdk/com/sun/tools/attach/StartManagementAgent.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/tools/attach/StartManagementAgent.java	Fri Sep 07 15:46:39 2018 -0700
@@ -46,7 +46,7 @@
  *          jdk.attach
  *          jdk.jartool/sun.tools.jar
  *
- * @run build Application SimpleProvider jdk.testlibrary.*
+ * @run build jdk.testlibrary.* Application SimpleProvider jdk.testlibrary.*
  * @run main/timeout=300 StartManagementAgent
  */
 
--- a/test/jdk/com/sun/tools/attach/TempDirTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/com/sun/tools/attach/TempDirTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -30,8 +30,8 @@
 import java.io.File;
 
 import jdk.test.lib.thread.ProcessThread;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 /*
  * @test
--- a/test/jdk/java/awt/Choice/ItemStateChangeTest/ItemStateChangeTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/Choice/ItemStateChangeTest/ItemStateChangeTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -28,15 +28,15 @@
   @summary awt Choice doesn't fire ItemStateChange when selecting item after select() call
   @author Oleg Pekhovskiy: area=awt-choice
   @library ../../regtesthelpers
-  @library ../../../../lib/testlibrary
+  @library /test/lib
   @modules java.desktop/sun.awt
   @build Util
-  @build jdk.testlibrary.OSInfo
+  @build jdk.test.lib.Platform
   @run main ItemStateChangeTest
 */
 
+import jdk.test.lib.Platform;
 import test.java.awt.regtesthelpers.Util;
-import jdk.testlibrary.OSInfo;
 
 import java.awt.*;
 import java.awt.event.*;
@@ -51,7 +51,7 @@
 
     public ItemStateChangeTest() {
 
-        if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
+        if (!Platform.isWindows()) {
             return;
         }
 
--- a/test/jdk/java/awt/Choice/PopupPosTest/PopupPosTest.html	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/Choice/PopupPosTest/PopupPosTest.html	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 <!--
- Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2004, 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
@@ -28,8 +28,8 @@
   @bug 5044150
   @summary Tests that pupup doesn't popdown if no space to display under 
   @author ssi@sparc.spb.su
-  @library ../../../../lib/testlibrary
-  @build jdk.testlibrary.OSInfo
+  @library /test/lib
+  @build jdk.test.lib.Platform
   @run applet PopupPosTest.html
   -->
 <head>
--- a/test/jdk/java/awt/Choice/PopupPosTest/PopupPosTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/Choice/PopupPosTest/PopupPosTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -26,8 +26,8 @@
   @bug 5044150
   @summary Tests that pupup doesn't popdown if no space to display under
   @author andrei.dmitriev area=awt.choice
-  @library ../../../../lib/testlibrary
-  @build jdk.testlibrary.OSInfo
+  @library /test/lib
+  @build jdk.test.lib.Platform
   @run applet PopupPosTest.html
 */
 
@@ -35,13 +35,13 @@
 import java.awt.*;
 import java.awt.event.*;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 public class PopupPosTest extends Applet
 {
     public void start ()
     {
-        if(OSInfo.getOSType().equals(OSInfo.OSType.MACOSX)) {
+        if (Platform.isOSX()) {
             // On OS X, popup isn't under the mouse
             return;
         }
--- a/test/jdk/java/awt/Choice/ResizeAutoClosesChoice/ResizeAutoClosesChoice.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/Choice/ResizeAutoClosesChoice/ResizeAutoClosesChoice.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,15 +26,15 @@
   @bug 6399679
   @summary Choice is not invalidated when the frame gets resized programmatically when the drop-down is visible
   @author andrei.dmitriev area=awt.choice
-  @library ../../../../lib/testlibrary
-  @build jdk.testlibrary.OSInfo
+  @library /test/lib
+  @build jdk.test.lib.Platform
   @run main ResizeAutoClosesChoice
 */
 
 import java.awt.*;
 import java.awt.event.*;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 public class ResizeAutoClosesChoice
 {
@@ -46,7 +46,7 @@
     static Button button = new Button("This button causes Frame to be resized on pack()");
     public static void main(String args[]) throws Exception
     {
-        if(OSInfo.getOSType().equals(OSInfo.OSType.MACOSX)) {
+        if (Platform.isOSX()) {
             System.out.println("Not for OS OX");
             return;
         }
--- a/test/jdk/java/awt/Cursor/MultiResolutionCursorTest/MultiResolutionCursorTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/Cursor/MultiResolutionCursorTest/MultiResolutionCursorTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -34,16 +34,17 @@
 import java.awt.image.BaseMultiResolutionImage;
 import java.awt.image.BufferedImage;
 import javax.swing.JApplet;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 /**
  * @test
  * @bug 8028212
  * @summary [macosx] Custom Cursor HiDPI support
  * @author Alexander Scherbatiy
- * @library ../../../../lib/testlibrary
+ * @library /test/lib
  * @modules java.desktop/sun.awt.image
- * @build jdk.testlibrary.OSInfo
+ * @build jdk.test.lib.Platform
  * @run applet/manual=yesno MultiResolutionCursorTest.html
  */
 public class MultiResolutionCursorTest extends JApplet {
@@ -58,7 +59,7 @@
         // etc.
         this.setLayout(new BorderLayout());
 
-        if (OSInfo.getOSType().equals(OSInfo.OSType.MACOSX)) {
+        if (Platform.isOSX()) {
             String[] instructions = {
                 "Verify that high resolution custom cursor is used"
                 + " on HiDPI displays.",
--- a/test/jdk/java/awt/Desktop/8064934/bug8064934.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/Desktop/8064934/bug8064934.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,16 +27,17 @@
  * @requires (os.family == "windows")
  * @summary Incorrect Exception message from java.awt.Desktop.open()
  * @author Dmitry Markov
- * @library ../../../../lib/testlibrary
+ * @library /test/lib
  * @modules java.desktop/sun.awt
- * @build jdk.testlibrary.OSInfo
+ * @build jdk.test.lib.Platform
  * @run main bug8064934
  */
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 import java.awt.*;
 import java.io.File;
 import java.io.IOException;
 import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 public class bug8064934 {
     private static final String NO_ASSOCIATION_ERROR_MESSAGE = "Error message: No application is associated with" +
@@ -44,7 +45,7 @@
 
     public static void main(String[] args) {
         // This test is intended only for Windows
-        if (AccessController.doPrivileged(OSInfo.getOSTypeAction()) != OSInfo.OSType.WINDOWS) {
+        if (!AccessController.doPrivileged((PrivilegedAction<Boolean>) Platform::isWindows)) {
             System.out.println("The test is for Windows platform only");
             return;
         }
--- a/test/jdk/java/awt/FileDialog/8003399/bug8003399.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/FileDialog/8003399/bug8003399.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,12 +25,13 @@
    @bug 8003399
    @summary JFileChooser gives wrong path to selected file when saving to Libraries folder on Windows 7
    @author Semyon Sadetsky
-   @library /lib/testlibrary
-   @build jdk.testlibrary.OSInfo
+   @library /test/lib
+   @build jdk.test.lib.OSVersion jdk.test.lib.Platform
    @run main bug8003399
   */
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
+import jdk.test.lib.OSVersion;
 
 import javax.swing.filechooser.FileSystemView;
 import java.io.File;
@@ -38,8 +39,8 @@
 public class bug8003399 {
 
     public static void main(String[] args) throws Exception {
-        if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS &&
-                OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_VISTA) > 0 ) {
+        if (Platform.isWindows() &&
+                OSVersion.current().compareTo(OSVersion.WINDOWS_VISTA) > 0 ) {
             FileSystemView fsv = FileSystemView.getFileSystemView();
             for (File file : fsv.getFiles(fsv.getHomeDirectory(), false)) {
                 if(file.isDirectory()) {
--- a/test/jdk/java/awt/FileDialog/8017487/bug8017487.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/FileDialog/8017487/bug8017487.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,13 +26,14 @@
    @summary filechooser in Windows-Libraries folder: columns are mixed up
    @author Semyon Sadetsky
    @modules java.desktop/sun.awt.shell
-   @library /lib/testlibrary
-   @build jdk.testlibrary.OSInfo
+   @library /test/lib
+   @build jdk.test.lib.OSVersion jdk.test.lib.Platform
    @run main bug8017487
   */
 
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
+import jdk.test.lib.OSVersion;
 
 import sun.awt.shell.ShellFolder;
 import sun.awt.shell.ShellFolderColumnInfo;
@@ -42,8 +43,8 @@
 public class bug8017487
 {
     public static void main(String[] p_args) throws Exception {
-        if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS &&
-                OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_VISTA) > 0 ) {
+        if (Platform.isWindows() &&
+                OSVersion.current().compareTo(OSVersion.WINDOWS_VISTA) > 0 ) {
             test();
             System.out.println("ok");
         }
--- a/test/jdk/java/awt/FileDialog/FileDialogForDirectories/FileDialogForDirectories.html	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/FileDialog/FileDialogForDirectories/FileDialogForDirectories.html	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 <!--
- Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2013, 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
@@ -28,9 +28,9 @@
   @summary We should support "apple.awt.fileDialogForDirectories" property.
   @author Sergey Bylokhov area=awt.filedialog
   @library ../../regtesthelpers
-  @library ../../../../lib/testlibrary
+  @library /test/lib
   @build Sysout
-  @build jdk.testlibrary.OSInfo
+  @build jdk.test.lib.Platform
   @run applet/manual=yesno FileDialogForDirectories.html
   -->
 <head>
--- a/test/jdk/java/awt/FileDialog/FileDialogForDirectories/FileDialogForDirectories.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/FileDialog/FileDialogForDirectories/FileDialogForDirectories.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,7 +22,7 @@
  */
 
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 import test.java.awt.regtesthelpers.Sysout;
 
 import java.applet.Applet;
@@ -39,7 +39,7 @@
 
     @Override
     public void init() {
-        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+        if (!Platform.isOSX()) {
             Sysout.createDialogWithInstructions(new String[]{
                     "Press PASS, this test is for MacOS X only."});
             return;
--- a/test/jdk/java/awt/FileDialog/FileDialogForPackages/FileDialogForPackages.html	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/FileDialog/FileDialogForPackages/FileDialogForPackages.html	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 <!--
- Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2013, 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
@@ -28,9 +28,9 @@
   @summary Support apple.awt.use-file-dialog-packages property.
   @author Petr Pchelko area=awt.filedialog
   @library ../../regtesthelpers
-  @library ../../../../lib/testlibrary
+  @library /test/lib
   @build Sysout
-  @build jdk.testlibrary.OSInfo
+  @build jdk.test.lib.Platform
   @run applet/manual=yesno FileDialogForPackages.html
   -->
 <head>
--- a/test/jdk/java/awt/FileDialog/FileDialogForPackages/FileDialogForPackages.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/FileDialog/FileDialogForPackages/FileDialogForPackages.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,7 +22,7 @@
  */
 
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 import test.java.awt.regtesthelpers.Sysout;
 
 import java.applet.Applet;
@@ -41,7 +41,7 @@
 
     @Override
     public void init() {
-        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+        if (!Platform.isOSX()) {
             Sysout.createDialogWithInstructions(new String[]{
                     "Press PASS, this test is for MacOS X only."});
             return;
--- a/test/jdk/java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,7 @@
 import javax.swing.JPopupMenu;
 import javax.swing.WindowConstants;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 /**
  * @test
@@ -47,8 +47,8 @@
  * @summary Focus request & mouse click being performed nearly synchronously
  *          shouldn't break the focus subsystem
  * @author  anton.tarasov@sun.com: area=awt-focus
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main MouseClickRequestFocusRaceTest
  */
 public class MouseClickRequestFocusRaceTest {
@@ -149,7 +149,7 @@
             throw new RuntimeException("The focus owner is not in the focused window!");
         }
 
-        if (!OSInfo.getOSType().equals(OSInfo.OSType.MACOSX)) {
+        if (!Platform.isOSX()) {
             // Try to close native focused window
             robot.keyPress(KeyEvent.VK_ALT);
             robot.keyPress(KeyEvent.VK_F4);
--- a/test/jdk/java/awt/Frame/MaximizedByPlatform/MaximizedByPlatform.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/Frame/MaximizedByPlatform/MaximizedByPlatform.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -27,12 +27,12 @@
  * @bug 8026143
  * @summary [macosx] Maximized state could be inconsistent between peer and frame
  * @author Petr Pchelko
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main MaximizedByPlatform
  */
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 import java.awt.*;
 
@@ -41,7 +41,7 @@
     private static Rectangle availableScreenBounds;
 
     public static void main(String[] args) {
-        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+        if (!Platform.isOSX()) {
             // Test only for macosx. Pass
             return;
         }
--- a/test/jdk/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeNextMnemonicKeyTypedTest.html	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeNextMnemonicKeyTypedTest.html	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 <!--
- Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,8 @@
   @bug        6346690
   @summary    Tests that key_typed is consumed after mnemonic key_pressed is handled for a menu item.
   @author     anton.tarasov@sun.com: area=awt-focus
-  @library   ../../../../lib/testlibrary
-  @build jdk.testlibrary.OSInfo
+  @library    /test/lib
+  @build      jdk.test.lib.Platform
   @run        applet ConsumeNextMnemonicKeyTypedTest.html
   -->
 <head>
--- a/test/jdk/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeNextMnemonicKeyTypedTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeNextMnemonicKeyTypedTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -26,11 +26,13 @@
   @bug       6346690
   @summary   Tests that key_typed is consumed after mnemonic key_pressed is handled for a menu item.
   @author    anton.tarasov@sun.com: area=awt-focus
-  @library   ../../../../lib/testlibrary
-  @build jdk.testlibrary.OSInfo
+  @library   /test/lib
+  @build     jdk.test.lib.Platform
   @run       applet ConsumeNextMnemonicKeyTypedTest.html
 */
 
+import jdk.test.lib.Platform;
+
 import java.awt.*;
 import javax.swing.*;
 import java.awt.event.*;
@@ -116,7 +118,7 @@
 
         robot.waitForIdle();
 
-        if (jdk.testlibrary.OSInfo.getOSType() == jdk.testlibrary.OSInfo.OSType.MACOSX) {
+        if (Platform.isOSX()) {
             robot.keyPress(KeyEvent.VK_CONTROL);
         }
         robot.keyPress(KeyEvent.VK_ALT);
@@ -124,7 +126,7 @@
         robot.delay(100);
         robot.keyRelease(KeyEvent.VK_F);
         robot.keyRelease(KeyEvent.VK_ALT);
-        if (jdk.testlibrary.OSInfo.getOSType() == jdk.testlibrary.OSInfo.OSType.MACOSX) {
+        if (Platform.isOSX()) {
             robot.keyRelease(KeyEvent.VK_CONTROL);
         }
 
--- a/test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.html	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.html	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 <!--
- Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -29,9 +29,9 @@
   @summary    Submenu should be shown by mnemonic key press.
   @author     anton.tarasov@...: area=awt.focus
   @library    ../../../regtesthelpers
-  @library    ../../../../../lib/testlibrary
+  @library    /test/lib
   @build      Util
-  @build      jdk.testlibrary.OSInfo
+  @build      jdk.test.lib.Platform
   @run        applet SubMenuShowTest.html
   -->
 <head>
--- a/test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -35,8 +35,9 @@
 import java.applet.Applet;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.lang.reflect.InvocationTargetException;
+
+import jdk.test.lib.Platform;
 import test.java.awt.regtesthelpers.Util;
-import jdk.testlibrary.OSInfo;
 
 public class SubMenuShowTest extends Applet {
     Robot robot;
@@ -85,7 +86,7 @@
 
         frame.setVisible(true);
 
-        boolean isMacOSX = (OSInfo.getOSType() == OSInfo.OSType.MACOSX);
+        boolean isMacOSX = Platform.isOSX();
         if (isMacOSX) {
             robot.keyPress(KeyEvent.VK_CONTROL);
         }
--- a/test/jdk/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.html	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.html	Fri Sep 07 15:46:39 2018 -0700
@@ -1,6 +1,6 @@
 <html>
 <!--
-  Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+  Copyright (c) 2013, 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
@@ -27,8 +27,8 @@
   @bug 6299858
   @summary PIT. Focused border not shown on List if selected item is removed, XToolkit
   @author Dmitry.Cherepanov@SUN.COM area=awt.list
-  @library ../../../../lib/testlibrary
-  @build jdk.testlibrary.OSInfo
+  @library /test/lib
+  @build jdk.test.lib.Platform
   @run applet FirstItemRemoveTest.html
   -->
 <head>
--- a/test/jdk/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -29,6 +29,8 @@
   @run applet FirstItemRemoveTest.html
 */
 
+import jdk.test.lib.Platform;
+
 import java.applet.Applet;
 import java.awt.*;
 import java.awt.event.*;
@@ -65,7 +67,7 @@
 
     private void test(){
 
-        if (jdk.testlibrary.OSInfo.getOSType() == jdk.testlibrary.OSInfo.OSType.MACOSX) {
+        if (Platform.isOSX()) {
             System.err.println("Skipped. This test is not for OS X.");
             return;
         }
--- a/test/jdk/java/awt/List/KeyEventsTest/KeyEventsTest.html	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/List/KeyEventsTest/KeyEventsTest.html	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 <!--
- Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,8 @@
   @bug 6190768 6190778
   @summary Tests that triggering events on AWT list by pressing CTRL + HOME, CTRL + END, PG-UP, PG-DOWN similar Motif behavior
   @author Dmitry.Cherepanov@SUN.COM area=awt.list
-  @library ../../../../lib/testlibrary
-  @build jdk.testlibrary.OSInfo
+  @library /test/lib
+  @build jdk.test.lib.Platform
   @run applet KeyEventsTest.html
   -->
 <head>
--- a/test/jdk/java/awt/List/KeyEventsTest/KeyEventsTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/List/KeyEventsTest/KeyEventsTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,8 @@
   @bug 6190768 6190778
   @summary Tests that triggering events on AWT list by pressing CTRL + HOME, CTRL + END, PG-UP, PG-DOWN similar Motif behavior
   @author Dmitry.Cherepanov@SUN.COM area=awt.list
-  @library ../../../../lib/testlibrary
-  @build jdk.testlibrary.OSInfo
+  @library /test/lib
+  @build jdk.test.lib.Platform
   @run applet KeyEventsTest.html
 */
 
@@ -43,7 +43,7 @@
 import java.util.Set;
 import java.lang.reflect.*;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 public class KeyEventsTest extends Applet implements ItemListener, FocusListener, KeyListener
 {
@@ -273,9 +273,9 @@
       throws InterruptedException, InvocationTargetException {
 
         boolean isWin = false;
-        if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
+        if (Platform.isWindows()) {
             isWin = true;
-        }else if(OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+        } else if (Platform.isOSX()) {
             System.out.println("Not for OS X");
             return;
         }
--- a/test/jdk/java/awt/Menu/OpensWithNoGrab/OpensWithNoGrab.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/Menu/OpensWithNoGrab/OpensWithNoGrab.java	Fri Sep 07 15:46:39 2018 -0700
@@ -28,9 +28,9 @@
   @summary REG: Menu does not disappear when clicked, keeping Choice's drop-down open, XToolkit
   @author andrei.dmitriev: area=awt.menu
   @library ../../regtesthelpers
-  @library ../../../../lib/testlibrary
+  @library /test/lib
   @modules java.desktop/sun.awt
-  @build jdk.testlibrary.OSInfo
+  @build jdk.test.lib.Platform
   @build Util
   @run main OpensWithNoGrab
 */
@@ -38,7 +38,7 @@
 import java.awt.*;
 import java.awt.event.*;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 import test.java.awt.regtesthelpers.Util;
 
 public class OpensWithNoGrab
@@ -46,8 +46,7 @@
     final static int delay = 50;
     private static void init()
     {
-        if (!(OSInfo.getOSType().equals(OSInfo.OSType.LINUX)
-                || OSInfo.getOSType().equals(OSInfo.OSType.SOLARIS))) {
+        if (!(Platform.isLinux() || Platform.isSolaris())) {
             System.out.println("This test is for XAWT/Motif only");
             OpensWithNoGrab.pass();
         }
--- a/test/jdk/java/awt/MenuBar/8007006/bug8007006.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/MenuBar/8007006/bug8007006.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -27,22 +27,22 @@
  * @bug 8007006
  * @summary [macosx] Closing subwindow loses main window menus.
  * @author Leonid Romanov
- * @library ../../../../lib/testlibrary
- * @build ExtendedRobot jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build ExtendedRobot jdk.test.lib.Platform
  * @run main bug8007006
  */
 
 import java.awt.*;
 import java.awt.event.*;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 public class bug8007006 {
     private static Frame frame1;
     private static Frame frame2;
 
     public static void main(String[] args) throws Exception {
-        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+        if (!Platform.isOSX()) {
             System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
             return;
         }
--- a/test/jdk/java/awt/MenuBar/MenuBarSetFont/MenuBarSetFont.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/MenuBar/MenuBarSetFont/MenuBarSetFont.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,7 @@
 import java.awt.event.ActionListener;
 import java.awt.event.InputEvent;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 /**
  * @test
@@ -41,8 +41,8 @@
  * @bug 6263470
  * @summary Tries to change font of MenuBar. Test passes if the font has changed
  * fails otherwise.
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @author Vyacheslav.Baranov: area=menu
  * @run main MenuBarSetFont
  */
@@ -68,7 +68,7 @@
 
     public static void main(final String[] args) throws Exception {
 
-        if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+        if (Platform.isOSX()) {
             System.err.println("This test is not for OS X. Menu.setFont() is not supported on OS X.");
             return;
         }
--- a/test/jdk/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,12 +27,12 @@
   @bug 6315717
   @summary verifies that modifiers are correct for extra buttons
   @author Andrei Dmitriev : area=awt.mouse
-  @library ../../../../lib/testlibrary
-  @build jdk.testlibrary.OSInfo
+  @library /test/lib
+  @build jdk.test.lib.Platform
   @run main MouseModifiersUnitTest_Extra
  */
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 import java.awt.*;
 import java.awt.event.*;
@@ -66,14 +66,14 @@
     static int [] modifiersExStandardCTRL;
     static int [] modifiersExStandardALT;
 
-    private final static String SHIFT_MODIFIER = OSInfo.getOSType().equals(OSInfo.OSType.MACOSX) ?
+    private final static String SHIFT_MODIFIER = Platform.isOSX() ?
                                                 "\u21e7" : "Shift";
 
-    private final static String ALT_MODIFIER = OSInfo.getOSType().equals(OSInfo.OSType.MACOSX) ?
+    private final static String ALT_MODIFIER = Platform.isOSX() ?
                                                 "\u2325" : "Alt";
 
 
-    private final static String CTRL_MODIFIER = OSInfo.getOSType().equals(OSInfo.OSType.MACOSX) ?
+    private final static String CTRL_MODIFIER = Platform.isOSX() ?
                                                 "\u2303" : "Ctrl";
 
 
--- a/test/jdk/java/awt/Multiscreen/MultiScreenInsetsTest/MultiScreenInsetsTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/Multiscreen/MultiScreenInsetsTest/MultiScreenInsetsTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -28,8 +28,8 @@
   @summary Frame is not created on the specified GraphicsDevice with two
 monitors
   @author Oleg Pekhovskiy
-  @library ../../../../lib/testlibrary
-  @build jdk.testlibrary.OSInfo
+  @library /test/lib
+  @build jdk.test.lib.Platform
   @run main MultiScreenInsetsTest
  */
 
@@ -40,14 +40,14 @@
 import java.awt.Insets;
 import java.awt.Rectangle;
 import java.awt.Toolkit;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 public class MultiScreenInsetsTest {
     private static final int SIZE = 100;
 
     public static void main(String[] args) throws InterruptedException {
-        OSInfo.OSType type = OSInfo.getOSType();
-        if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) {
+        if (!Platform.isLinux() && !Platform.isSolaris()) {
             System.out.println("This test is for Solaris and Linux only..." +
                                "skipping!");
             return;
--- a/test/jdk/java/awt/Robot/RobotWheelTest/RobotWheelTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/Robot/RobotWheelTest/RobotWheelTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -24,7 +24,8 @@
 import java.awt.Frame;
 import java.awt.Rectangle;
 import java.awt.Robot;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 /*
  * @test 1.2 98/08/05
@@ -32,8 +33,8 @@
  * @bug 4373478 8079255
  * @summary Test mouse wheel functionality of Robot
  * @author bchristi: area=Robot
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main RobotWheelTest
  */
 public class RobotWheelTest {
@@ -45,7 +46,7 @@
 
         Frame frame = null;
         try {
-            int wheelSign = OSInfo.getOSType().equals(OSInfo.OSType.MACOSX) ? -1 : 1;
+            int wheelSign = Platform.isOSX() ? -1 : 1;
 
             frame = new Frame();
             frame.setSize(200, 200);
--- a/test/jdk/java/awt/TextArea/ScrollbarIntersectionTest/ScrollbarIntersectionTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/TextArea/ScrollbarIntersectionTest/ScrollbarIntersectionTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,15 +28,15 @@
   @summary Tests that mouse click at the are of intersection of two
    scrollbars for text area doesn't trigger any scrolling
   @author artem.ananiev@sun.com: area=awt.text
-  @library ../../../../lib/testlibrary
-  @build jdk.testlibrary.OSInfo
+  @library /test/lib
+  @build jdk.test.lib.Platform
   @run main ScrollbarIntersectionTest
 */
 
 import java.awt.*;
 import java.awt.event.*;
-import jdk.testlibrary.OSInfo;
 
+import jdk.test.lib.Platform;
 
 public class ScrollbarIntersectionTest
 {
@@ -134,7 +134,7 @@
 
     public static void main( String args[] ) throws InterruptedException
     {
-        if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+        if (Platform.isOSX()) {
             // On OS X, this area is commandeered by the system,
             // and frame would be wildly resized
             System.out.println("Not for OS X");
--- a/test/jdk/java/awt/Toolkit/ToolkitPropertyTest/bug7129133.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/Toolkit/ToolkitPropertyTest/bug7129133.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -26,16 +26,18 @@
  * @bug 7129133
  * @summary [macosx] Accelerators are displayed as Meta instead of the Command symbol
  * @author leonid.romanov@oracle.com
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main bug7129133
  */
 
+import jdk.test.lib.Platform;
+
 import java.awt.*;
 
 public class bug7129133 {
     public static void main(String[] args) throws Exception {
-        if (jdk.testlibrary.OSInfo.getOSType() != jdk.testlibrary.OSInfo.OSType.MACOSX) {
+        if (!Platform.isOSX()) {
             System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
             return;
         }
--- a/test/jdk/java/awt/TrayIcon/8072769/bug8072769.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/TrayIcon/8072769/bug8072769.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,12 +27,12 @@
    @requires (os.family == "windows")
    @summary System tray icon title freezes java
    @author Semyon Sadetsky
-   @library ../../../../lib/testlibrary
-   @build jdk.testlibrary.OSInfo
+   @library /test/lib
+   @build jdk.test.lib.Platform
    @run main bug8072769
   */
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 import javax.swing.*;
 import java.awt.*;
@@ -41,7 +41,7 @@
 public class bug8072769 {
 
     public static void main(String[] args) throws Exception {
-        if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
+        if (Platform.isWindows()) {
             if (SystemTray.isSupported()) {
                 test();
             } else {
--- a/test/jdk/java/awt/TrayIcon/DblClickActionEventTest/DblClickActionEventTest.html	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/TrayIcon/DblClickActionEventTest/DblClickActionEventTest.html	Fri Sep 07 15:46:39 2018 -0700
@@ -1,7 +1,7 @@
 <html>
 
 <!--
- Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2014, 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
@@ -28,9 +28,9 @@
   @bug 6284070
   @summary Tests that ActionEvent is generated when a tray icon is double-clicked
   @library ../../regtesthelpers
-  @library ../../../../lib/testlibrary
+  @library /test/lib
   @build Sysout
-  @build jdk.testlibrary.OSInfo
+  @build jdk.test.lib.Platform
   @author artem.ananiev: area=awt.tray
   @run applet/manual=yesno DblClickActionEventTest.html
   -->
--- a/test/jdk/java/awt/TrayIcon/DblClickActionEventTest/DblClickActionEventTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/TrayIcon/DblClickActionEventTest/DblClickActionEventTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -37,7 +37,7 @@
 import java.awt.event.*;
 import java.awt.image.*;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 import test.java.awt.regtesthelpers.Sysout;
 
 public class DblClickActionEventTest extends Applet {
@@ -50,7 +50,7 @@
         traySupported = SystemTray.isSupported();
         if (traySupported) {
             String clickInstruction;
-            if (OSInfo.getOSType().equals(OSInfo.OSType.MACOSX)) {
+            if (Platform.isOSX()) {
                 clickInstruction = "right";
             } else {
                 clickInstruction = "left";
--- a/test/jdk/java/awt/TrayIcon/DisposeInActionEventTest/DisposeInActionEventTest.html	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/TrayIcon/DisposeInActionEventTest/DisposeInActionEventTest.html	Fri Sep 07 15:46:39 2018 -0700
@@ -1,7 +1,7 @@
 <html>
 
 <!--
- Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2014, 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
@@ -29,9 +29,9 @@
   @summary Tests that no NPE is thrown when the tray icon is disposed from the
   handler of action event caused by clicking on this icon.
   @library ../../regtesthelpers
-  @library ../../../../lib/testlibrary
+  @library /test/lib
   @build Sysout
-  @build jdk.testlibrary.OSInfo
+  @build jdk.test.lib.Platform
   @author artem.ananiev: area=awt.tray
   @run applet/manual=yesno DisposeInActionEventTest.html
   -->
--- a/test/jdk/java/awt/TrayIcon/DisposeInActionEventTest/DisposeInActionEventTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/TrayIcon/DisposeInActionEventTest/DisposeInActionEventTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -38,7 +38,7 @@
 import java.awt.*;
 import java.awt.image.*;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 import test.java.awt.regtesthelpers.Sysout;
 
 public class DisposeInActionEventTest extends Applet {
@@ -59,7 +59,7 @@
             };
         } else {
             String clickInstruction;
-            if (OSInfo.getOSType().equals(OSInfo.OSType.MACOSX)) {
+            if (Platform.isOSX()) {
                 clickInstruction = "right";
             } else {
                 clickInstruction = "left";
--- a/test/jdk/java/awt/datatransfer/HTMLDataFlavors/HTMLDataFlavorTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/datatransfer/HTMLDataFlavors/HTMLDataFlavorTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -28,13 +28,15 @@
  * @summary WIN: Provide a way to format HTML on drop
  * @author Denis Fokin: area=datatransfer
  * @requires (os.family == "windows")
- * @library ../../../../lib/testlibrary
+ * @library /test/lib
  * @build HtmlTransferable PutAllHtmlFlavorsOnClipboard
  * @build PutOnlyAllHtmlFlavorOnClipboard PutSelectionAndFragmentHtmlFlavorsOnClipboard
- * @build jdk.testlibrary.OSInfo
+ * @build jdk.test.lib.Platform
  * @run main HTMLDataFlavorTest
  */
 
+import jdk.test.lib.Platform;
+
 import java.awt.*;
 import java.awt.datatransfer.*;
 import java.io.*;
@@ -47,7 +49,7 @@
 
     public static void main(String[] args) throws IOException, UnsupportedFlavorException {
 
-        if (jdk.testlibrary.OSInfo.getOSType() != jdk.testlibrary.OSInfo.OSType.WINDOWS) {
+        if (!Platform.isWindows()) {
             System.err.println("This test is for MS Windows only. Considered passed.");
             return;
         }
--- a/test/jdk/java/awt/datatransfer/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.html	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/datatransfer/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.html	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 <!--
- Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2013, 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
@@ -30,10 +30,10 @@
   @author mikhail.cherkasov@oracle.com
   @library ../../regtesthelpers
   @library ../../regtesthelpers/process
-  @library ../../../../lib/testlibrary
+  @library /test/lib
   @build Util
   @build ProcessResults ProcessCommunicator
-  @build jdk.testlibrary.OSInfo
+  @build jdk.test.lib.Platform
   @run applet/othervm MissedHtmlAndRtfBug.html
 -->
 
--- a/test/jdk/java/awt/datatransfer/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/datatransfer/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -28,10 +28,10 @@
 import java.io.File;
 import java.util.ArrayList;
 
+import jdk.test.lib.Platform;
 import test.java.awt.regtesthelpers.process.ProcessCommunicator;
 import test.java.awt.regtesthelpers.process.ProcessResults;
 import test.java.awt.regtesthelpers.Util;
-import jdk.testlibrary.OSInfo;
 
 import static java.lang.Thread.sleep;
 
@@ -42,8 +42,7 @@
     }//End  init()
 
     public void start() {
-        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX
-                && OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
+        if (!Platform.isOSX() && !Platform.isWindows()) {
             System.out.println("This test is for Windows and Mac only. Passed.");
             return;
         }
--- a/test/jdk/java/awt/dnd/ImageTransferTest/ImageTransferTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/dnd/ImageTransferTest/ImageTransferTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -27,16 +27,16 @@
  * @bug 4397404 4720930 8197926
  * @summary tests that images of all supported native image formats are
  * transferred properly
- * @library ../../../../lib/testlibrary
+ * @library /test/lib
  * @library ../../regtesthelpers/process/
- * @build jdk.testlibrary.OSInfo ProcessResults ProcessCommunicator
+ * @build jdk.test.lib.Platform ProcessResults ProcessCommunicator
  * @author gas@sparc.spb.su area=Clipboard
  * @run main/timeout=240 ImageTransferTest
  */
 
+import jdk.test.lib.Platform;
 import test.java.awt.regtesthelpers.process.ProcessCommunicator;
 import test.java.awt.regtesthelpers.process.ProcessResults;
-import jdk.testlibrary.OSInfo;
 
 import java.awt.*;
 import java.awt.datatransfer.DataFlavor;
@@ -174,8 +174,7 @@
                 (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
         java.util.List<String> ln =
                 sfm.getNativesForFlavor(DataFlavor.imageFlavor);
-        if (OSInfo.OSType.WINDOWS.equals(OSInfo.getOSType()) &&
-            !ln.contains("METAFILEPICT"))
+        if (Platform.isWindows() &&  !ln.contains("METAFILEPICT"))
         {
             // for test failing on JDK without this fix
             ln.add("METAFILEPICT");
--- a/test/jdk/java/awt/event/KeyEvent/8020209/bug8020209.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/event/KeyEvent/8020209/bug8020209.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -27,15 +27,15 @@
  * @bug 8020209
  * @summary [macosx] Mac OS X key event confusion for "COMMAND PLUS"
  * @author leonid.romanov@oracle.com
- * @library ../../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main bug8020209
  */
 
 import java.awt.*;
 import java.awt.event.*;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 public class bug8020209 {
     static volatile int listenerCallCounter = 0;
@@ -47,7 +47,7 @@
     };
 
     public static void main(String[] args) throws Exception {
-        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+        if (!Platform.isOSX()) {
             System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
             return;
         }
--- a/test/jdk/java/awt/event/KeyEvent/DeadKey/DeadKeyMacOSXInputText.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/event/KeyEvent/DeadKey/DeadKeyMacOSXInputText.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -27,8 +27,8 @@
  * @bug 7199180
  * @summary [macosx] Dead keys handling for input methods
  * @author alexandr.scherbatiy area=awt.event
- * @library ../../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main DeadKeyMacOSXInputText
  */
 
@@ -37,7 +37,7 @@
 import java.awt.event.KeyEvent;
 import javax.swing.JTextField;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 public class DeadKeyMacOSXInputText {
 
@@ -45,7 +45,7 @@
 
     public static void main(String[] args) throws Exception {
 
-        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+        if (!Platform.isOSX()) {
             return;
         }
 
--- a/test/jdk/java/awt/event/KeyEvent/DeadKey/deadKeyMacOSX.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/event/KeyEvent/DeadKey/deadKeyMacOSX.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -27,8 +27,8 @@
  * @bug 7196547
  * @summary Dead Key implementation for KeyEvent on Mac OS X
  * @author alexandr.scherbatiy area=awt.event
- * @library ../../../../../lib/testlibrary
- * @build  jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build  jdk.test.lib.Platform
  * @run main deadKeyMacOSX
  */
 
@@ -36,7 +36,7 @@
 import java.awt.event.*;
 import java.awt.event.KeyEvent;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 public class deadKeyMacOSX {
 
@@ -44,7 +44,7 @@
 
     public static void main(String[] args) throws Exception {
 
-        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+        if (!Platform.isOSX()) {
             return;
         }
 
--- a/test/jdk/java/awt/event/KeyEvent/SwallowKeyEvents/SwallowKeyEvents.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/event/KeyEvent/SwallowKeyEvents/SwallowKeyEvents.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -28,14 +28,14 @@
   @summary   Tests that key events with modifiers are not swallowed.
   @author    anton.tarasov: area=awt.focus
   @library   ../../../regtesthelpers
-  @library ../../../../../lib/testlibrary
+  @library /test/lib
   @modules java.desktop/sun.awt
-  @build jdk.testlibrary.OSInfo
+  @build jdk.test.lib.Platform
   @build     Util
   @run       main SwallowKeyEvents
 */
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 import java.awt.AWTException;
 import java.awt.Frame;
 import java.awt.Robot;
@@ -54,7 +54,7 @@
     static Robot r;
 
     public static void main(String[] args) {
-        if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
+        if (Platform.isWindows()) {
             System.out.println("Skipped. Test not for MS Windows.");
             return;
         }
--- a/test/jdk/java/awt/image/MultiResolutionImage/NSImageToMultiResolutionImageTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/image/MultiResolutionImage/NSImageToMultiResolutionImageTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -24,7 +24,8 @@
 import java.awt.Image;
 import java.awt.Toolkit;
 import java.awt.image.MultiResolutionImage;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 /*
  * @test
@@ -32,8 +33,8 @@
  * @summary [macosx] Get MultiResolution image from native system
  * @author Alexander Scherbatiy
  * @modules java.desktop/sun.awt.image
- * @library /lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main NSImageToMultiResolutionImageTest
  */
 
@@ -41,7 +42,7 @@
 
     public static void main(String[] args) throws Exception {
 
-        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+        if (!Platform.isOSX()) {
             return;
         }
 
--- a/test/jdk/java/awt/image/multiresolution/MultiDisplayTest/MultiDisplayTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/awt/image/multiresolution/MultiDisplayTest/MultiDisplayTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,8 @@
   @summary Check if multiresolution image behaves properly
            on HiDPI + non-HiDPI display pair.
   @author a.stepanov
-  @library /lib/testlibrary
-  @build jdk.testlibrary.OSInfo
+  @library /test/lib
+  @build jdk.test.lib.Platform
   @run applet/manual=yesno MultiDisplayTest.html
 */
 
@@ -38,8 +38,8 @@
 import java.awt.*;
 import java.awt.event.*;
 import java.awt.image.*;
-import jdk.testlibrary.OSInfo;
 
+import jdk.test.lib.Platform;
 
 public class MultiDisplayTest extends Applet {
 
@@ -50,9 +50,7 @@
         generateImage(1, Color.BLACK), generateImage(2, Color.BLUE)});
 
     private static boolean checkOS() {
-        OSInfo.OSType os = OSInfo.getOSType();
-        return (os.equals(OSInfo.OSType.WINDOWS) ||
-            os.equals(OSInfo.OSType.MACOSX));
+        return Platform.isWindows() || Platform.isOSX();
     }
 
     public void init() { this.setLayout(new BorderLayout()); }
--- a/test/jdk/java/io/BufferedInputStream/LargeCopyWithMark.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/io/BufferedInputStream/LargeCopyWithMark.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -25,8 +25,7 @@
  * @bug 7129312
  * @summary BufferedInputStream calculates negative array size with large
  *          streams and mark
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main/othervm LargeCopyWithMark
  */
 
@@ -34,7 +33,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 
 
 public class LargeCopyWithMark {
--- a/test/jdk/java/lang/Class/forName/modules/TestDriver.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/Class/forName/modules/TestDriver.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@
 
 import jdk.test.lib.util.FileUtils;
 import jdk.test.lib.compiler.CompilerUtils;
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -41,12 +41,12 @@
  * @test
  * @bug 8087335
  * @summary Tests for Class.forName(Module,String)
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
  * @build jdk.test.lib.Platform
  *        jdk.test.lib.util.FileUtils
  *        jdk.test.lib.compiler.CompilerUtils
- *        jdk.testlibrary.ProcessTools
+ *        jdk.test.lib.process.ProcessTools
  *        TestDriver TestMain TestLayer
  * @run testng TestDriver
  */
--- a/test/jdk/java/lang/Class/getResource/ResourcesTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/Class/getResource/ResourcesTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
-import static jdk.testlibrary.ProcessTools.executeTestJava;
+import static jdk.test.lib.process.ProcessTools.executeTestJava;
 import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
@@ -33,9 +33,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
- * @build ResourcesTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @build ResourcesTest jdk.test.lib.compiler.CompilerUtils
  * @run testng ResourcesTest
  * @summary Driver for basic test of Class getResource and getResourceAsStream
  */
--- a/test/jdk/java/lang/ClassLoader/EndorsedDirs.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/ClassLoader/EndorsedDirs.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -24,11 +24,11 @@
 /*
  * @test
  * @bug 8060206 8067366
- * @library /lib/testlibrary
+ * @library /test/lib
  * @summary Endorsed standards and override mechanism is removed
  */
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 import java.util.stream.Stream;
 
--- a/test/jdk/java/lang/ClassLoader/ExtDirs.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/ClassLoader/ExtDirs.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -24,11 +24,11 @@
 /*
  * @test
  * @bug 8060206 8067366
- * @library /lib/testlibrary
+ * @library /test/lib
  * @summary Extension mechanism is removed
  */
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 import java.lang.Integer;
 import java.util.stream.Stream;
--- a/test/jdk/java/lang/ClassLoader/GetDotResource.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/ClassLoader/GetDotResource.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -26,8 +26,7 @@
  * @bug 4273031
  * @summary ClassLoader.getResouce() should be able to
  *          find resources with leading "." in their names
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main GetDotResource
  */
 
@@ -37,7 +36,7 @@
 import java.util.jar.JarEntry;
 import java.util.jar.JarOutputStream;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 public class GetDotResource {
 
--- a/test/jdk/java/lang/ClassLoader/GetSystemPackage.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/ClassLoader/GetSystemPackage.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -24,8 +24,8 @@
 /*
  * @test
  * @bug 8060130
- * @library /lib/testlibrary
- * @build package2.Class2 GetSystemPackage jdk.testlibrary.*
+ * @library /test/lib
+ * @build package2.Class2 GetSystemPackage
  * @summary Test if getSystemPackage() return consistent values for cases
  *          where a manifest is provided or not and ensure only jars on
  *          bootclasspath gets resolved via Package.getSystemPackage
@@ -41,7 +41,7 @@
 import java.util.jar.JarEntry;
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 public class GetSystemPackage {
 
--- a/test/jdk/java/lang/ClassLoader/getResource/GetResource.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/ClassLoader/getResource/GetResource.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -25,7 +25,8 @@
  * @test
  * @bug 6760902
  * @library /lib/testlibrary
- * @build jdk.testlibrary.ProcessTools
+ * @library /test/lib
+ * @build jdk.test.lib.process.ProcessTools
  * @run testng GetResource
  * @summary Empty path on bootclasspath is not default to current working
  *          directory for both class lookup and resource lookup whereas
@@ -45,7 +46,7 @@
 import java.util.stream.Stream;
 
 import jdk.testlibrary.JDKToolFinder;
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/lang/ClassLoader/getResource/automaticmodules/Driver.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/ClassLoader/getResource/automaticmodules/Driver.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -23,8 +23,8 @@
 
 /**
  * @test
- * @library /lib/testlibrary
- * @build Driver Main JarUtils jdk.testlibrary.ProcessTools
+ * @library /lib/testlibrary /test/lib
+ * @build Driver Main JarUtils
  * @run main Driver
  * @summary Test ClassLoader.getResourceXXX to locate resources in an automatic
  *          module
@@ -38,7 +38,7 @@
 import java.util.jar.Attributes;
 import java.util.jar.Manifest;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 /**
  * The driver creates a JAR file containing p/Foo.class, p/foo.properties,
--- a/test/jdk/java/lang/ClassLoader/getResource/modules/ResourcesTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/ClassLoader/getResource/modules/ResourcesTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
-import static jdk.testlibrary.ProcessTools.executeTestJava;
+import static jdk.test.lib.process.ProcessTools.executeTestJava;
 import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
@@ -34,9 +34,9 @@
 /**
  * @test
  * @bug 8087335
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
- * @build ResourcesTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @build ResourcesTest jdk.test.lib.compiler.CompilerUtils
  * @run testng ResourcesTest
  * @summary Driver for basic test of ClassLoader getResource and getResourceAsStream
  */
--- a/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -27,6 +27,7 @@
  * @summary Different types of ClassLoader running with(out) SecurityManager and
  *          (in)valid security policy file.
  * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.base/jdk.internal.module
  * @build JarUtils
  * @build TestClassLoader TestClient
@@ -49,7 +50,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import jdk.internal.module.ModuleInfoWriter;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 public class ClassLoaderTest {
 
--- a/test/jdk/java/lang/ModuleTests/access/AccessTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/ModuleTests/access/AccessTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
 import java.util.List;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import static jdk.testlibrary.ProcessTools.executeTestJava;
+import static jdk.test.lib.process.ProcessTools.executeTestJava;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -35,9 +35,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
- * @build AccessTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @build AccessTest jdk.test.lib.compiler.CompilerUtils
  * @run testng AccessTest
  * @summary Driver for test that checks access to access to types in
  *          exported and non-exported packages.
--- a/test/jdk/java/lang/Runtime/shutdown/ShutdownInterruptedMain.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/Runtime/shutdown/ShutdownInterruptedMain.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,16 +24,15 @@
 /*
  * @test
  * @bug 8154017
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @summary Shutdown hooks are racing against shutdown sequence,
             if System.exit()-calling thread is interrupted
  * @run main ShutdownInterruptedMain exec
  */
 
-import jdk.testlibrary.OutputAnalyzer;
-import static jdk.testlibrary.ProcessTools.createJavaProcessBuilder;
-import static jdk.testlibrary.ProcessTools.executeProcess;
+import jdk.test.lib.process.OutputAnalyzer;
+import static jdk.test.lib.process.ProcessTools.createJavaProcessBuilder;
+import static jdk.test.lib.process.ProcessTools.executeProcess;
 
 public class ShutdownInterruptedMain {
 
--- a/test/jdk/java/lang/StackWalker/CallerFromMain.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/StackWalker/CallerFromMain.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,14 +24,13 @@
 /*
  * @test
  * @bug 8140450
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @summary Test if the getCallerClass method returns empty optional
  * @run main CallerFromMain exec
  */
 
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
 
 public class CallerFromMain {
 
--- a/test/jdk/java/lang/System/LoggerFinder/modules/Base.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/Base.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -35,7 +35,7 @@
 import jdk.testlibrary.JDKToolFinder;
 import jdk.test.lib.compiler.CompilerUtils;
 
-import static jdk.testlibrary.ProcessTools.executeCommand;
+import static jdk.test.lib.process.ProcessTools.executeCommand;
 
 /*
  * Base class for tests.
--- a/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForImageTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForImageTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -23,19 +23,6 @@
  * questions.
  */
 
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Stream;
-
-import jdk.testlibrary.JDKToolFinder;
-
-import static jdk.testlibrary.ProcessTools.executeCommand;
-
 /*
  * @test
  * @modules jdk.compiler
--- a/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForJDKTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForJDKTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -23,19 +23,6 @@
  * questions.
  */
 
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Stream;
-
-import jdk.testlibrary.JDKToolFinder;
-
-import static jdk.testlibrary.ProcessTools.executeCommand;
-
 /*
  * @test
  * @modules java.logging
--- a/test/jdk/java/lang/System/LoggerFinder/modules/LoggerInImageTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/LoggerInImageTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -23,19 +23,6 @@
  * questions.
  */
 
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Stream;
-
-import jdk.testlibrary.JDKToolFinder;
-
-import static jdk.testlibrary.ProcessTools.executeCommand;
-
 /*
  * @test
  * @modules jdk.compiler
--- a/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForImageTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForImageTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -24,17 +24,6 @@
  */
 
 import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Stream;
-
-import jdk.testlibrary.JDKToolFinder;
-
-import static jdk.testlibrary.ProcessTools.executeCommand;
 
 /*
  * @test
--- a/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForJDKTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForJDKTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -24,17 +24,6 @@
  */
 
 import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Stream;
-
-import jdk.testlibrary.JDKToolFinder;
-
-import static jdk.testlibrary.ProcessTools.executeCommand;
 
 /*
  * @test
--- a/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForImageTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForImageTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -24,17 +24,6 @@
  */
 
 import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Stream;
-
-import jdk.testlibrary.JDKToolFinder;
-
-import static jdk.testlibrary.ProcessTools.executeCommand;
 
 /*
  * @test
--- a/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForJDKTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForJDKTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -24,17 +24,6 @@
  */
 
 import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Stream;
-
-import jdk.testlibrary.JDKToolFinder;
-
-import static jdk.testlibrary.ProcessTools.executeCommand;
 
 /*
  * @test
--- a/test/jdk/java/lang/System/OsVersionTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/System/OsVersionTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -22,16 +22,15 @@
  */
 
 import jdk.test.lib.Platform;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 /*
  * @test
  * @bug 8132374
  * @summary Check that the value of the os.version property is equal
  *          to the value of the corresponding OS provided tools.
- * @library /lib/testlibrary /test/lib
- * @build jdk.test.lib.Platform
+ * @library /test/lib
  * @run main OsVersionTest
  * @author Volker Simonis
  */
--- a/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThread.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThread.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,6 +1,6 @@
 /*
  * Copyright 2014 Goldman Sachs.
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -24,11 +24,11 @@
 /* @test
  * @bug 7142035
  * @summary Assert in java.lang.instrument agents during shutdown when classloading occurs after shutdown
- * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @modules java.instrument
  *          java.management
- * @build jdk.testlibrary.* DummyAgent DummyClass TestDaemonThreadLauncher TestDaemonThread
+ * @build DummyAgent DummyClass TestDaemonThreadLauncher TestDaemonThread
  * @run shell ../MakeJAR3.sh DummyAgent
  * @run main/timeout=240 TestDaemonThreadLauncher
  *
--- a/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,6 +1,6 @@
 /*
  * Copyright 2014 Goldman Sachs.
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -23,8 +23,8 @@
  */
 
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 public class TestDaemonThreadLauncher {
     public static void main(String args[]) throws Exception {
--- a/test/jdk/java/lang/instrument/PremainClass/NoPremainAgentTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/instrument/PremainClass/NoPremainAgentTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -21,8 +21,8 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Utils;
 
 /*
@@ -30,6 +30,7 @@
  * @bug 6289149
  * @summary test when the agent's class is missing the premain() function.
  * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.management
  *          java.instrument
  * @run build jdk.testlibrary.* DummyMain
--- a/test/jdk/java/lang/instrument/PremainClass/PremainClassTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/instrument/PremainClass/PremainClassTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -21,8 +21,8 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Utils;
 
 /*
@@ -30,6 +30,7 @@
  * @bug 5055293
  * @summary Test non ascii characters in the Premain-Class attribute.
  * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.management
  * @run build jdk.testlibrary.* DummyMain
  * @run main PremainClassTest
--- a/test/jdk/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -21,8 +21,8 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Utils;
 
 /*
@@ -30,6 +30,7 @@
  * @bug 6289149
  * @summary test when the agent's class has a zero arg premain() function.
  * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.management
  *          java.instrument
  * @run build jdk.testlibrary.* DummyMain
--- a/test/jdk/java/lang/instrument/executableJAR/ExecJarWithAgent.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/instrument/executableJAR/ExecJarWithAgent.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -24,6 +24,7 @@
 /**
  * @test
  * @library /lib/testlibrary
+ * @library /test/lib
  * @build ExecJarWithAgent Main Agent AgentHelper JarUtils jdk.testlibrary.*
  * @run testng ExecJarWithAgent
  * @summary Test starting agents in executable JAR files
@@ -38,8 +39,8 @@
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
 
 @Test
 public class ExecJarWithAgent {
--- a/test/jdk/java/lang/instrument/modules/AppendToClassPathModuleTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/instrument/modules/AppendToClassPathModuleTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,14 +24,18 @@
 /**
  * @test
  * @bug 8169909
- * @library src /lib/testlibrary
+ * @library src /test/lib
  * @build test/*
  * @run shell AppendToClassPathModuleTest.sh
  * @run main AppendToClassPathModuleTest
  */
 
+import jdk.test.lib.JDKToolFinder;
+
 import java.util.Map;
-import static jdk.testlibrary.ProcessTools.*;
+import java.util.stream.Stream;
+
+import static jdk.test.lib.process.ProcessTools.*;
 
 /**
  * Launch a modular test with no class path and no CLASSPATH set.
@@ -41,14 +45,17 @@
 public class AppendToClassPathModuleTest {
     public static void main(String... args) throws Throwable {
         String modulepath = System.getProperty("test.module.path");
-        ProcessBuilder pb =
-            createJavaProcessBuilder("-javaagent:Agent.jar",
-                                     "--module-path", modulepath,
-                                     "-m", "test/jdk.test.Main");
 
-        // remove CLASSPATH environment variable
+        // can't use ProcessTools.createJavaProcessBuilder as it always adds -cp
+        ProcessBuilder pb = new ProcessBuilder(
+                JDKToolFinder.getTestJDKTool("java"),
+                "-javaagent:Agent.jar",
+                "--module-path", modulepath,
+                "-m", "test/jdk.test.Main");
+
         Map<String,String> env = pb.environment();
-        String value = env.remove("CLASSPATH");
+        // remove CLASSPATH environment variable
+        env.remove("CLASSPATH");
 
         int exitCode = executeCommand(pb).getExitValue();
         if (exitCode != 0) {
--- a/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -45,7 +45,7 @@
 import java.util.concurrent.Phaser;
 import javax.management.*;
 import javax.management.openmbean.CompositeData;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.JDKToolFinder;
 import jdk.testlibrary.Utils;
 
--- a/test/jdk/java/lang/management/MemoryMXBean/RunUtil.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/management/MemoryMXBean/RunUtil.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -28,9 +28,9 @@
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Utils;
-import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.JDKToolFinder;
 
 public class RunUtil {
--- a/test/jdk/java/lang/reflect/Proxy/ProxyClassAccessTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/reflect/Proxy/ProxyClassAccessTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 import java.util.List;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import static jdk.testlibrary.ProcessTools.executeTestJava;
+import static jdk.test.lib.process.ProcessTools.executeTestJava;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -38,9 +38,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
- * @build ProxyClassAccessTest q.NP jdk.testlibrary.*
+ * @build ProxyClassAccessTest q.NP
  *        jdk.test.lib.compiler.CompilerUtils
  * @run testng ProxyClassAccessTest
  * @summary Driver for testing proxy class doesn't have access to
--- a/test/jdk/java/lang/reflect/Proxy/ProxyLayerTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/reflect/Proxy/ProxyLayerTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 import java.util.Arrays;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import static jdk.testlibrary.ProcessTools.executeTestJava;
+import static jdk.test.lib.process.ProcessTools.executeTestJava;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -38,9 +38,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
- * @build ProxyTest jdk.testlibrary.ProcessTools
+ * @build ProxyTest jdk.test.lib.process.ProcessTools
  *        jdk.test.lib.compiler.CompilerUtils
  * @run testng ProxyLayerTest
  * @summary Test proxies to implement interfaces in a layer
--- a/test/jdk/java/lang/reflect/Proxy/ProxyTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/lang/reflect/Proxy/ProxyTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
 import java.util.List;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import static jdk.testlibrary.ProcessTools.executeTestJava;
+import static jdk.test.lib.process.ProcessTools.executeTestJava;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -35,9 +35,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
- * @build ProxyTest q.U jdk.testlibrary.*
+ * @build ProxyTest q.U
  *        jdk.test.lib.compiler.CompilerUtils
  * @run testng ProxyTest
  * @summary Driver for testing proxies accessing interfaces in named modules
--- a/test/jdk/java/net/Inet6Address/serialize/Inet6AddressSerializationTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/net/Inet6Address/serialize/Inet6AddressSerializationTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -192,6 +192,7 @@
                     System.err.println("Testing with " + iadr);
                     System.err.println(" scoped iface: "
                             + i6adr.getScopedInterface());
+                    System.err.println(" hostname: " + i6adr.getHostName());
                     testInet6AddressSerialization(i6adr, null);
                 }
             }
--- a/test/jdk/java/nio/channels/Selector/RegisterDuringSelect.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/nio/channels/Selector/RegisterDuringSelect.java	Fri Sep 07 15:46:39 2018 -0700
@@ -23,94 +23,92 @@
 
 /* @test
  * @bug 8201315
+ * @build SelectorUtils
+ * @run main RegisterDuringSelect
  * @summary Test that channels can be registered, interest ops can changed,
  *          and keys cancelled while a selection operation is in progress.
  */
 
 import java.io.IOException;
-import java.nio.channels.ClosedSelectorException;
 import java.nio.channels.Pipe;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.Phaser;
 
 public class RegisterDuringSelect {
+    interface TestOperation {
+        void accept(Thread t, Selector sel, Pipe.SourceChannel sc) throws Exception;
+    }
+    static class Test {
+        final Selector sel;
+        final Pipe p;
+        final Pipe.SourceChannel sc;
 
-    static Callable<Void> selectLoop(Selector sel, Phaser barrier) {
-        return new Callable<Void>() {
-            @Override
-            public Void call() throws IOException {
-                for (;;) {
+        Test() throws Exception {
+            sel = Selector.open();
+            p = Pipe.open();
+            sc = p.source();
+            sc.configureBlocking(false);
+        }
+        void test(TestOperation op) throws Exception {
+            try {
+                Thread t = new Thread(() -> {
                     try {
                         sel.select();
-                    } catch (ClosedSelectorException ignore) {
-                        return null;
+                    } catch (IOException ex) {
+                        throw new RuntimeException(ex);
                     }
-                    if (sel.isOpen()) {
-                        barrier.arriveAndAwaitAdvance();
-                        System.out.println("selectLoop advanced ...");
-                    } else {
-                        // closed
-                        return null;
-                    }
-                }
+                });
+                t.start();
+                op.accept(t, sel, sc);
+            } finally {
+                sel.close();
+                p.source().close();
+                p.sink().close();
             }
-        };
+        }
     }
     /**
      * Invoke register, interestOps, and cancel concurrently with a thread
      * doing a selection operation
      */
     public static void main(String args[]) throws Exception {
-        Future<Void> result;
-
-        ExecutorService pool = Executors.newFixedThreadPool(1);
-        try (Selector sel = Selector.open()) {
-            Phaser barrier = new Phaser(2);
-
-            // submit task to do the select loop
-            result = pool.submit(selectLoop(sel, barrier));
-
-            Pipe p = Pipe.open();
+        new Test().test((t, sel, sc) -> {
+            System.out.println("register ...");
+            // spin until make sure select is invoked
+            SelectorUtils.spinUntilLocked(t, sel);
+            SelectionKey key = sc.register(sel, SelectionKey.OP_READ);
             try {
-                Pipe.SourceChannel sc = p.source();
-                sc.configureBlocking(false);
-
-                System.out.println("register ...");
-                SelectionKey key = sc.register(sel, SelectionKey.OP_READ);
                 if (!sel.keys().contains(key))
                     throw new RuntimeException("key not in key set");
-                sel.wakeup();
-                barrier.arriveAndAwaitAdvance();
-
-                System.out.println("interestOps ...");
-                key.interestOps(0);
-                sel.wakeup();
-                barrier.arriveAndAwaitAdvance();
-
-                System.out.println("cancel ...");
-                key.cancel();
+            } finally {
                 sel.wakeup();
-                barrier.arriveAndAwaitAdvance();
-                if (sel.keys().contains(key))
-                    throw new RuntimeException("key not removed from key set");
-
-            } finally {
-                p.source().close();
-                p.sink().close();
+                t.join();
             }
-
-        } finally {
-            pool.shutdown();
-        }
-
-        // ensure selectLoop completes without exception
-        result.get();
-
+        });
+        new Test().test((t, sel, sc) -> {
+            System.out.println("interestOps ...");
+            SelectionKey key = sc.register(sel, SelectionKey.OP_READ);
+            // spin until make sure select is invoked
+            SelectorUtils.spinUntilLocked(t, sel);
+            key.interestOps(0);
+            try {
+                if (key.interestOps() != 0)
+                    throw new RuntimeException("interested ops not cleared");
+            } finally {
+                sel.wakeup();
+                t.join();
+            }
+        });
+        new Test().test((t, sel, sc) -> {
+            System.out.println("cancel ...");
+            SelectionKey key = sc.register(sel, SelectionKey.OP_READ);
+            // spin until make sure select is invoked
+            SelectorUtils.spinUntilLocked(t, sel);
+            key.cancel();
+            sel.wakeup();
+            t.join();
+            if (sel.keys().contains(key))
+                throw new RuntimeException("key not removed from key set");
+        });
     }
 }
-
--- a/test/jdk/java/nio/channels/Selector/SelectAndClose.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/nio/channels/Selector/SelectAndClose.java	Fri Sep 07 15:46:39 2018 -0700
@@ -23,33 +23,18 @@
 
 /* @test
  * @bug 5004077 8203765
+ * @build SelectorUtils
+ * @run main SelectAndClose
  * @summary Check blocking of select and close
  */
 
 import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.lang.management.MonitorInfo;
-import java.lang.management.ThreadInfo;
 import java.nio.channels.Selector;
 
 public class SelectAndClose {
     static Selector selector;
     static volatile boolean awakened = false;
 
-    private static boolean mightHoldLock(Thread t, Object lock) {
-        long tid = t.getId();
-        int hash = System.identityHashCode(lock);
-        ThreadInfo ti = ManagementFactory.getThreadMXBean().
-            getThreadInfo(new long[]{ tid} , true, false, 100)[0];
-        if (ti != null) {
-            for (MonitorInfo mi : ti.getLockedMonitors()) {
-                if (mi.getIdentityHashCode() == hash)
-                    return true;
-            }
-        }
-        return false;
-    }
-
     public static void main(String[] args) throws Exception {
         selector = Selector.open();
 
@@ -66,12 +51,8 @@
             });
         selectThread.start();
 
-        // Spin until the monitor of the selected-key set is likely held
-        // as selected operations are specified to synchronize on the
-        // selected-key set.
-        while (!mightHoldLock(selectThread, selector.selectedKeys())) {
-            Thread.sleep(50);
-        }
+        // spin until make sure select is invoked
+        SelectorUtils.spinUntilLocked(selectThread, selector);
 
         // Close the selector.
         selector.close();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/nio/channels/Selector/SelectorUtils.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.MonitorInfo;
+import java.lang.management.ThreadInfo;
+import java.nio.channels.Selector;
+
+public class SelectorUtils {
+
+    /**
+     * tell if the monitor of an Object is held by a Thread.
+     * @param t    the Thread to hold the monitor of the selected-key set
+     * @param lock the Object
+     * @return
+     */
+    public static boolean mightHoldLock(Thread t, Object lock) {
+        long tid = t.getId();
+        int hash = System.identityHashCode(lock);
+        ThreadInfo ti = ManagementFactory.getThreadMXBean().
+                getThreadInfo(new long[]{ tid} , true, false, 100)[0];
+        if (ti != null) {
+            for (MonitorInfo mi : ti.getLockedMonitors()) {
+                if (mi.getIdentityHashCode() == hash)
+                    return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Spin until the monitor of the selected-key set is likely held
+     * as selected operations are specified to synchronize on the
+     * selected-key set.
+     * @param t   the Thread to hold the monitor of the selected-key set
+     * @param sel the Selector
+     * @throws Exception
+     */
+    public static void spinUntilLocked(Thread t, Selector sel) throws Exception {
+        while (!mightHoldLock(t, sel.selectedKeys())) {
+            Thread.sleep(50);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/nio/channels/etc/PrintSupportedOptions.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @requires (os.family == "linux" | os.family == "mac" | os.family == "windows")
+ * @bug 8209152
+ * @run main PrintSupportedOptions
+ * @run main/othervm -Djava.net.preferIPv4Stack=true PrintSupportedOptions
+ */
+
+import java.io.IOException;
+import java.net.SocketOption;
+import java.nio.channels.*;
+
+public class PrintSupportedOptions {
+
+    @FunctionalInterface
+    interface NetworkChannelSupplier<T extends NetworkChannel> {
+        T get() throws IOException;
+    }
+
+    public static void main(String[] args) throws IOException {
+        test(() -> SocketChannel.open());
+        test(() -> ServerSocketChannel.open());
+        test(() -> DatagramChannel.open());
+
+        test(() -> AsynchronousSocketChannel.open());
+        test(() -> AsynchronousServerSocketChannel.open());
+    }
+
+    @SuppressWarnings("unchecked")
+    static <T extends NetworkChannel>
+    void test(NetworkChannelSupplier<T> supplier) throws IOException {
+        try (T ch = supplier.get()) {
+            System.out.println(ch);
+            for (SocketOption<?> opt : ch.supportedOptions()) {
+                Object value = ch.getOption(opt);
+                System.out.format(" %s -> %s%n", opt.name(), value);
+                if (value != null) {
+                    ch.setOption((SocketOption<Object>) opt, value);
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/nio/charset/CharsetDecoder/NaNinCtor.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+/* @test
+ * @bug 8210285
+ * @summary NaN arguments to the constructor should be rejected
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+
+public class NaNinCtor {
+
+    public static void main(String[] args) throws Throwable {
+        Charset ascii = Charset.forName("US-ASCII");
+
+        // sanity check
+        new MyDecoder(ascii, 0.5f, 1.5f);
+
+        // various combinations of invalid arguments
+        test(() -> new MyDecoder(ascii, 0.0f, 1.0f));
+        test(() -> new MyDecoder(ascii, 1.0f, 0.0f));
+        test(() -> new MyDecoder(ascii, -1.0f, 1.0f));
+        test(() -> new MyDecoder(ascii, 1.0f, -1.0f));
+        test(() -> new MyDecoder(ascii, Float.NaN, 1.0f));
+        test(() -> new MyDecoder(ascii, 1.0f, Float.NaN));
+        test(() -> new MyDecoder(ascii, 1.5f, 0.5f));
+    }
+
+    static void test(Runnable r) {
+        try {
+            r.run();
+            throw new RuntimeException("IllegalArgumentException not thrown");
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    static class MyDecoder extends CharsetDecoder {
+        public MyDecoder(Charset cs, float avg, float max) {
+            super(cs, avg, max);
+        }
+        protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) {
+            return null;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/nio/charset/CharsetEncoder/NaNinCtor.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+/* @test
+ * @bug 8210285
+ * @summary NaN arguments to the constructor should be rejected
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+
+public class NaNinCtor {
+
+    public static void main(String[] args) throws Throwable {
+        Charset ascii = Charset.forName("US-ASCII");
+
+        // sanity check
+        new MyEncoder(ascii, 0.5f, 1.5f);
+
+        // various combinations of invalid arguments
+        test(() -> new MyEncoder(ascii, 0.0f, 1.0f));
+        test(() -> new MyEncoder(ascii, 1.0f, 0.0f));
+        test(() -> new MyEncoder(ascii, -1.0f, 1.0f));
+        test(() -> new MyEncoder(ascii, 1.0f, -1.0f));
+        test(() -> new MyEncoder(ascii, Float.NaN, 1.0f));
+        test(() -> new MyEncoder(ascii, 1.0f, Float.NaN));
+        test(() -> new MyEncoder(ascii, 1.5f, 0.5f));
+    }
+
+    static void test(Runnable r) {
+        try {
+            r.run();
+            throw new RuntimeException("IllegalArgumentException not thrown");
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    static class MyEncoder extends CharsetEncoder {
+        public MyEncoder(Charset cs, float avg, float max) {
+            super(cs, avg, max);
+        }
+        protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) {
+            return null;
+        }
+    }
+}
--- a/test/jdk/java/nio/file/spi/SetDefaultProvider.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/nio/file/spi/SetDefaultProvider.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,8 @@
 /**
  * @test
  * @modules jdk.jartool
- * @library /lib/testlibrary
- * @build SetDefaultProvider TestProvider m/* jdk.testlibrary.ProcessTools
+ * @library /test/lib
+ * @build SetDefaultProvider TestProvider m/* jdk.test.lib.process.ProcessTools
  * @run testng/othervm SetDefaultProvider
  * @summary Runs tests with -Djava.nio.file.spi.DefaultFileSystemProvider set on
  *          the command line to override the default file system provider
@@ -38,7 +38,7 @@
 import java.nio.file.Paths;
 import java.util.spi.ToolProvider;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/test/jdk/java/rmi/module/ModuleTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/rmi/module/ModuleTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,13 +24,13 @@
 /**
  * @test
  * @library /lib/testlibrary /test/lib
- * @build jdk.testlibrary.ProcessTools
+ * @build jdk.test.lib.process.ProcessTools
  *        ModuleTest jdk.test.lib.compiler.CompilerUtils JarUtils
  * @run testng ModuleTest
  * @summary Basic tests for using rmi in module world
  */
 
-import static jdk.testlibrary.ProcessTools.executeTestJava;
+import static jdk.test.lib.process.ProcessTools.executeTestJava;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 
--- a/test/jdk/java/security/AccessController/DoPrivAccompliceTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/security/AccessController/DoPrivAccompliceTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -23,7 +23,6 @@
  * questions.
  */
 
-import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.util.JarUtils;
 
--- a/test/jdk/java/security/KeyStore/PKCS12/KeytoolReaderP12Test.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/security/KeyStore/PKCS12/KeytoolReaderP12Test.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -26,7 +26,7 @@
 import java.nio.file.Files;
 import java.nio.file.StandardOpenOption;
 import java.util.Base64;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import static java.lang.System.out;
 import java.nio.file.Paths;
 import java.util.List;
@@ -37,6 +37,7 @@
  * @summary Test for PKCS12 keystore list , export commands. Refer README for
  * keystore files information
  * @library /lib/testlibrary ../
+ * @library /test/lib
  * @run main KeytoolReaderP12Test
  */
 public class KeytoolReaderP12Test {
--- a/test/jdk/java/security/KeyStore/PKCS12/KeytoolWriteP12Test.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/security/KeyStore/PKCS12/KeytoolWriteP12Test.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -24,7 +24,7 @@
  */
 
 import java.io.File;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import static java.lang.System.out;
 
 /**
@@ -32,6 +32,7 @@
  * @bug 8048830
  * @summary Tests for creating pkcs12 keystore with various algorithms
  * @library /lib/testlibrary ../
+ * @library /test/lib
  * @run main KeytoolWriteP12Test
  */
 public class KeytoolWriteP12Test {
--- a/test/jdk/java/security/KeyStore/PKCS12/MetadataEmptyTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/security/KeyStore/PKCS12/MetadataEmptyTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -40,6 +40,7 @@
  * @bug 8048830
  * @summary Entry's attribute set should be empty
  * @library /lib/testlibrary ../
+ * @library /test/lib
  * @run main MetadataEmptyTest
  */
 public class MetadataEmptyTest {
--- a/test/jdk/java/security/KeyStore/PKCS12/MetadataStoreLoadTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/security/KeyStore/PKCS12/MetadataStoreLoadTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -44,6 +44,7 @@
  * @bug 8048830
  * @summary Test store metadata attributes to PKCS12 keystore.
  * @library /lib/testlibrary ../
+ * @library /test/lib
  * @run main MetadataStoreLoadTest
  */
 public class MetadataStoreLoadTest {
--- a/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertAPITest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertAPITest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -43,6 +43,7 @@
  * trusted certificate Check import errors (must be not errors) & check keystore
  * content after import
  * @library /lib/testlibrary ../
+ * @library /test/lib
  * @run main StoreTrustedCertAPITest
  */
 public class StoreTrustedCertAPITest {
--- a/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertKeytool.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertKeytool.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -30,7 +30,7 @@
 import java.security.NoSuchAlgorithmException;
 import java.security.cert.CertificateException;
 import java.security.cert.X509Certificate;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import static java.lang.System.out;
 
 /**
@@ -39,6 +39,7 @@
  * @summary Tests keytool command imports certificate , list keystore, print
  * certificate and import password help.
  * @library /lib/testlibrary ../
+ * @library /test/lib
  * @run main StoreTrustedCertKeytool
  */
 public class StoreTrustedCertKeytool {
--- a/test/jdk/java/security/KeyStore/PKCS12/Utils.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/security/KeyStore/PKCS12/Utils.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -32,8 +32,8 @@
 import java.security.cert.CertificateException;
 import java.util.Arrays;
 import java.util.List;
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.testlibrary.JDKToolFinder;
 import static java.lang.System.out;
 import java.util.ArrayList;
--- a/test/jdk/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,14 +26,14 @@
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.security.AccessController;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8050402
  * @summary Check policy is extensible with user defined permissions
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @build jdk.test.lib.util.JarUtils
  * @compile TVJar/TVPermission.java
  * @run main ExtensiblePolicyWithJarTest
--- a/test/jdk/java/security/Policy/SignedJar/SignedJarTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/security/Policy/SignedJar/SignedJarTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,13 +28,13 @@
 import java.security.AccessController;
 import java.security.Permission;
 import java.security.PrivilegedAction;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 /**
  * @test
  * @bug 8048360
  * @summary test policy entry with signedBy alias
- * @library /lib/testlibrary
+ * @library /test/lib
  * @run main/othervm SignedJarTest
  */
 public class SignedJarTest {
--- a/test/jdk/java/text/Format/NumberFormat/CurrencyFormat.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/text/Format/NumberFormat/CurrencyFormat.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4290801 4942982 5102005 8008577 8021121
+ * @bug 4290801 4942982 5102005 8008577 8021121 8210153
  * @summary Basic tests for currency formatting.
  * @modules jdk.localedata
  * @run main/othervm -Djava.locale.providers=JRE,SPI CurrencyFormat
--- a/test/jdk/java/text/Format/NumberFormat/CurrencySymbols.properties	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/text/Format/NumberFormat/CurrencySymbols.properties	Fri Sep 07 15:46:39 2018 -0700
@@ -66,7 +66,7 @@
 es_PY=G
 es_SV=C
 es_UY=NU$
-es_VE=Bs.F.
+es_VE=Bs.S.
 et=\u00A4
 et_EE=\u20AC
 fi=\u00A4
--- a/test/jdk/java/util/Arrays/TimSortStackSize2.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/util/Arrays/TimSortStackSize2.java	Fri Sep 07 15:46:39 2018 -0700
@@ -26,10 +26,9 @@
  * @bug 8072909
  * @summary Test TimSort stack size on big arrays
  * @key intermittent
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules java.management
  *          java.base/jdk.internal
- * @build jdk.testlibrary.*
  * @build TimSortStackSize2
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -41,9 +40,8 @@
 import java.util.List;
 import java.util.function.Consumer;
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.Utils;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import sun.hotspot.WhiteBox;
 
 public class TimSortStackSize2 {
--- a/test/jdk/java/util/Calendar/CalendarTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/util/Calendar/CalendarTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -23,9 +23,10 @@
 
 /**
  * @test
- * @bug 4064654 4374886 4984320 4984574 4944795
+ * @bug 4064654 4374886 4984320 4984574 4944795 8210142
  * @summary test for Calendar
  * @library /java/text/testlib
+ * @modules java.base/java.util:+open
  * @run main CalendarTest
  * @key randomness
  */
@@ -37,6 +38,7 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutput;
 import java.io.ObjectOutputStream;
+import java.lang.reflect.Field;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
@@ -1176,6 +1178,29 @@
             TimeZone.setDefault(savedTimeZone);
         }
     }
+
+    public void TestClonedSharedZones() throws NoSuchFieldException, IllegalAccessException {
+        Field zone = Calendar.class.getDeclaredField("zone");
+        zone.setAccessible(true);
+        Field sharedZone = Calendar.class.getDeclaredField("sharedZone");
+        sharedZone.setAccessible(true);
+
+        // create a new calendar with any date, and clone it.
+        Calendar c1 = new GregorianCalendar();
+        Calendar c2 = (Calendar) c1.clone();
+
+        // c1 should have a shared zone
+        if (!sharedZone.getBoolean(c1)) {
+            errln("Failed : c1.sharedZone == false");
+        } else {
+            // c2 should have a shared zone too
+            if (!sharedZone.getBoolean(c2)) {
+                errln("Failed : c2.sharedZone == false");
+            } else if (zone.get(c1) != zone.get(c2)) {
+                errln("Failed : c1.zone != c2.zone");
+            }
+        }
+    }
 }
 
 //eof
--- a/test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java	Fri Sep 07 15:46:39 2018 -0700
@@ -23,15 +23,15 @@
 
 /*
  * @test
- * @library /lib/testlibrary
+ * @library /test/lib
  * @bug 8189134
  * @summary Tests the system properties
  * @modules jdk.localedata
- * @build DefaultLocaleTest jdk.testlibrary.*
+ * @build DefaultLocaleTest
  * @run testng/othervm SystemPropertyTests
  */
 
-import static jdk.testlibrary.ProcessTools.executeTestJava;
+import static jdk.test.lib.process.ProcessTools.executeTestJava;
 import static org.testng.Assert.assertTrue;
 
 import java.util.Locale;
--- a/test/jdk/java/util/ResourceBundle/modules/cache/CacheTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/util/ResourceBundle/modules/cache/CacheTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,19 +24,17 @@
 /**
  * @test
  * @bug 8170772
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
- * @build CacheTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @build CacheTest jdk.test.lib.compiler.CompilerUtils
  * @run testng CacheTest
  */
 
-import java.io.File;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
-import jdk.testlibrary.OutputAnalyzer;
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
--- a/test/jdk/java/util/ResourceBundle/modules/casesensitive/CaseInsensitiveNameClash.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/util/ResourceBundle/modules/casesensitive/CaseInsensitiveNameClash.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -24,17 +24,17 @@
 /*
  * @test
  * @bug 8177980
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
  * @build jdk.test.lib.compiler.CompilerUtils
- *        jdk.testlibrary.ProcessTools CaseInsensitiveNameClash
+ *        jdk.test.lib.process.ProcessTools CaseInsensitiveNameClash
  * @run testng CaseInsensitiveNameClash
  */
 
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
--- a/test/jdk/java/util/ResourceBundle/modules/security/TestPermission.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/util/ResourceBundle/modules/security/TestPermission.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
 import java.util.List;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import static jdk.testlibrary.ProcessTools.executeTestJava;
+import static jdk.test.lib.process.ProcessTools.executeTestJava;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -35,9 +35,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
- * @build TestPermission jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @build TestPermission jdk.test.lib.compiler.CompilerUtils
  * @run testng TestPermission
  * @summary Driver for testing ResourceBundle::getBundle(String, Module)
  */
--- a/test/jdk/java/util/logging/TestLoggerWeakRefLeak.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/util/logging/TestLoggerWeakRefLeak.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -26,7 +26,7 @@
 import java.io.InputStreamReader;
 
 import static jdk.testlibrary.Asserts.assertGreaterThan;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 import com.sun.tools.attach.AttachNotSupportedException;
 import com.sun.tools.attach.VirtualMachine;
@@ -38,9 +38,10 @@
  * @bug 6942989
  * @summary Check for WeakReference leak in Logger and anonymous Logger objects
  * @library /lib/testlibrary
+ * @library /test/lib
  * @modules jdk.attach/sun.tools.attach
  *          java.logging
- * @build jdk.testlibrary.ProcessTools
+ * @build jdk.test.lib.process.ProcessTools
  * @run main/othervm -Djdk.attach.allowAttachSelf TestLoggerWeakRefLeak Logger
  * @run main/othervm -Djdk.attach.allowAttachSelf TestLoggerWeakRefLeak AnonymousLogger
  */
--- a/test/jdk/java/util/logging/modules/GetResourceBundleTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/util/logging/modules/GetResourceBundleTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,17 +29,17 @@
 import org.testng.annotations.Test;
 
 import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 import jdk.test.lib.compiler.CompilerUtils;
 import static org.testng.Assert.*;
 
 /**
  * @test
  * @bug 8129126 8136802 8137316 8137317 8136804 8139350
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
  *          java.logging
- * @build GetResourceBundleTest jdk.testlibrary.ProcessTools
+ * @build GetResourceBundleTest jdk.test.lib.process.ProcessTools
  *        jdk.test.lib.compiler.CompilerUtils
  * @run testng GetResourceBundleTest
  * @summary Tests Logger.getLogger + logger.getResourceBundle in an named/unnamed module,
--- a/test/jdk/java/util/zip/EntryCount64k.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/java/util/zip/EntryCount64k.java	Fri Sep 07 15:46:39 2018 -0700
@@ -24,7 +24,7 @@
 /**
  * @test
  * @summary Test java.util.zip behavior with ~64k entries
- * @library /lib/testlibrary
+ * @library /test/lib
  * @run main/othervm EntryCount64k
  * @run main/othervm -Djdk.util.zip.inhibitZip64=true EntryCount64k
  * @run main/othervm -Djdk.util.zip.inhibitZip64=false EntryCount64k
@@ -44,8 +44,8 @@
 import java.util.zip.ZipInputStream;
 import java.util.zip.ZipOutputStream;
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 public class EntryCount64k {
     public static class Main {
--- a/test/jdk/javax/management/mxbean/MXBeanWeirdParamTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/management/mxbean/MXBeanWeirdParamTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
  * @author Olivier Lagneau
  * @modules java.management.rmi
  * @library /lib/testlibrary
+ * @library /test/lib
  * @compile Basic.java
  * @run main/othervm/timeout=300 -DDEBUG_STANDARD MXBeanWeirdParamTest
  */
@@ -58,7 +59,7 @@
 import javax.management.openmbean.TabularDataSupport;
 import javax.management.openmbean.TabularType;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.JDKToolFinder;
 
 public class MXBeanWeirdParamTest {
--- a/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
  * @test
  * @bug 8159377
  * @library /lib/testlibrary
+ * @library /test/lib
  * @summary Tests ObjectFilter on default agent
  * @author Harsha Wardhana B
  * @modules java.management
@@ -54,7 +55,7 @@
 import javax.management.remote.JMXConnectorFactory;
 import javax.management.remote.JMXServiceURL;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Utils;
 
 public class DefaultAgentFilterTest {
--- a/test/jdk/javax/management/security/AuthorizationTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/management/security/AuthorizationTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
  * @author Olivier Lagneau
  * @modules java.management.rmi
  * @library /lib/testlibrary
+ * @library /test/lib
  * @compile Simple.java
  * @run main/othervm/timeout=300 -DDEBUG_STANDARD -Dusername=username1 -Dpassword=password1 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials
  * @run main/othervm/timeout=300 -DDEBUG_STANDARD -Dusername=username2 -Dpassword=password2 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials -expectedCreateException -expectedSetException -expectedInvokeException
@@ -64,7 +65,7 @@
 import javax.management.Attribute ;
 import javax.management.ObjectName ;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.JDKToolFinder;
 
 public class AuthorizationTest {
--- a/test/jdk/javax/management/security/SecurityTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/management/security/SecurityTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
  * @author Olivier Lagneau
  * @modules java.management.rmi
  * @library /lib/testlibrary
+ * @library /test/lib
  * @compile MBS_Light.java ServerDelegate.java TestSampleLoginModule.java
  * @run main/othervm/timeout=300 -DDEBUG_STANDARD -Dusername=SQE_username -Dpassword=SQE_password SecurityTest -server -mapType x.password.file -client -mapType credentials
  * @run main/othervm/timeout=300 -DDEBUG_STANDARD -Dusername=UNKNOWN_username -Dpassword=SQE_password SecurityTest -server -mapType x.password.file -client -mapType credentials -expectedThrowable java.lang.SecurityException
@@ -80,7 +81,7 @@
 
 import java.security.Security;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.JDKToolFinder;
 
 public class SecurityTest {
--- a/test/jdk/javax/net/ssl/templates/SSLEngineTemplate.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/net/ssl/templates/SSLEngineTemplate.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
  * @summary SSLEngine has not yet caused Solaris kernel to panic
  * @run main/othervm SSLEngineTemplate
  */
-
 /**
  * A SSLEngine usage example which simplifies the presentation
  * by removing the I/O and multi-threading concerns.
@@ -66,7 +65,6 @@
  *      unwrap()        ...             ChangeCipherSpec
  *      unwrap()        ...             Finished
  */
-
 import javax.net.ssl.*;
 import javax.net.ssl.SSLEngineResult.*;
 import java.io.*;
@@ -115,7 +113,7 @@
     private static final String pathToStores = "../etc";
     private static final String keyStoreFile = "keystore";
     private static final String trustStoreFile = "truststore";
-    private static final String passwd = "passphrase";
+    private static final char[] passphrase = "passphrase".toCharArray();
 
     private static final String keyFilename =
             System.getProperty("test.src", ".") + "/" + pathToStores +
@@ -146,8 +144,6 @@
         KeyStore ks = KeyStore.getInstance("JKS");
         KeyStore ts = KeyStore.getInstance("JKS");
 
-        char[] passphrase = "passphrase".toCharArray();
-
         ks.load(new FileInputStream(keyFilename), passphrase);
         ts.load(new FileInputStream(trustFilename), passphrase);
 
@@ -187,8 +183,11 @@
         createSSLEngines();
         createBuffers();
 
-        SSLEngineResult clientResult;   // results from client's last operation
-        SSLEngineResult serverResult;   // results from server's last operation
+        // results from client's last operation
+        SSLEngineResult clientResult;
+
+        // results from server's last operation
+        SSLEngineResult serverResult;
 
         /*
          * Examining the SSLEngineResults could be much more involved,
@@ -198,31 +197,62 @@
          * to write to the output pipe, we could reallocate a larger
          * pipe, but instead we wait for the peer to drain it.
          */
-        while (!isEngineClosed(clientEngine) ||
-                !isEngineClosed(serverEngine)) {
+        Exception clientException = null;
+        Exception serverException = null;
+
+        while (!isEngineClosed(clientEngine)
+                || !isEngineClosed(serverEngine)) {
 
             log("================");
 
-            clientResult = clientEngine.wrap(clientOut, cTOs);
-            log("client wrap: ", clientResult);
-            runDelegatedTasks(clientResult, clientEngine);
+            try {
+                clientResult = clientEngine.wrap(clientOut, cTOs);
+                log("client wrap: ", clientResult);
+            } catch (Exception e) {
+                clientException = e;
+                System.out.println("Client wrap() threw: " + e.getMessage());
+            }
+            logEngineStatus(clientEngine);
+            runDelegatedTasks(clientEngine);
 
-            serverResult = serverEngine.wrap(serverOut, sTOc);
-            log("server wrap: ", serverResult);
-            runDelegatedTasks(serverResult, serverEngine);
+            log("----");
+
+            try {
+                serverResult = serverEngine.wrap(serverOut, sTOc);
+                log("server wrap: ", serverResult);
+            } catch (Exception e) {
+                serverException = e;
+                System.out.println("Server wrap() threw: " + e.getMessage());
+            }
+            logEngineStatus(serverEngine);
+            runDelegatedTasks(serverEngine);
 
             cTOs.flip();
             sTOc.flip();
 
+            log("--------");
+
+            try {
+                clientResult = clientEngine.unwrap(sTOc, clientIn);
+                log("client unwrap: ", clientResult);
+            } catch (Exception e) {
+                clientException = e;
+                System.out.println("Client unwrap() threw: " + e.getMessage());
+            }
+            logEngineStatus(clientEngine);
+            runDelegatedTasks(clientEngine);
+
             log("----");
 
-            clientResult = clientEngine.unwrap(sTOc, clientIn);
-            log("client unwrap: ", clientResult);
-            runDelegatedTasks(clientResult, clientEngine);
-
-            serverResult = serverEngine.unwrap(cTOs, serverIn);
-            log("server unwrap: ", serverResult);
-            runDelegatedTasks(serverResult, serverEngine);
+            try {
+                serverResult = serverEngine.unwrap(cTOs, serverIn);
+                log("server unwrap: ", serverResult);
+            } catch (Exception e) {
+                serverException = e;
+                System.out.println("Server unwrap() threw: " + e.getMessage());
+            }
+            logEngineStatus(serverEngine);
+            runDelegatedTasks(serverEngine);
 
             cTOs.compact();
             sTOc.compact();
@@ -244,13 +274,22 @@
 
                 log("\tClosing clientEngine's *OUTBOUND*...");
                 clientEngine.closeOutbound();
+                logEngineStatus(clientEngine);
+
                 dataDone = true;
                 log("\tClosing serverEngine's *OUTBOUND*...");
                 serverEngine.closeOutbound();
+                logEngineStatus(serverEngine);
             }
         }
     }
 
+    private static void logEngineStatus(SSLEngine engine) {
+        log("\tCurrent HS State  " + engine.getHandshakeStatus().toString());
+        log("\tisInboundDone():  " + engine.isInboundDone());
+        log("\tisOutboundDone(): " + engine.isOutboundDone());
+    }
+
     /*
      * Using the SSLContext created during object creation,
      * create/configure the SSLEngines we'll use for this test.
@@ -264,11 +303,19 @@
         serverEngine.setUseClientMode(false);
         serverEngine.setNeedClientAuth(true);
 
+        // Get/set parameters if needed
+        SSLParameters paramsServer = serverEngine.getSSLParameters();
+        serverEngine.setSSLParameters(paramsServer);
+
         /*
          * Similar to above, but using client mode instead.
          */
         clientEngine = sslc.createSSLEngine("client", 80);
         clientEngine.setUseClientMode(true);
+
+        // Get/set parameters if needed
+        SSLParameters paramsClient = clientEngine.getSSLParameters();
+        clientEngine.setSSLParameters(paramsClient);
     }
 
     /*
@@ -307,13 +354,12 @@
      * If the result indicates that we have outstanding tasks to do,
      * go ahead and run them in this thread.
      */
-    private static void runDelegatedTasks(SSLEngineResult result,
-            SSLEngine engine) throws Exception {
+    private static void runDelegatedTasks(SSLEngine engine) throws Exception {
 
-        if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+        if (engine.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
             Runnable runnable;
             while ((runnable = engine.getDelegatedTask()) != null) {
-                log("\trunning delegated task...");
+                log("    running delegated task...");
                 runnable.run();
             }
             HandshakeStatus hsStatus = engine.getHandshakeStatus();
@@ -321,7 +367,7 @@
                 throw new Exception(
                     "handshake shouldn't need additional tasks");
             }
-            log("\tnew HandshakeStatus: " + hsStatus);
+            logEngineStatus(engine);
         }
     }
 
@@ -361,14 +407,14 @@
         if (resultOnce) {
             resultOnce = false;
             System.out.println("The format of the SSLEngineResult is: \n" +
-                "\t\"getStatus() / getHandshakeStatus()\" +\n" +
-                "\t\"bytesConsumed() / bytesProduced()\"\n");
+                    "\t\"getStatus() / getHandshakeStatus()\" +\n" +
+                    "\t\"bytesConsumed() / bytesProduced()\"\n");
         }
         HandshakeStatus hsStatus = result.getHandshakeStatus();
         log(str +
-            result.getStatus() + "/" + hsStatus + ", " +
-            result.bytesConsumed() + "/" + result.bytesProduced() +
-            " bytes");
+                result.getStatus() + "/" + hsStatus + ", " +
+                result.bytesConsumed() + "/" + result.bytesProduced() +
+                " bytes");
         if (hsStatus == HandshakeStatus.FINISHED) {
             log("\t...ready for application data");
         }
--- a/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java	Fri Sep 07 15:46:39 2018 -0700
@@ -220,12 +220,12 @@
     /*
      * What's the server port?  Use any free port by default
      */
-    private volatile int serverPort = 0;
+    protected volatile int serverPort = 0;
 
     /*
      * Define the server side of the test.
      */
-    private void doServerSide() throws Exception {
+    protected void doServerSide() throws Exception {
         // kick start the server side service
         SSLContext context = createServerSSLContext();
         SSLServerSocketFactory sslssf = context.getServerSocketFactory();
@@ -286,7 +286,7 @@
     /*
      * Define the client side of the test.
      */
-    private void doClientSide() throws Exception {
+    protected void doClientSide() throws Exception {
 
         // Wait for server to get started.
         //
--- a/test/jdk/javax/security/auth/Subject/doAs/NestedActions.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/security/auth/Subject/doAs/NestedActions.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@
 import java.util.jar.Manifest;
 import javax.security.auth.Subject;
 import javax.security.auth.x500.X500Principal;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 /**
  * @test
@@ -50,7 +50,7 @@
  *          in case of nested Subject.doAs() invocations
  *          when one of protection domains doesn't have permissions
  *
- * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @run main NestedActions jar NestedActionsACE.jar
  *              NestedActionsACE.class Utils.class
--- a/test/jdk/javax/swing/JButton/4796987/bug4796987.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JButton/4796987/bug4796987.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -28,15 +28,16 @@
  * @summary XP Only: JButton.setBorderPainted() does not work with XP L&F
  * @author Alexander Scherbatiy
  * @library ../../regtesthelpers
- * @library ../../../../lib/testlibrary
+ * @library /test/lib
  * @modules java.desktop/com.sun.java.swing.plaf.windows
  *          java.desktop/sun.awt
- * @build jdk.testlibrary.OSInfo
+ * @build jdk.test.lib.OSVersion jdk.test.lib.Platform
  * @build Util
  * @run main bug4796987
  */
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
+import jdk.test.lib.OSVersion;
 import java.awt.*;
 import javax.swing.*;
 import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
@@ -47,8 +48,8 @@
     private static JButton button2;
 
     public static void main(String[] args) throws Exception {
-        if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS
-                && OSInfo.getWindowsVersion() == OSInfo.WINDOWS_XP) {
+        if (Platform.isWindows()
+                && OSVersion.current().equals(OSVersion.WINDOWS_XP)) {
             UIManager.setLookAndFeel(new WindowsLookAndFeel());
             testButtonBorder();
         }
--- a/test/jdk/javax/swing/JCheckBox/4449413/bug4449413.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JCheckBox/4449413/bug4449413.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -25,9 +25,9 @@
  * @bug 4449413
  * @summary Tests that checkbox and radiobuttons' check marks are visible when background is black
  * @author Ilya Boyandin
- * @library ../../../../lib/testlibrary
+ * @library /test/lib
  * @modules java.desktop/sun.awt
- * @build jdk.testlibrary.OSInfo
+ * @build jdk.test.lib.Platform
  * @run applet/manual=yesno bug4449413.html
  */
 
@@ -35,7 +35,8 @@
 import javax.swing.plaf.metal.*;
 import java.awt.event.*;
 import java.awt.*;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 public class bug4449413 extends JApplet {
 
@@ -44,7 +45,7 @@
 
         try {
 
-            if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+            if (Platform.isOSX()) {
                 UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
             }
 
--- a/test/jdk/javax/swing/JCheckBox/8032667/bug8032667_image_diff.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JCheckBox/8032667/bug8032667_image_diff.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -28,13 +28,14 @@
 import javax.swing.JCheckBox;
 import javax.swing.JComponent;
 import javax.swing.SwingUtilities;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 /* @test
  * @bug 8032667
  * @summary [macosx] Components cannot be rendered in HiDPI to BufferedImage
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main bug8032667_image_diff
  */
 public class bug8032667_image_diff {
@@ -44,7 +45,7 @@
 
     public static void main(String[] args) throws Exception {
 
-        if(!OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())){
+        if (!Platform.isOSX()) {
             return;
         }
 
--- a/test/jdk/javax/swing/JComboBox/4199622/bug4199622.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JComboBox/4199622/bug4199622.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -28,14 +28,14 @@
    @requires (os.family == "windows")
    @summary RFE: JComboBox shouldn't send ActionEvents for keyboard navigation
    @author Vladislav Karnaukhov
-   @library ../../../../lib/testlibrary
+   @library /test/lib
    @modules java.desktop/com.sun.java.swing.plaf.windows
-   @build jdk.testlibrary.OSInfo
+   @build jdk.test.libr.Platform
    @run main bug4199622
  */
 
 import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 import javax.swing.*;
 import javax.swing.plaf.metal.MetalLookAndFeel;
@@ -229,7 +229,7 @@
         }
         doTest();
 
-        if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
+        if (Platform.isWindows()) {
             try {
                 SwingUtilities.invokeAndWait(new Runnable() {
                     @Override
--- a/test/jdk/javax/swing/JFileChooser/4150029/bug4150029.html	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JFileChooser/4150029/bug4150029.html	Fri Sep 07 15:46:39 2018 -0700
@@ -1,6 +1,6 @@
 <html>
 <!--
- Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2013, 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
@@ -27,8 +27,8 @@
  @bug 4150029 8006087
  @summary BackSpace keyboard button does not lead to parent directory
  @author Oleg Mokhovikov
- @library ../../../../lib/testlibrary
- @build jdk.testlibrary.OSInfo
+ @library /test/lib
+ @build jdk.test.lib.Platform
  @run applet/manual=done bug4150029.html
 -->
 
--- a/test/jdk/javax/swing/JFileChooser/4150029/bug4150029.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JFileChooser/4150029/bug4150029.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -27,6 +27,8 @@
    author Oleg Mokhovikov
 */
 
+import jdk.test.lib.Platform;
+
 import javax.swing.*;
 import java.io.File;
 import java.io.IOException;
@@ -35,7 +37,7 @@
     private boolean res;
 
     public void init() {
-        if (jdk.testlibrary.OSInfo.getOSType() == jdk.testlibrary.OSInfo.OSType.MACOSX) {
+        if (Platform.isOSX()) {
             try {
                 UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
             } catch (Exception e) {
--- a/test/jdk/javax/swing/JFileChooser/4524490/bug4524490.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JFileChooser/4524490/bug4524490.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -28,15 +28,16 @@
  * @summary Tests if in JFileChooser, ALT+L does not bring focus to 'Files' selection list in Motif LAF
  * @author Konstantin Eremin
  * @library ../../regtesthelpers
- * @library ../../../../lib/testlibrary
- * @build Util jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build Util jdk.test.lib.Platform
  * @run main bug4524490
  */
 import java.awt.Robot;
 import java.awt.Toolkit;
 import java.awt.event.KeyEvent;
 import javax.swing.*;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 public class bug4524490 {
 
@@ -58,7 +59,7 @@
 
         robot.waitForIdle();
 
-        if (OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())) {
+        if (Platform.isOSX()) {
             Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_L);
         } else {
             Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_L);
--- a/test/jdk/javax/swing/JFileChooser/6840086/bug6840086.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JFileChooser/6840086/bug6840086.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,13 @@
    @bug 6840086
    @summary JFileChooser lacks icons on top right when running on Windows 7
    @author Pavel Porvatov
-   @library ../../../../lib/testlibrary
+   @library /test/lib
    @modules java.desktop/sun.awt.shell
-   @build jdk.testlibrary.OSInfo
+   @build jdk.test.lib.Platform
    @run main bug6840086
 */
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 import sun.awt.shell.ShellFolder;
 
 import java.awt.*;
@@ -46,7 +46,7 @@
     };
 
     public static void main(String[] args) {
-        if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
+        if (!Platform.isWindows()) {
             System.out.println("The test was skipped because it is sensible only for Windows.");
 
             return;
--- a/test/jdk/javax/swing/JFileChooser/8041694/bug8041694.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JFileChooser/8041694/bug8041694.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,8 @@
  * @bug 8041694
  * @summary JFileChooser removes trailing spaces in the selected directory name
  * @author Anton Litvinov
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main bug8041694
  */
 
@@ -45,7 +45,7 @@
 import javax.swing.UnsupportedLookAndFeelException;
 import javax.swing.plaf.metal.MetalLookAndFeel;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 public class bug8041694 {
     private static volatile File dir1;
@@ -59,7 +59,7 @@
             Robot robot = new Robot();
 
             dir1 = Files.createTempDirectory("bug8041694").toFile();
-            if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
+            if (Platform.isWindows()) {
                 dir2 = new File(String.format(
                     "\\\\?\\%s\\d ", dir1.getAbsolutePath().replace('/', '\\')));
             } else {
--- a/test/jdk/javax/swing/JFileChooser/8046391/bug8046391.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JFileChooser/8046391/bug8046391.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -27,15 +27,14 @@
  * @requires (os.family == "windows")
  * @summary JFileChooser hangs if displayed in Windows L&F
  * @author Alexey Ivanov
- * @library ../../../../lib/testlibrary
+ * @library /test/lib
  * @modules java.desktop/com.sun.java.swing.plaf.windows
- * @build jdk.testlibrary.OSInfo
+ * @build jdk.test.lib.Platform
  * @run main/othervm/timeout=10 bug8046391
 */
 
 import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
-import jdk.testlibrary.OSInfo;
-import jdk.testlibrary.OSInfo.OSType;
+import jdk.test.lib.Platform;
 
 import javax.swing.JFileChooser;
 import javax.swing.SwingUtilities;
@@ -45,8 +44,7 @@
 public class bug8046391  {
 
     public static void main(String[] args) throws Exception {
-        OSType type = OSInfo.getOSType();
-        if (type != OSType.WINDOWS) {
+        if (!Platform.isWindows()) {
             System.out.println("This test is for Windows only... skipping!");
             return;
         }
--- a/test/jdk/javax/swing/JFileChooser/8062561/bug8062561.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JFileChooser/8062561/bug8062561.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -21,7 +21,7 @@
  * questions.
  */
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 import java.awt.Robot;
 import java.awt.event.KeyEvent;
 import java.io.File;
@@ -39,9 +39,9 @@
  * @key headful
  * @requires (os.family == "windows")
  * @summary File system view returns null default directory
- * @library ../../../../lib/testlibrary
+ * @library /test/lib
  * @modules java.desktop/sun.awt
- * @build jdk.testlibrary.OSInfo
+ * @build jdk.test.lib.Platform
  * @run main/othervm bug8062561 GENERATE_POLICY
  * @run main/othervm/policy=security.policy bug8062561 CHECK_DEFAULT_DIR run
  */
@@ -119,7 +119,7 @@
             throw new RuntimeException("Security manager should be null!");
         }
 
-        if (!OSInfo.getOSType().equals(OSInfo.OSType.WINDOWS)) {
+        if (!Platform.isWindows()) {
             return;
         }
 
--- a/test/jdk/javax/swing/JFrame/8016356/bug8016356.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JFrame/8016356/bug8016356.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -28,8 +28,8 @@
  * @summary Any swing frame resizes ugly.
  * @author Oleg Pekhovskiy
  * @requires (os.family == "windows")
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main bug8016356
  */
 
@@ -47,7 +47,8 @@
 import javax.swing.JFrame;
 import javax.swing.JPanel;
 import javax.swing.SwingUtilities;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 public class bug8016356 {
     private static JFrame frame;
@@ -60,7 +61,7 @@
     public static void main(String[] args) throws Exception {
 
         // Windows only test
-        if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
+        if (Platform.isWindows()) {
 
             // Retrieving top edge of Desktop
             GraphicsConfiguration grConf = GraphicsEnvironment
--- a/test/jdk/javax/swing/JFrame/NSTexturedJFrame/NSTexturedJFrame.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JFrame/NSTexturedJFrame/NSTexturedJFrame.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -27,7 +27,8 @@
 
 import javax.swing.JFrame;
 import javax.swing.SwingUtilities;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 /**
  * @test
@@ -35,8 +36,8 @@
  * @bug 7124513
  * @summary We should support NSTexturedBackgroundWindowMask style on OSX.
  * @author Sergey Bylokhov
- * @library ../../../../lib/testlibrary
- * @build ExtendedRobot jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build ExtendedRobot jdk.test.lib.Platform
  * @run main NSTexturedJFrame
  */
 
@@ -51,7 +52,7 @@
     private static ExtendedRobot robot;
 
     public static void main(final String[] args) throws Exception {
-        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+        if (!Platform.isOSX()) {
             System.out.println("This test is for OSX, considered passed.");
             return;
         }
--- a/test/jdk/javax/swing/JInternalFrame/4251301/bug4251301.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JInternalFrame/4251301/bug4251301.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -24,8 +24,8 @@
    @bug 4251301
    @summary Keybinding for show/hide the system menu.
    @author Andrey Pikalev
-   @library ../../../../lib/testlibrary
-   @build jdk.testlibrary.OSInfo
+   @library /test/lib
+   @build jdk.test.lib.Platform
    @run main/manual bug4251301
 */
 
@@ -34,13 +34,13 @@
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.beans.*;
-import jdk.testlibrary.OSInfo;
 
+import jdk.test.lib.Platform;
 
 public class bug4251301 {
     static Test test = new Test();
     public static void main(String[] args) throws Exception {
-        if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+        if (Platform.isOSX()) {
             System.out.println("This test is not applicable for MacOS. Passed.");
             return;
         }
--- a/test/jdk/javax/swing/JLabel/6596966/bug6596966.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JLabel/6596966/bug6596966.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,8 @@
  * @bug 6596966
  * @summary Some JFileChooser mnemonics do not work with sticky keys
  * @library ../../regtesthelpers
- * @library ../../../../lib/testlibrary
- * @build Util jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build Util jdk.test.lib.Platform
  * @run main bug6596966
  * @author Pavel Porvatov
  */
@@ -39,7 +39,7 @@
 import java.util.ArrayList;
 import javax.swing.*;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 public class bug6596966 {
     private static JFrame frame;
@@ -78,7 +78,7 @@
 
 
         int keyMask = InputEvent.ALT_MASK;
-        if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+        if (Platform.isOSX()) {
             keyMask = InputEvent.CTRL_MASK | InputEvent.ALT_MASK;
         }
         ArrayList<Integer> keys = Util.getKeyCodesFromKeyMask(keyMask);
--- a/test/jdk/javax/swing/JMenu/6470128/bug6470128.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JMenu/6470128/bug6470128.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,15 +27,16 @@
  * @bug 6470128
  * @summary Escape Key causes JMenu Selection to Disappear
  * @author Alexander Potochkin
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main bug6470128
  */
 
 import javax.swing.*;
 import java.awt.*;
 import java.awt.event.KeyEvent;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 public class bug6470128 {
     static JFrame frame;
@@ -66,14 +67,14 @@
         Robot robot = new Robot();
         robot.setAutoDelay(10);
         robot.waitForIdle();
-        if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+        if (Platform.isOSX()) {
             robot.keyPress(KeyEvent.VK_CONTROL);
         }
         robot.keyPress(KeyEvent.VK_ALT);
         robot.keyPress(KeyEvent.VK_M);
         robot.keyRelease(KeyEvent.VK_M);
         robot.keyRelease(KeyEvent.VK_ALT);
-        if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+        if (Platform.isOSX()) {
             robot.keyRelease(KeyEvent.VK_CONTROL);
         }
         robot.keyPress(KeyEvent.VK_ENTER);
--- a/test/jdk/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -28,12 +28,12 @@
  * @summary [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar
  * @author vera.akulova@oracle.com
  * @modules java.desktop/java.awt:open
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main ActionListenerCalledTwiceTest
  */
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
@@ -56,7 +56,7 @@
     static volatile int listenerCallCounter = 0;
 
     public static void main(String[] args) throws Exception {
-        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+        if (!Platform.isOSX()) {
             System.out.println("This test is for MacOS only." +
                     " Automatically passed on other platforms.");
             return;
--- a/test/jdk/javax/swing/JMenuItem/ShortcutNotDiplayed/ShortcutNotDisplayedTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JMenuItem/ShortcutNotDiplayed/ShortcutNotDisplayedTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -26,11 +26,13 @@
  * @bug 7186371
  * @summary [macosx] Main menu shortcuts not displayed
  * @author vera.akulova@oracle.com
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main/manual ShortcutNotDisplayedTest
  */
 
+import jdk.test.lib.Platform;
+
 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
@@ -41,7 +43,7 @@
     static final String PASS_COMMAND = "pass";
 
     public static void main(String[] args) throws Exception {
-        if (jdk.testlibrary.OSInfo.getOSType() != jdk.testlibrary.OSInfo.OSType.MACOSX) {
+        if (!Platform.isOSX()) {
             System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
             return;
         }
--- a/test/jdk/javax/swing/JOptionPane/8024926/bug8024926.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JOptionPane/8024926/bug8024926.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -27,15 +27,16 @@
 import java.awt.TextArea;
 import javax.swing.JApplet;
 import javax.swing.JOptionPane;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 /**
  * @test
  * @bug 8024926 8040279
  * @summary [macosx] AquaIcon HiDPI support
  * @author Alexander Scherbatiy
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run applet/manual=yesno bug8024926.html
  */
 public class bug8024926 extends JApplet {
@@ -48,7 +49,7 @@
         this.setLayout(new BorderLayout());
 
 
-        if (OSInfo.getOSType().equals(OSInfo.OSType.MACOSX)) {
+        if (Platform.isOSX()) {
             String[] instructions = {
                 "Verify that high resolution system icons are used"
                 + " in JOptionPane on HiDPI displays.",
--- a/test/jdk/javax/swing/JPopupMenu/6827786/bug6827786.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JPopupMenu/6827786/bug6827786.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -28,13 +28,14 @@
  * @summary Tests duplicate mnemonics
  * @author Peter Zhelezniakov
  * @library ../../regtesthelpers
- * @library ../../../../lib/testlibrary
+ * @library /test/lib
  * @modules java.desktop/sun.awt
- * @build jdk.testlibrary.OSInfo
+ * @build jdk.test.lib.Platform
  * @build Util
  * @run main bug6827786
  */
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 import java.awt.*;
 import java.awt.event.KeyEvent;
 import javax.swing.*;
@@ -70,7 +71,7 @@
         checkfocus();
 
         // select menu
-        if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+        if (Platform.isOSX()) {
             Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_F);
         } else {
             Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_F);
--- a/test/jdk/javax/swing/JPopupMenu/7154841/bug7154841.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JPopupMenu/7154841/bug7154841.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -27,8 +27,8 @@
  * @bug 7154841
  * @summary JPopupMenu is overlapped by a Dock on Mac OS X
  * @author Petr Pchelko
- * @library ../../../../lib/testlibrary
- * @build ExtendedRobot jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build ExtendedRobot jdk.test.lib.Platform
  * @run main bug7154841
  */
 
@@ -37,7 +37,8 @@
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseMotionAdapter;
 import java.util.concurrent.atomic.AtomicReference;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 public class bug7154841 {
 
@@ -68,7 +69,7 @@
     }
 
     public static void main(String[] args) throws Exception {
-        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+        if (!Platform.isOSX()) {
             return; // Test only for Mac OS X
         }
 
--- a/test/jdk/javax/swing/JScrollBar/bug4202954/bug4202954.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JScrollBar/bug4202954/bug4202954.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -24,9 +24,9 @@
    @test
    @key headful
    @bug 4202954
-   @library ../../../../lib/testlibrary
+   @library /test/lib
    @library ../../regtesthelpers
-   @build Util jdk.testlibrary.OSInfo
+   @build Util jdk.test.lib.Platform
    @author Michael C. Albers
    @run main bug4202954
  */
@@ -34,13 +34,14 @@
 import java.awt.*;
 import java.awt.event.InputEvent;
 import javax.swing.*;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 public class bug4202954 {
     static JScrollPane buttonScrollPane;
     static Robot robot;
     public static void main(String[] args) throws Exception {
-        if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+        if (Platform.isOSX()) {
             UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
         }
 
--- a/test/jdk/javax/swing/JScrollPane/HorizontalMouseWheelOnShiftPressed/HorizontalMouseWheelOnShiftPressed.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JScrollPane/HorizontalMouseWheelOnShiftPressed/HorizontalMouseWheelOnShiftPressed.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@
 import javax.swing.JTextArea;
 import javax.swing.SwingUtilities;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 /**
  * @test
@@ -39,8 +39,8 @@
  * @bug 8033000 8147994
  * @author Alexander Scherbatiy
  * @summary No Horizontal Mouse Wheel Support In BasicScrollPaneUI
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main HorizontalMouseWheelOnShiftPressed
  */
 public class HorizontalMouseWheelOnShiftPressed {
@@ -52,7 +52,7 @@
     private static JFrame frame;
 
     static {
-        delta = OSInfo.getOSType().equals(OSInfo.OSType.MACOSX) ? -30 : 30;
+        delta = Platform.isOSX() ? -30 : 30;
     }
 
     public static void main(String[] args) throws Exception {
--- a/test/jdk/javax/swing/JSlider/6579827/bug6579827.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JSlider/6579827/bug6579827.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,20 +26,21 @@
  * @requires (os.family == "windows")
  * @summary vista : JSlider on JColorchooser is not properly render or can't be seen completely
  * @author Pavel Porvatov
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.OSVersion jdk.test.lib.Platform
    @run main bug6579827
  */
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
+import jdk.test.lib.OSVersion;
 
 import javax.swing.*;
 import java.awt.*;
 
 public class bug6579827 {
     public static void main(String[] args) throws Exception {
-        if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS ||
-                OSInfo.getWindowsVersion() != OSInfo.WINDOWS_VISTA) {
+        if (!Platform.isWindows() ||
+                !OSVersion.current().equals(OSVersion.WINDOWS_VISTA)) {
             System.out.println("This test is only for Windows Vista. Skipped.");
 
             return;
--- a/test/jdk/javax/swing/JTabbedPane/4624207/bug4624207.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JTabbedPane/4624207/bug4624207.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,9 +27,9 @@
  * @bug 4624207
  * @summary JTabbedPane mnemonics don't work from outside the tabbed pane
  * @author Oleg Mokhovikov
- * @library ../../../../lib/testlibrary
+ * @library /test/lib
  * @library ../../regtesthelpers
- * @build Util jdk.testlibrary.OSInfo
+ * @build Util jdk.test.lib.Platform
  * @run main bug4624207
  */
 import javax.swing.*;
@@ -40,7 +40,7 @@
 import java.awt.event.FocusListener;
 import java.awt.event.KeyEvent;
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 public class bug4624207 implements ChangeListener, FocusListener {
 
@@ -101,7 +101,7 @@
 
         robot.waitForIdle();
 
-        if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+        if (Platform.isOSX()) {
             Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_B);
         } else {
             Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_B);
--- a/test/jdk/javax/swing/JTabbedPane/6416920/bug6416920.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JTabbedPane/6416920/bug6416920.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,8 @@
  * @summary Ensures that selected tab is painted properly in the scroll tab layout
  *         under WindowsLookAndFeel in Windows' "Windows XP" theme.
  * @author Mikhail Lapshin
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main bug6416920
  */
 
@@ -37,14 +37,15 @@
 import javax.swing.SwingConstants;
 import java.awt.Rectangle;
 import java.awt.Insets;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 public class bug6416920 extends BasicTabbedPaneUI {
     public AccessibleTabbedPaneLayout layout = new AccessibleTabbedPaneLayout();
 
     public static void main(String[] args) {
 
-        if(OSInfo.getOSType() != OSInfo.OSType.WINDOWS){
+        if (!Platform.isWindows()) {
             return;
         }
 
--- a/test/jdk/javax/swing/JTextArea/6940863/bug6940863.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/JTextArea/6940863/bug6940863.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -28,12 +28,12 @@
  * @summary Textarea within scrollpane shows vertical scrollbar
  * @author Pavel Porvatov
  * @requires (os.family == "windows")
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main bug6940863
  */
 
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
 
 import javax.swing.*;
 import java.awt.*;
@@ -59,7 +59,7 @@
     });
 
     public static void main(String[] args) throws Exception {
-        if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
+        if (!Platform.isWindows()) {
             System.out.println("The test is suitable only for Windows OS. Skipped");
             return;
         }
--- a/test/jdk/javax/swing/UITest/UITest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/UITest/UITest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -28,80 +28,68 @@
  *          GTK is not on Windows and Mac.
  * added as tabs
  * @author Scott Violet
- * @library ../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main UITest
  */
 import javax.swing.*;
 import javax.swing.UIManager.LookAndFeelInfo;
-import jdk.testlibrary.OSInfo;
-import jdk.testlibrary.OSInfo.OSType;
+
+import jdk.test.lib.Platform;
 
 public class UITest {
 
     public static void main(String[] args) {
-        OSType os = OSInfo.getOSType();
         LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
-
-        switch (os) {
-            case WINDOWS:
-
-                // Make sure we don't have GTK.
-                if (hasLAF("gtk", lafInfo)) {
-                    throw new RuntimeException("On windows, but GTK is present");
-                }
+        if (Platform.isWindows()) {
+            // Make sure we don't have GTK.
+            if (hasLAF("gtk", lafInfo)) {
+                throw new RuntimeException("On windows, but GTK is present");
+            }
 
-                // Make sure we don't have Aqua.
-                if (hasLAF("mac", lafInfo)) {
-                    throw new RuntimeException("On windows, but Aqua is present");
-                }
+            // Make sure we don't have Aqua.
+            if (hasLAF("mac", lafInfo)) {
+                throw new RuntimeException("On windows, but Aqua is present");
+            }
 
-                // Make sure we have Windows.
-                if (!hasLAF("windows", lafInfo)) {
-                    throw new RuntimeException("On windows and don't have Windows");
-                }
-
-                break;
-
-            case MACOSX:
-
-                // Make sure we don't have GTK.
-                if (hasLAF("gtk", lafInfo)) {
-                    throw new RuntimeException("On mac, but GTK is present");
-                }
+            // Make sure we have Windows.
+            if (!hasLAF("windows", lafInfo)) {
+                throw new RuntimeException("On windows and don't have Windows");
+            }
+        } else if (Platform.isOSX()) {
+            // Make sure we don't have GTK.
+            if (hasLAF("gtk", lafInfo)) {
+                throw new RuntimeException("On mac, but GTK is present");
+            }
 
-                // Make sure we don't have Windows.
-                if (hasLAF("windows", lafInfo)) {
-                    throw new RuntimeException("On mac, but Windows is present");
-                }
+            // Make sure we don't have Windows.
+            if (hasLAF("windows", lafInfo)) {
+                throw new RuntimeException("On mac, but Windows is present");
+            }
 
-                // Make sure we have Aqua.
-                if (!hasLAF("mac", lafInfo)) {
-                    throw new RuntimeException("On mac and don't have Aqua");
-                }
-
-                break;
-
-            default:
-                // Not windows and mac
+            // Make sure we have Aqua.
+            if (!hasLAF("mac", lafInfo)) {
+                throw new RuntimeException("On mac and don't have Aqua");
+            }
+        } else {
+            // Not windows and mac
 
-                // Make sure we don't have Windows.
-                if (hasLAF("windows", lafInfo)) {
-                    throw new RuntimeException("Not on windows and have Windows");
-                }
+            // Make sure we don't have Windows.
+            if (hasLAF("windows", lafInfo)) {
+                throw new RuntimeException("Not on windows and have Windows");
+            }
 
-                // Make sure we don't have Aqua.
-                if (hasLAF("mac", lafInfo)) {
-                    throw new RuntimeException("Not on mac and have Aqua");
-                }
+            // Make sure we don't have Aqua.
+            if (hasLAF("mac", lafInfo)) {
+                throw new RuntimeException("Not on mac and have Aqua");
+            }
 
-                // Make sure we have GTK.
-                if (!hasLAF("gtk", lafInfo)) {
-                    throw new RuntimeException(
-                            "Not on Windows and Mac and don't have GTK!");
-                }
+            // Make sure we have GTK.
+            if (!hasLAF("gtk", lafInfo)) {
+                throw new RuntimeException(
+                        "Not on Windows and Mac and don't have GTK!");
+            }
         }
-
     }
 
     public static boolean hasLAF(String name, LookAndFeelInfo[] lafInfo) {
--- a/test/jdk/javax/swing/plaf/aqua/CustomComboBoxFocusTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/plaf/aqua/CustomComboBoxFocusTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,8 @@
  * @bug     8073001 8081764
  * @summary Test verifies that combo box with custom editor renders
  *          focus ring around arrow button correctly.
- * @library /lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run     main CustomComboBoxFocusTest
  */
 
@@ -54,14 +54,15 @@
 import javax.swing.JPanel;
 import javax.swing.JTextField;
 import javax.swing.SwingUtilities;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 public class CustomComboBoxFocusTest {
 
     private static CustomComboBoxFocusTest test = null;
 
     public static void main(String[] args) {
-        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
+        if (!Platform.isOSX()) {
             System.out.println("Only Mac platform test. Test is skipped for other OS.");
             return;
         }
--- a/test/jdk/javax/swing/plaf/basic/BasicLabelUI/bug7172652.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/swing/plaf/basic/BasicLabelUI/bug7172652.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,8 @@
  * @summary With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
  * @author Semyon Sadetsky
  * @requires (os.family == "windows")
- * @library /lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main bug7172652
  */
 
@@ -38,7 +38,8 @@
 import javax.swing.event.ChangeListener;
 import java.awt.*;
 import java.awt.event.KeyEvent;
-import jdk.testlibrary.OSInfo;
+
+import jdk.test.lib.Platform;
 
 public class bug7172652  {
 
@@ -47,7 +48,7 @@
     private static Boolean selected;
 
     public static void main(String[] args) throws Exception {
-        if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
+        if (!Platform.isWindows()) {
             System.out.println("ok");
             return;
         }
--- a/test/jdk/javax/xml/crypto/dsig/GenerationTests.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/javax/xml/crypto/dsig/GenerationTests.java	Fri Sep 07 15:46:39 2018 -0700
@@ -314,7 +314,7 @@
         try (Http server = Http.startServer()) {
             server.start();
 
-            // tests for XML documents
+            System.out.println("\ntests for XML documents");
             Arrays.stream(canonicalizationMethods).forEach(c ->
                 Arrays.stream(allSignatureMethods).forEach(s ->
                     Arrays.stream(allDigestMethods).forEach(d ->
@@ -326,7 +326,7 @@
                                 }
                         })))));
 
-            // tests for text data with no transform
+            System.out.println("\ntests for text data with no transform");
             Arrays.stream(canonicalizationMethods).forEach(c ->
                 Arrays.stream(allSignatureMethods).forEach(s ->
                     Arrays.stream(allDigestMethods).forEach(d ->
@@ -337,7 +337,7 @@
                             }
                         }))));
 
-            // tests for base64 data
+            System.out.println("\ntests for base64 data");
             Arrays.stream(canonicalizationMethods).forEach(c ->
                 Arrays.stream(allSignatureMethods).forEach(s ->
                     Arrays.stream(allDigestMethods).forEach(d ->
@@ -352,7 +352,7 @@
 
             // negative tests
 
-            // unknown CanonicalizationMethod
+            System.out.println("\nunknown CanonicalizationMethod");
             test_create_detached_signature(
                     CanonicalizationMethod.EXCLUSIVE + BOGUS,
                     SignatureMethod.DSA_SHA1,
@@ -364,7 +364,7 @@
                     true,
                     NoSuchAlgorithmException.class);
 
-            // unknown SignatureMethod
+            System.out.println("\nunknown SignatureMethod");
             test_create_detached_signature(
                     CanonicalizationMethod.EXCLUSIVE,
                     SignatureMethod.DSA_SHA1 + BOGUS,
@@ -375,7 +375,7 @@
                     true,
                     NoSuchAlgorithmException.class);
 
-            // unknown DigestMethod
+            System.out.println("\nunknown DigestMethod");
             test_create_detached_signature(
                     CanonicalizationMethod.EXCLUSIVE,
                     SignatureMethod.DSA_SHA1,
@@ -386,7 +386,7 @@
                     true,
                     NoSuchAlgorithmException.class);
 
-            // unknown Transform
+            System.out.println("\nunknown Transform");
             test_create_detached_signature(
                     CanonicalizationMethod.EXCLUSIVE,
                     SignatureMethod.DSA_SHA1,
@@ -397,7 +397,7 @@
                     true,
                     NoSuchAlgorithmException.class);
 
-            // no source document
+            System.out.println("\nno source document");
             test_create_detached_signature(
                     CanonicalizationMethod.EXCLUSIVE,
                     SignatureMethod.DSA_SHA1,
@@ -409,7 +409,7 @@
                     true,
                     XMLSignatureException.class);
 
-            // wrong transform for text data
+            System.out.println("\nwrong transform for text data");
             test_create_detached_signature(
                     CanonicalizationMethod.EXCLUSIVE,
                     SignatureMethod.DSA_SHA1,
@@ -1608,6 +1608,7 @@
             throws Exception {
 
         System.out.print("-S");
+        System.out.flush();
 
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         dbf.setNamespaceAware(true);
@@ -1720,6 +1721,7 @@
         }
 
         System.out.print("V");
+        System.out.flush();
         try (ByteArrayInputStream bis = new ByteArrayInputStream(
                 signatureString.getBytes())) {
             doc = dbf.newDocumentBuilder().parse(bis);
@@ -1743,12 +1745,14 @@
         boolean success = signature.validate(vc);
         if (!success) {
             System.out.print("x");
+            System.out.flush();
             return false;
         }
 
         success = signature.getSignatureValue().validate(vc);
         if (!success) {
             System.out.print("X");
+            System.out.flush();
             return false;
         }
 
--- a/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 /**
  * @test
  * @summary Basic test of VM::getRuntimeArguments
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.base/jdk.internal.misc
  *          jdk.zipfs
  * @run testng RuntimeArguments
@@ -34,7 +34,7 @@
 import java.util.List;
 import java.util.stream.Stream;
 import jdk.internal.misc.VM;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
--- a/test/jdk/jdk/internal/reflect/Reflection/GetCallerClassTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/jdk/internal/reflect/Reflection/GetCallerClassTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -21,6 +21,17 @@
  * questions.
  */
 
+/*
+ * @test
+ * @bug 8010117
+ * @summary Test if the VM enforces Reflection.getCallerClass
+ *          be called by methods annotated with CallerSensitive
+ * @modules java.base/jdk.internal.reflect
+ * @build SetupGetCallerClass boot.GetCallerClass
+ * @run driver SetupGetCallerClass
+ * @run main/othervm -Xbootclasspath/a:bcp GetCallerClassTest
+ */
+
 import boot.GetCallerClass;
 import java.lang.reflect.*;
 import jdk.internal.reflect.CallerSensitive;
--- a/test/jdk/jdk/internal/reflect/Reflection/GetCallerClassTest.sh	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-#
-# Copyright (c) 2013, 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
-# @bug 8010117
-# @summary Test if the VM enforces Reflection.getCallerClass
-#          be called by methods annotated with CallerSensitive
-#
-# @run shell GetCallerClassTest.sh
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${COMPILEJAVA}" = "" ]
-then
-  COMPILEJAVA="${TESTJAVA}"
-fi
-echo "COMPILEJAVA=${COMPILEJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-BCP=${TESTCLASSES}/bcp
-rm -rf ${BCP}
-mkdir ${BCP}
-
-EXTRAOPTS="--add-exports java.base/jdk.internal.reflect=ALL-UNNAMED"
-
-# Compile GetCallerClass in bootclasspath
-${COMPILEJAVA}/bin/javac ${TESTTOOLVMOPTS} ${EXTRAOPTS} \
-     -XDignore.symbol.file \
-     -d ${BCP} ${TESTSRC}/GetCallerClass.java  || exit 1
-
-${COMPILEJAVA}/bin/javac ${TESTTOOLVMOPTS} ${EXTRAOPTS} \
-     -XDignore.symbol.file -cp ${BCP} \
-     -d ${TESTCLASSES} ${TESTSRC}/GetCallerClassTest.java  || exit 2
-
-${TESTJAVA}/bin/java ${TESTVMOPTS} ${EXTRAOPTS} -Xbootclasspath/a:${BCP} \
-     -cp ${TESTCLASSES} GetCallerClassTest || exit 3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jdk/internal/reflect/Reflection/SetupGetCallerClass.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+
+public class SetupGetCallerClass {
+
+    private static final String BOOT_CLASS
+            = boot.GetCallerClass.class.getSimpleName() + ".class";
+    private static final String TEST_CLASSES
+            = System.getProperty("test.classes", "build/classes");
+
+    public static void main(String[] args) throws IOException {
+        Path source = Path.of(TEST_CLASSES, "boot").resolve(BOOT_CLASS);
+        Path dest = Path.of("bcp", "boot");
+        Path target = dest.resolve(BOOT_CLASS);
+        Files.createDirectories(dest);
+        Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
+    }
+}
--- a/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java	Fri Sep 07 15:46:39 2018 -0700
@@ -69,7 +69,6 @@
             ProcessTools.createJavaProcessBuilder(true,
                 "-Xmx64m",
                 "-Xint",
-                "-XX:-TransmitErrorReport",
                 "-XX:-CreateCoredumpOnCrash",
                 "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
                 "-XX:StartFlightRecording=dumponexit=true",
--- a/test/jdk/jdk/modules/etc/DefaultModules.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/jdk/modules/etc/DefaultModules.java	Fri Sep 07 15:46:39 2018 -0700
@@ -27,7 +27,7 @@
  * @modules jdk.compiler
  *          jdk.jlink
  *          jdk.zipfs
- * @library src /lib/testlibrary
+ * @library src /test/lib
  * @build java.json/*
  * @run main DefaultModules
  * @summary Test that all modules that export an API are in the set of modules
@@ -37,13 +37,9 @@
 import java.io.PrintStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.lang.module.ModuleDescriptor;
-import java.lang.module.ModuleFinder;
-import java.lang.module.ModuleReference;
 import java.util.spi.ToolProvider;
 
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 /**
  * This test compiles and runs the following tests on the class path:
--- a/test/jdk/jdk/modules/incubator/DefaultImage.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/jdk/modules/incubator/DefaultImage.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8170859
  * @summary Ensure no incubator modules are resolved by default in the image
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
  * @build jdk.test.lib.compiler.CompilerUtils
  * @run testng DefaultImage
@@ -47,7 +47,7 @@
 import org.testng.annotations.Test;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
-import static jdk.testlibrary.ProcessTools.executeCommand;
+import static jdk.test.lib.process.ProcessTools.executeCommand;
 import static org.testng.Assert.*;
 
 @Test
--- a/test/jdk/jdk/modules/incubator/ImageModules.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/jdk/modules/incubator/ImageModules.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8170859
  * @summary Basic test for incubator modules in jmods and images
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @key intermittent
  * @modules jdk.compiler jdk.jartool jdk.jlink
  * @build jdk.test.lib.Platform
@@ -54,7 +54,7 @@
 import org.testng.annotations.Test;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
-import static jdk.testlibrary.ProcessTools.executeCommand;
+import static jdk.test.lib.process.ProcessTools.executeCommand;
 import static org.testng.Assert.*;
 
 public class ImageModules {
--- a/test/jdk/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,7 @@
  *          java.scripting
  *          jdk.zipfs
  * @build RunWithAutomaticModules jdk.test.lib.compiler.CompilerUtils JarUtils
- *        jdk.testlibrary.ProcessTools
+ *        jdk.test.lib.process.ProcessTools
  * @run testng RunWithAutomaticModules
  * @summary Runs tests that make use of automatic modules
  */
@@ -38,7 +38,7 @@
 import java.nio.file.Paths;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
--- a/test/jdk/jdk/modules/scenarios/container/ContainerTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/jdk/modules/scenarios/container/ContainerTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -23,12 +23,12 @@
 
 /**
  * @test
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.jartool/sun.tools.jar
  *          jdk.compiler
  *          jdk.zipfs
  *          java.se
- * @build ContainerTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @build ContainerTest jdk.test.lib.compiler.CompilerUtils
  * @run testng ContainerTest
  * @summary Starts a simple container that uses dynamic configurations
  *          and launches two applications in the same VM
@@ -39,7 +39,7 @@
 import java.nio.file.Paths;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/test/jdk/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
- * @build OverlappingPackagesTest jdk.testlibrary.*
+ * @build OverlappingPackagesTest
  *        jdk.test.lib.compiler.CompilerUtils
  * @run testng OverlappingPackagesTest
  * @summary Basic test to ensure that startup fails if two or more modules
@@ -38,7 +38,7 @@
 import java.util.List;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/test/jdk/jdk/net/Sockets/Test.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/jdk/net/Sockets/Test.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -25,17 +25,17 @@
  * @test
  * @bug 8032808 8044773
  * @modules jdk.net
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
+ * @build jdk.test.lib.OSVersion jdk.test.lib.Platform
  * @run main/othervm -Xcheck:jni Test success
  * @run main/othervm/policy=policy.fail -Xcheck:jni Test fail
  * @run main/othervm/policy=policy.success -Xcheck:jni Test success
  */
 
-import jdk.net.ExtendedSocketOptions;
 import jdk.net.SocketFlow;
 import jdk.net.Sockets;
-import jdk.testlibrary.OSInfo;
+import jdk.test.lib.Platform;
+import jdk.test.lib.OSVersion;
 
 import java.io.IOException;
 import java.net.*;
@@ -53,7 +53,6 @@
 
     static boolean expectSuccess;
     private static final boolean expectSupport = checkExpectedOptionSupport();
-    private static final double solarisVersionToCheck = 11.2;
 
     public static void main(String[] args) throws Exception {
 
@@ -190,9 +189,10 @@
     }
 
     private static boolean checkExpectedOptionSupport() {
-        if (OSInfo.getOSType().equals(OSInfo.OSType.SOLARIS)) {
-            double solarisVersion = OSInfo.getSolarisVersion();
-            if (solarisVersion >= solarisVersionToCheck) {
+        if (Platform.isSolaris()) {
+            OSVersion solarisVersion = OSVersion.current();
+            OSVersion solarisVersionToCheck = new OSVersion(11, 2);
+            if (solarisVersion.compareTo(solarisVersionToCheck) >= 0) {
                 System.out.println("This Solaris version (" + solarisVersion
                         + ") should support SO_FLOW_SLA option");
                 return true;
--- a/test/jdk/jdk/net/Sockets/policy.fail	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/jdk/net/Sockets/policy.fail	Fri Sep 07 15:46:39 2018 -0700
@@ -1,8 +1,10 @@
-grant {
-    permission java.util.PropertyPermission "os.name", "read";
+grant codeBase "file:${test.classes}/../../../../test/lib/-" {
+    permission java.util.PropertyPermission "*", "read";
+    permission java.io.FilePermission "/etc/release", "read";
     permission java.io.FilePermission "<<ALL FILES>>", "execute";
-    permission java.util.PropertyPermission "line.separator", "read";
-    permission java.io.FilePermission "/etc/release", "read";
-    permission java.net.SocketPermission "127.0.0.1", "connect,accept" ;
-    permission java.net.SocketPermission "localhost", "listen" ;
 };
+
+grant codeBase "file:${test.classes}/*" {
+    permission java.net.SocketPermission "127.0.0.1", "connect,accept";
+    permission java.net.SocketPermission "localhost", "listen";
+};
--- a/test/jdk/jdk/net/Sockets/policy.success	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/jdk/net/Sockets/policy.success	Fri Sep 07 15:46:39 2018 -0700
@@ -1,10 +1,12 @@
-grant {
-    permission java.util.PropertyPermission "os.name", "read";
+grant codeBase "file:${test.classes}/../../../../test/lib/-" {
+    permission java.util.PropertyPermission "*", "read";
+    permission java.io.FilePermission "/etc/release", "read";
     permission java.io.FilePermission "<<ALL FILES>>", "execute";
-    permission java.util.PropertyPermission "line.separator", "read";
-    permission java.io.FilePermission "/etc/release", "read";
-    permission java.net.SocketPermission "127.0.0.1", "connect,accept" ;
-    permission java.net.SocketPermission "localhost", "listen" ;
+};
+
+grant codeBase "file:${test.classes}/*" {
+    permission java.net.SocketPermission "127.0.0.1", "connect,accept";
+    permission java.net.SocketPermission "localhost", "listen";
     permission jdk.net.NetworkPermission "setOption.SO_FLOW_SLA";
     permission jdk.net.NetworkPermission "getOption.SO_FLOW_SLA";
 };
--- a/test/jdk/jdk/nio/zipfs/ZFSTests.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/jdk/nio/zipfs/ZFSTests.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 7156873 8040059 8028480 8034773 8153248 8061777
+ * @bug 7156873 8040059 8028480 8034773 8153248 8061777 8197398 8210394
  * @summary ZipFileSystem regression tests
  *
  * @modules jdk.zipfs
@@ -31,22 +31,160 @@
  */
 
 
+import java.io.IOException;
 import java.io.OutputStream;
 import java.net.URI;
 import java.nio.ByteBuffer;
 import java.nio.channels.*;
 import java.nio.file.*;
+import java.nio.file.attribute.BasicFileAttributes;
 import java.nio.file.spi.*;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
 
 public class ZFSTests {
 
     public static void main(String[] args) throws Throwable {
+        test8197398();
         test7156873();
         test8061777();
         tests();
     }
 
+    static void test8197398() throws Throwable {
+
+        // root entry "/"
+        Path path = Paths.get("rootdir.zip");
+        URI uri = URI.create("jar:" + path.toUri());
+
+        Set<String> dirs = new HashSet<>();
+        Set<String> files = new HashSet<>();
+        try (OutputStream os = Files.newOutputStream(path);
+             ZipOutputStream zos = new ZipOutputStream(os)) {
+            zos.putNextEntry(new ZipEntry("/"));     dirs.add("/");
+            zos.putNextEntry(new ZipEntry("foo"));   files.add("/foo");
+            zos.write("/foo".getBytes());
+            zos.putNextEntry(new ZipEntry("bar"));   files.add("/bar");
+            zos.write("/bar".getBytes());
+        }
+        AtomicInteger cnt = new AtomicInteger();
+        int max = 3;
+        try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) {
+            Files.walkFileTree(fs.getRootDirectories().iterator().next(),
+                                new SimpleFileVisitor<Path>() {
+
+                @Override
+                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
+                        throws IOException {
+                    if (cnt.incrementAndGet() > max)
+                        throw new RuntimeException("visited too many files/dirs");
+                    files.remove(file.toString());
+                    if (!Arrays.equals(Files.readAllBytes(file), file.toString().getBytes()))
+                        throw new RuntimeException("visited files has wrong content: " + file);
+                    return FileVisitResult.CONTINUE;
+                }
+
+                @Override
+                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
+                        throws IOException {
+                    if (cnt.incrementAndGet() > max)
+                        throw new RuntimeException("visited too many files/dirs");
+                    dirs.remove(dir.toString());
+                    return FileVisitResult.CONTINUE;
+                }
+            });
+            if (cnt.get() != max || dirs.size() != 0 || files.size() != 0)
+                throw new RuntimeException("walk files/dirs failed");
+
+        } finally {
+            Files.deleteIfExists(path);
+        }
+
+        // absolute file/dir, no need to test cnt again..
+        dirs.clear();
+        files.clear();
+        try {
+            try (OutputStream os = Files.newOutputStream(path);
+                ZipOutputStream zos = new ZipOutputStream(os)) {
+                zos.putNextEntry(new ZipEntry("/"));     dirs.add("/");
+                zos.putNextEntry(new ZipEntry("/fooo/"));     dirs.add("/fooo");
+                zos.putNextEntry(new ZipEntry("/foo"));   files.add("/foo");
+                zos.write("/foo".getBytes());
+                zos.putNextEntry(new ZipEntry("/bar"));   files.add("/bar");
+                zos.write("/bar".getBytes());
+                zos.putNextEntry(new ZipEntry("/fooo/bar"));   files.add("/fooo/bar");
+                zos.write("/fooo/bar".getBytes());
+            }
+
+            try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) {
+                Files.walkFileTree(fs.getRootDirectories().iterator().next(),
+                                    new SimpleFileVisitor<Path>() {
+                    @Override
+                    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
+                            throws IOException {
+                        files.remove(file.toString());
+                        if (!Arrays.equals(Files.readAllBytes(file), file.toString().getBytes()))
+                            throw new RuntimeException("visited files has wrong content: " + file);
+                        return FileVisitResult.CONTINUE;
+                    }
+                    @Override
+                    public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
+                            throws IOException {
+                        dirs.remove(dir.toString());
+                        return FileVisitResult.CONTINUE;
+                    }
+                });
+                if (dirs.size() != 0 || files.size() != 0)
+                    throw new RuntimeException("walk files/dirs failed");
+
+                // for next test: updated any entry, the result zipfs file should have no
+                // absolute path entry
+                Files.write(fs.getPath("/foo"), "/foo".getBytes());
+            }
+
+            // updated zfs should have the same dirs/files (path is not absolute though)
+            dirs.add("/");
+            dirs.add("/fooo");
+            files.add("/foo");
+            files.add("/bar");
+            files.add("/fooo/bar");
+            try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) {
+                    Files.walk(fs.getPath("/")).forEach( p -> {
+                        if (Files.isDirectory(p)) {
+                            dirs.remove(p.toString());
+                        } else {
+                            files.remove(p.toString());
+                            try {
+                                if (!Arrays.equals(Files.readAllBytes(p), p.toString().getBytes()))
+                                    throw new RuntimeException("visited files has wrong content: " + p);
+                            } catch (IOException x) {
+                                throw new RuntimeException(x);
+                            }
+                        }
+                    });
+                if (dirs.size() != 0 || files.size() != 0)
+                    throw new RuntimeException("walk files/dirs failed");
+
+            }
+            // updated zip file should  not have "/" and entry with absolute path
+            try (var zf = new ZipFile(path.toFile())) {
+                String[] entries = zf.stream()
+                                     .map(ZipEntry::toString)
+                                     .sorted()
+                                     .toArray(String[]::new);
+                if (!Arrays.equals(entries, new String[] {"bar", "foo", "fooo/", "fooo/bar" })) {
+                    System.out.println("unexpeded: " + Arrays.toString(entries));
+                    throw new RuntimeException("unexpected entreis in updated zipfs file");
+                }
+            }
+        } finally {
+            Files.deleteIfExists(path);
+        }
+    }
+
     static void test7156873() throws Throwable {
         String DIRWITHSPACE = "testdir with spaces";
         Path dir = Paths.get(DIRWITHSPACE);
@@ -95,6 +233,7 @@
         Path path = Paths.get("file.zip");
         try {
             URI uri = URI.create("jar:" + path.toUri());
+
             Map<String, Object> env = new HashMap<String, Object>();
             env.put("create", "true");
             try (FileSystem fs = FileSystems.newFileSystem(uri, env)) {
--- a/test/jdk/lib/security/cacerts/VerifyCACerts.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/lib/security/cacerts/VerifyCACerts.java	Fri Sep 07 15:46:39 2018 -0700
@@ -25,7 +25,7 @@
 /**
  * @test
  * @bug 8189131 8198240 8191844 8189949 8191031 8196141 8204923 8195774 8199779 8209452
- *      8209506
+ *      8209506 8210432
  * @summary Check root CA entries in cacerts file
  */
 import java.io.File;
@@ -42,7 +42,7 @@
             + File.separator + "security" + File.separator + "cacerts";
 
     // The numbers of certs now.
-    private static final int COUNT = 92;
+    private static final int COUNT = 93;
 
     // map of cert alias to SHA-256 fingerprint
     private static final Map<String, String> FINGERPRINT_MAP
@@ -232,6 +232,8 @@
                     "BE:C9:49:11:C2:95:56:76:DB:6C:0A:55:09:86:D7:6E:3B:A0:05:66:7C:44:2C:97:62:B4:FB:B7:73:DE:22:8C");
             put("globalsignr2ca [jdk]",
                     "CA:42:DD:41:74:5F:D0:B8:1E:B9:02:36:2C:F9:D8:BF:71:9D:A1:BD:1B:1E:FC:94:6F:5B:4C:99:F4:2C:1B:9E");
+            put("teliasonerarootcav1 [jdk]",
+                    "DD:69:36:FE:21:F8:F0:77:C1:23:A1:A5:21:C1:22:24:F7:22:55:B7:3E:03:A7:26:06:93:E8:A2:4B:0F:A3:89");
         }
     };
 
--- a/test/jdk/lib/testlibrary/OutputAnalyzerReportingTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/lib/testlibrary/OutputAnalyzerReportingTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -21,18 +21,18 @@
  * questions.
  */
 
-package jdk.testlibrary;
-
 /*
  * @test
  * @summary Test the OutputAnalyzer reporting functionality,
  *     such as printing additional diagnostic info
  *     (exit code, stdout, stderr, command line, etc.)
  * @modules java.management
- * @build jdk.testlibrary.*
- * @run main jdk.testlibrary.OutputAnalyzerReportingTest
+ * @library /test/lib
+ * @run main OutputAnalyzerReportingTest
  */
 
+import jdk.test.lib.process.OutputAnalyzer;
+
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
 
--- a/test/jdk/lib/testlibrary/OutputAnalyzerTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/lib/testlibrary/OutputAnalyzerTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -20,16 +20,17 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-package jdk.testlibrary;
 
 /*
  * @test
  * @summary Test the OutputAnalyzer utility class
  * @modules java.management
- * @build jdk.testlibrary.*
- * @run main jdk.testlibrary.OutputAnalyzerTest
+ * @library /test/lib
+ * @run main OutputAnalyzerTest
  */
 
+import jdk.test.lib.process.OutputAnalyzer;
+
 public class OutputAnalyzerTest {
 
     public static void main(String args[]) throws Exception {
@@ -150,17 +151,23 @@
             // expected
         }
 
-        if (output.shouldMatchByLine(byLinePattern) != 1) {
-            throw new Exception("shouldMatchByLine() should find one line");
+        try {
+            output.shouldMatchByLine(byLinePattern);
+        } catch (RuntimeException e) {
+            throw new Exception("shouldMatchByLine() failed", e);
         }
+
         try {
             output.shouldMatchByLine(nonExistingPattern);
             throw new Exception("shouldMatchByLine() failed to throw exception");
         } catch (RuntimeException e) {
             // expected
         }
-        if (output.stdoutShouldMatchByLine(stdoutByLinePattern) != 1) {
-            throw new Exception("stdoutShouldMatchByLine() should find one line");
+
+        try {
+            output.stdoutShouldMatchByLine(stdoutByLinePattern);
+        } catch (RuntimeException e) {
+            throw new Exception("stdoutShouldMatchByLine() failed", e);
         }
 
         // Should not match
--- a/test/jdk/lib/testlibrary/jdk/testlibrary/OSInfo.java	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,216 +0,0 @@
-/*
- * Copyright (c) 1997, 2014, 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.security.PrivilegedAction;
-import java.util.HashMap;
-import java.util.Map;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.InputStreamReader;
-
-import static jdk.testlibrary.OSInfo.OSType.*;
-
-/**
- * @author Pavel Porvatov
- * copied to testlibrary by yan
- */
-public class OSInfo {
-    public static enum OSType {
-        WINDOWS,
-        LINUX,
-        SOLARIS,
-        MACOSX,
-        UNKNOWN
-    }
-
-    /*
-       The map windowsVersionMap must contain all windows version constants except WINDOWS_UNKNOWN,
-       and so the method getWindowsVersion() will return the constant for known OS.
-       It allows compare objects by "==" instead of "equals".
-     */
-    public static final WindowsVersion WINDOWS_UNKNOWN = new WindowsVersion(-1, -1);
-    public static final WindowsVersion WINDOWS_95 = new WindowsVersion(4, 0);
-    public static final WindowsVersion WINDOWS_98 = new WindowsVersion(4, 10);
-    public static final WindowsVersion WINDOWS_ME = new WindowsVersion(4, 90);
-    public static final WindowsVersion WINDOWS_2000 = new WindowsVersion(5, 0);
-    public static final WindowsVersion WINDOWS_XP = new WindowsVersion(5, 1);
-    public static final WindowsVersion WINDOWS_2003 = new WindowsVersion(5, 2);
-    public static final WindowsVersion WINDOWS_VISTA = new WindowsVersion(6, 0);
-
-    private static final String OS_NAME = "os.name";
-    private static final String OS_VERSION = "os.version";
-
-    private final static Map<String, WindowsVersion> windowsVersionMap = new HashMap<String, OSInfo.WindowsVersion>();
-
-    static {
-        windowsVersionMap.put(WINDOWS_95.toString(), WINDOWS_95);
-        windowsVersionMap.put(WINDOWS_98.toString(), WINDOWS_98);
-        windowsVersionMap.put(WINDOWS_ME.toString(), WINDOWS_ME);
-        windowsVersionMap.put(WINDOWS_2000.toString(), WINDOWS_2000);
-        windowsVersionMap.put(WINDOWS_XP.toString(), WINDOWS_XP);
-        windowsVersionMap.put(WINDOWS_2003.toString(), WINDOWS_2003);
-        windowsVersionMap.put(WINDOWS_VISTA.toString(), WINDOWS_VISTA);
-    }
-
-    private static final PrivilegedAction<OSType> osTypeAction = new PrivilegedAction<OSType>() {
-        public OSType run() {
-            return getOSType();
-        }
-    };
-
-    private OSInfo() {
-        // Don't allow to create instances
-    }
-
-    /**
-     * Returns type of operating system.
-     */
-    public static OSType getOSType() throws SecurityException {
-        String osName = System.getProperty(OS_NAME);
-
-        if (osName != null) {
-            if (osName.contains("Windows")) {
-                return WINDOWS;
-            }
-
-            if (osName.contains("Linux")) {
-                return LINUX;
-            }
-
-            if (osName.contains("Solaris") || osName.contains("SunOS")) {
-                return SOLARIS;
-            }
-
-            if (osName.contains("OS X")) {
-                return MACOSX;
-            }
-
-            // determine another OS here
-        }
-
-        return UNKNOWN;
-    }
-
-    public static PrivilegedAction<OSType> getOSTypeAction() {
-        return osTypeAction;
-    }
-
-    public static WindowsVersion getWindowsVersion() throws SecurityException {
-        String osVersion = System.getProperty(OS_VERSION);
-
-        if (osVersion == null) {
-            return WINDOWS_UNKNOWN;
-        }
-
-        synchronized (windowsVersionMap) {
-            WindowsVersion result = windowsVersionMap.get(osVersion);
-
-            if (result == null) {
-                // Try parse version and put object into windowsVersionMap
-                String[] arr = osVersion.split("\\.");
-
-                if (arr.length == 2) {
-                    try {
-                        result = new WindowsVersion(Integer.parseInt(arr[0]), Integer.parseInt(arr[1]));
-                    } catch (NumberFormatException e) {
-                        return WINDOWS_UNKNOWN;
-                    }
-                } else {
-                    return WINDOWS_UNKNOWN;
-                }
-
-                windowsVersionMap.put(osVersion, result);
-            }
-
-            return result;
-        }
-    }
-
-    public static double getSolarisVersion() {
-        try {
-            OutputAnalyzer output = ProcessTools.executeProcess("uname", "-v");
-            System.out.println("'uname -v' finished with code "
-                    + output.getExitValue());
-            return Double.parseDouble(output.getOutput());
-        } catch (Exception e) {
-            System.out.println("First attempt failed with: " + e.getMessage());
-        }
-
-        //Try to get Solaris version from /etc/release
-        try (BufferedReader in =
-                     new BufferedReader(new FileReader("/etc/release"))) {
-            String line = in.readLine().trim().split(" ")[2];
-            return Double.parseDouble(line);
-        } catch (Exception e) {
-            System.out.println("Second attempt failed with: " + e.getMessage());
-        }
-
-        throw new RuntimeException("Unable to get Solaris version");
-    }
-
-    public static class WindowsVersion implements Comparable<WindowsVersion> {
-        private final int major;
-
-        private final int minor;
-
-        private WindowsVersion(int major, int minor) {
-            this.major = major;
-            this.minor = minor;
-        }
-
-        public int getMajor() {
-            return major;
-        }
-
-        public int getMinor() {
-            return minor;
-        }
-
-        public int compareTo(WindowsVersion o) {
-            int result = major - o.getMajor();
-
-            if (result == 0) {
-                result = minor - o.getMinor();
-            }
-
-            return result;
-        }
-
-        public boolean equals(Object obj) {
-            return obj instanceof WindowsVersion && compareTo((WindowsVersion) obj) == 0;
-        }
-
-        public int hashCode() {
-            return 31 * major + minor;
-        }
-
-        public String toString() {
-            return major + "." + minor;
-        }
-    }
-}
-
--- a/test/jdk/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,577 +0,0 @@
-/*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import static jdk.testlibrary.Asserts.*;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
-
-/**
- * Utility class for verifying output and exit value from a {@code Process}.
- *
- * @deprecated  This class is deprecated. Use the one from
- *              {@code <root>/test/lib/jdk/test/lib/process}
- *
- */
-@Deprecated
-public final class OutputAnalyzer {
-    private final OutputBuffer output;
-    private final String stdout;
-    private final String stderr;
-    private final int exitValue;    // useless now. output contains exit value.
-
-    /**
-     * Create an OutputAnalyzer, a utility class for verifying output and exit
-     * value from a Process.
-     * <p>
-     * OutputAnalyzer should never be instantiated directly -
-     * use {@linkplain ProcessTools#executeProcess(ProcessBuilder)} instead
-     *
-     * @param process
-     *            Process to analyze
-     * @throws IOException
-     *             If an I/O error occurs.
-     */
-    OutputAnalyzer(Process process) throws IOException {
-        output = new OutputBuffer(process);
-        exitValue = -1;
-        this.stdout = null;
-        this.stderr = null;
-    }
-
-    /**
-     * Create an OutputAnalyzer, a utility class for verifying output.
-     *
-     * @param buf
-     *            String buffer to analyze
-     */
-    OutputAnalyzer(String buf) {
-        this(buf, buf);
-    }
-
-    /**
-     * Create an OutputAnalyzer, a utility class for verifying output
-     *
-     * @param stdout
-     *            stdout buffer to analyze
-     * @param stderr
-     *            stderr buffer to analyze
-     */
-    OutputAnalyzer(String stdout, String stderr) {
-        this.output = null;
-        this.stdout = stdout;
-        this.stderr = stderr;
-        exitValue = -1;
-    }
-
-    /**
-     * Verify that the stdout and stderr contents of output buffer contains the
-     * string
-     *
-     * @param expectedString
-     *            String that buffer should contain
-     * @throws RuntimeException
-     *             If the string was not found
-     */
-    public OutputAnalyzer shouldContain(String expectedString) {
-        if (!getStdout().contains(expectedString)
-                && !getStderr().contains(expectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + expectedString
-                    + "' missing from stdout/stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout contents of output buffer contains the string
-     *
-     * @param expectedString
-     *            String that buffer should contain
-     * @throws RuntimeException
-     *             If the string was not found
-     */
-    public OutputAnalyzer stdoutShouldContain(String expectedString) {
-        if (!getStdout().contains(expectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + expectedString
-                    + "' missing from stdout \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stderr contents of output buffer contains the string
-     *
-     * @param expectedString
-     *            String that buffer should contain
-     * @throws RuntimeException
-     *             If the string was not found
-     */
-    public OutputAnalyzer stderrShouldContain(String expectedString) {
-        if (!getStderr().contains(expectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + expectedString
-                    + "' missing from stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout and stderr contents of output buffer does not
-     * contain the string
-     *
-     * @param notExpectedString
-     *            String that the buffer should not contain
-     * @throws RuntimeException
-     *             If the string was found
-     */
-    public OutputAnalyzer shouldNotContain(String notExpectedString) {
-        if (getStdout().contains(notExpectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + notExpectedString
-                    + "' found in stdout \n");
-        }
-        if (getStderr().contains(notExpectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + notExpectedString
-                    + "' found in stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout contents of output buffer does not contain the
-     * string
-     *
-     * @param notExpectedString
-     *            String that the buffer should not contain
-     * @throws RuntimeException
-     *             If the string was found
-     */
-    public OutputAnalyzer stdoutShouldNotContain(String notExpectedString) {
-        if (getStdout().contains(notExpectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + notExpectedString
-                    + "' found in stdout \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stderr contents of output buffer does not contain the
-     * string
-     *
-     * @param notExpectedString
-     *            String that the buffer should not contain
-     * @throws RuntimeException
-     *             If the string was found
-     */
-    public OutputAnalyzer stderrShouldNotContain(String notExpectedString) {
-        if (getStderr().contains(notExpectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + notExpectedString
-                    + "' found in stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout and stderr contents of output buffer matches the
-     * pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was not found
-     */
-    public OutputAnalyzer shouldMatch(String pattern) {
-        Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE)
-                .matcher(getStdout());
-        Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE)
-                .matcher(getStderr());
-        if (!stdoutMatcher.find() && !stderrMatcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern
-                    + "' missing from stdout/stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout contents of output buffer matches the pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was not found
-     */
-    public OutputAnalyzer stdoutShouldMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(
-                getStdout());
-        if (!matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern
-                    + "' missing from stdout \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stderr contents of output buffer matches the pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was not found
-     */
-    public OutputAnalyzer stderrShouldMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(
-                getStderr());
-        if (!matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern
-                    + "' missing from stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout and stderr contents of output buffer does not
-     * match the pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was found
-     */
-    public OutputAnalyzer shouldNotMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(
-                getStdout());
-        if (matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern + "' found in stdout: '"
-                    + matcher.group() + "' \n");
-        }
-        matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(getStderr());
-        if (matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern + "' found in stderr: '"
-                    + matcher.group() + "' \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout contents of output buffer does not match the
-     * pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was found
-     */
-    public OutputAnalyzer stdoutShouldNotMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(
-                getStdout());
-        if (matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern + "' found in stdout \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stderr contents of output buffer does not match the
-     * pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was found
-     */
-    public OutputAnalyzer stderrShouldNotMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(
-                getStderr());
-        if (matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern + "' found in stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Get the captured group of the first string matching the pattern. stderr
-     * is searched before stdout.
-     *
-     * @param pattern
-     *            The multi-line pattern to match
-     * @param group
-     *            The group to capture
-     * @return The matched string or null if no match was found
-     */
-    public String firstMatch(String pattern, int group) {
-        Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE)
-                .matcher(getStderr());
-        Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE)
-                .matcher(getStdout());
-        if (stderrMatcher.find()) {
-            return stderrMatcher.group(group);
-        }
-        if (stdoutMatcher.find()) {
-            return stdoutMatcher.group(group);
-        }
-        return null;
-    }
-
-    /**
-     * Get the first string matching the pattern. stderr is searched before
-     * stdout.
-     *
-     * @param pattern
-     *            The multi-line pattern to match
-     * @return The matched string or null if no match was found
-     */
-    public String firstMatch(String pattern) {
-        return firstMatch(pattern, 0);
-    }
-
-    /**
-     * Verify the exit value of the process
-     *
-     * @param expectedExitValue
-     *            Expected exit value from process
-     * @throws RuntimeException
-     *             If the exit value from the process did not match the expected
-     *             value
-     */
-    public OutputAnalyzer shouldHaveExitValue(int expectedExitValue) {
-        if (getExitValue() != expectedExitValue) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("Expected to get exit value of ["
-                    + expectedExitValue + "]\n");
-        }
-        return this;
-    }
-
-    /**
-     * Report summary that will help to diagnose the problem Currently includes:
-     * - standard input produced by the process under test - standard output -
-     * exit code Note: the command line is printed by the ProcessTools
-     */
-    private OutputAnalyzer reportDiagnosticSummary() {
-        String msg = " stdout: [" + getStdout() + "];\n" + " stderr: [" + getStderr()
-                + "]\n" + " exitValue = " + getExitValue() + "\n";
-
-        System.err.println(msg);
-        return this;
-    }
-
-    /**
-     * Get the contents of the output buffer (stdout and stderr)
-     *
-     * @return Content of the output buffer
-     */
-    public String getOutput() {
-        return getStdout() + getStderr();
-    }
-
-    /**
-     * Get the contents of the stdout buffer
-     *
-     * @return Content of the stdout buffer
-     */
-    public String getStdout() {
-        return output == null ? stdout : output.getStdout();
-    }
-
-    /**
-     * Get the contents of the stderr buffer
-     *
-     * @return Content of the stderr buffer
-     */
-    public String getStderr() {
-        return output == null ? stderr : output.getStderr();
-    }
-
-    /**
-     * Get the process exit value
-     *
-     * @return Process exit value
-     */
-    public int getExitValue() {
-        return output == null ? exitValue : output.getExitValue();
-    }
-
-
-    /**
-     * Print the stdout buffer to the given {@code PrintStream}.
-     *
-     * @return this OutputAnalyzer
-     */
-    public OutputAnalyzer outputTo(PrintStream out) {
-        out.println(getStdout());
-        return this;
-    }
-
-    /**
-     * Print the stderr buffer to the given {@code PrintStream}.
-     *
-     * @return this OutputAnalyzer
-     */
-    public OutputAnalyzer errorTo(PrintStream out) {
-        out.println(getStderr());
-        return this;
-    }
-
-
-    /**
-     * Get the contents of the output buffer (stdout and stderr)
-     * as a list of strings. Output will be split at new-lines as
-     * recognized by java.io.BufferedReader.readLine().
-     *
-     * @return Contents of the output buffer as list of strings
-     */
-    public List<String> asLines() {
-        return asLines(getOutput());
-    }
-
-    private List<String> asLines(String buffer) {
-        return new BufferedReader(new StringReader(buffer))
-            .lines().collect(Collectors.toList());
-    }
-
-    /**
-     * Check if there is a line matching {@code pattern} and return its index
-     *
-     * @param pattern Matching pattern
-     * @return Index of first matching line
-     */
-    private int indexOf(List<String> lines, String pattern) {
-        for (int i = 0; i < lines.size(); i++) {
-            if (lines.get(i).matches(pattern)) {
-                return i;
-            }
-        }
-        return -1;
-    }
-
-    /**
-     * @see #shouldMatchByLine(String, String, String)
-     */
-    public int shouldMatchByLine(String pattern) {
-        return shouldMatchByLine(null, null, pattern);
-    }
-
-    /**
-     * @see #stdoutShouldMatchByLine(String, String, String)
-     */
-    public int stdoutShouldMatchByLine(String pattern) {
-        return stdoutShouldMatchByLine(null, null, pattern);
-    }
-
-    /**
-     * @see #shouldMatchByLine(String, String, String)
-     */
-    public int shouldMatchByLineFrom(String from, String pattern) {
-        return shouldMatchByLine(from, null, pattern);
-    }
-
-    /**
-     * @see #shouldMatchByLine(String, String, String)
-     */
-    public int shouldMatchByLineTo(String to, String pattern) {
-        return shouldMatchByLine(null, to, pattern);
-    }
-
-    /**
-     * Verify that the stdout and stderr contents of output buffer match the
-     * {@code pattern} line by line. The whole output could be matched or
-     * just a subset of it.
-     *
-     * @param from
-     *            The line from where output will be matched.
-     *            Set {@code from} to null for matching from the first line.
-     * @param to
-     *            The line until where output will be matched.
-     *            Set {@code to} to null for matching until the last line.
-     * @param pattern
-     *            Matching pattern
-     * @return Count of lines which match the {@code pattern}
-     */
-    public int shouldMatchByLine(String from, String to, String pattern) {
-        return shouldMatchByLine(getOutput(), from, to, pattern);
-    }
-
-    /**
-     * Verify that the stdout contents of output buffer matches the
-     * {@code pattern} line by line. The whole stdout could be matched or
-     * just a subset of it.
-     *
-     * @param from
-     *            The line from where stdout will be matched.
-     *            Set {@code from} to null for matching from the first line.
-     * @param to
-     *            The line until where stdout will be matched.
-     *            Set {@code to} to null for matching until the last line.
-     * @param pattern
-     *            Matching pattern
-     * @return Count of lines which match the {@code pattern}
-     */
-    public int stdoutShouldMatchByLine(String from, String to, String pattern) {
-        return shouldMatchByLine(getStdout(), from, to, pattern);
-    }
-
-    private int shouldMatchByLine(String buffer, String from, String to, String pattern) {
-        List<String> lines = asLines(buffer);
-
-        int fromIndex = 0;
-        if (from != null) {
-            fromIndex = indexOf(lines, from);
-            assertGreaterThan(fromIndex, -1,
-                    "The line/pattern '" + from + "' from where the output should match can not be found");
-        }
-
-        int toIndex = lines.size();
-        if (to != null) {
-            toIndex = indexOf(lines, to);
-            assertGreaterThan(toIndex, -1,
-                    "The line/pattern '" + to + "' until where the output should match can not be found");
-        }
-
-        List<String> subList = lines.subList(fromIndex, toIndex);
-        int matchedCount = 0;
-        for (String line : subList) {
-            assertTrue(line.matches(pattern),
-                    "The line '" + line + "' does not match pattern '" + pattern + "'");
-            matchedCount++;
-        }
-
-        return matchedCount;
-    }
-
-}
--- a/test/jdk/lib/testlibrary/jdk/testlibrary/OutputBuffer.java	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.io.ByteArrayOutputStream;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-/**
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/jdk/test/lib/process}
- */
-@Deprecated
-class OutputBuffer {
-    private static class OutputBufferException extends RuntimeException {
-        private static final long serialVersionUID = 8528687792643129571L;
-
-        public OutputBufferException(Throwable cause) {
-            super(cause);
-        }
-    }
-
-    private final Process p;
-    private final Future<Void> outTask;
-    private final Future<Void> errTask;
-    private final ByteArrayOutputStream stderrBuffer = new ByteArrayOutputStream();
-    private final ByteArrayOutputStream stdoutBuffer = new ByteArrayOutputStream();
-
-    /**
-     * Create an OutputBuffer, a class for storing and managing stdout and
-     * stderr results separately
-     *
-     * @param stdout
-     *            stdout result
-     * @param stderr
-     *            stderr result
-     */
-    OutputBuffer(Process p) {
-        this.p = p;
-        StreamPumper outPumper = new StreamPumper(p.getInputStream(),
-                stdoutBuffer);
-        StreamPumper errPumper = new StreamPumper(p.getErrorStream(),
-                stderrBuffer);
-
-        outTask = outPumper.process();
-        errTask = errPumper.process();
-    }
-
-    /**
-     * Returns the stdout result
-     *
-     * @return stdout result
-     */
-    public String getStdout() {
-        try {
-            outTask.get();
-            return stdoutBuffer.toString();
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-            throw new OutputBufferException(e);
-        } catch (ExecutionException | CancellationException e) {
-            throw new OutputBufferException(e);
-        }
-    }
-
-    /**
-     * Returns the stderr result
-     *
-     * @return stderr result
-     */
-    public String getStderr() {
-        try {
-            errTask.get();
-            return stderrBuffer.toString();
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-            throw new OutputBufferException(e);
-        } catch (ExecutionException | CancellationException e) {
-            throw new OutputBufferException(e);
-        }
-    }
-
-    public int getExitValue() {
-        try {
-            return p.waitFor();
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-            throw new OutputBufferException(e);
-        }
-    }
-}
--- a/test/jdk/lib/testlibrary/jdk/testlibrary/ProcessTools.java	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,560 +0,0 @@
-/*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.concurrent.CountDownLatch;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.function.Predicate;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-
-
-/**
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/jdk/test/lib/process}
- */
-@Deprecated
-public final class ProcessTools {
-    private static final class LineForwarder extends StreamPumper.LinePump {
-        private final PrintStream ps;
-        private final String prefix;
-        LineForwarder(String prefix, PrintStream os) {
-            this.ps = os;
-            this.prefix = prefix;
-        }
-        @Override
-        protected void processLine(String line) {
-            ps.println("[" + prefix + "] " + line);
-        }
-    }
-
-    private ProcessTools() {
-    }
-
-    /**
-     * <p>Starts a process from its builder.</p>
-     * <span>The default redirects of STDOUT and STDERR are started</span>
-     * @param name The process name
-     * @param processBuilder The process builder
-     * @return Returns the initialized process
-     * @throws IOException
-     */
-    public static Process startProcess(String name,
-                                       ProcessBuilder processBuilder)
-    throws IOException {
-        return startProcess(name, processBuilder, (Consumer<String>)null);
-    }
-
-    /**
-     * <p>Starts a process from its builder.</p>
-     * <span>The default redirects of STDOUT and STDERR are started</span>
-     * <p>It is possible to monitor the in-streams via the provided {@code consumer}
-     * @param name The process name
-     * @param consumer {@linkplain Consumer} instance to process the in-streams
-     * @param processBuilder The process builder
-     * @return Returns the initialized process
-     * @throws IOException
-     */
-    @SuppressWarnings("overloads")
-    public static Process startProcess(String name,
-                                       ProcessBuilder processBuilder,
-                                       Consumer<String> consumer)
-    throws IOException {
-        try {
-            return startProcess(name, processBuilder, consumer, null, -1, TimeUnit.NANOSECONDS);
-        } catch (InterruptedException | TimeoutException e) {
-            // will never happen
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * <p>Starts a process from its builder.</p>
-     * <span>The default redirects of STDOUT and STDERR are started</span>
-     * <p>
-     * It is possible to wait for the process to get to a warmed-up state
-     * via {@linkplain Predicate} condition on the STDOUT
-     * </p>
-     * @param name The process name
-     * @param processBuilder The process builder
-     * @param linePredicate The {@linkplain Predicate} to use on the STDOUT
-     *                      Used to determine the moment the target app is
-     *                      properly warmed-up.
-     *                      It can be null - in that case the warmup is skipped.
-     * @param timeout The timeout for the warmup waiting; -1 = no wait; 0 = wait forever
-     * @param unit The timeout {@linkplain TimeUnit}
-     * @return Returns the initialized {@linkplain Process}
-     * @throws IOException
-     * @throws InterruptedException
-     * @throws TimeoutException
-     */
-    public static Process startProcess(String name,
-                                       ProcessBuilder processBuilder,
-                                       final Predicate<String> linePredicate,
-                                       long timeout,
-                                       TimeUnit unit)
-    throws IOException, InterruptedException, TimeoutException {
-        return startProcess(name, processBuilder, null, linePredicate, timeout, unit);
-    }
-
-    /**
-     * <p>Starts a process from its builder.</p>
-     * <span>The default redirects of STDOUT and STDERR are started</span>
-     * <p>
-     * It is possible to wait for the process to get to a warmed-up state
-     * via {@linkplain Predicate} condition on the STDOUT and monitor the
-     * in-streams via the provided {@linkplain Consumer}
-     * </p>
-     * @param name The process name
-     * @param processBuilder The process builder
-     * @param lineConsumer  The {@linkplain Consumer} the lines will be forwarded to
-     * @param linePredicate The {@linkplain Predicate} to use on the STDOUT
-     *                      Used to determine the moment the target app is
-     *                      properly warmed-up.
-     *                      It can be null - in that case the warmup is skipped.
-     * @param timeout The timeout for the warmup waiting; -1 = no wait; 0 = wait forever
-     * @param unit The timeout {@linkplain TimeUnit}
-     * @return Returns the initialized {@linkplain Process}
-     * @throws IOException
-     * @throws InterruptedException
-     * @throws TimeoutException
-     */
-    public static Process startProcess(String name,
-                                       ProcessBuilder processBuilder,
-                                       final Consumer<String> lineConsumer,
-                                       final Predicate<String> linePredicate,
-                                       long timeout,
-                                       TimeUnit unit)
-    throws IOException, InterruptedException, TimeoutException {
-        System.out.println("["+name+"]:" + processBuilder.command().stream().collect(Collectors.joining(" ")));
-        Process p = processBuilder.start();
-        StreamPumper stdout = new StreamPumper(p.getInputStream());
-        StreamPumper stderr = new StreamPumper(p.getErrorStream());
-
-        stdout.addPump(new LineForwarder(name, System.out));
-        stderr.addPump(new LineForwarder(name, System.err));
-        if (lineConsumer != null) {
-            StreamPumper.LinePump pump = new StreamPumper.LinePump() {
-                @Override
-                protected void processLine(String line) {
-                    lineConsumer.accept(line);
-                }
-            };
-            stdout.addPump(pump);
-            stderr.addPump(pump);
-        }
-
-
-        CountDownLatch latch = new CountDownLatch(1);
-        if (linePredicate != null) {
-            StreamPumper.LinePump pump = new StreamPumper.LinePump() {
-                @Override
-                protected void processLine(String line) {
-                    if (latch.getCount() > 0 && linePredicate.test(line)) {
-                        latch.countDown();
-                    }
-                }
-            };
-            stdout.addPump(pump);
-            stderr.addPump(pump);
-        } else {
-            latch.countDown();
-        }
-        final Future<Void> stdoutTask = stdout.process();
-        final Future<Void> stderrTask = stderr.process();
-
-        try {
-            if (timeout > -1) {
-                if (timeout == 0) {
-                    latch.await();
-                } else {
-                    if (!latch.await(Utils.adjustTimeout(timeout), unit)) {
-                        throw new TimeoutException();
-                    }
-                }
-            }
-        } catch (TimeoutException | InterruptedException e) {
-            System.err.println("Failed to start a process (thread dump follows)");
-            for(Map.Entry<Thread, StackTraceElement[]> s : Thread.getAllStackTraces().entrySet()) {
-                printStack(s.getKey(), s.getValue());
-            }
-
-            if (p.isAlive()) {
-                p.destroyForcibly();
-            }
-
-            stdoutTask.cancel(true);
-            stderrTask.cancel(true);
-            throw e;
-        }
-
-        return new ProcessImpl(p, stdoutTask, stderrTask);
-    }
-
-    /**
-     * <p>Starts a process from its builder.</p>
-     * <span>The default redirects of STDOUT and STDERR are started</span>
-     * <p>
-     * It is possible to wait for the process to get to a warmed-up state
-     * via {@linkplain Predicate} condition on the STDOUT. The warm-up will
-     * wait indefinitely.
-     * </p>
-     * @param name The process name
-     * @param processBuilder The process builder
-     * @param linePredicate The {@linkplain Predicate} to use on the STDOUT
-     *                      Used to determine the moment the target app is
-     *                      properly warmed-up.
-     *                      It can be null - in that case the warmup is skipped.
-     * @return Returns the initialized {@linkplain Process}
-     * @throws IOException
-     * @throws InterruptedException
-     * @throws TimeoutException
-     */
-    @SuppressWarnings("overloads")
-    public static Process startProcess(String name,
-                                       ProcessBuilder processBuilder,
-                                       final Predicate<String> linePredicate)
-    throws IOException, InterruptedException, TimeoutException {
-        return startProcess(name, processBuilder, linePredicate, 0, TimeUnit.SECONDS);
-    }
-
-    /**
-     * Get the process id of the current running Java process
-     *
-     * @return Process id
-     */
-    public static long getProcessId() {
-        return ProcessHandle.current().pid();
-    }
-
-    /**
-     * Create ProcessBuilder using the java launcher from the jdk to be tested,
-     * and with any platform specific arguments prepended.
-     *
-     * @param command Arguments to pass to the java command.
-     * @return The ProcessBuilder instance representing the java command.
-     */
-    public static ProcessBuilder createJavaProcessBuilder(String... command) {
-        return createJavaProcessBuilder(false, command);
-    }
-
-    /**
-     * Create ProcessBuilder using the java launcher from the jdk to be tested,
-     * and with any platform specific arguments prepended.
-     *
-     * @param addTestVmAndJavaOptions If true, adds test.vm.opts and test.java.opts
-     *        to the java arguments.
-     * @param command Arguments to pass to the java command.
-     * @return The ProcessBuilder instance representing the java command.
-     */
-    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) {
-        String javapath = JDKToolFinder.getJDKTool("java");
-
-        ArrayList<String> args = new ArrayList<>();
-        args.add(javapath);
-
-        if (addTestVmAndJavaOptions) {
-            // -cp is needed to make sure the same classpath is used whether the test is
-            // run in AgentVM mode or OtherVM mode. It was added to the hotspot version
-            // of this API as part of 8077608. However, for the jdk version it is only
-            // added when addTestVmAndJavaOptions is true in order to minimize
-            // disruption to existing JDK tests, which have yet to be tested with -cp
-            // being added. At some point -cp should always be added to be consistent
-            // with what the hotspot version does.
-            args.add("-cp");
-            args.add(System.getProperty("java.class.path"));
-            Collections.addAll(args, Utils.getTestJavaOpts());
-        }
-
-        Collections.addAll(args, command);
-
-        // Reporting
-        StringBuilder cmdLine = new StringBuilder();
-        for (String cmd : args)
-            cmdLine.append(cmd).append(' ');
-        System.out.println("Command line: [" + cmdLine.toString() + "]");
-
-        return new ProcessBuilder(args.toArray(new String[args.size()]));
-    }
-
-    private static void printStack(Thread t, StackTraceElement[] stack) {
-        System.out.println("\t" +  t +
-                           " stack: (length = " + stack.length + ")");
-        if (t != null) {
-            for (StackTraceElement stack1 : stack) {
-                System.out.println("\t" + stack1);
-            }
-            System.out.println();
-        }
-    }
-
-    /**
-     * Executes a test java process, waits for it to finish and returns the process output.
-     * The default options from jtreg, test.vm.opts and test.java.opts, are added.
-     * The java from the test.jdk is used to execute the command.
-     *
-     * The command line will be like:
-     * {test.jdk}/bin/java {test.vm.opts} {test.java.opts} cmds
-     *
-     * The java process will have exited before this method returns.
-     *
-     * @param cmds User specifed arguments.
-     * @return The output from the process.
-     */
-    public static OutputAnalyzer executeTestJava(String... options) throws Exception {
-        ProcessBuilder pb = createJavaProcessBuilder(Utils.addTestJavaOpts(options));
-        return executeProcess(pb);
-    }
-
-    /**
-     * @deprecated Use executeTestJava instead
-     */
-    public static OutputAnalyzer executeTestJvm(String... options) throws Exception {
-        return executeTestJava(options);
-    }
-
-    /**
-     * Executes a process, waits for it to finish and returns the process output.
-     * The process will have exited before this method returns.
-     * @param pb The ProcessBuilder to execute.
-     * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
-     */
-    public static OutputAnalyzer executeProcess(ProcessBuilder pb) throws Exception {
-        return executeProcess(pb, null);
-    }
-
-    /**
-     * Executes a process, pipe some text into its STDIN, waits for it
-     * to finish and returns the process output. The process will have exited
-     * before this method returns.
-     * @param pb The ProcessBuilder to execute.
-     * @param input The text to pipe into STDIN. Can be null.
-     * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
-     */
-    public static OutputAnalyzer executeProcess(ProcessBuilder pb, String input)
-            throws Exception {
-        OutputAnalyzer output = null;
-        Process p = null;
-        boolean failed = false;
-        try {
-            p = pb.start();
-            if (input != null) {
-                try (OutputStream os = p.getOutputStream();
-                        PrintStream ps = new PrintStream(os)) {
-                    ps.print(input);
-                    ps.flush();
-                }
-            }
-            output = new OutputAnalyzer(p);
-            p.waitFor();
-
-            return output;
-        } catch (Throwable t) {
-            if (p != null) {
-                p.destroyForcibly().waitFor();
-            }
-
-            failed = true;
-            System.out.println("executeProcess() failed: " + t);
-            throw t;
-        } finally {
-            if (failed) {
-                System.err.println(getProcessLog(pb, output));
-            }
-        }
-    }
-
-    /**
-     * Executes a process, waits for it to finish and returns the process output.
-     *
-     * The process will have exited before this method returns.
-     *
-     * @param cmds The command line to execute.
-     * @return The output from the process.
-     */
-    public static OutputAnalyzer executeProcess(String... cmds) throws Exception {
-        return executeProcess(new ProcessBuilder(cmds));
-    }
-
-    /**
-     * Used to log command line, stdout, stderr and exit code from an executed process.
-     * @param pb The executed process.
-     * @param output The output from the process.
-     */
-    public static String getProcessLog(ProcessBuilder pb, OutputAnalyzer output) {
-        String stderr = output == null ? "null" : output.getStderr();
-        String stdout = output == null ? "null" : output.getStdout();
-        String exitValue = output == null ? "null": Integer.toString(output.getExitValue());
-        StringBuilder logMsg = new StringBuilder();
-        final String nl = System.getProperty("line.separator");
-        logMsg.append("--- ProcessLog ---" + nl);
-        logMsg.append("cmd: " + getCommandLine(pb) + nl);
-        logMsg.append("exitvalue: " + exitValue + nl);
-        logMsg.append("stderr: " + stderr + nl);
-        logMsg.append("stdout: " + stdout + nl);
-
-        return logMsg.toString();
-    }
-
-    /**
-     * @return The full command line for the ProcessBuilder.
-     */
-    public static String getCommandLine(ProcessBuilder pb) {
-        if (pb == null) {
-            return "null";
-        }
-        StringBuilder cmd = new StringBuilder();
-        for (String s : pb.command()) {
-            cmd.append(s).append(" ");
-        }
-        return cmd.toString().trim();
-    }
-
-    /**
-     * Executes a process, waits for it to finish, prints the process output
-     * to stdout, and returns the process output.
-     *
-     * The process will have exited before this method returns.
-     *
-     * @param cmds The command line to execute.
-     * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
-     */
-    public static OutputAnalyzer executeCommand(String... cmds)
-            throws Throwable {
-        String cmdLine = Arrays.stream(cmds).collect(Collectors.joining(" "));
-        System.out.println("Command line: [" + cmdLine + "]");
-        OutputAnalyzer analyzer = ProcessTools.executeProcess(cmds);
-        System.out.println(analyzer.getOutput());
-        return analyzer;
-    }
-
-    /**
-     * Executes a process, waits for it to finish, prints the process output
-     * to stdout and returns the process output.
-     *
-     * The process will have exited before this method returns.
-     *
-     * @param pb The ProcessBuilder to execute.
-     * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
-     */
-    public static OutputAnalyzer executeCommand(ProcessBuilder pb)
-            throws Throwable {
-        String cmdLine = pb.command().stream().collect(Collectors.joining(" "));
-        System.out.println("Command line: [" + cmdLine + "]");
-        OutputAnalyzer analyzer = ProcessTools.executeProcess(pb);
-        System.out.println(analyzer.getOutput());
-        return analyzer;
-    }
-
-    private static class ProcessImpl extends Process {
-
-        private final Process p;
-        private final Future<Void> stdoutTask;
-        private final Future<Void> stderrTask;
-
-        public ProcessImpl(Process p, Future<Void> stdoutTask, Future<Void> stderrTask) {
-            this.p = p;
-            this.stdoutTask = stdoutTask;
-            this.stderrTask = stderrTask;
-        }
-
-        @Override
-        public OutputStream getOutputStream() {
-            return p.getOutputStream();
-        }
-
-        @Override
-        public InputStream getInputStream() {
-            return p.getInputStream();
-        }
-
-        @Override
-        public InputStream getErrorStream() {
-            return p.getErrorStream();
-        }
-
-        @Override
-        public int waitFor() throws InterruptedException {
-            int rslt = p.waitFor();
-            waitForStreams();
-            return rslt;
-        }
-
-        @Override
-        public int exitValue() {
-            return p.exitValue();
-        }
-
-        @Override
-        public void destroy() {
-            p.destroy();
-        }
-
-        @Override
-        public long pid() {
-            return p.pid();
-        }
-
-        @Override
-        public boolean isAlive() {
-            return p.isAlive();
-        }
-
-        @Override
-        public Process destroyForcibly() {
-            return p.destroyForcibly();
-        }
-
-        @Override
-        public boolean waitFor(long timeout, TimeUnit unit) throws InterruptedException {
-            boolean rslt = p.waitFor(timeout, unit);
-            if (rslt) {
-                waitForStreams();
-            }
-            return rslt;
-        }
-
-        private void waitForStreams() throws InterruptedException {
-            try {
-                stdoutTask.get();
-            } catch (ExecutionException e) {
-            }
-            try {
-                stderrTask.get();
-            } catch (ExecutionException e) {
-            }
-        }
-    }
-}
--- a/test/jdk/lib/testlibrary/jdk/testlibrary/StreamPumper.java	Wed Aug 29 09:45:58 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,204 +0,0 @@
-/*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.Future;
-import java.util.concurrent.FutureTask;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/jdk/test/lib/process}
- */
-@Deprecated
-public final class StreamPumper implements Runnable {
-
-    private static final int BUF_SIZE = 256;
-
-    /**
-     * Pump will be called by the StreamPumper to process the incoming data
-     */
-    abstract public static class Pump {
-        abstract void register(StreamPumper d);
-    }
-
-    /**
-     * OutputStream -> Pump adapter
-     */
-    final public static class StreamPump extends Pump {
-        private final OutputStream out;
-        public StreamPump(OutputStream out) {
-            this.out = out;
-        }
-
-        @Override
-        void register(StreamPumper sp) {
-            sp.addOutputStream(out);
-        }
-    }
-
-    /**
-     * Used to process the incoming data line-by-line
-     */
-    abstract public static class LinePump extends Pump {
-        @Override
-        final void register(StreamPumper sp) {
-            sp.addLineProcessor(this);
-        }
-
-        abstract protected void processLine(String line);
-    }
-
-    private final InputStream in;
-    private final Set<OutputStream> outStreams = new HashSet<>();
-    private final Set<LinePump> linePumps = new HashSet<>();
-
-    private final AtomicBoolean processing = new AtomicBoolean(false);
-    private final FutureTask<Void> processingTask = new FutureTask<>(this, null);
-
-    public StreamPumper(InputStream in) {
-        this.in = in;
-    }
-
-    /**
-     * Create a StreamPumper that reads from in and writes to out.
-     *
-     * @param in
-     *            The stream to read from.
-     * @param out
-     *            The stream to write to.
-     */
-    public StreamPumper(InputStream in, OutputStream out) {
-        this(in);
-        this.addOutputStream(out);
-    }
-
-    /**
-     * Implements Thread.run(). Continuously read from {@code in} and write to
-     * {@code out} until {@code in} has reached end of stream. Abort on
-     * interruption. Abort on IOExceptions.
-     */
-    @Override
-    public void run() {
-        try (BufferedInputStream is = new BufferedInputStream(in)) {
-            ByteArrayOutputStream lineBos = new ByteArrayOutputStream();
-            byte[] buf = new byte[BUF_SIZE];
-            int len = 0;
-            int linelen = 0;
-
-            while ((len = is.read(buf)) > 0 && !Thread.interrupted()) {
-                for(OutputStream out : outStreams) {
-                    out.write(buf, 0, len);
-                }
-                if (!linePumps.isEmpty()) {
-                    int i = 0;
-                    int lastcrlf = -1;
-                    while (i < len) {
-                        if (buf[i] == '\n' || buf[i] == '\r') {
-                            int bufLinelen = i - lastcrlf - 1;
-                            if (bufLinelen > 0) {
-                                lineBos.write(buf, lastcrlf + 1, bufLinelen);
-                            }
-                            linelen += bufLinelen;
-
-                            if (linelen > 0) {
-                                lineBos.flush();
-                                final String line = lineBos.toString();
-                                linePumps.stream().forEach((lp) -> {
-                                    lp.processLine(line);
-                                });
-                                lineBos.reset();
-                                linelen = 0;
-                            }
-                            lastcrlf = i;
-                        }
-
-                        i++;
-                    }
-                    if (lastcrlf == -1) {
-                        lineBos.write(buf, 0, len);
-                        linelen += len;
-                    } else if (lastcrlf < len - 1) {
-                        lineBos.write(buf, lastcrlf + 1, len - lastcrlf - 1);
-                        linelen += len - lastcrlf - 1;
-                    }
-                }
-            }
-
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            for(OutputStream out : outStreams) {
-                try {
-                    out.flush();
-                } catch (IOException e) {}
-            }
-            try {
-                in.close();
-            } catch (IOException e) {}
-        }
-    }
-
-    final void addOutputStream(OutputStream out) {
-        outStreams.add(out);
-    }
-
-    final void addLineProcessor(LinePump lp) {
-        linePumps.add(lp);
-    }
-
-    final public StreamPumper addPump(Pump ... pump) {
-        if (processing.get()) {
-            throw new IllegalStateException("Can not modify pumper while " +
-                                            "processing is in progress");
-        }
-        for(Pump p : pump) {
-            p.register(this);
-        }
-        return this;
-    }
-
-    final public Future<Void> process() {
-        if (!processing.compareAndSet(false, true)) {
-            throw new IllegalStateException("Can not re-run the processing");
-        }
-        Thread t = new Thread(new Runnable() {
-            @Override
-            public void run() {
-                processingTask.run();
-            }
-        });
-        t.setDaemon(true);
-        t.start();
-
-        return processingTask;
-    }
-}
--- a/test/jdk/native_sanity/simplenativelauncher/ProgramTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/native_sanity/simplenativelauncher/ProgramTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,14 +23,14 @@
 
  /*
  * @test
- * @library /lib/testlibrary
- * @build jdk.testlibrary.OutputAnalyzer
+ * @library /test/lib
+ * @build jdk.test.lib.process.OutputAnalyzer
  * @build ProgramTest
  * @run main/native ProgramTest
  */
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 public class ProgramTest {
     public static void main(String... args) throws Exception {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sanity/client/SwingSet/src/ToolTipDemoTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,140 @@
+/*
+ * 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.
+ */
+
+import static com.sun.swingset3.demos.tooltip.ToolTipDemo.DEMO_TITLE;
+import static com.sun.swingset3.demos.tooltip.ToolTipDemo.HTML_TOOLTIP_COMP_TITLE;
+import static com.sun.swingset3.demos.tooltip.ToolTipDemo.HTML_TOOLTIP_TEXT;
+import static com.sun.swingset3.demos.tooltip.ToolTipDemo.PLAIN_TOOLTIP_COMP_TITLE;
+import static com.sun.swingset3.demos.tooltip.ToolTipDemo.PLAIN_TOOLTIP_TEXT;
+import static com.sun.swingset3.demos.tooltip.ToolTipDemo.STYLE_TOOLTIP_COMP_TITLE;
+import static com.sun.swingset3.demos.tooltip.ToolTipDemo.STYLE_TOOLTIP_TEXT;
+import static org.jemmy2ext.JemmyExt.EXACT_STRING_COMPARATOR;
+
+import java.awt.Dimension;
+import java.awt.Point;
+
+import javax.swing.ToolTipManager;
+
+import org.jtregext.GuiTestListener;
+import org.netbeans.jemmy.ClassReference;
+import org.netbeans.jemmy.operators.JComponentOperator;
+import org.netbeans.jemmy.operators.JFrameOperator;
+import org.netbeans.jemmy.operators.JLabelOperator;
+import org.netbeans.jemmy.operators.JToolTipOperator;
+import org.testng.annotations.Listeners;
+import org.testng.annotations.Test;
+
+import com.sun.swingset3.demos.tooltip.ToolTipDemo;
+
+/*
+ * @test
+ * @key headful
+ * @summary Verifies SwingSet3 ToolTipDemo page by checking whether tooltip
+ *  shown or removed on user actions, tooltip text, location, number of
+ *  tooltips shown at a time, with different tooltip texts plain, html and
+ *  styled.
+ *
+ * @library /sanity/client/lib/jemmy/src
+ * @library /sanity/client/lib/Extensions/src
+ * @library /sanity/client/lib/SwingSet3/src
+ * @modules java.desktop
+ *         java.logging
+ * @build org.jemmy2ext.JemmyExt
+ * @build com.sun.swingset3.demos.tooltip.ToolTipDemo
+ * @run testng ToolTipDemoTest
+ */
+@Listeners(GuiTestListener.class)
+public class ToolTipDemoTest {
+
+    private static int TOOLTIP_DISMISS_DELAY = 60000;
+
+    /**
+     * Testing whether tooltip shown while keeping the mouse on label, removed
+     * on mouse press, tooltip text, location, number of tooltips shown at a
+     * time with different tooltip texts plain, html and styled.
+     *
+     * @throws Exception
+     */
+    @Test
+    public void test() throws Exception {
+        new ClassReference(ToolTipDemo.class.getCanonicalName()).startApplication();
+        JFrameOperator frameOperator = new JFrameOperator(DEMO_TITLE);
+        frameOperator.setComparator(EXACT_STRING_COMPARATOR);
+        // Setting the tooltip dismiss delay
+        ToolTipManager.sharedInstance().setDismissDelay(TOOLTIP_DISMISS_DELAY);
+
+        // Verifying the plain tooltip properties
+        checkToolTip(frameOperator, PLAIN_TOOLTIP_COMP_TITLE,
+                PLAIN_TOOLTIP_TEXT);
+        // Verifying the html tooltip properties
+        checkToolTip(frameOperator, HTML_TOOLTIP_COMP_TITLE,
+                HTML_TOOLTIP_TEXT);
+        // Verifying the styled tooltip properties
+        checkToolTip(frameOperator, STYLE_TOOLTIP_COMP_TITLE,
+                STYLE_TOOLTIP_TEXT);
+
+        // Reducing the frame size to half and verifying that tooltip shown
+        // even it goes out of the window
+        Dimension newSize = new Dimension(frameOperator.getWidth() / 2,
+                frameOperator.getHeight() / 2);
+        frameOperator.resize(newSize.width, newSize.height);
+        frameOperator.waitComponentSize(newSize);
+        checkToolTip(frameOperator, HTML_TOOLTIP_COMP_TITLE,
+                HTML_TOOLTIP_TEXT);
+    }
+
+    /**
+     * Shows the tooltip on specified component and verifies the properties
+     * tooltip text, location. And dismisses thetooltip after verification of
+     * the properties.
+     *
+     * @param frameOperator
+     * @param compTitle
+     * @param toolTipText
+     */
+    private void checkToolTip(JFrameOperator frameOperator, String compTitle,
+            String toolTipText) {
+
+        JLabelOperator toolTipHostComp =
+                new JLabelOperator(frameOperator, compTitle);
+        JToolTipOperator toolTipOperator =
+                new JToolTipOperator(toolTipHostComp.showToolTip());
+        toolTipOperator.waitTipText(toolTipText);
+        checkToolTipLocation(toolTipHostComp, toolTipOperator);
+
+        // Dismissing the tooltip by mouse click
+        toolTipHostComp.clickMouse();
+        toolTipOperator.waitComponentShowing(false);
+
+    }
+
+    private void checkToolTipLocation(JComponentOperator componentOpertor,
+                JToolTipOperator toolTipOperator) {
+        Point labelStartPoint = componentOpertor.getLocationOnScreen();
+        Dimension labelSize = componentOpertor.getSize();
+        Point labelEndPoint = new Point((labelStartPoint.x + labelSize.width),
+                (labelStartPoint.y + labelSize.height));
+        toolTipOperator.waitComponentLocationOnScreen(
+                labelStartPoint, labelEndPoint);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/tooltip/ToolTipDemo.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,160 @@
+/*
+ * 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 com.sun.swingset3.demos.tooltip;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Rectangle;
+
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import com.sun.swingset3.DemoProperties;
+import com.sun.swingset3.demos.ResourceManager;
+
+/**
+ * ToolTip Demo
+ *
+ * @version 1.9 11/17/05
+ * @author Jeff Dinkins
+ */
+@DemoProperties(
+        value = "ToolTips Demo",
+        category = "General",
+        description = "Demonstrates how tooltips can be easily added to Swing GUI components",
+        sourceFiles = {
+                "com/sun/swingset3/demos/tooltip/ToolTipDemo.java",
+                "com/sun/swingset3/demos/ResourceManager.java",
+                "com/sun/swingset3/demos/tooltip/resources/ToolTipDemo.properties",
+                "com/sun/swingset3/demos/tooltip/resources/images/tooltip_background.png",
+                "com/sun/swingset3/demos/tooltip/resources/images/ToolTipDemo.gif"
+                }
+)
+public class ToolTipDemo extends JPanel {
+
+    public static final String DEMO_TITLE = ToolTipDemo.class.getAnnotation(DemoProperties.class).value();
+    private final static ResourceManager resourceManager = new ResourceManager(ToolTipDemo.class);
+    public static final String PLAIN_TOOLTIP_COMP_TITLE = resourceManager.getString("ToolTipDemo.plain");;
+    public static final String PLAIN_TOOLTIP_TEXT = "A simple one line tip.";
+    public static final String HTML_TOOLTIP_COMP_TITLE = resourceManager.getString("ToolTipDemo.html");;
+    public static final String HTML_TOOLTIP_TEXT = "<html><body bgcolor=\"#AABBFF\">In case you thought that tooltips had to be<p>" +
+            "boring, one line descriptions, the <font color=blue size=+2>Swing!</font> team<p>" +
+            "is happy to shatter your illusions.<p>" +
+            "In Swing, you can use HTML to <ul><li>Have Lists<li><b>Bold</b> text<li><em>emphasized</em>" +
+            "text<li>text with <font color=red>Color</font><li>text in different <font size=+3>sizes</font>" +
+            "<li>and <font face=AvantGarde>Fonts</font></ul>Oh, and they can be multi-line, too.</body></html>";
+    public static final String STYLE_TOOLTIP_COMP_TITLE = resourceManager.getString("ToolTipDemo.styled");
+    public static final String STYLE_TOOLTIP_TEXT = "<html>Tips can be styled to be" +
+            "<br><b>interesting</b> and <i>fun</i></html>";
+
+    /**
+     * main method allows us to run as a standalone demo.
+     */
+    public static void main(String[] args) {
+        JFrame frame = new JFrame(ToolTipDemo.class.getAnnotation(DemoProperties.class).value());
+
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.getContentPane().add(new ToolTipDemo());
+        frame.setPreferredSize(new Dimension(800, 600));
+        frame.pack();
+        frame.setLocationRelativeTo(null);
+        frame.setVisible(true);
+    }
+
+    /**
+     * ToolTipDemo Constructor
+     */
+    public ToolTipDemo() {
+        setLayout(new BorderLayout());
+
+        // Create a panel which contains specific tooltip regions.
+        Toolbox toolbox = new Toolbox();
+
+        add(toolbox, BorderLayout.CENTER);
+    }
+
+    public class Toolbox extends JPanel {
+        private final Rectangle plainRect = new Rectangle(44, 0, 186, 128);
+        private final Rectangle htmlRect = new Rectangle(240, 134, 186, 186);
+        private final Rectangle styledRect = new Rectangle(45, 327, 188, 134);
+
+        private final JLabel background;
+        private final JComponent plainToolTipRegion;
+        private final JComponent htmlToolTipRegion;
+        private final JComponent styledToolTipRegion;
+
+        public Toolbox() {
+            setLayout(null);
+
+            background = new JLabel(resourceManager.createImageIcon("tooltip_background.png",
+                    resourceManager.getString("ToolTipDemo.toolbox")));
+
+            background.setVerticalAlignment(JLabel.TOP);
+            background.setHorizontalAlignment(JLabel.LEFT);
+
+            // Note: tooltip text isn't retrieved from properties file in order
+            // to make this code easier to understand
+
+            //<snip>Create region for displaying plain tooltip
+            plainToolTipRegion = createToolTipRegion(PLAIN_TOOLTIP_COMP_TITLE);
+            plainToolTipRegion.setToolTipText(PLAIN_TOOLTIP_TEXT);
+            //</snip>
+
+            //<snip>Create region for displaying HTML tooltip
+            htmlToolTipRegion = createToolTipRegion(HTML_TOOLTIP_COMP_TITLE);
+            htmlToolTipRegion.setToolTipText(HTML_TOOLTIP_TEXT);
+            //</snip>
+
+            //<snip>Create region for displaying styled tooltip
+            styledToolTipRegion = createToolTipRegion(STYLE_TOOLTIP_COMP_TITLE);
+            styledToolTipRegion.setToolTipText(STYLE_TOOLTIP_TEXT);
+            //</snip>
+
+            add(htmlToolTipRegion);
+            add(styledToolTipRegion);
+            add(plainToolTipRegion);
+
+            add(background);
+        }
+
+        public void doLayout() {
+            background.setBounds(0, 0, getWidth(), getHeight());
+            plainToolTipRegion.setBounds(plainRect);
+            htmlToolTipRegion.setBounds(htmlRect);
+            styledToolTipRegion.setBounds(styledRect);
+        }
+
+        private JComponent createToolTipRegion(String text) {
+            JLabel region = new JLabel(text);
+            region.setForeground(Color.white);
+            region.setFont(getFont().deriveFont(18f));
+            region.setHorizontalAlignment(JLabel.CENTER);
+            region.setVerticalAlignment(JLabel.CENTER);
+            return region;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/tooltip/resources/ToolTipDemo.properties	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,10 @@
+### ToolTip Demo ###
+
+ToolTipDemo.accessible_description=ToolTips show short help descriptions for a component
+ToolTipDemo.tooltip=ToolTip demo
+ToolTipDemo.name=ToolTip Demo
+ToolTipDemo.toolbox=Toolbox containing tooltip regions
+ToolTipDemo.plain=<html><p align="center">Roll over here<br>to see a tooltip</p></html>
+ToolTipDemo.html=<html><p align="center">Roll over this box<br>to see a tooltip<br>in HTML</p></html>
+ToolTipDemo.styled=<html><p align="center">Roll over here\nto see a tooltip<br> in styled text</p></html>
+
Binary file test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/tooltip/resources/images/ToolTipDemo.gif has changed
Binary file test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/tooltip/resources/images/tooltip_background.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/TeliaSoneraCA.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,195 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8210432
+ * @summary Interoperability tests with TeliaSonera Root CA v1
+ * @build ValidatePathWithParams
+ * @run main/othervm -Djava.security.debug=certpath TeliaSoneraCA OCSP
+ * @run main/othervm -Djava.security.debug=certpath TeliaSoneraCA CRL
+ */
+
+/*
+ * Obtain TLS test artifacts for TeliaSonera Root CA v1 from:
+ *
+ * Valid TLS Certificates:
+ * https://juolukka.cover.sonera.net:10443/
+ *
+ * Revoked TLS Certificates:
+ * https://juolukka.cover.sonera.net:10444/
+ */
+public class TeliaSoneraCA {
+
+    // Owner: CN=TeliaSonera Server CA v2, O=TeliaSonera, C=FI
+    // Issuer: CN=TeliaSonera Root CA v1, O=TeliaSonera
+    private static final String INT = "-----BEGIN CERTIFICATE-----\n"
+            + "MIIHHjCCBQagAwIBAgIQTEYq9tv794BPhMF8/qlytjANBgkqhkiG9w0BAQsFADA3\n"
+            + "MRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwWVGVsaWFTb25lcmEgUm9v\n"
+            + "dCBDQSB2MTAeFw0xNDEwMTYwODA5NTdaFw0zMjEwMTYwNTA0MDBaMEYxCzAJBgNV\n"
+            + "BAYTAkZJMRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEhMB8GA1UEAwwYVGVsaWFTb25l\n"
+            + "cmEgU2VydmVyIENBIHYyMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA\n"
+            + "rwQN5rfRLbVAiYWLJF9SI4YLm8oqrtf8OjGybgoLyiMIo8nhY/atuGRFWCQNOnUK\n"
+            + "caZn29C360PlC5yYrsrSHuouROisqHSJcgA7HvV+37Rcry7daeDj6rfyx4yI5dmj\n"
+            + "LwHkK0j1NzhX1JxFDgPeLNuebgzv/j8OfRhYK/BttpystC4Zgm3gZheKDjYsDS5D\n"
+            + "gjffuOysP3vewrcuw0EIZFx+HawuwNBLq4tMf4VSitYDHJSLIM2TeXZGGY5slTbT\n"
+            + "yLnrU5mIzG9WKqxyy7qHuFw1JtlAXkCLmUEVaF9M+dRPiGIjlDrpBgbDD9mT2CSk\n"
+            + "V/XG1696/voY5xB8KNIC1cOSmSO7kdJyR5tWiDIJiwMXrTwG+kZiqlbcKDsZeJ9p\n"
+            + "5bZxXO0pEpde3wgEYRvFr5Cx4vcz4h5pom9coJOCW9tqXU43KcueTrt4Ks9f92q1\n"
+            + "ehjyEnCh0BCdrjUOXsUtFosm9qxJnDwVlThYhS9EHuCTNBgj1Yxj6A+8fwwJP9DN\n"
+            + "CbWQx5afT+h+9FNDNRC/nEcesP1Yh9s15Se270pQW0CejUNziYG7Dft7T+PVH/fU\n"
+            + "zaWU8g0tJjtuQgiCWVqw4WkUmYY2S0R89zAotcpz2mvNO8ma2iJbubHi3c0ULfHH\n"
+            + "nkWKsdpzZmK4N0Wi6/V5yWdmL5RFkFecL8r7+9OtCB0CAwEAAaOCAhUwggIRMIGK\n"
+            + "BggrBgEFBQcBAQR+MHwwLQYIKwYBBQUHMAGGIWh0dHA6Ly9vY3NwLnRydXN0LnRl\n"
+            + "bGlhc29uZXJhLmNvbTBLBggrBgEFBQcwAoY/aHR0cDovL3JlcG9zaXRvcnkudHJ1\n"
+            + "c3QudGVsaWFzb25lcmEuY29tL3RlbGlhc29uZXJhcm9vdGNhdjEuY2VyMBIGA1Ud\n"
+            + "EwEB/wQIMAYBAf8CAQAwVQYDVR0gBE4wTDBKBgwrBgEEAYIPAgMBAQIwOjA4Bggr\n"
+            + "BgEFBQcCARYsaHR0cHM6Ly9yZXBvc2l0b3J5LnRydXN0LnRlbGlhc29uZXJhLmNv\n"
+            + "bS9DUFMwDgYDVR0PAQH/BAQDAgEGMIHGBgNVHR8Egb4wgbswQKA+oDyGOmh0dHA6\n"
+            + "Ly9jcmwtMy50cnVzdC50ZWxpYXNvbmVyYS5jb20vdGVsaWFzb25lcmFyb290Y2F2\n"
+            + "MS5jcmwwd6B1oHOGcWxkYXA6Ly9jcmwtMS50cnVzdC50ZWxpYXNvbmVyYS5jb20v\n"
+            + "Y249VGVsaWFTb25lcmElMjBSb290JTIwQ0ElMjB2MSxvPVRlbGlhU29uZXJhP2Nl\n"
+            + "cnRpZmljYXRlcmV2b2NhdGlvbmxpc3Q7YmluYXJ5MB0GA1UdDgQWBBQvSTwpT9cH\n"
+            + "JfnGjNVk9WY9EoMilTAfBgNVHSMEGDAWgBTwj1k4ALP1j5qWDNXr+nuqF+gTEjAN\n"
+            + "BgkqhkiG9w0BAQsFAAOCAgEAg9EVFW6ioZ2ctrX8KqvW9XPYZR01yNgqlO7pwBWf\n"
+            + "HzuBCbUdyVzumfQnU24Sce92oMtEfyuxIOmhvoXU7LpnYlH3Q29UGP5dL0D3edGz\n"
+            + "HeU6Tf8bkcOEHtnTrkd+y+rfFSDWYl9r1y993NAcrBHhroQCE53mlrO7TjXa3zDq\n"
+            + "6LGR8T8VgvGw0IBz6mzAks0wMYB0b4uREPmWXi+m+RqG3lnpl+eBzz6YVLkxIYMq\n"
+            + "QIXJIBsu4/ybmadsfdql6E8Lo3dKVD4UG10mtd+iPbJiBiW/a9VbEe3NVKIv4H2y\n"
+            + "HqYcxDXAeUI66E3K2cjCmKoQaa0Ywt02ikZFd0v1OWNPS7YWbEJWkVR1PcPMESK9\n"
+            + "6HKI4xhG2tJesmXjQ8q8aSx2u79Zts3ewjKqTmurf6FXW3u9TpSCUe6Drr/3X7Ve\n"
+            + "nBy4M0sLwCecD/L9gjTa+EItQTYzCkpxiMO49tQdX/BpwgWju4Kg3qkaBNTzvSlk\n"
+            + "gdnRJqCUkVuzwK4yBqUoyRz3prlhvvRGdZJKf6IXRDhncpey5pm0PQYQ4cArx7Go\n"
+            + "AaAKz0ZTHOKjnM2KIdUhBJQybL7oPklSfkeMWoUoYED6R4YMTt/JXX4ixEb5DgDJ\n"
+            + "0F+bNcF7qGrJTkTx0Ccy4BuuY05hJckd72E7WdmjN7DDeosghgWZNV/6D7N5tfxo\n"
+            + "nlU=\n"
+            + "-----END CERTIFICATE-----";
+
+    // Owner: CN=juolukka.cover.sonera.net, OU=security, O=Telia Finland Oyj, L=helsinki, C=FI
+    // Issuer: CN=TeliaSonera Server CA v2, O=TeliaSonera, C=FI
+    private static final String VALID = "-----BEGIN CERTIFICATE-----\n" +
+            "MIIHiDCCBXCgAwIBAgIPAWOq14hk136UDQY3WSjLMA0GCSqGSIb3DQEBCwUAMEYx\n" +
+            "CzAJBgNVBAYTAkZJMRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEhMB8GA1UEAwwYVGVs\n" +
+            "aWFTb25lcmEgU2VydmVyIENBIHYyMB4XDTE4MDUyOTA3NDA0MVoXDTE5MDUyOTA3\n" +
+            "NDA0MVowczELMAkGA1UEBhMCRkkxETAPBgNVBAcMCGhlbHNpbmtpMRowGAYDVQQK\n" +
+            "DBFUZWxpYSBGaW5sYW5kIE95ajERMA8GA1UECwwIc2VjdXJpdHkxIjAgBgNVBAMM\n" +
+            "GWp1b2x1a2thLmNvdmVyLnNvbmVyYS5uZXQwggEiMA0GCSqGSIb3DQEBAQUAA4IB\n" +
+            "DwAwggEKAoIBAQDLks9F8ZUqV9G4jn3fY234OX09Dmqqtuk0qAmjWpF0JAn2o64t\n" +
+            "whVxFLx9e2IwUPTQgyo6FwRsiT19m99BhgxYnJOxVRwURxSL3mqlV9gX4oFMmT4O\n" +
+            "EOYEjaJXi8ne1pJX80y2hVQ48XqgODnKdKZVwa5YoeWZQJiaq+C5JkMDN8qzpiyQ\n" +
+            "X3EfJspLkKy2E+UVxWmfnyf0v70ES9TQ8qgxwvsf7LRZ8Jixq7TTO5VbqWsdBvJC\n" +
+            "9Zm2aBOYJ7ptSZQ5YDfeUJG2c9S/zFmngoPnTrvAZwUeU3YTrbdZQy899ZOatWac\n" +
+            "6lHUYU2EagEmbj/jtIvJ6wMbzhleIXRQFWibAgMBAAGjggNEMIIDQDAfBgNVHSME\n" +
+            "GDAWgBQvSTwpT9cHJfnGjNVk9WY9EoMilTAdBgNVHQ4EFgQUbMozh4osL4gFJvb5\n" +
+            "baELpQSKEhIwDgYDVR0PAQH/BAQDAgSwME4GA1UdIARHMEUwQwYGZ4EMAQICMDkw\n" +
+            "NwYIKwYBBQUHAgEWK2h0dHA6Ly9yZXBvc2l0b3J5LnRydXN0LnRlbGlhc29uZXJh\n" +
+            "LmNvbS9DUFMwJAYDVR0RBB0wG4IZanVvbHVra2EuY292ZXIuc29uZXJhLm5ldDBN\n" +
+            "BgNVHR8ERjBEMEKgQKA+hjxodHRwOi8vY3JsLTMudHJ1c3QudGVsaWFzb25lcmEu\n" +
+            "Y29tL3RlbGlhc29uZXJhc2VydmVyY2F2Mi5jcmwwHQYDVR0lBBYwFAYIKwYBBQUH\n" +
+            "AwIGCCsGAQUFBwMBMIGGBggrBgEFBQcBAQR6MHgwJwYIKwYBBQUHMAGGG2h0dHA6\n" +
+            "Ly9vY3NwLnRydXN0LnRlbGlhLmNvbTBNBggrBgEFBQcwAoZBaHR0cDovL3JlcG9z\n" +
+            "aXRvcnkudHJ1c3QudGVsaWFzb25lcmEuY29tL3RlbGlhc29uZXJhc2VydmVyY2F2\n" +
+            "Mi5jZXIwggF/BgorBgEEAdZ5AgQCBIIBbwSCAWsBaQB2AG9Tdqwx8DEZ2JkApFEV\n" +
+            "/3cVHBHZAsEAKQaNsgiaN9kTAAABY6rXpS0AAAQDAEcwRQIgfMLEFYxQcncL3am/\n" +
+            "W2x7DMZ1+Vh1tDLw/0qIQB40VBQCIQC1eyF8Q6CcQs+gIgzpy7OiZSosSlykyOgW\n" +
+            "qHkj/0UPygB3AO5Lvbd1zmC64UJpH6vhnmajD35fsHLYgwDEe4l6qP3LAAABY6rX\n" +
+            "pLEAAAQDAEgwRgIhAJxveFVsFrfttSJIxHsMPAvvevptaV2CxsGwubAi8wDDAiEA\n" +
+            "jNbbYfUiYtmQ5v4yc6T+GcixztNIlMzQ7OTK+u9zqSoAdgBVgdTCFpA2AUrqC5tX\n" +
+            "PFPwwOQ4eHAlCBcvo6odBxPTDAAAAWOq16YXAAAEAwBHMEUCIQCCkCL2zn/AoMVI\n" +
+            "BdsoJelUBLsAnQ+GlIafiyZYcCwhBAIgdsFM05eNmL5hfn3+WtfgmipwcK1qp7kO\n" +
+            "ONzO69aqrnEwDQYJKoZIhvcNAQELBQADggIBAIl5UWSwCXF85+2lU6t89K7I4TvZ\n" +
+            "Ggof0NLngea9qxBq00opfnl9i2LPRnsjh9s3iA29i2daTEuJn3qt3Ygcm27Jd7WM\n" +
+            "5StcxQ483GAaL5s5m2QqkZB8eLfez3tIyCMGCAyixBDNRNPVI4xZr6sSOenWtipo\n" +
+            "gMt+/gvRIMdMT79IXPFz4W9RWCwnfJNOlfH2OkS3KZYaPSaEvs6sfMW1DDZosrBy\n" +
+            "6F+DITPLllOVSE4+PTxvXLKVy+srFwF1VocQXKkWMHQ7AfWNnOGzb7B1qg7gsw0n\n" +
+            "axqinyCjkhMpHpcVtmD9Pi15HLFDIy9yI2S+FHJQfhUSmM/LdCWzQpnee6/Wo+uw\n" +
+            "p0Jg2v6v9GGaqfpuiVJPFN9dOv3OjMU7DL5lgMRWFRo2T8+wBHXDyBhT0W0y5kRJ\n" +
+            "eWA7t6CnkziHuaOihZAHUH3nn5exjqUFVS0ThbF6hxN7HAlq/xIbTKlZjkLlc14W\n" +
+            "fB8vkxJyy/tgBZ4dCj9Y1Y32d4eFT5JZJgqgkN59SmX56BswNXncGrk/vWZFFx+g\n" +
+            "9dgb8QSe8KseD1iSLc7SsqVDv8NPYdaI3eZ90W8Wv0/CDls321O6UbAmURzQwFGB\n" +
+            "w8WnteoVBi6Wf6M1TxIfJsXBYeIN0BB6AYc8cmZIOtx2C8aH4JJT45MyFnBv3ac5\n" +
+            "Ahs9pGn/+K+5yb2e\n" +
+            "-----END CERTIFICATE-----";
+
+    // Owner: CN=juolukka.cover.sonera.net, OU=Security, O=TeliaSonera Finland, L=Helsinki, C=FI
+    // Issuer: CN=TeliaSonera Server CA v2, O=TeliaSonera, C=FI
+    private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" +
+            "MIIGEDCCA/igAwIBAgIRAKWJTjs6v04ZTyb2wJxfnJswDQYJKoZIhvcNAQELBQAw\n" +
+            "RjELMAkGA1UEBhMCRkkxFDASBgNVBAoMC1RlbGlhU29uZXJhMSEwHwYDVQQDDBhU\n" +
+            "ZWxpYVNvbmVyYSBTZXJ2ZXIgQ0EgdjIwHhcNMTYxMjIzMDcwMTQ2WhcNMTkxMjIz\n" +
+            "MDcwMTQ2WjB1MQswCQYDVQQGEwJGSTERMA8GA1UEBwwISGVsc2lua2kxHDAaBgNV\n" +
+            "BAoME1RlbGlhU29uZXJhIEZpbmxhbmQxETAPBgNVBAsMCFNlY3VyaXR5MSIwIAYD\n" +
+            "VQQDDBlqdW9sdWtrYS5jb3Zlci5zb25lcmEubmV0MIIBIjANBgkqhkiG9w0BAQEF\n" +
+            "AAOCAQ8AMIIBCgKCAQEAt2u92TgTFdm1OEfmWFPe+ESBi+2ox4y1EDoin8RydMyO\n" +
+            "DI6+0HHnKfDZa1YViI5b6MLJKWIAyUszAg5hc0S3upElfSsBvUW6zuQTxMi2vTYE\n" +
+            "4tcqwIEyCUaiv4wC+DuO5CyGR32yR6HB/W5Ny200dPs2SO03ESEJ+LH4Tw5AI8JJ\n" +
+            "UZHW+lA+yUHnlc3q47svpbspjt0C/THyukd1hbXTBB0mPXqPux+ClvtZBWUJb7ti\n" +
+            "1cPfcCNd79KRObzcgxqcOIaUFz4LjjKezhzVSL7tJOANOHZ09qDeOAkk/X9POx4h\n" +
+            "a5XyWfH1zaQ0QlZ2mKBeHebCIJkgTZZVipagRVOgcwIDAQABo4IByDCCAcQwgY0G\n" +
+            "CCsGAQUFBwEBBIGAMH4wLQYIKwYBBQUHMAGGIWh0dHA6Ly9vY3NwLnRydXN0LnRl\n" +
+            "bGlhc29uZXJhLmNvbTBNBggrBgEFBQcwAoZBaHR0cDovL3JlcG9zaXRvcnkudHJ1\n" +
+            "c3QudGVsaWFzb25lcmEuY29tL3RlbGlhc29uZXJhc2VydmVyY2F2Mi5jZXIwHwYD\n" +
+            "VR0jBBgwFoAUL0k8KU/XByX5xozVZPVmPRKDIpUwTgYDVR0gBEcwRTBDBgZngQwB\n" +
+            "AgIwOTA3BggrBgEFBQcCARYraHR0cDovL3JlcG9zaXRvcnkudHJ1c3QudGVsaWFz\n" +
+            "b25lcmEuY29tL0NQUzBNBgNVHR8ERjBEMEKgQKA+hjxodHRwOi8vY3JsLTMudHJ1\n" +
+            "c3QudGVsaWFzb25lcmEuY29tL3RlbGlhc29uZXJhc2VydmVyY2F2Mi5jcmwwHQYD\n" +
+            "VR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMA4GA1UdDwEB/wQEAwIEsDAkBgNV\n" +
+            "HREEHTAbghlqdW9sdWtrYS5jb3Zlci5zb25lcmEubmV0MB0GA1UdDgQWBBSa+vJH\n" +
+            "I6Lt9Aqw5ondhoZu4/IJezANBgkqhkiG9w0BAQsFAAOCAgEASRK1l1MZb/IRlyi+\n" +
+            "XjfZcxJdFuNzW2kpZstW6Ni2XiD3p7aROBfDFtu7GajzZHb6p76auDb4NwJgeE/3\n" +
+            "6gnXoIK00HwpF2RAhxDpkF8r3q0jSqGhSv/xz9Nx7JBzgqfSw3Ha4ohioIed3uc+\n" +
+            "nMDyvVenio4GYgtxIIubSybCxMv/lBA/S4daIVCYK3VOoBbM2F36ecAKvRU5vIWM\n" +
+            "urXsfANL3u4qgJpaM0DclzFsOkVsRPffzToko/Nr6pGXYjt47IzTRlwLMnLehoZW\n" +
+            "ZZMGMVVOlR7XGf81UjWB6OsKeoQ4FWgcb/rIJcZusm+LqvnsCHuC3gtuC2nGA7lr\n" +
+            "fseUlG7QZN9/QfUIyvL69wAzeVj1cUcd7GHcAH9DyZJfI8orv4PyUvitDdgISkFu\n" +
+            "GZ562O7cGmCv00/6I4t0z9wZal8a5lRDoKXAYy+u/adrO1JjLwi11y/DTw9LQ7sJ\n" +
+            "gVP/v2GsI0ajF9A6z33UHN9uxXZVmQNvOiMkcJiGLovFgu5zxoAg2W3pHjbBbeL8\n" +
+            "v5MPqgsKafgzaSRtXBBvaISHi9hhRR8v/qSwO3NyLm8uAhQD4x+OPHrmQ/s16j45\n" +
+            "Ib53UHj1k6byXGUqDgzFBsmEPV6Shf2C4/HcRHpAX8wQx3xVwDtRzDpNUR6vnNfi\n" +
+            "PwzRU1xsQKd8llmgl4l+fYV0tBA=\n" +
+            "-----END CERTIFICATE-----";
+
+    public static void main(String[] args) throws Exception {
+
+        ValidatePathWithParams pathValidator = new ValidatePathWithParams(null);
+
+        if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) {
+            pathValidator.enableCRLCheck();
+        } else {
+            // OCSP check by default
+            pathValidator.enableOCSPCheck();
+        }
+
+        // Validate valid
+        pathValidator.validate(new String[]{VALID, INT},
+                ValidatePathWithParams.Status.GOOD, null, System.out);
+
+        // Validate Revoked
+        pathValidator.validate(new String[]{REVOKED, INT},
+                ValidatePathWithParams.Status.REVOKED,
+                "Thu Dec 22 23:14:55 PST 2016", System.out);
+
+        // reset validation date back to current date
+        pathValidator.resetValidationDate();
+    }
+}
--- a/test/jdk/sun/awt/dnd/8024061/bug8024061.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/awt/dnd/8024061/bug8024061.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -27,8 +27,8 @@
  * @bug 8024061
  * @summary Checks that no exception is thrown if dragGestureRecognized
  *          takes a while to complete.
- * @library ../../../../lib/testlibrary
- * @build jdk.testlibrary.OSInfo
+ * @library /test/lib
+ * @build jdk.test.lib.Platform
  * @run main bug8024061
  */
 import java.awt.*;
@@ -56,8 +56,8 @@
 import java.util.concurrent.TimeUnit;
 
 import javax.swing.*;
-import jdk.testlibrary.OSInfo;
 
+import jdk.test.lib.Platform;
 
 /**
  * If dragGestureRecognized() takes a while to complete and if user performs a drag quickly,
@@ -114,8 +114,7 @@
     }
 
     public static void main(String[] args) throws AWTException, InvocationTargetException, InterruptedException {
-        OSInfo.OSType type = OSInfo.getOSType();
-        if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) {
+        if (!Platform.isLinux() && !Platform.isSolaris()) {
             System.out.println("This test is for Linux and Solaris only... " +
                                "skipping!");
             return;
--- a/test/jdk/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -21,7 +21,6 @@
  * questions.
  */
 
-import java.io.File;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.nio.file.Files;
@@ -34,8 +33,8 @@
 import java.util.UUID;
 import java.util.concurrent.Semaphore;
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import sun.jvmstat.monitor.MonitorException;
 import sun.jvmstat.monitor.MonitoredHost;
 import sun.jvmstat.monitor.MonitoredVm;
@@ -66,11 +65,10 @@
  * @test
  * @bug 4990825
  * @summary attach to external but local JVM processes
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.management
  *          jdk.internal.jvmstat/sun.jvmstat.monitor
  *          jdk.internal.jvmstat/sun.jvmstat.monitor.event
- * @build jdk.testlibrary.*
  * @run main/othervm MonitorVmStartTerminate
  */
 public final class MonitorVmStartTerminate {
--- a/test/jdk/sun/management/jdp/DynamicLauncher.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/management/jdp/DynamicLauncher.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,8 +22,8 @@
  */
 
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Utils;
 
 import java.util.UUID;
--- a/test/jdk/sun/management/jdp/JdpDefaultsTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/management/jdp/JdpDefaultsTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -32,6 +32,7 @@
  * @summary Assert that we can read JDP packets from a multicast socket connection, on default IP and port.
  *
  * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpOnTestCase DynamicLauncher
  * @run main/othervm JdpDefaultsTest
--- a/test/jdk/sun/management/jdp/JdpJmxRemoteDynamicPortTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/management/jdp/JdpJmxRemoteDynamicPortTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -28,6 +28,7 @@
  *          when VM is started with jmxremote.port=0.
  *
  * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpJmxRemoteDynamicPortTestCase DynamicLauncher
  * @run main/othervm JdpJmxRemoteDynamicPortTest
--- a/test/jdk/sun/management/jdp/JdpOffTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/management/jdp/JdpOffTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -33,6 +33,7 @@
  * @summary Assert that no JDP packets are sent to the default address and port.
  *
  * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpOffTestCase DynamicLauncher
  * @run main/othervm JdpOffTest
--- a/test/jdk/sun/management/jdp/JdpSpecificAddressTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/management/jdp/JdpSpecificAddressTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -32,6 +32,7 @@
  * @summary Assert that we can read JDP packets from a multicast socket connection, on specific IP and port.
  *
  * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpOnTestCase DynamicLauncher
  * @run main/othervm JdpSpecificAddressTest
--- a/test/jdk/sun/management/jdp/PortAlreadyInUseTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/management/jdp/PortAlreadyInUseTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,7 +22,7 @@
  */
 
 
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.testlibrary.Utils;
 
 import java.io.IOException;
--- a/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -21,8 +21,8 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.Platform;
 
 import java.io.BufferedWriter;
--- a/test/jdk/sun/management/jmxremote/bootstrap/CustomLauncherTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/management/jmxremote/bootstrap/CustomLauncherTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -35,19 +35,18 @@
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 /**
  * @test
  * @bug 6434402 8004926
  * @author Jaroslav Bachorik
  *
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.management
  *          jdk.attach
  *          jdk.management.agent/jdk.internal.agent
  *
- * @build jdk.testlibrary.*
  * @build TestManager TestApplication CustomLauncherTest
  * @run main/othervm CustomLauncherTest
  */
--- a/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -30,7 +30,7 @@
 import java.util.stream.Collectors;
 
 import jdk.test.lib.thread.ProcessThread;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 /**
  * NOTE:
@@ -48,11 +48,10 @@
  * @summary Test JMX agent host address binding. Same ports but different
  *          interfaces to bind to (using plain sockets and SSL sockets).
  *
- * @library /lib/testlibrary
  * @library /test/lib
  * @modules java.management.rmi
  *
- * @build jdk.testlibrary.* JMXAgentInterfaceBinding
+ * @build JMXAgentInterfaceBinding
  * @run main/timeout=5 JMXInterfaceBindingTest
  */
 public class JMXInterfaceBindingTest {
--- a/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -27,7 +27,7 @@
 import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Utils;
 
 /**
@@ -39,6 +39,7 @@
  *          both agent properties and jvmstat buffer.
  *
  * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.management
  *          jdk.attach
  *          jdk.management.agent/jdk.internal.agent
--- a/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -21,8 +21,8 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Utils;
 
 import java.io.BufferedReader;
@@ -44,6 +44,7 @@
  * @author Luis-Miguel Alventosa, Taras Ledkov
  *
  * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @build jdk.testlibrary.* RmiRegistrySslTestApp
  * @run main/timeout=300 RmiRegistrySslTest
--- a/test/jdk/sun/management/jmxremote/startstop/JMXStartStopTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/management/jmxremote/startstop/JMXStartStopTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -44,7 +44,7 @@
 import javax.management.remote.*;
 import javax.net.ssl.SSLHandshakeException;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Utils;
 import jdk.internal.agent.Agent;
 import jdk.internal.agent.AgentConfigurationError;
@@ -58,6 +58,7 @@
  *          achieves the desired results
  *
  * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.management
  *          java.rmi
  *          jdk.management.agent/jdk.internal.agent
--- a/test/jdk/sun/management/jmxremote/startstop/JMXStatusPerfCountersTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/management/jmxremote/startstop/JMXStatusPerfCountersTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 
 /**
@@ -43,6 +43,7 @@
  *          in the related performance counters.
  *
  * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @build jdk.testlibrary.* PortAllocator TestApp ManagementAgentJcmd
  * @run testng/othervm -XX:+UsePerfData JMXStatusPerfCountersTest
--- a/test/jdk/sun/management/jmxremote/startstop/JMXStatusTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/management/jmxremote/startstop/JMXStatusTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
 import org.testng.annotations.*;
 import static org.testng.Assert.*;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 /**
  * @test
@@ -39,6 +39,7 @@
  *          The test asserts that the expected text is being printed.
  *
  * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @build jdk.testlibrary.* PortAllocator TestApp ManagementAgentJcmd
  *        JMXStatusTest JMXStatus1Test JMXStatus2Test
--- a/test/jdk/sun/management/jmxremote/startstop/ManagementAgentJcmd.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/management/jmxremote/startstop/ManagementAgentJcmd.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
 import jdk.internal.agent.AgentConfigurationError;
 
 import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 /**
  * A helper class for issuing ManagementAgent.* diagnostic commands and capturing
--- a/test/jdk/sun/security/krb5/auto/tools/KinitConfPlusProps.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/krb5/auto/tools/KinitConfPlusProps.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,15 +24,15 @@
 import java.io.File;
 import java.util.HashMap;
 import java.util.Map;
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
 
 /*
  * @test
  * @bug 6857795 8075299
  * @summary Checks if kinit uses both krb5 conf file and system properties
  * @requires os.family == "windows"
- * @library /lib/testlibrary
+ * @library /test/lib
  * @library /sun/security/krb5/auto
  * @run main/othervm KinitConfPlusProps
  */
--- a/test/jdk/sun/security/ssl/ClientHandshaker/LengthCheckTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/ssl/ClientHandshaker/LengthCheckTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -74,6 +74,7 @@
 import java.nio.*;
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Iterator;
 
 public class LengthCheckTest {
 
@@ -203,7 +204,11 @@
 
                 // Now send each ByteBuffer (each being a complete
                 // TLS record) into the client-side unwrap.
-                for (ByteBuffer bBuf : recList) {
+                // for (ByteBuffer bBuf : recList) {
+
+                Iterator<ByteBuffer> iter = recList.iterator();
+                while (!gotException && (iter.hasNext())) {
+                    ByteBuffer bBuf = iter.next();
                     dumpByteBuffer("SERVER-TO-CLIENT", bBuf);
                     try {
                         clientResult = clientEngine.unwrap(bBuf, clientIn);
@@ -232,8 +237,8 @@
             // was thrown and the proper action (a TLS alert) was
             // sent back to the server.
             if (gotException == false ||
-                !isTlsMessage(cTOs, TLS_RECTYPE_ALERT, TLS_ALERT_LVL_FATAL,
-                        TLS_ALERT_UNEXPECTED_MSG)) {
+                    !isTlsMessage(cTOs, TLS_RECTYPE_ALERT, TLS_ALERT_LVL_FATAL,
+                            TLS_ALERT_ILLEGAL_PARAMETER)) {
                 throw new SSLException(
                     "Client failed to throw Alert:fatal:internal_error");
             }
@@ -253,38 +258,36 @@
             ByteBuffer evilClientHello = createEvilClientHello(64);
             dumpByteBuffer("CLIENT-TO-SERVER", evilClientHello);
 
+            // Server consumes Client Hello
+            serverResult = serverEngine.unwrap(evilClientHello, serverIn);
+            log("server unwrap: ", serverResult);
+            runDelegatedTasks(serverResult, serverEngine);
+            evilClientHello.compact();
+
+            // Under normal circumstances this should be a ServerHello
+            // But should throw an exception instead due to the invalid
+            // session ID.
             try {
-                // Server consumes Client Hello
-                serverResult = serverEngine.unwrap(evilClientHello, serverIn);
-                log("server unwrap: ", serverResult);
-                runDelegatedTasks(serverResult, serverEngine);
-                evilClientHello.compact();
-
-                // Under normal circumstances this should be a ServerHello
-                // But should throw an exception instead due to the invalid
-                // session ID.
                 serverResult = serverEngine.wrap(serverOut, sTOc);
                 log("server wrap: ", serverResult);
                 runDelegatedTasks(serverResult, serverEngine);
-                sTOc.flip();
-                dumpByteBuffer("SERVER-TO-CLIENT", sTOc);
-
-                // We expect to see the server generate an alert here
-                serverResult = serverEngine.wrap(serverOut, sTOc);
-                log("server wrap: ", serverResult);
-                runDelegatedTasks(serverResult, serverEngine);
-                sTOc.flip();
-                dumpByteBuffer("SERVER-TO-CLIENT", sTOc);
             } catch (SSLProtocolException ssle) {
                 log("Received expected SSLProtocolException: " + ssle);
                 gotException = true;
             }
 
+            // We expect to see the server generate an alert here
+            serverResult = serverEngine.wrap(serverOut, sTOc);
+            log("server wrap: ", serverResult);
+            runDelegatedTasks(serverResult, serverEngine);
+            sTOc.flip();
+            dumpByteBuffer("SERVER-TO-CLIENT", sTOc);
+
             // At this point we can verify that both an exception
             // was thrown and the proper action (a TLS alert) was
             // sent back to the client.
             if (gotException == false ||
-                !isTlsMessage(sTOc, TLS_RECTYPE_ALERT, TLS_ALERT_LVL_FATAL,
+                    !isTlsMessage(sTOc, TLS_RECTYPE_ALERT, TLS_ALERT_LVL_FATAL,
                         TLS_ALERT_ILLEGAL_PARAMETER)) {
                 throw new SSLException(
                     "Server failed to throw Alert:fatal:internal_error");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineFailedALPN.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,449 @@
+/*
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+
+/*
+ * @test
+ * @bug 8207317
+ * @summary SSLEngine negotiation fail Exception behavior changed from
+ *          fail-fast to fail-lazy
+ * @run main/othervm SSLEngineFailedALPN
+ */
+/**
+ * A SSLEngine usage example which simplifies the presentation
+ * by removing the I/O and multi-threading concerns.
+ *
+ * The test creates two SSLEngines, simulating a client and server.
+ * The "transport" layer consists two byte buffers:  think of them
+ * as directly connected pipes.
+ *
+ * Note, this is a *very* simple example: real code will be much more
+ * involved.  For example, different threading and I/O models could be
+ * used, transport mechanisms could close unexpectedly, and so on.
+ *
+ * When this application runs, notice that several messages
+ * (wrap/unwrap) pass before any application data is consumed or
+ * produced.  (For more information, please see the SSL/TLS
+ * specifications.)  There may several steps for a successful handshake,
+ * so it's typical to see the following series of operations:
+ *
+ *      client          server          message
+ *      ======          ======          =======
+ *      wrap()          ...             ClientHello
+ *      ...             unwrap()        ClientHello
+ *      ...             wrap()          ServerHello/Certificate
+ *      unwrap()        ...             ServerHello/Certificate
+ *      wrap()          ...             ClientKeyExchange
+ *      wrap()          ...             ChangeCipherSpec
+ *      wrap()          ...             Finished
+ *      ...             unwrap()        ClientKeyExchange
+ *      ...             unwrap()        ChangeCipherSpec
+ *      ...             unwrap()        Finished
+ *      ...             wrap()          ChangeCipherSpec
+ *      ...             wrap()          Finished
+ *      unwrap()        ...             ChangeCipherSpec
+ *      unwrap()        ...             Finished
+ */
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+import java.io.*;
+import java.security.*;
+import java.nio.*;
+
+public class SSLEngineFailedALPN {
+
+    /*
+     * Enables logging of the SSLEngine operations.
+     */
+    private static final boolean logging = true;
+
+    /*
+     * Enables the JSSE system debugging system property:
+     *
+     *     -Djavax.net.debug=all
+     *
+     * This gives a lot of low-level information about operations underway,
+     * including specific handshake messages, and might be best examined
+     * after gaining some familiarity with this application.
+     */
+    private static final boolean debug = false;
+
+    private final SSLContext sslc;
+
+    private SSLEngine clientEngine;     // client Engine
+    private ByteBuffer clientOut;       // write side of clientEngine
+    private ByteBuffer clientIn;        // read side of clientEngine
+
+    private SSLEngine serverEngine;     // server Engine
+    private ByteBuffer serverOut;       // write side of serverEngine
+    private ByteBuffer serverIn;        // read side of serverEngine
+
+    /*
+     * For data transport, this example uses local ByteBuffers.  This
+     * isn't really useful, but the purpose of this example is to show
+     * SSLEngine concepts, not how to do network transport.
+     */
+    private ByteBuffer cTOs;            // "reliable" transport client->server
+    private ByteBuffer sTOc;            // "reliable" transport server->client
+
+    /*
+     * The following is to set up the keystores.
+     */
+    private static final String pathToStores = "../../../../javax/net/ssl/etc";
+    private static final String keyStoreFile = "keystore";
+    private static final String trustStoreFile = "truststore";
+    private static final char[] passphrase = "passphrase".toCharArray();
+
+    private static final String keyFilename =
+            System.getProperty("test.src", ".") + "/" + pathToStores +
+                "/" + keyStoreFile;
+    private static final String trustFilename =
+            System.getProperty("test.src", ".") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+    /*
+     * Main entry point for this test.
+     */
+    public static void main(String args[]) throws Exception {
+        if (debug) {
+            System.setProperty("javax.net.debug", "all");
+        }
+
+        SSLEngineFailedALPN test = new SSLEngineFailedALPN();
+        test.runTest();
+
+        System.out.println("Test Passed.");
+    }
+
+    /*
+     * Create an initialized SSLContext to use for these tests.
+     */
+    public SSLEngineFailedALPN() throws Exception {
+
+        KeyStore ks = KeyStore.getInstance("JKS");
+        KeyStore ts = KeyStore.getInstance("JKS");
+
+        ks.load(new FileInputStream(keyFilename), passphrase);
+        ts.load(new FileInputStream(trustFilename), passphrase);
+
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+        kmf.init(ks, passphrase);
+
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+        tmf.init(ts);
+
+        SSLContext sslCtx = SSLContext.getInstance("TLS");
+
+        sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+        sslc = sslCtx;
+    }
+
+    /*
+     * Run the test.
+     *
+     * Sit in a tight loop, both engines calling wrap/unwrap regardless
+     * of whether data is available or not.  We do this until both engines
+     * report back they are closed.
+     *
+     * The main loop handles all of the I/O phases of the SSLEngine's
+     * lifetime:
+     *
+     *     initial handshaking
+     *     application data transfer
+     *     engine closing
+     *
+     * One could easily separate these phases into separate
+     * sections of code.
+     */
+    private void runTest() throws Exception {
+        boolean dataDone = false;
+
+        createSSLEngines();
+        createBuffers();
+
+        // results from client's last operation
+        SSLEngineResult clientResult;
+
+        // results from server's last operation
+        SSLEngineResult serverResult;
+
+        /*
+         * Examining the SSLEngineResults could be much more involved,
+         * and may alter the overall flow of the application.
+         *
+         * For example, if we received a BUFFER_OVERFLOW when trying
+         * to write to the output pipe, we could reallocate a larger
+         * pipe, but instead we wait for the peer to drain it.
+         */
+        Exception clientException = null;
+        Exception serverException = null;
+
+        while (!isEngineClosed(clientEngine)
+                || !isEngineClosed(serverEngine)) {
+
+            log("================");
+
+            try {
+                clientResult = clientEngine.wrap(clientOut, cTOs);
+                log("client wrap: ", clientResult);
+            } catch (Exception e) {
+                clientException = e;
+                System.out.println("Client wrap() threw: " + e.getMessage());
+            }
+            logEngineStatus(clientEngine);
+            runDelegatedTasks(clientEngine);
+
+            log("----");
+
+            try {
+                serverResult = serverEngine.wrap(serverOut, sTOc);
+                log("server wrap: ", serverResult);
+            } catch (Exception e) {
+                serverException = e;
+                System.out.println("Server wrap() threw: " + e.getMessage());
+            }
+            logEngineStatus(serverEngine);
+            runDelegatedTasks(serverEngine);
+
+            cTOs.flip();
+            sTOc.flip();
+
+            log("--------");
+
+            try {
+                clientResult = clientEngine.unwrap(sTOc, clientIn);
+                log("client unwrap: ", clientResult);
+            } catch (Exception e) {
+                clientException = e;
+                System.out.println("Client unwrap() threw: " + e.getMessage());
+            }
+            logEngineStatus(clientEngine);
+            runDelegatedTasks(clientEngine);
+
+            log("----");
+
+            try {
+                serverResult = serverEngine.unwrap(cTOs, serverIn);
+                log("server unwrap: ", serverResult);
+            } catch (Exception e) {
+                serverException = e;
+                System.out.println("Server unwrap() threw: " + e.getMessage());
+            }
+            logEngineStatus(serverEngine);
+            runDelegatedTasks(serverEngine);
+
+            cTOs.compact();
+            sTOc.compact();
+
+            /*
+             * After we've transfered all application data between the client
+             * and server, we close the clientEngine's outbound stream.
+             * This generates a close_notify handshake message, which the
+             * server engine receives and responds by closing itself.
+             */
+            if (!dataDone && (clientOut.limit() == serverIn.position()) &&
+                    (serverOut.limit() == clientIn.position())) {
+
+                /*
+                 * A sanity check to ensure we got what was sent.
+                 */
+                checkTransfer(serverOut, clientIn);
+                checkTransfer(clientOut, serverIn);
+
+                log("\tClosing clientEngine's *OUTBOUND*...");
+                clientEngine.closeOutbound();
+                logEngineStatus(clientEngine);
+
+                dataDone = true;
+                log("\tClosing serverEngine's *OUTBOUND*...");
+                serverEngine.closeOutbound();
+                logEngineStatus(serverEngine);
+            }
+        }
+
+        log("================");
+
+        if ((clientException != null) &&
+                (clientException instanceof SSLHandshakeException)) {
+            log("Client threw proper exception");
+            clientException.printStackTrace(System.out);
+        } else {
+            throw new Exception("Client Exception not seen");
+        }
+
+        if ((serverException != null) &&
+                (serverException instanceof SSLHandshakeException)) {
+            log("Server threw proper exception:");
+            serverException.printStackTrace(System.out);
+        } else {
+            throw new Exception("Server Exception not seen");
+        }
+    }
+
+    private static void logEngineStatus(SSLEngine engine) {
+        log("\tCurrent HS State  " + engine.getHandshakeStatus().toString());
+        log("\tisInboundDone():  " + engine.isInboundDone());
+        log("\tisOutboundDone(): " + engine.isOutboundDone());
+    }
+
+    /*
+     * Using the SSLContext created during object creation,
+     * create/configure the SSLEngines we'll use for this test.
+     */
+    private void createSSLEngines() throws Exception {
+        /*
+         * Configure the serverEngine to act as a server in the SSL/TLS
+         * handshake.  Also, require SSL client authentication.
+         */
+        serverEngine = sslc.createSSLEngine();
+        serverEngine.setUseClientMode(false);
+        serverEngine.setNeedClientAuth(true);
+
+        // Get/set parameters if needed
+        SSLParameters paramsServer = serverEngine.getSSLParameters();
+        paramsServer.setApplicationProtocols(new String[]{"one"});
+        serverEngine.setSSLParameters(paramsServer);
+
+        /*
+         * Similar to above, but using client mode instead.
+         */
+        clientEngine = sslc.createSSLEngine("client", 80);
+        clientEngine.setUseClientMode(true);
+
+        // Get/set parameters if needed
+        SSLParameters paramsClient = clientEngine.getSSLParameters();
+        paramsClient.setApplicationProtocols(new String[]{"two"});
+        clientEngine.setSSLParameters(paramsClient);
+    }
+
+    /*
+     * Create and size the buffers appropriately.
+     */
+    private void createBuffers() {
+
+        /*
+         * We'll assume the buffer sizes are the same
+         * between client and server.
+         */
+        SSLSession session = clientEngine.getSession();
+        int appBufferMax = session.getApplicationBufferSize();
+        int netBufferMax = session.getPacketBufferSize();
+
+        /*
+         * We'll make the input buffers a bit bigger than the max needed
+         * size, so that unwrap()s following a successful data transfer
+         * won't generate BUFFER_OVERFLOWS.
+         *
+         * We'll use a mix of direct and indirect ByteBuffers for
+         * tutorial purposes only.  In reality, only use direct
+         * ByteBuffers when they give a clear performance enhancement.
+         */
+        clientIn = ByteBuffer.allocate(appBufferMax + 50);
+        serverIn = ByteBuffer.allocate(appBufferMax + 50);
+
+        cTOs = ByteBuffer.allocateDirect(netBufferMax);
+        sTOc = ByteBuffer.allocateDirect(netBufferMax);
+
+        clientOut = ByteBuffer.wrap("Hi Server, I'm Client".getBytes());
+        serverOut = ByteBuffer.wrap("Hello Client, I'm Server".getBytes());
+    }
+
+    /*
+     * If the result indicates that we have outstanding tasks to do,
+     * go ahead and run them in this thread.
+     */
+    private static void runDelegatedTasks(SSLEngine engine) throws Exception {
+
+        if (engine.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+            Runnable runnable;
+            while ((runnable = engine.getDelegatedTask()) != null) {
+                log("    running delegated task...");
+                runnable.run();
+            }
+            HandshakeStatus hsStatus = engine.getHandshakeStatus();
+            if (hsStatus == HandshakeStatus.NEED_TASK) {
+                throw new Exception(
+                    "handshake shouldn't need additional tasks");
+            }
+            logEngineStatus(engine);
+        }
+    }
+
+    private static boolean isEngineClosed(SSLEngine engine) {
+        return (engine.isOutboundDone() && engine.isInboundDone());
+    }
+
+    /*
+     * Simple check to make sure everything came across as expected.
+     */
+    private static void checkTransfer(ByteBuffer a, ByteBuffer b)
+            throws Exception {
+        a.flip();
+        b.flip();
+
+        if (!a.equals(b)) {
+            throw new Exception("Data didn't transfer cleanly");
+        } else {
+            log("\tData transferred cleanly");
+        }
+
+        a.position(a.limit());
+        b.position(b.limit());
+        a.limit(a.capacity());
+        b.limit(b.capacity());
+    }
+
+    /*
+     * Logging code
+     */
+    private static boolean resultOnce = true;
+
+    private static void log(String str, SSLEngineResult result) {
+        if (!logging) {
+            return;
+        }
+        if (resultOnce) {
+            resultOnce = false;
+            System.out.println("The format of the SSLEngineResult is: \n" +
+                    "\t\"getStatus() / getHandshakeStatus()\" +\n" +
+                    "\t\"bytesConsumed() / bytesProduced()\"\n");
+        }
+        HandshakeStatus hsStatus = result.getHandshakeStatus();
+        log(str +
+                result.getStatus() + "/" + hsStatus + ", " +
+                result.bytesConsumed() + "/" + result.bytesProduced() +
+                " bytes");
+        if (hsStatus == HandshakeStatus.FINISHED) {
+            log("\t...ready for application data");
+        }
+    }
+
+    private static void log(String str) {
+        if (logging) {
+            System.out.println(str);
+        }
+    }
+}
--- a/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java	Fri Sep 07 15:46:39 2018 -0700
@@ -25,6 +25,7 @@
  * @test
  * @bug 8164879
  * @library /lib/testlibrary ../../
+ * @library /test/lib
  * @summary Verify AES/GCM's limits set in the jdk.tls.keyLimits property
  * start a new handshake sequence to renegotiate the symmetric key with an
  * SSLSocket connection.  This test verifies the handshake method was called
@@ -53,9 +54,9 @@
 import java.security.SecureRandom;
 import java.util.Arrays;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.testlibrary.Utils;
-import jdk.testlibrary.OutputAnalyzer;
 
 public class SSLEngineKeyLimit {
 
--- a/test/jdk/sun/security/ssl/SSLSocketImpl/ReuseAddr.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/ssl/SSLSocketImpl/ReuseAddr.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,240 +25,31 @@
  * @test
  * @bug 4482446
  * @summary java.net.SocketTimeoutException on 98, NT, 2000 for JSSE
- * @run main/othervm ReuseAddr
+ * @library /javax/net/ssl/templates
+ * @run main ReuseAddr
  *
  *     SunJSSE does not support dynamic system properties, no way to re-use
  *     system properties in samevm/agentvm mode.
  * @author Brad Wetmore
  */
 
-import java.io.*;
-import java.net.*;
-import javax.net.ssl.*;
-
-public class ReuseAddr {
-
-    /*
-     * =============================================================
-     * Set the various variables needed for the tests, then
-     * specify what tests to run on each side.
-     */
-
-    /*
-     * Should we run the client or server in a separate thread?
-     * Both sides can throw exceptions, but do you have a preference
-     * as to which side should be the main thread.
-     */
-    static boolean separateServerThread = true;
+import java.net.ServerSocket;
 
-    /*
-     * Where do we find the keystores?
-     */
-    private final static String pathToStores = "../../../../javax/net/ssl/etc";
-    static String keyStoreFile = "keystore";
-    static String trustStoreFile = "truststore";
-    static String passwd = "passphrase";
-
-    /*
-     * Is the server ready to serve?
-     */
-    volatile static boolean serverReady = false;
-
-    /*
-     * Turn on SSL debugging?
-     */
-    static boolean debug = false;
-
-    /*
-     * If the client or server is doing some kind of object creation
-     * that the other side depends on, and that thread prematurely
-     * exits, you may experience a hang.  The test harness will
-     * terminate all hung threads after its timeout has expired,
-     * currently 3 minutes by default, but you might try to be
-     * smart about it....
-     */
+public class ReuseAddr extends SSLSocketTemplate {
 
-    /*
-     * Define the server side of the test.
-     *
-     * If the server prematurely exits, serverReady will be set to true
-     * to avoid infinite hangs.
-     */
-    void doServerSide() throws Exception {
-        SSLServerSocketFactory sslssf =
-            (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
-        SSLServerSocket sslServerSocket =
-            (SSLServerSocket) sslssf.createServerSocket(serverPort);
-        serverPort = sslServerSocket.getLocalPort();
-
-        /*
-         * Signal Client, we're ready for his connect.
-         */
-        serverReady = true;
-
-        SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
-        InputStream sslIS = sslSocket.getInputStream();
-        OutputStream sslOS = sslSocket.getOutputStream();
-
-        sslIS.read();
-        sslOS.write(85);
-        sslOS.flush();
-
-        sslSocket.close();
-
-        // Close original server socket
-        sslServerSocket.close();
+    @Override
+    protected void doServerSide() throws Exception {
+        super.doServerSide();
 
-        // Try rebinding to same port
-        sslServerSocket =
-            (SSLServerSocket) sslssf.createServerSocket(serverPort);
-        sslServerSocket.close();
-    }
-
-    /*
-     * Define the client side of the test.
-     *
-     * If the server prematurely exits, serverReady will be set to true
-     * to avoid infinite hangs.
-     */
-    void doClientSide() throws Exception {
-
-        /*
-         * Wait for server to get started.
-         */
-        while (!serverReady) {
-            Thread.sleep(50);
+        // Note that if this port is already used by another test,
+        // this test will fail.
+        System.out.println("Try rebinding to same port: " + serverPort);
+        try (ServerSocket server = new ServerSocket(serverPort)) {
+            System.out.println("Server port: " + server.getLocalPort());
         }
-
-        SSLSocketFactory sslsf =
-            (SSLSocketFactory) SSLSocketFactory.getDefault();
-        SSLSocket sslSocket = (SSLSocket)
-            sslsf.createSocket("localhost", serverPort);
-
-        InputStream sslIS = sslSocket.getInputStream();
-        OutputStream sslOS = sslSocket.getOutputStream();
-
-        sslOS.write(280);
-        sslOS.flush();
-        sslIS.read();
-
-        sslSocket.close();
     }
 
-    /*
-     * =============================================================
-     * The remainder is just support stuff
-     */
-
-    // use any free port by default
-    volatile int serverPort = 0;
-
-    volatile Exception serverException = null;
-    volatile Exception clientException = null;
-
     public static void main(String[] args) throws Exception {
-        String keyFilename =
-            System.getProperty("test.src", "./") + "/" + pathToStores +
-                "/" + keyStoreFile;
-        String trustFilename =
-            System.getProperty("test.src", "./") + "/" + pathToStores +
-                "/" + trustStoreFile;
-
-        System.setProperty("javax.net.ssl.keyStore", keyFilename);
-        System.setProperty("javax.net.ssl.keyStorePassword", passwd);
-        System.setProperty("javax.net.ssl.trustStore", trustFilename);
-        System.setProperty("javax.net.ssl.trustStorePassword", passwd);
-
-        if (debug)
-            System.setProperty("javax.net.debug", "all");
-
-        /*
-         * Start the tests.
-         */
-        new ReuseAddr();
-    }
-
-    Thread clientThread = null;
-    Thread serverThread = null;
-
-    /*
-     * Primary constructor, used to drive remainder of the test.
-     *
-     * Fork off the other side, then do your work.
-     */
-    ReuseAddr() throws Exception {
-        if (separateServerThread) {
-            startServer(true);
-            startClient(false);
-        } else {
-            startClient(true);
-            startServer(false);
-        }
-
-        /*
-         * Wait for other side to close down.
-         */
-        if (separateServerThread) {
-            serverThread.join();
-        } else {
-            clientThread.join();
-        }
-
-        /*
-         * When we get here, the test is pretty much over.
-         *
-         * If the main thread excepted, that propagates back
-         * immediately.  If the other thread threw an exception, we
-         * should report back.
-         */
-        if (serverException != null)
-            throw serverException;
-        if (clientException != null)
-            throw clientException;
-    }
-
-    void startServer(boolean newThread) throws Exception {
-        if (newThread) {
-            serverThread = new Thread() {
-                public void run() {
-                    try {
-                        doServerSide();
-                    } catch (Exception e) {
-                        /*
-                         * Our server thread just died.
-                         *
-                         * Release the client, if not active already...
-                         */
-                        System.err.println("Server died...");
-                        serverReady = true;
-                        serverException = e;
-                    }
-                }
-            };
-            serverThread.start();
-        } else {
-            doServerSide();
-        }
-   }
-
-    void startClient(boolean newThread) throws Exception {
-        if (newThread) {
-            clientThread = new Thread() {
-                public void run() {
-                    try {
-                        doClientSide();
-                    } catch (Exception e) {
-                        /*
-                         * Our client thread just died.
-                         */
-                        System.err.println("Client died...");
-                        clientException = e;
-                    }
-                }
-            };
-            clientThread.start();
-        } else {
-            doClientSide();
-        }
+        new ReuseAddr().run();
     }
 }
--- a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java	Fri Sep 07 15:46:39 2018 -0700
@@ -25,6 +25,7 @@
  * @test
  * @bug 8164879
  * @library /lib/testlibrary ../../
+ * @library /test/lib
  * @modules java.base/sun.security.util
  * @summary Verify AES/GCM's limits set in the jdk.tls.keyLimits property
  * @run main SSLSocketKeyLimit 0 server AES/GCM/NoPadding keyupdate 1000000
@@ -47,8 +48,6 @@
 import javax.net.ssl.SSLSocket;
 import javax.net.ssl.SSLSocketFactory;
 import javax.net.ssl.TrustManagerFactory;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -57,9 +56,9 @@
 import java.security.SecureRandom;
 import java.util.Arrays;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Utils;
-import jdk.testlibrary.OutputAnalyzer;
 import sun.security.util.HexDumpEncoder;
 
 public class SSLSocketKeyLimit {
--- a/test/jdk/sun/security/tools/jarsigner/TsacertOptionTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/tools/jarsigner/TsacertOptionTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -21,7 +21,7 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.util.JarUtils;
 
 /**
--- a/test/jdk/sun/security/tools/jarsigner/Warning.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/tools/jarsigner/Warning.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,8 @@
 
 import jdk.testlibrary.JDKToolLauncher;
 import jdk.test.lib.util.JarUtils;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 import java.nio.file.Files;
 import java.nio.file.Paths;
--- a/test/jdk/sun/security/tools/jarsigner/warnings/AliasNotInStoreTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/AliasNotInStoreTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -21,14 +21,14 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for aliasNotInStore warning
- * @library /lib/testlibrary /test/lib ../
+ * @library /test/lib ../
  * @build jdk.test.lib.util.JarUtils
  * @run main AliasNotInStoreTest
  */
--- a/test/jdk/sun/security/tools/jarsigner/warnings/BadExtendedKeyUsageTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/BadExtendedKeyUsageTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -21,14 +21,14 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for badExtendedKeyUsage warning
- * @library /lib/testlibrary /test/lib ../
+ * @library /test/lib ../
  * @build jdk.test.lib.util.JarUtils
  * @run main BadExtendedKeyUsageTest
  */
--- a/test/jdk/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -21,14 +21,14 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for badKeyUsage warning
- * @library /lib/testlibrary /test/lib ../
+ * @library /test/lib ../
  * @ignore until 8026393 is fixed
  * @build jdk.test.lib.util.JarUtils
  * @run main BadKeyUsageTest
--- a/test/jdk/sun/security/tools/jarsigner/warnings/BadNetscapeCertTypeTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/BadNetscapeCertTypeTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -21,14 +21,14 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for badNetscapeCertType warning
- * @library /lib/testlibrary /test/lib ../
+ * @library /test/lib ../
  * @build jdk.test.lib.util.JarUtils
  * @run main BadNetscapeCertTypeTest
  */
--- a/test/jdk/sun/security/tools/jarsigner/warnings/ChainNotValidatedTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/ChainNotValidatedTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -21,7 +21,7 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.util.JarUtils;
 
 import java.nio.file.Files;
@@ -31,7 +31,7 @@
  * @test
  * @bug 8024302 8026037
  * @summary Test for chainNotValidated warning
- * @library /lib/testlibrary /test/lib ../
+ * @library /test/lib ../
  * @build jdk.test.lib.util.JarUtils
  * @run main ChainNotValidatedTest ca2yes
  * @run main ChainNotValidatedTest ca2no
--- a/test/jdk/sun/security/tools/jarsigner/warnings/HasExpiredCertTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/HasExpiredCertTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -21,14 +21,14 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for hasExpiredCert warning
- * @library /lib/testlibrary /test/lib ../
+ * @library /test/lib ../
  * @build jdk.test.lib.util.JarUtils
  * @run main HasExpiredCertTest
  */
--- a/test/jdk/sun/security/tools/jarsigner/warnings/HasExpiringCertTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/HasExpiringCertTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -21,14 +21,14 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for hasExpiringCert warning
- * @library /lib/testlibrary /test/lib ../
+ * @library /test/lib ../
  * @build jdk.test.lib.util.JarUtils
  * @run main HasExpiringCertTest
  */
--- a/test/jdk/sun/security/tools/jarsigner/warnings/HasUnsignedEntryTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/HasUnsignedEntryTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -21,14 +21,14 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for hasUnsignedEntry warning
- * @library /lib/testlibrary /test/lib ../
+ * @library /test/lib ../
  * @build jdk.test.lib.util.JarUtils
  * @run main HasUnsignedEntryTest
  */
--- a/test/jdk/sun/security/tools/jarsigner/warnings/MultipleWarningsTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/MultipleWarningsTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -21,14 +21,14 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Checks if jarsigner prints appropriate warnings
- * @library /lib/testlibrary /test/lib ../
+ * @library /test/lib ../
  * @build jdk.test.lib.util.JarUtils
  * @run main MultipleWarningsTest
  */
--- a/test/jdk/sun/security/tools/jarsigner/warnings/NoTimestampTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/NoTimestampTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -23,14 +23,14 @@
 
 import java.util.Date;
 import java.util.Locale;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037 8196213
  * @summary Checks warnings if -tsa and -tsacert options are not specified
- * @library /lib/testlibrary /test/lib ../
+ * @library /test/lib ../
  * @build jdk.test.lib.util.JarUtils
  * @run main NoTimestampTest
  */
--- a/test/jdk/sun/security/tools/jarsigner/warnings/NotSignedByAliasTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/NotSignedByAliasTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -21,14 +21,14 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for notSignedByAlias warning
- * @library /lib/testlibrary /test/lib ../
+ * @library /test/lib ../
  * @build jdk.test.lib.util.JarUtils
  * @run main NotSignedByAliasTest
  */
--- a/test/jdk/sun/security/tools/jarsigner/warnings/NotYetValidCertTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/NotYetValidCertTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -21,14 +21,14 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for notYetValidCert warning
- * @library /lib/testlibrary /test/lib ../
+ * @library /test/lib ../
  * @build jdk.test.lib.util.JarUtils
  * @run main NotYetValidCertTest
  */
--- a/test/jdk/sun/security/tools/jarsigner/warnings/Test.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/Test.java	Fri Sep 07 15:46:39 2018 -0700
@@ -21,8 +21,8 @@
  * questions.
  */
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 import java.util.ArrayList;
 import java.util.Arrays;
--- a/test/jdk/sun/tools/jcmd/JcmdBase.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/tools/jcmd/JcmdBase.java	Fri Sep 07 15:46:39 2018 -0700
@@ -23,8 +23,8 @@
 
 import java.util.Arrays;
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.JDKToolLauncher;
 
 /**
--- a/test/jdk/sun/tools/jcmd/TestJcmdDefaults.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/tools/jcmd/TestJcmdDefaults.java	Fri Sep 07 15:46:39 2018 -0700
@@ -23,14 +23,13 @@
 
 import static jdk.testlibrary.Asserts.*;
 
-import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.List;
 
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.testlibrary.Utils;
 
 /*
@@ -40,6 +39,7 @@
  * requests to a specific JVM process.
  *
  * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @build jdk.testlibrary.*
  * @run main TestJcmdDefaults
@@ -90,12 +90,9 @@
      * 24428 com.sun.javatest.regtest.MainWrapper /tmp/jtreg/jtreg-workdir/classes/sun/tools/jcmd/TestJcmdDefaults.jta
      *
      * @param output The generated output from the jcmd.
-     * @throws Exception
      */
-    private static void matchListedProcesses(OutputAnalyzer output) throws Exception {
-        int matchedCount = output.shouldMatchByLine(JCMD_LIST_REGEX);
-        assertGreaterThan(matchedCount , 0,
-                "Found no lines matching pattern: " + JCMD_LIST_REGEX);
+    private static void matchListedProcesses(OutputAnalyzer output) {
+        output.shouldMatchByLine(JCMD_LIST_REGEX);
     }
 
     private static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException {
--- a/test/jdk/sun/tools/jcmd/TestJcmdSanity.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/tools/jcmd/TestJcmdSanity.java	Fri Sep 07 15:46:39 2018 -0700
@@ -30,8 +30,8 @@
 import java.nio.file.Paths;
 import java.util.List;
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Utils;
 
 /*
@@ -41,6 +41,7 @@
  * command requests to the current java process.
  *
  * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @build jdk.testlibrary.*
  * @run main/othervm -XX:+UsePerfData TestJcmdSanity
@@ -134,12 +135,10 @@
      * @param output The generated output from the jcmd.
      * @throws Exception
      */
-    private static void matchJcmdCommands(OutputAnalyzer output) throws Exception {
-        int matchedCount = output.shouldMatchByLine(JCMD_COMMAND_REGEX,
+    private static void matchJcmdCommands(OutputAnalyzer output) {
+        output.shouldMatchByLine(JCMD_COMMAND_REGEX,
                 "help",
                 JCMD_COMMAND_REGEX);
-        assertGreaterThan(matchedCount , 0,
-                "Found no lines matching pattern: " + JCMD_COMMAND_REGEX);
     }
 
     /**
@@ -154,11 +153,9 @@
      * @param output The generated output from the PerfCounter.print command.
      * @throws Exception
      */
-    private static void matchPerfCounters(OutputAnalyzer output) throws Exception {
-        int matchedCount = output.shouldMatchByLineFrom(PERF_COUNTER_REGEX,
+    private static void matchPerfCounters(OutputAnalyzer output) {
+        output.shouldMatchByLineFrom(PERF_COUNTER_REGEX,
                 PERF_COUNTER_REGEX);
-        assertGreaterThan(matchedCount , 0,
-                "Found no lines matching pattern: " + PERF_COUNTER_REGEX);
     }
 
     private static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException {
--- a/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -40,12 +40,12 @@
 import java.util.List;
 import java.util.Arrays;
 import java.util.Optional;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.apps.LingeredApp;
+import jdk.test.lib.Platform;
 import jdk.testlibrary.JDKToolLauncher;
 import jdk.testlibrary.Utils;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
-import jdk.test.lib.apps.LingeredApp;
-import jdk.test.lib.Platform;
 
 public class BasicLauncherTest {
 
--- a/test/jdk/sun/tools/jhsdb/HeapDumpTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/tools/jhsdb/HeapDumpTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -38,12 +38,13 @@
 import java.io.File;
 import java.util.List;
 import java.util.Arrays;
-import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.apps.LingeredApp;
 import jdk.test.lib.Platform;
 import jdk.test.lib.hprof.parser.HprofReader;
+import jdk.testlibrary.JDKToolLauncher;
 
 public class HeapDumpTest {
 
--- a/test/jdk/sun/tools/jinfo/BasicJInfoTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/tools/jinfo/BasicJInfoTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,14 +23,15 @@
 
 import java.util.Arrays;
 
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 
 /*
  * @test
  * @summary Unit test for jinfo utility
  * @library /lib/testlibrary
+ * @library /test/lib
  * @build jdk.testlibrary.*
  * @run main BasicJInfoTest
  */
--- a/test/jdk/sun/tools/jmap/BasicJMapTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/tools/jmap/BasicJMapTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,9 +28,9 @@
 import java.util.Arrays;
 
 import jdk.test.lib.hprof.HprofParser;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 
 /*
  * @test
--- a/test/jdk/sun/tools/jps/JpsHelper.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/tools/jps/JpsHelper.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -35,11 +35,11 @@
 import java.util.Arrays;
 import java.util.List;
 
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Asserts;
 import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.OutputAnalyzer;
 import jdk.testlibrary.Utils;
-import jdk.testlibrary.ProcessTools;
 
 /**
  * The helper class for running jps utility and verifying output from it
@@ -184,10 +184,9 @@
      * 35417 Main
      * 31103 org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
      */
-    public static void verifyJpsOutput(OutputAnalyzer output, String regex) throws Exception {
+    public static void verifyJpsOutput(OutputAnalyzer output, String regex) {
         output.shouldHaveExitValue(0);
-        int matchedCount = output.stdoutShouldMatchByLine(regex);
-        assertGreaterThan(matchedCount , 0, "Found no lines matching pattern: " + regex);
+        output.stdoutShouldMatchByLine(regex);
         output.stderrShouldNotMatch("[E|e]xception");
         output.stderrShouldNotMatch("[E|e]rror");
     }
--- a/test/jdk/sun/tools/jps/TestJpsSanity.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/tools/jps/TestJpsSanity.java	Fri Sep 07 15:46:39 2018 -0700
@@ -22,7 +22,7 @@
  */
 
 import jdk.testlibrary.Asserts;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.apps.LingeredApp;
 
 /*
--- a/test/jdk/sun/tools/jstack/BasicJStackTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/tools/jstack/BasicJStackTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,14 +23,15 @@
 
 import java.util.Arrays;
 
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 
 /*
  * @test
  * @summary Unit test for jstack utility
  * @library /lib/testlibrary
+ * @library /test/lib
  * @build jdk.testlibrary.*
  * @run main BasicJStackTest
  */
--- a/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -28,11 +28,11 @@
 import jdk.test.lib.apps.LingeredApp;
 import jdk.test.lib.apps.LingeredAppWithDeadlock;
 import jdk.test.lib.Platform;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 import jdk.testlibrary.Utils;
 import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 
 /**
  * @test
--- a/test/jdk/sun/tools/jstat/JStatInterval.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/tools/jstat/JStatInterval.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -25,6 +25,7 @@
  * @test
  * @bug 8035668
  * @library /lib/testlibrary
+ * @library /test/lib
  * @summary Test checks case when target application finishes execution and jstat didn't complete work.
             jstat is started with interval = 100 (jstat -compiler 100) and monitored application finishes
             after 500ms. This shouldn't cause crash or hang in target application or in jstat.
@@ -33,7 +34,7 @@
  * @run main JStatInterval
  */
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.JDKToolLauncher;
 
 import java.util.concurrent.TimeUnit;
--- a/test/jdk/sun/tools/jstatd/JstatdTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/tools/jstatd/JstatdTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -32,8 +32,8 @@
 import static jdk.testlibrary.Asserts.*;
 import jdk.testlibrary.JDKToolLauncher;
 import jdk.testlibrary.Utils;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 /**
  * The base class for tests of jstatd.
@@ -328,7 +328,7 @@
         }
 
         // Verify output from jstatd
-        jdk.test.lib.process.OutputAnalyzer output = jstatdThread.getOutput();
+        OutputAnalyzer output = jstatdThread.getOutput();
         assertTrue(output.getOutput().isEmpty(),
                 "jstatd should get an empty output, got: "
                 + Utils.NEW_LINE + output.getOutput());
--- a/test/jdk/sun/tools/jstatd/TestJstatdUsage.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/sun/tools/jstatd/TestJstatdUsage.java	Fri Sep 07 15:46:39 2018 -0700
@@ -22,8 +22,8 @@
  */
 
 import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 /*
  * @test
--- a/test/jdk/tools/jimage/JImageToolTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/jimage/JImageToolTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,8 +22,8 @@
  */
 /*
  * @test
- * @library /lib/testlibrary
- * @build jdk.testlibrary.ProcessTools
+ * @library /test/lib
+ * @build jdk.test.lib.process.ProcessTools
  * @summary Test to check if jimage tool exists and is working
  * @run main/timeout=360 JImageToolTest
  */
@@ -34,7 +34,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 /**
  * Basic test for jimage tool.
--- a/test/jdk/tools/jlink/basic/AllModulePath.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/jlink/basic/AllModulePath.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,10 +24,10 @@
 /*
  * @test
  * @summary jlink test of --add-module ALL-MODULE-PATH
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
- * @build jdk.testlibrary.ProcessTools
- *        jdk.testlibrary.OutputAnalyzer
+ * @build jdk.test.lib.process.ProcessTools
+ *        jdk.test.lib.process.OutputAnalyzer
  *        jdk.test.lib.compiler.CompilerUtils
  * @run testng AllModulePath
  */
@@ -49,7 +49,7 @@
 import java.util.spi.ToolProvider;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
--- a/test/jdk/tools/jlink/basic/BasicTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/jlink/basic/BasicTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,8 +29,8 @@
  * @modules java.base/jdk.internal.module
  *          jdk.jlink
  *          jdk.compiler
- * @build jdk.testlibrary.ProcessTools
- *        jdk.testlibrary.OutputAnalyzer
+ * @build jdk.test.lib.process.ProcessTools
+ *        jdk.test.lib.process.OutputAnalyzer
  *        JarUtils jdk.test.lib.compiler.CompilerUtils
  * @run main BasicTest
  */
@@ -46,8 +46,8 @@
 import java.util.spi.ToolProvider;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 public class BasicTest {
     static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
--- a/test/jdk/tools/jlink/bindservices/BindServices.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/jlink/bindservices/BindServices.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -34,7 +34,7 @@
 import java.util.stream.Stream;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -43,9 +43,9 @@
 /**
  * @test
  * @bug 8174826
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler jdk.jlink
- * @build BindServices jdk.testlibrary.ProcessTools
+ * @build BindServices jdk.test.lib.process.ProcessTools
  *        jdk.test.lib.compiler.CompilerUtils
  * @run testng BindServices
  */
--- a/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@
 
 import jdk.test.lib.compiler.CompilerUtils;
 import jdk.test.lib.util.FileUtils;
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 
 
 import org.testng.annotations.BeforeTest;
@@ -40,12 +40,12 @@
 
 /**
  * @test
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler jdk.jlink
  * @build jdk.test.lib.compiler.CompilerUtils
  *        jdk.test.lib.util.FileUtils
  *        jdk.test.lib.Platform
- *        CompiledVersionTest jdk.testlibrary.ProcessTools
+ *        CompiledVersionTest jdk.test.lib.process.ProcessTools
  * @run testng CompiledVersionTest
  */
 
--- a/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
 import jdk.test.lib.compiler.CompilerUtils;
 import jdk.test.lib.util.FileUtils;
 
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -51,7 +51,7 @@
  * @build jdk.test.lib.compiler.CompilerUtils
  *        jdk.test.lib.util.FileUtils
  *        jdk.test.lib.Platform
- *        ModuleTargetHelper UserModuleTest jdk.testlibrary.ProcessTools
+ *        ModuleTargetHelper UserModuleTest jdk.test.lib.process.ProcessTools
  * @run testng UserModuleTest
  */
 
--- a/test/jdk/tools/launcher/InfoStreams.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/InfoStreams.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,15 +23,14 @@
 
 /**
  * @test
- * @library /lib/testlibrary
- * @build InfoStreams jdk.testlibrary.ProcessTools
+ * @library /test/lib
+ * @build InfoStreams jdk.test.lib.process.ProcessTools
  * @run main InfoStreams
  * @summary Test that informational options use the correct streams
  */
 
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.OutputAnalyzer;
-
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
 
 public class InfoStreams {
 
--- a/test/jdk/tools/launcher/modules/addexports/AddExportsTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/addexports/AddExportsTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -23,9 +23,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
- * @build AddExportsTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @build AddExportsTest jdk.test.lib.compiler.CompilerUtils
  * @run testng AddExportsTest
  * @summary Basic tests for java --add-exports
  */
@@ -35,8 +35,8 @@
 import java.util.stream.Stream;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import jdk.testlibrary.OutputAnalyzer;
-import static jdk.testlibrary.ProcessTools.*;
+import jdk.test.lib.process.OutputAnalyzer;
+import static jdk.test.lib.process.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/tools/launcher/modules/addexports/AddExportsTestWarningError.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/addexports/AddExportsTestWarningError.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,10 @@
  * @test
  * @bug 8168836
  * @summary Basic argument validation for --add-exports
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
  * @build jdk.test.lib.compiler.ModuleInfoMaker
  *        jdk.test.lib.compiler.CompilerUtils
- *        jdk.testlibrary.*
  * @run testng AddExportsTestWarningError
  */
 
@@ -42,8 +41,8 @@
 import java.util.stream.Stream;
 
 import jdk.test.lib.compiler.ModuleInfoMaker;
-import jdk.testlibrary.OutputAnalyzer;
-import static jdk.testlibrary.ProcessTools.*;
+import jdk.test.lib.process.OutputAnalyzer;
+import static jdk.test.lib.process.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/tools/launcher/modules/addexports/manifest/AddExportsAndOpensInManifest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/addexports/manifest/AddExportsAndOpensInManifest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -24,6 +24,7 @@
 /**
  * @test
  * @library /lib/testlibrary
+ * @library /test/lib
  * @modules jdk.compiler
  * @build AddExportsAndOpensInManifest Test2 JarUtils jdk.testlibrary.*
  * @compile --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED Test1.java
@@ -39,8 +40,8 @@
 import java.util.jar.Attributes;
 import java.util.jar.Manifest;
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
--- a/test/jdk/tools/launcher/modules/addmods/AddModsTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/addmods/AddModsTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -23,10 +23,10 @@
 
 /**
  * @test
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.jlink/jdk.tools.jmod
  *          jdk.compiler
- * @build AddModsTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @build AddModsTest jdk.test.lib.compiler.CompilerUtils
  * @run testng AddModsTest
  * @summary Basic test for java --add-modules
  */
@@ -36,7 +36,7 @@
 import java.nio.file.Paths;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/test/jdk/tools/launcher/modules/addreads/AddReadsTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/addreads/AddReadsTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build AddReadsTest JarUtils jdk.testlibrary.*
+ * @build AddReadsTest JarUtils
  *        jdk.test.lib.compiler.CompilerUtils
  * @run testng AddReadsTest
  * @summary Basic tests for java --add-reads
@@ -35,8 +35,8 @@
 import java.nio.file.Paths;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import jdk.testlibrary.OutputAnalyzer;
-import static jdk.testlibrary.ProcessTools.*;
+import jdk.test.lib.process.OutputAnalyzer;
+import static jdk.test.lib.process.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/tools/launcher/modules/addreads/AddReadsTestWarningError.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/addreads/AddReadsTestWarningError.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,10 @@
  * @test
  * @bug 8168836
  * @summary  Basic argument validation for --add-reads
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
  * @build jdk.test.lib.compiler.ModuleInfoMaker
  * @build jdk.test.lib.compiler.CompilerUtils
- * @build jdk.testlibrary.*
  * @build AddReadsTestWarningError
  * @run testng AddReadsTestWarningError
  */
@@ -43,8 +42,8 @@
 import java.util.stream.Stream;
 
 import jdk.test.lib.compiler.ModuleInfoMaker;
-import jdk.testlibrary.OutputAnalyzer;
-import static jdk.testlibrary.ProcessTools.*;
+import jdk.test.lib.process.OutputAnalyzer;
+import static jdk.test.lib.process.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/tools/launcher/modules/basic/BasicTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/basic/BasicTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -23,11 +23,11 @@
 
 /**
  * @test
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
  *          jdk.jartool
  *          jdk.jlink
- * @build BasicTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @build BasicTest jdk.test.lib.compiler.CompilerUtils
  * @run testng BasicTest
  * @summary Basic test of starting an application as a module
  */
@@ -39,7 +39,7 @@
 import java.util.spi.ToolProvider;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/test/jdk/tools/launcher/modules/basic/InitErrors.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/basic/InitErrors.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -23,8 +23,8 @@
 
 /**
  * @test
- * @library /lib/testlibrary
- * @build InitErrors jdk.testlibrary.*
+ * @library /test/lib
+ * @build InitErrors
  * @run testng InitErrors
  * @summary Basic test to ensure that module system initialization errors
  *          go the right stream and with the right level of verbosity
@@ -32,8 +32,8 @@
 
 
 import java.util.Arrays;
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 
--- a/test/jdk/tools/launcher/modules/classpath/JavaClassPathTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/classpath/JavaClassPathTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,24 +29,27 @@
 import java.util.List;
 import java.util.Map;
 import java.util.spi.ToolProvider;
+import java.util.stream.Stream;
 
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.Platform;
 import jdk.test.lib.compiler.CompilerUtils;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 import static org.testng.Assert.assertTrue;
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 
 /**
  * @test
  * @bug 8168205
  * @summary Test the default class path if -Djava.class.path is set
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
  *          jdk.jartool
- * @build jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @build jdk.test.lib.compiler.CompilerUtils
  * @run testng JavaClassPathTest
  */
 
@@ -197,28 +200,27 @@
     }
 
     private OutputAnalyzer execute(List<String> options) throws Throwable {
-        ProcessBuilder pb = createJavaProcessBuilder(
-            options.stream()
-                   .map(this::autoQuote)
-                   .toArray(String[]::new)
+        // can't use ProcessTools.createJavaProcessBuilder as it always adds -cp
+        ProcessBuilder pb = new ProcessBuilder(
+                Stream.concat(Stream.of(JDKToolFinder.getTestJDKTool("java")),
+                              options.stream()
+                                     .map(this::autoQuote))
+                      .toArray(String[]::new)
         );
 
         Map<String,String> env = pb.environment();
         // remove CLASSPATH environment variable
-        String value = env.remove("CLASSPATH");
+        env.remove("CLASSPATH");
         return executeCommand(pb)
                     .outputTo(System.out)
                     .errorTo(System.out);
     }
 
-    private static final boolean IS_WINDOWS
-        = System.getProperty("os.name").startsWith("Windows");
-
     /*
      * Autoquote empty string argument on Windows
      */
     private String autoQuote(String arg) {
-        if (IS_WINDOWS && arg.isEmpty()) {
+        if (Platform.isWindows() && arg.isEmpty()) {
             return "\"\"";
         }
         return arg;
--- a/test/jdk/tools/launcher/modules/describe/DescribeModuleTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/describe/DescribeModuleTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -24,13 +24,13 @@
 /**
  * @test
  * @modules java.xml
- * @library /lib/testlibrary
- * @build DescribeModuleTest jdk.testlibrary.*
+ * @library /test/lib
+ * @build DescribeModuleTest
  * @run testng DescribeModuleTest
  * @summary Basic test for java --describe-module
  */
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
--- a/test/jdk/tools/launcher/modules/dryrun/DryRunTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/dryrun/DryRunTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,10 +24,10 @@
 /**
  * @test
  * @bug 8159596
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
  *          jdk.jartool
- * @build DryRunTest jdk.testlibrary.ProcessTools
+ * @build DryRunTest jdk.test.lib.process.ProcessTools
  *        jdk.test.lib.compiler.CompilerUtils
  * @run testng DryRunTest
  * @summary Test java --dry-run
@@ -41,7 +41,7 @@
 import java.util.spi.ToolProvider;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/test/jdk/tools/launcher/modules/illegalaccess/IllegalAccessTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/illegalaccess/IllegalAccessTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -29,7 +29,6 @@
  * @library /test/lib /lib/testlibrary modules
  * @build IllegalAccessTest TryAccess JarUtils
  *        jdk.test.lib.compiler.CompilerUtils
- *        jdk.testlibrary.*
  * @build m/*
  * @run testng/othervm/timeout=180 IllegalAccessTest
  * @summary Basic test for java --illegal-access=$VALUE
@@ -45,8 +44,8 @@
 import java.util.stream.Stream;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
 
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
--- a/test/jdk/tools/launcher/modules/limitmods/LimitModsTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/limitmods/LimitModsTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -24,9 +24,9 @@
 /**
  * @test
  * @requires !vm.graal.enabled
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules java.desktop java.logging jdk.compiler
- * @build LimitModsTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @build LimitModsTest jdk.test.lib.compiler.CompilerUtils
  * @run testng LimitModsTest
  * @summary Basic tests for java --limit-modules
  */
@@ -35,7 +35,7 @@
 import java.nio.file.Paths;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/test/jdk/tools/launcher/modules/listmods/ListModsTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/listmods/ListModsTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,9 +24,9 @@
 /**
  * @test
  * @requires !vm.graal.enabled
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules java.se
- * @build ListModsTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @build ListModsTest jdk.test.lib.compiler.CompilerUtils
  * @run testng ListModsTest
  * @summary Basic test for java --list-modules
  */
@@ -35,8 +35,8 @@
 import java.nio.file.Paths;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/test/jdk/tools/launcher/modules/patch/basic/PatchTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/patch/basic/PatchTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
  * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
  *          jdk.naming.dns
- * @build PatchTest JarUtils jdk.testlibrary.*
+ * @build PatchTest JarUtils
  *        jdk.test.lib.compiler.CompilerUtils
  * @run testng PatchTest
  * @summary Basic test for --patch-module
@@ -40,7 +40,7 @@
 import java.util.stream.Stream;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/test/jdk/tools/launcher/modules/patch/basic/PatchTestWarningError.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/patch/basic/PatchTestWarningError.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
  * @summary Basic argument validation for --patch-module
  * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build PatchTestWarningError JarUtils jdk.testlibrary.*
+ * @build PatchTestWarningError JarUtils
  *        jdk.test.lib.compiler.CompilerUtils
  * @run testng PatchTestWarningError
  */
@@ -40,7 +40,7 @@
 import java.util.stream.Stream;
 
 import jdk.test.lib.compiler.CompilerUtils;
-import static jdk.testlibrary.ProcessTools.*;
+import static jdk.test.lib.process.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
-import static jdk.testlibrary.ProcessTools.executeCommand;
+import static jdk.test.lib.process.ProcessTools.executeCommand;
 import static org.testng.Assert.*;
 
 public class PatchSystemModules {
--- a/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -25,13 +25,13 @@
  * @test
  * @requires !vm.graal.enabled
  * @modules jdk.jdeps jdk.zipfs
- * @library /lib/testlibrary
- * @build ShowModuleResolutionTest jdk.testlibrary.*
+ * @library /test/lib
+ * @build ShowModuleResolutionTest
  * @run testng ShowModuleResolutionTest
  * @summary Basic test for java --show-module-resolution
  */
 
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.process.ProcessTools;
 
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
--- a/test/jdk/tools/launcher/modules/validate/ValidateModulesTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/jdk/tools/launcher/modules/validate/ValidateModulesTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @bug 8178380 8194937
  * @modules java.xml
- * @library src /lib/testlibrary
- * @build ValidateModulesTest hello/* JarUtils jdk.testlibrary.*
+ * @library src /lib/testlibrary /test/lib
+ * @build ValidateModulesTest hello/* JarUtils
  * @run testng ValidateModulesTest
  * @summary Basic test for java --validate-modules
  */
@@ -36,8 +36,8 @@
 import java.nio.file.Files;
 import java.nio.file.Path;
 
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
 
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/T8210435/NoLocalsMustBeReservedForDCEedVarsTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @summary
+ * @library /tools/lib
+ * @modules jdk.jdeps/com.sun.tools.classfile
+ *          jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.main
+ *          jdk.compiler/com.sun.tools.javac.util
+ *          jdk.jdeps/com.sun.tools.javap
+ * @build toolbox.ToolBox toolbox.JavacTask
+ * @run main NoLocalsMustBeReservedForDCEedVarsTest
+ */
+
+import java.io.File;
+import java.nio.file.Paths;
+
+import com.sun.tools.classfile.*;
+import com.sun.tools.javac.util.Assert;
+
+import toolbox.JavacTask;
+import toolbox.ToolBox;
+
+public class NoLocalsMustBeReservedForDCEedVarsTest {
+
+    static final String source =
+            "class Test {\n" +
+            "    static String foo() {\n" +
+            "        final String hello = \"Hello!\";\n" +
+            "        return hello;\n" +
+            "    }\n" +
+            "} ";
+
+    public static void main(String[] args) throws Exception {
+        new NoLocalsMustBeReservedForDCEedVarsTest().run();
+    }
+
+    void run() throws Exception {
+        ToolBox tb = new ToolBox();
+        new JavacTask(tb)
+                .sources(source)
+                .run();
+
+        File cfile = new File(Paths.get(System.getProperty("user.dir"), "Test.class").toUri());
+        ClassFile classFile = ClassFile.read(cfile);
+        for (Method method: classFile.methods) {
+            if (method.getName(classFile.constant_pool).equals("foo")) {
+                Code_attribute codeAttr = (Code_attribute)method.attributes.get("Code");
+                Assert.check(codeAttr.max_locals == 0, "max locals found " + codeAttr.max_locals);
+            }
+        }
+    }
+}
--- a/test/langtools/tools/javac/diags/examples.not-yet.txt	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/langtools/tools/javac/diags/examples.not-yet.txt	Fri Sep 07 15:46:39 2018 -0700
@@ -174,12 +174,14 @@
 compiler.err.invalid.profile
 compiler.err.invalid.source
 compiler.err.invalid.target
+compiler.err.multiple.values.for.module.source.path
 compiler.err.no.source.files.classes
 compiler.err.no.value.for.option
 compiler.err.option.not.allowed.with.target
 compiler.err.option.too.many
 compiler.err.profile.bootclasspath.conflict
 compiler.err.release.bootclasspath.conflict
+compiler.err.repeated.value.for.module.source.path
 compiler.err.repeated.value.for.patch.module
 compiler.err.req.arg
 compiler.err.sourcepath.modulesourcepath.conflict
--- a/test/langtools/tools/javac/file/SetLocationForModule.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/langtools/tools/javac/file/SetLocationForModule.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -160,8 +160,7 @@
             Path src1 = Files.createDirectories(base.resolve("src1"));
             Path src1_m = src1.resolve("m");
             tb.writeJavaFiles(src1_m, "module m { }");
-//            fm.setLocationFromPaths(locn, List.of(src1));
-            fm.handleOption("--module-source-path", List.of(src1.toString()).iterator());
+            fm.setLocationFromPaths(locn, List.of(src1));
 
             Location m = fm.getLocationForModule(locn, "m");
             checkEqual("default setting",
@@ -186,8 +185,7 @@
             Path src2 = Files.createDirectories(base.resolve("src2"));
             Path src2_m = src2.resolve("m");
             tb.writeJavaFiles(src2_m, "module m { }");
-//            fm.setLocationFromPaths(locn, List.of(src2));
-            fm.handleOption("--module-source-path", List.of(src2.toString()).iterator());
+            fm.setLocationFromPaths(locn, List.of(src2));
 
             m = fm.getLocationForModule(locn, "m");
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/lambda/8210495/T8210495.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,66 @@
+/*
+ * 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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
+ * @bug 8210495
+ * @summary compiler crashes because of illegal signature in otherwise legal code
+ * @compile T8210495.java
+ */
+
+import java.awt.*;
+import java.awt.event.ActionListener;
+import java.util.List;
+
+class T8210495 {
+    interface IFilter {
+        Component getComponent();
+    }
+
+    static class Filter implements IFilter {
+        @Override
+        public Component getComponent() {
+            return null;
+        }
+
+    }
+
+    public Component buildFilter(List<? extends Filter> l, Dialog dialog) {
+        Panel c = new Panel();
+        l.stream()
+                .map(f -> {
+                    Button btn = (Button)f.getComponent();
+                    btn.addActionListener((java.io.Serializable & ActionListener)evt -> {
+                        applyFilter(f);
+                        dialog.setVisible(false);
+                    });
+                    return btn;
+                })
+                .forEach(c::add);
+        return c;
+    }
+
+    private void applyFilter(IFilter f) { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/launcher/GetResourceTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8210009
+ * @summary Source Launcher classloader should support getResource and getResourceAsStream
+ * @modules jdk.compiler jdk.jdeps
+ * @library /tools/lib
+ * @build toolbox.JavaTask toolbox.ToolBox
+ * @run main GetResourceTest
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import toolbox.JavaTask;
+import toolbox.Task;
+import toolbox.ToolBox;
+
+/*
+ * The body of this test is in ${test.src}/src/CLTest.java,
+ * which is executed in single-file source-launcher mode,
+ * in order to test the classloader used to launch such programs.
+ */
+public class GetResourceTest {
+    public static void main(String... args) throws Exception {
+        GetResourceTest t = new GetResourceTest();
+        t.run();
+    }
+
+    void run() throws Exception {
+        ToolBox tb = new ToolBox();
+        Path file = Paths.get(tb.testSrc).resolve("src").resolve("CLTest.java");
+        new JavaTask(tb)
+            .vmOptions("--add-modules", "jdk.jdeps",
+                       "--add-exports", "jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED")
+            .className(file.toString()) // implies source file mode
+            .run(Task.Expect.SUCCESS)
+            .writeAll();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/launcher/src/CLTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,181 @@
+/*
+ * 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.
+ */
+
+/*
+ * This class is intended to be run in the single source-file launcher
+ * mode defined by JEP 330. It checks the operation of the getResource*
+ * methods provided by the MemoryClassLoader used to run the compiled
+ * classes.
+ *
+ * The class uses the ClassFile library to validate the contents of
+ * the URLs and streams returned by the methods being tested.
+ *
+ * $ java \
+ *      --add-modules jdk.jdeps \
+ *      --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED
+ *      /path/to/CLTest.java
+ */
+package p.q;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import com.sun.tools.classfile.ClassFile;
+
+public class CLTest {
+        public static void main(String... args) throws Exception {
+                try {
+                        new CLTest().run();
+                } catch (Throwable t) {
+                        t.printStackTrace();
+                        System.exit(1);
+                }
+        }
+
+        void run() throws Exception {
+                String[] names = {
+                                "p/q/CLTest.class",
+                                "p/q/CLTest$Inner.class",
+                                "p/q/CLTest2.class",
+                                "java/lang/Object.class",
+                                "UNKNOWN.class",
+                                "UNKNOWN"
+                };
+
+                for (String name : names) {
+                        testGetResource(name);
+                        testGetResources(name);
+                        testGetResourceAsStream(name);
+                }
+
+                if (errors > 0) {
+                        throw new Exception(errors + " errors found");
+                }
+        }
+
+    void testGetResource(String name) {
+                System.err.println("testGetResource: " + name);
+        try {
+            ClassLoader cl = getClass().getClassLoader();
+            URL u = cl.getResource(name);
+            if (u == null) {
+                if (!name.contains("UNKNOWN")) {
+                    error("resource not found: " + name);
+                }
+                return;
+            }
+
+            checkURL(u);
+            checkClass(name, u);
+
+        } catch (Throwable t) {
+            t.printStackTrace(System.err);
+            error("unexpected exception: " + t);
+        }
+    }
+
+    void testGetResources(String name) {
+                System.err.println("testGetResources: " + name);
+        try {
+            ClassLoader cl = getClass().getClassLoader();
+            Enumeration<URL> e = cl.getResources(name);
+            List<URL> list = new ArrayList<>();
+            while (e.hasMoreElements()) {
+                list.add(e.nextElement());
+            }
+
+            switch (list.size()) {
+                case 0:
+                    if (!name.contains("UNKNOWN")) {
+                        error("resource not found: " + name);
+                    }
+                    break;
+
+                case 1:
+                    checkClass(name, list.get(0));
+                    break;
+
+                default:
+                    error("unexpected resources found: " + list);
+            }
+
+        } catch (Throwable t) {
+            t.printStackTrace(System.err);
+            error("unexpected exception: " + t);
+        }
+    }
+
+    void testGetResourceAsStream(String name) {
+        System.err.println("testGetResourceAsStream: " + name);
+        try {
+            ClassLoader cl = getClass().getClassLoader();
+            try (InputStream in = cl.getResourceAsStream(name)) {
+                if (in == null) {
+                    if (!name.contains("UNKNOWN")) {
+                        error("resource not found: " + name);
+                    }
+                    return;
+                }
+
+                checkClass(name, in);
+            }
+        } catch (Throwable t) {
+            t.printStackTrace(System.err);
+            error("unexpected exception: " + t);
+        }
+    }
+
+    void checkClass(String name, URL u) throws Exception {
+        try (InputStream in = u.openConnection().getInputStream()) {
+            checkClass(name, in);
+        }
+    }
+
+    void checkClass(String name, InputStream in) throws Exception {
+        ClassFile cf = ClassFile.read(in);
+        System.err.println("    class " + cf.getName());
+        if (!name.equals(cf.getName() + ".class")) {
+            error("unexpected class found: " + cf.getName());
+        }
+    }
+
+    void checkURL(URL url) {
+        try {
+            // verify the URL is formatted strictly according to RFC2396
+            url.toURI();
+        } catch (URISyntaxException e) {
+            error("bad URL: " + url + "; " + e);
+        }
+    }
+
+    void error(String message) {
+        System.err.println("Error: " + message);
+        errors++;
+    }
+
+    int errors = 0;
+
+    class Inner { }
+}
+
+class CLTest2 { }
--- a/test/langtools/tools/javac/modules/ModuleSourcePathTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/langtools/tools/javac/modules/ModuleSourcePathTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -519,11 +519,175 @@
         }
     }
 
+    @Test
+    public void moduleSpecificFormsOnly(Path base) throws Exception {
+        // The dirs for the modules do not use a subdirectory named for the module,
+        // meaning they can only be used by the module-specific form of the option.
+        String[] srcDirs = {
+                "src0",         // m0x
+                "src1",         // m1x
+                "src2",         // m2x
+                "src3"          // m3x
+        };
+        generateModules(base, false, srcDirs);
+
+        final Path modules = base.resolve("modules");
+        tb.createDirectories(modules);
+
+        new JavacTask(tb, Task.Mode.CMDLINE)
+                .options("-XDrawDiagnostics",
+                        "--module-source-path", "m0x=" + base.resolve("src0"),
+                        "--module-source-path", "m1x=" + base.resolve("src1"),
+                        "--module-source-path", "m2x=" + base.resolve("src2"),
+                        "--module-source-path", "m3x=" + base.resolve("src3"))
+                .files(findJavaFiles(base.resolve(srcDirs[srcDirs.length - 1])))
+                .outdir(modules)
+                .run()
+                .writeAll();
+
+        for (int i = 0; i < srcDirs.length; i++) {
+            checkFiles(modules.resolve("m" + i + "x/module-info.class"));
+        }
+        checkFiles(modules.resolve("m3x/pkg3/A.class"));
+    }
+
+    @Test
+    public void modulePatternWithEquals(Path base) throws Exception {
+        // The dirs for the modules contain an '=' character, but
+        // the option should still be recognized as the module pattern form.
+        String[] srcDirs = {
+                "src=",         // m0x
+                "src=",         // m1x
+                "src=",         // m2x
+                "src="  // m3x
+        };
+        generateModules(base, true, srcDirs);
+
+        final Path modules = base.resolve("modules");
+        tb.createDirectories(modules);
+
+        new JavacTask(tb, Task.Mode.CMDLINE)
+                .options("-XDrawDiagnostics",
+                        "--module-source-path", base.resolve("src=").toString())
+                .files(findJavaFiles(base.resolve(srcDirs[srcDirs.length - 1])))
+                .outdir(modules)
+                .run()
+                .writeAll();
+
+        for (int i = 0; i < srcDirs.length; i++) {
+            checkFiles(modules.resolve("m" + i + "x/module-info.class"));
+        }
+        checkFiles(modules.resolve("m3x/pkg3/A.class"));
+    }
+
+    @Test
+    public void duplicateModuleSpecificForms(Path base) throws Exception {
+        // The dirs for the modules do not use a subdirectory named for the module,
+        // meaning they can only be used by the module-specific form of the option.
+        String[] srcDirs = {
+                "src0",         // m0x
+                "src1",         // m1x
+                "src2",         // m2x
+                "src3"          // m3x
+        };
+        generateModules(base, false, srcDirs);
+
+        final Path modules = base.resolve("modules");
+        tb.createDirectories(modules);
+
+        // in the following, it should not matter that src1 does not contain
+        // a definition of m0x; it is bad/wrong to specify the option for m0x twice.
+        String log = new JavacTask(tb, Task.Mode.CMDLINE)
+                .options("-XDrawDiagnostics",
+                        "--module-source-path", "m0x=" + base.resolve("src0"),
+                        "--module-source-path", "m0x=" + base.resolve("src1"))
+                .files(findJavaFiles(base.resolve(srcDirs[srcDirs.length - 1])))
+                .outdir(modules)
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (!log.contains("error: --module-source-path specified more than once for module m0x"))
+            throw new Exception("Expected error message not found");
+    }
+
+    @Test
+    public void duplicateModulePatternForms(Path base) throws Exception {
+        // module-specific subdirs are used to allow for use of module-pattern form
+        String[] srcDirs = {
+                "src",  // m0x
+                "src",  // m1x
+                "src",  // m2x
+                "src"   // m3x
+        };
+        generateModules(base, true, srcDirs);
+
+        final Path modules = base.resolve("modules");
+        tb.createDirectories(modules);
+
+        // in the following, it should not matter that the same pattern
+        // is used for both occurrences; it is bad/wrong to give any two patterns
+        String log = new JavacTask(tb, Task.Mode.CMDLINE)
+                .options("-XDrawDiagnostics",
+                        "--module-source-path", base.resolve("src").toString(),
+                        "--module-source-path", base.resolve("src").toString())
+                .files(findJavaFiles(base.resolve(srcDirs[srcDirs.length - 1])))
+                .outdir(modules)
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (!log.contains("error: --module-source-path specified more than once with a pattern argument"))
+            throw new Exception("Expected error message not found");
+    }
+
+    @Test
+    public void mixedOptionForms(Path base) throws Exception {
+        // The dirs for m0x, m2x use a subdirectory named for the module,
+        // meaning they can be used in the module pattern form of the option;
+        // the dirs for m1x, m3x do not use a subdirectory named for the module,
+        // meaning they can only be used by the module-specific form of the option
+        String[] srcDirs = {
+                "src/m0x",      // m0x
+                "src1",         // m1x
+                "src/m2x",      // m2x
+                "src3"          // m3x
+        };
+        generateModules(base, false, srcDirs);
+
+        final Path modules = base.resolve("modules");
+        tb.createDirectories(modules);
+
+        new JavacTask(tb, Task.Mode.CMDLINE)
+                .options("-XDrawDiagnostics",
+                        "--module-source-path", base.resolve("src").toString(), // for m0x, m2x
+                        "--module-source-path", "m1x=" + base.resolve("src1"),
+                        "--module-source-path", "m3x=" + base.resolve("src3"))
+                .files(findJavaFiles(base.resolve(srcDirs[srcDirs.length - 1])))
+                .outdir(modules)
+                .run()
+                .writeAll();
+
+        for (int i = 0; i < srcDirs.length; i++) {
+            checkFiles(modules.resolve("m" + i + "x/module-info.class"));
+        }
+        checkFiles(modules.resolve("m3x/pkg3/A.class"));
+    }
+
     private void generateModules(Path base, String... paths) throws IOException {
+        generateModules(base, true, paths);
+    }
+
+    private void generateModules(Path base, boolean useModuleSubdirs, String... paths)
+                throws IOException {
         for (int i = 0; i < paths.length; i++) {
             String moduleName = "m" + i + "x";
             String dependency = i > 0 ? "requires m" + (i - 1) + "x;" : "";
-            tb.writeJavaFiles(base.resolve(paths[i]).resolve(moduleName),
+            Path dir = base.resolve(paths[i]);
+            if (useModuleSubdirs) {
+                dir = dir.resolve(moduleName);
+            }
+            tb.writeJavaFiles(dir,
                     "module " + moduleName + " { " + dependency + " }",
                     "package pkg" + i + "; class A { }");
         }
--- a/test/langtools/tools/javac/modules/PatchModulesTest.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/langtools/tools/javac/modules/PatchModulesTest.java	Fri Sep 07 15:46:39 2018 -0700
@@ -98,7 +98,7 @@
     @Test
     public void testDuplicates(Path base) throws Exception {
         test(asList("java.base=a", "java.compiler=b", "java.base=c"),
-            false, "error: --patch-module specified more than once for java.base");
+            false, "error: --patch-module specified more than once for module java.base");
     }
 
     @Test
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/OSVersion.java	Fri Sep 07 15:46:39 2018 -0700
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 1997, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.lib;
+
+import java.util.Arrays;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+public final class OSVersion implements Comparable<OSVersion> {
+    public static final OSVersion WINDOWS_95 = new OSVersion(4, 0);
+    public static final OSVersion WINDOWS_98 = new OSVersion(4, 10);
+    public static final OSVersion WINDOWS_ME = new OSVersion(4, 90);
+    public static final OSVersion WINDOWS_2000 = new OSVersion(5, 0);
+    public static final OSVersion WINDOWS_XP = new OSVersion(5, 1);
+    public static final OSVersion WINDOWS_2003 = new OSVersion(5, 2);
+    public static final OSVersion WINDOWS_VISTA = new OSVersion(6, 0);
+
+    private final int[] versionTokens;
+
+    public static OSVersion current() {
+        if (Platform.isSolaris()) {
+            return new OSVersion(getSolarisVersion());
+        }
+        return new OSVersion(Platform.getOsVersion());
+    }
+
+    public OSVersion(int major, int minor) {
+        versionTokens = new int[] {major, minor};
+    }
+
+    public OSVersion(String version) {
+        Pattern onlyDigits = Pattern.compile("^\\d+$");
+        this.versionTokens = Arrays.stream(version.split("-")[0].split("\\."))
+                                   .filter(onlyDigits.asPredicate())
+                                   .mapToInt(Integer::parseInt)
+                                   .toArray();
+    }
+
+    private static String getSolarisVersion() {
+        try {
+            return Utils.distro();
+        } catch (Throwable e) {
+            System.out.println("First attempt failed with: " + e.getMessage());
+        }
+
+        // Try to get Solaris version from /etc/release
+        try (BufferedReader in = new BufferedReader(AccessController.doPrivileged(
+                (PrivilegedExceptionAction<FileReader>) () -> new FileReader("/etc/release")))) {
+            return in.readLine().trim().split(" ")[2];
+        } catch (PrivilegedActionException e) {
+            System.out.println("Second attempt failed with: " + e.getException().getMessage());
+        } catch (Exception e) {
+            System.out.println("Second attempt failed with: " + e.getMessage());
+        }
+
+        throw new RuntimeException("Unable to get Solaris version");
+    }
+
+    @Override
+    public int compareTo(OSVersion o) {
+        return Arrays.compare(this.versionTokens, o.versionTokens);
+    }
+
+    @Override
+    public int hashCode() {
+        return Arrays.hashCode(versionTokens);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        OSVersion osVersion = (OSVersion) o;
+        return Arrays.equals(versionTokens, osVersion.versionTokens);
+    }
+
+    @Override
+    public String toString() {
+        return Arrays.stream(versionTokens)
+                     .mapToObj(String::valueOf)
+                     .collect(Collectors.joining("."));
+    }
+}
+
--- a/test/lib/jdk/test/lib/Platform.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/lib/jdk/test/lib/Platform.java	Fri Sep 07 15:46:39 2018 -0700
@@ -26,26 +26,30 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.RandomAccessFile;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
 import java.util.regex.Pattern;
-import java.util.stream.Collectors;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 
 public class Platform {
-    public  static final String vmName      = System.getProperty("java.vm.name");
-    public  static final String vmInfo      = System.getProperty("java.vm.info");
-    private static final String osVersion   = System.getProperty("os.version");
-    private static       String[] osVersionTokens;
+    public  static final String vmName      = privilegedGetProperty("java.vm.name");
+    public  static final String vmInfo      = privilegedGetProperty("java.vm.info");
+    private static final String osVersion   = privilegedGetProperty("os.version");
     private static       int osVersionMajor = -1;
     private static       int osVersionMinor = -1;
-    private static final String osName      = System.getProperty("os.name");
-    private static final String dataModel   = System.getProperty("sun.arch.data.model");
-    private static final String vmVersion   = System.getProperty("java.vm.version");
-    private static final String jdkDebug    = System.getProperty("jdk.debug");
-    private static final String osArch      = System.getProperty("os.arch");
-    private static final String userName    = System.getProperty("user.name");
-    private static final String compiler    = System.getProperty("sun.management.compiler");
+    private static final String osName      = privilegedGetProperty("os.name");
+    private static final String dataModel   = privilegedGetProperty("sun.arch.data.model");
+    private static final String vmVersion   = privilegedGetProperty("java.vm.version");
+    private static final String jdkDebug    = privilegedGetProperty("jdk.debug");
+    private static final String osArch      = privilegedGetProperty("os.arch");
+    private static final String userName    = privilegedGetProperty("user.name");
+    private static final String compiler    = privilegedGetProperty("sun.management.compiler");
+
+    private static String privilegedGetProperty(String key) {
+        return AccessController.doPrivileged((
+                PrivilegedAction<String>) () -> System.getProperty(key));
+    }
 
     public static boolean isClient() {
         return vmName.endsWith(" Client VM");
@@ -129,7 +133,7 @@
 
     // Os version support.
     private static void init_version() {
-        osVersionTokens = osVersion.split("\\.");
+        String[] osVersionTokens = osVersion.split("\\.");
         try {
             if (osVersionTokens.length > 0) {
                 osVersionMajor = Integer.parseInt(osVersionTokens[0]);
@@ -160,45 +164,6 @@
         return osVersionMinor;
     }
 
-    /**
-     * Compares the platform version with the supplied version. The
-     * version must be of the form a[.b[.c[.d...]]] where a, b, c, d, ...
-     * are decimal integers.
-     *
-     * @throws NullPointerException if the parameter is null
-     * @throws NumberFormatException if there is an error parsing either
-     *         version as split into component strings
-     * @return -1, 0, or 1 according to whether the platform version is
-     *         less than, equal to, or greater than the supplied version
-     */
-    public static int compareOsVersion(String version) {
-        if (osVersionTokens == null) init_version();
-
-        Objects.requireNonNull(version);
-
-        List<Integer> s1 = Arrays
-            .stream(osVersionTokens)
-            .map(Integer::valueOf)
-            .collect(Collectors.toList());
-        List<Integer> s2 = Arrays
-            .stream(version.split("\\."))
-            .map(Integer::valueOf)
-            .collect(Collectors.toList());
-
-        int count = Math.max(s1.size(), s2.size());
-        for (int i = 0; i < count; i++) {
-            int i1 = i < s1.size() ? s1.get(i) : 0;
-            int i2 = i < s2.size() ? s2.get(i) : 0;
-            if (i1 > i2) {
-                return 1;
-            } else if (i2 > i1) {
-                return -1;
-            }
-        }
-
-        return 0;
-    }
-
     public static boolean isDebugBuild() {
         return (jdkDebug.toLowerCase().contains("debug"));
     }
@@ -294,10 +259,15 @@
         // SELinux deny_ptrace:
         File deny_ptrace = new File("/sys/fs/selinux/booleans/deny_ptrace");
         if (deny_ptrace.exists()) {
-            try (RandomAccessFile file = new RandomAccessFile(deny_ptrace, "r")) {
+            try (RandomAccessFile file = AccessController.doPrivileged(
+                    (PrivilegedExceptionAction<RandomAccessFile>) () -> new RandomAccessFile(deny_ptrace, "r"))) {
                 if (file.readByte() != '0') {
                     return false;
                 }
+            } catch (PrivilegedActionException e) {
+                @SuppressWarnings("unchecked")
+                IOException t = (IOException) e.getException();
+                throw t;
             }
         }
 
@@ -308,7 +278,8 @@
         // 3 - no attach: no processes may use ptrace with PTRACE_ATTACH
         File ptrace_scope = new File("/proc/sys/kernel/yama/ptrace_scope");
         if (ptrace_scope.exists()) {
-            try (RandomAccessFile file = new RandomAccessFile(ptrace_scope, "r")) {
+            try (RandomAccessFile file = AccessController.doPrivileged(
+                    (PrivilegedExceptionAction<RandomAccessFile>) () -> new RandomAccessFile(ptrace_scope, "r"))) {
                 byte yama_scope = file.readByte();
                 if (yama_scope == '3') {
                     return false;
@@ -317,6 +288,10 @@
                 if (!userName.equals("root") && yama_scope != '0') {
                     return false;
                 }
+            } catch (PrivilegedActionException e) {
+                @SuppressWarnings("unchecked")
+                IOException t = (IOException) e.getException();
+                throw t;
             }
         }
         // Otherwise expect to be permitted:
@@ -354,10 +329,6 @@
      * This should match the #if condition in ClassListParser::load_class_from_source().
      */
     public static boolean areCustomLoadersSupportedForCDS() {
-        boolean isLinux = Platform.isLinux();
-        boolean is64 = Platform.is64bit();
-        boolean isSolaris = Platform.isSolaris();
-
-        return (is64 && (isLinux || isSolaris));
+        return (is64bit() && (isLinux() || isSolaris() || isOSX()));
     }
 }
--- a/test/lib/jdk/test/lib/apps/LingeredApp.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/lib/jdk/test/lib/apps/LingeredApp.java	Fri Sep 07 15:46:39 2018 -0700
@@ -146,7 +146,7 @@
             throw new RuntimeException("Process is still alive. Can't get its output.");
         }
         if (output == null) {
-            output = new OutputBuffer(stdoutBuffer.toString(), stderrBuffer.toString());
+            output = OutputBuffer.of(stdoutBuffer.toString(), stderrBuffer.toString());
         }
         return output;
     }
--- a/test/lib/jdk/test/lib/dcmd/CommandExecutor.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/lib/jdk/test/lib/dcmd/CommandExecutor.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
      * Execute a diagnostic command
      *
      * @param cmd The diagnostic command to execute
-     * @return an {@link jdk.testlibrary.OutputAnalyzer} encapsulating the output of the command
+     * @return an {@link jdk.test.lib.process.OutputAnalyzer} encapsulating the output of the command
      * @throws CommandExecutorException if there is an exception on the "calling side" while trying to execute the
      *          Diagnostic Command. Exceptions thrown on the remote side are available as textual representations in
      *          stderr, regardless of the specific executor used.
@@ -48,7 +48,7 @@
      *
      * @param cmd The diagnostic command to execute
      * @param silent Do not print the command output
-     * @return an {@link jdk.testlibrary.OutputAnalyzer} encapsulating the output of the command
+     * @return an {@link jdk.test.lib.process.OutputAnalyzer} encapsulating the output of the command
      * @throws CommandExecutorException if there is an exception on the "calling side" while trying to execute the
      *          Diagnostic Command. Exceptions thrown on the remote side are available as textual representations in
      *          stderr, regardless of the specific executor used.
--- a/test/lib/jdk/test/lib/process/OutputAnalyzer.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/lib/jdk/test/lib/process/OutputAnalyzer.java	Fri Sep 07 15:46:39 2018 -0700
@@ -23,6 +23,8 @@
 
 package jdk.test.lib.process;
 
+import jdk.test.lib.Asserts;
+
 import java.io.IOException;
 import java.io.PrintStream;
 import java.util.Arrays;
@@ -33,10 +35,7 @@
 
 public final class OutputAnalyzer {
 
-    private final String stdout;
-    private final String stderr;
-    private final int exitValue;
-
+    private final OutputBuffer buffer;
     /**
      * Create an OutputAnalyzer, a utility class for verifying output and exit
      * value from a Process
@@ -45,10 +44,7 @@
      * @throws IOException If an I/O error occurs.
      */
     public OutputAnalyzer(Process process) throws IOException {
-        OutputBuffer output = ProcessTools.getOutput(process);
-        exitValue = process.exitValue();
-        this.stdout = output.getStdout();
-        this.stderr = output.getStderr();
+        buffer = OutputBuffer.of(process);
     }
 
     /**
@@ -57,7 +53,7 @@
      * @param buf String buffer to analyze
      */
     public OutputAnalyzer(String buf) {
-        this(buf, buf);
+        buffer = OutputBuffer.of(buf, buf);
     }
 
     /**
@@ -67,9 +63,7 @@
      * @param stderr stderr buffer to analyze
      */
     public OutputAnalyzer(String stdout, String stderr) {
-        this.stdout = stdout;
-        this.stderr = stderr;
-        exitValue = -1;
+        buffer = OutputBuffer.of(stdout, stderr);
     }
 
     /**
@@ -78,11 +72,12 @@
      * @throws RuntimeException
      *             If stdout was not empty
      */
-    public void stdoutShouldBeEmpty() {
+    public OutputAnalyzer stdoutShouldBeEmpty() {
         if (!getStdout().isEmpty()) {
             reportDiagnosticSummary();
             throw new RuntimeException("stdout was not empty");
         }
+        return this;
     }
 
     /**
@@ -91,11 +86,12 @@
      * @throws RuntimeException
      *             If stderr was not empty
      */
-    public void stderrShouldBeEmpty() {
+    public OutputAnalyzer stderrShouldBeEmpty() {
         if (!getStderr().isEmpty()) {
             reportDiagnosticSummary();
             throw new RuntimeException("stderr was not empty");
         }
+        return this;
     }
 
     /**
@@ -105,11 +101,12 @@
      * @throws RuntimeException
      *             If stderr was not empty
      */
-    public void stderrShouldBeEmptyIgnoreVMWarnings() {
+    public OutputAnalyzer stderrShouldBeEmptyIgnoreVMWarnings() {
         if (!getStderr().replaceAll(jvmwarningmsg + "\\R", "").isEmpty()) {
             reportDiagnosticSummary();
             throw new RuntimeException("stderr was not empty");
         }
+        return this;
     }
 
     /**
@@ -118,11 +115,12 @@
      * @throws RuntimeException
      *             If stdout was empty
      */
-    public void stdoutShouldNotBeEmpty() {
+    public OutputAnalyzer stdoutShouldNotBeEmpty() {
         if (getStdout().isEmpty()) {
             reportDiagnosticSummary();
             throw new RuntimeException("stdout was empty");
         }
+        return this;
     }
 
     /**
@@ -131,11 +129,12 @@
      * @throws RuntimeException
      *             If stderr was empty
      */
-    public void stderrShouldNotBeEmpty() {
+    public OutputAnalyzer stderrShouldNotBeEmpty() {
         if (getStderr().isEmpty()) {
             reportDiagnosticSummary();
             throw new RuntimeException("stderr was empty");
         }
+        return this;
     }
 
     /**
@@ -145,6 +144,8 @@
      * @throws RuntimeException If the string was not found
      */
     public OutputAnalyzer shouldContain(String expectedString) {
+        String stdout = getStdout();
+        String stderr = getStderr();
         if (!stdout.contains(expectedString) && !stderr.contains(expectedString)) {
             reportDiagnosticSummary();
             throw new RuntimeException("'" + expectedString + "' missing from stdout/stderr \n");
@@ -159,6 +160,7 @@
      * @throws RuntimeException If the string was not found
      */
     public OutputAnalyzer stdoutShouldContain(String expectedString) {
+        String stdout = getStdout();
         if (!stdout.contains(expectedString)) {
             reportDiagnosticSummary();
             throw new RuntimeException("'" + expectedString + "' missing from stdout \n");
@@ -173,6 +175,7 @@
      * @throws RuntimeException If the string was not found
      */
     public OutputAnalyzer stderrShouldContain(String expectedString) {
+        String stderr = getStderr();
         if (!stderr.contains(expectedString)) {
             reportDiagnosticSummary();
             throw new RuntimeException("'" + expectedString + "' missing from stderr \n");
@@ -183,10 +186,12 @@
     /**
      * Verify that the stdout and stderr contents of output buffer does not contain the string
      *
-     * @param expectedString String that the buffer should not contain
+     * @param notExpectedString String that the buffer should not contain
      * @throws RuntimeException If the string was found
      */
     public OutputAnalyzer shouldNotContain(String notExpectedString) {
+        String stdout = getStdout();
+        String stderr = getStderr();
         if (stdout.contains(notExpectedString)) {
             reportDiagnosticSummary();
             throw new RuntimeException("'" + notExpectedString + "' found in stdout \n");
@@ -204,6 +209,8 @@
      * @throws RuntimeException If the stdout and stderr are not empty
      */
     public OutputAnalyzer shouldBeEmpty() {
+        String stdout = getStdout();
+        String stderr = getStderr();
         if (!stdout.isEmpty()) {
             reportDiagnosticSummary();
             throw new RuntimeException("stdout was not empty");
@@ -218,10 +225,11 @@
     /**
      * Verify that the stdout contents of output buffer does not contain the string
      *
-     * @param expectedString String that the buffer should not contain
+     * @param notExpectedString String that the buffer should not contain
      * @throws RuntimeException If the string was found
      */
     public OutputAnalyzer stdoutShouldNotContain(String notExpectedString) {
+        String stdout = getStdout();
         if (stdout.contains(notExpectedString)) {
             reportDiagnosticSummary();
             throw new RuntimeException("'" + notExpectedString + "' found in stdout \n");
@@ -232,10 +240,11 @@
     /**
      * Verify that the stderr contents of output buffer does not contain the string
      *
-     * @param expectedString String that the buffer should not contain
+     * @param notExpectedString String that the buffer should not contain
      * @throws RuntimeException If the string was found
      */
     public OutputAnalyzer stderrShouldNotContain(String notExpectedString) {
+        String stderr = getStderr();
         if (stderr.contains(notExpectedString)) {
             reportDiagnosticSummary();
             throw new RuntimeException("'" + notExpectedString + "' found in stderr \n");
@@ -247,15 +256,18 @@
      * Verify that the stdout and stderr contents of output buffer matches
      * the pattern
      *
-     * @param pattern
+     * @param regexp
      * @throws RuntimeException If the pattern was not found
      */
-    public OutputAnalyzer shouldMatch(String pattern) {
-        Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
-        Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
+    public OutputAnalyzer shouldMatch(String regexp) {
+        String stdout = getStdout();
+        String stderr = getStderr();
+        Pattern pattern = Pattern.compile(regexp, Pattern.MULTILINE);
+        Matcher stdoutMatcher = pattern.matcher(stdout);
+        Matcher stderrMatcher = pattern.matcher(stderr);
         if (!stdoutMatcher.find() && !stderrMatcher.find()) {
             reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern
+            throw new RuntimeException("'" + regexp
                   + "' missing from stdout/stderr \n");
         }
         return this;
@@ -265,14 +277,15 @@
      * Verify that the stdout contents of output buffer matches the
      * pattern
      *
-     * @param pattern
+     * @param regexp
      * @throws RuntimeException If the pattern was not found
      */
-    public OutputAnalyzer stdoutShouldMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
+    public OutputAnalyzer stdoutShouldMatch(String regexp) {
+        String stdout = getStdout();
+        Matcher matcher = Pattern.compile(regexp, Pattern.MULTILINE).matcher(stdout);
         if (!matcher.find()) {
             reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern
+            throw new RuntimeException("'" + regexp
                   + "' missing from stdout \n");
         }
         return this;
@@ -286,7 +299,7 @@
      * @throws RuntimeException If the pattern was not found
      */
     public OutputAnalyzer stderrShouldMatch(String pattern) {
-
+        String stderr = getStderr();
         Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
         if (!matcher.find()) {
             reportDiagnosticSummary();
@@ -300,22 +313,27 @@
      * Verify that the stdout and stderr contents of output buffer does not
      * match the pattern
      *
-     * @param pattern
+     * @param regexp
      * @throws RuntimeException If the pattern was found
      */
-    public OutputAnalyzer shouldNotMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
+    public OutputAnalyzer shouldNotMatch(String regexp) {
+        String stdout = getStdout();
+        Pattern pattern = Pattern.compile(regexp, Pattern.MULTILINE);
+        Matcher matcher = pattern.matcher(stdout);
         if (matcher.find()) {
             reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern
+            throw new RuntimeException("'" + regexp
                     + "' found in stdout: '" + matcher.group() + "' \n");
         }
-        matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
+
+        String stderr = getStderr();
+        matcher = pattern.matcher(stderr);
         if (matcher.find()) {
             reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern
+            throw new RuntimeException("'" + regexp
                     + "' found in stderr: '" + matcher.group() + "' \n");
         }
+
         return this;
     }
 
@@ -323,14 +341,15 @@
      * Verify that the stdout contents of output buffer does not match the
      * pattern
      *
-     * @param pattern
+     * @param regexp
      * @throws RuntimeException If the pattern was found
      */
-    public OutputAnalyzer stdoutShouldNotMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
+    public OutputAnalyzer stdoutShouldNotMatch(String regexp) {
+        String stdout = getStdout();
+        Matcher matcher = Pattern.compile(regexp, Pattern.MULTILINE).matcher(stdout);
         if (matcher.find()) {
             reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern
+            throw new RuntimeException("'" + regexp
                     + "' found in stdout \n");
         }
         return this;
@@ -340,14 +359,15 @@
      * Verify that the stderr contents of output buffer does not match the
      * pattern
      *
-     * @param pattern
+     * @param regexp
      * @throws RuntimeException If the pattern was found
      */
-    public OutputAnalyzer stderrShouldNotMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
+    public OutputAnalyzer stderrShouldNotMatch(String regexp) {
+        String stderr = getStderr();
+        Matcher matcher = Pattern.compile(regexp, Pattern.MULTILINE).matcher(stderr);
         if (matcher.find()) {
             reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern
+            throw new RuntimeException("'" + regexp
                     + "' found in stderr \n");
         }
         return this;
@@ -357,16 +377,19 @@
      * Get the captured group of the first string matching the pattern.
      * stderr is searched before stdout.
      *
-     * @param pattern The multi-line pattern to match
+     * @param regexp The multi-line pattern to match
      * @param group The group to capture
      * @return The matched string or null if no match was found
      */
-    public String firstMatch(String pattern, int group) {
-        Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
-        Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
+    public String firstMatch(String regexp, int group) {
+        Pattern pattern = Pattern.compile(regexp, Pattern.MULTILINE);
+        String stderr = getStderr();
+        Matcher stderrMatcher = pattern.matcher(stderr);
         if (stderrMatcher.find()) {
             return stderrMatcher.group(group);
         }
+        String stdout = getStdout();
+        Matcher stdoutMatcher = pattern.matcher(stdout);
         if (stdoutMatcher.find()) {
             return stdoutMatcher.group(group);
         }
@@ -425,8 +448,8 @@
      */
     public void reportDiagnosticSummary() {
         String msg =
-            " stdout: [" + stdout + "];\n" +
-            " stderr: [" + stderr + "]\n" +
+            " stdout: [" + getStdout() + "];\n" +
+            " stderr: [" + getStderr() + "]\n" +
             " exitValue = " + getExitValue() + "\n";
 
         System.err.println(msg);
@@ -458,7 +481,7 @@
      * @return Content of the output buffer
      */
     public String getOutput() {
-        return stdout + stderr;
+        return getStdout() + getStderr();
     }
 
     /**
@@ -467,7 +490,7 @@
      * @return Content of the stdout buffer
      */
     public String getStdout() {
-        return stdout;
+        return buffer.getStdout();
     }
 
     /**
@@ -476,7 +499,7 @@
      * @return Content of the stderr buffer
      */
     public String getStderr() {
-        return stderr;
+        return buffer.getStderr();
     }
 
     /**
@@ -485,7 +508,7 @@
      * @return Process exit value
      */
     public int getExitValue() {
-        return exitValue;
+        return buffer.getExitValue();
     }
 
     /**
@@ -499,7 +522,7 @@
     }
 
     private List<String> asLines(String buffer) {
-        return Arrays.asList(buffer.split("(\\r\\n|\\n|\\r)"));
+        return Arrays.asList(buffer.split("\\R"));
     }
 
 
@@ -512,6 +535,8 @@
      * @throws RuntimeException If the stdout and stderr are not empty
      */
     public OutputAnalyzer shouldBeEmptyIgnoreVMWarnings() {
+        String stdout = getStdout();
+        String stderr = getStderr();
         if (!stdout.isEmpty()) {
             reportDiagnosticSummary();
             throw new RuntimeException("stdout was not empty");
@@ -531,7 +556,7 @@
      * @throws RuntimeException If the pattern was not found
      */
     public OutputAnalyzer stderrShouldMatchIgnoreVMWarnings(String pattern) {
-        String stderr = this.stderr.replaceAll(jvmwarningmsg + "\\R", "");
+        String stderr = getStderr().replaceAll(jvmwarningmsg + "\\R", "");
         Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
         if (!matcher.find()) {
             reportDiagnosticSummary();
@@ -548,10 +573,118 @@
      * @return Contents of the output buffer as list of strings
      */
     public List<String> asLinesWithoutVMWarnings() {
-        return Arrays.asList(getOutput().split("\\R"))
-                .stream()
-                .filter(Pattern.compile(jvmwarningmsg).asPredicate().negate())
-                .collect(Collectors.toList());
+        return Arrays.stream(getOutput().split("\\R"))
+                     .filter(Pattern.compile(jvmwarningmsg).asPredicate().negate())
+                     .collect(Collectors.toList());
+    }
+
+    /**
+     * @see #shouldMatchByLine(String, String, String)
+     */
+    public OutputAnalyzer shouldMatchByLine(String pattern) {
+        return shouldMatchByLine(null, null, pattern);
+    }
+
+    /**
+     * @see #stdoutShouldMatchByLine(String, String, String)
+     */
+    public OutputAnalyzer stdoutShouldMatchByLine(String pattern) {
+        return stdoutShouldMatchByLine(null, null, pattern);
+    }
+
+    /**
+     * @see #shouldMatchByLine(String, String, String)
+     */
+    public OutputAnalyzer shouldMatchByLineFrom(String from, String pattern) {
+        return shouldMatchByLine(from, null, pattern);
+    }
+
+    /**
+     * @see #shouldMatchByLine(String, String, String)
+     */
+    public OutputAnalyzer shouldMatchByLineTo(String to, String pattern) {
+        return shouldMatchByLine(null, to, pattern);
+    }
+
+    /**
+     * Verify that the stdout and stderr contents of output buffer match the
+     * {@code pattern} line by line. The whole output could be matched or
+     * just a subset of it.
+     *
+     * @param from
+     *            The line from where output will be matched.
+     *            Set {@code from} to null for matching from the first line.
+     * @param to
+     *            The line until where output will be matched.
+     *            Set {@code to} to null for matching until the last line.
+     * @param pattern
+     *            Matching pattern
+     */
+    public OutputAnalyzer shouldMatchByLine(String from, String to, String pattern) {
+        return shouldMatchByLine(getOutput(), from, to, pattern);
+    }
+
+    /**
+     * Verify that the stdout contents of output buffer matches the
+     * {@code pattern} line by line. The whole stdout could be matched or
+     * just a subset of it.
+     *
+     * @param from
+     *            The line from where stdout will be matched.
+     *            Set {@code from} to null for matching from the first line.
+     * @param to
+     *            The line until where stdout will be matched.
+     *            Set {@code to} to null for matching until the last line.
+     * @param pattern
+     *            Matching pattern
+     */
+    public OutputAnalyzer stdoutShouldMatchByLine(String from, String to, String pattern) {
+        return shouldMatchByLine(getStdout(), from, to, pattern);
+    }
+
+    private OutputAnalyzer shouldMatchByLine(String buffer, String from, String to, String pattern) {
+        List<String> lines = asLines(buffer);
+
+        int fromIndex = 0;
+        if (from != null) {
+            fromIndex = indexOf(lines, from);
+            Asserts.assertGreaterThan(fromIndex, -1,
+                    "The line/pattern '" + from + "' from where the output should match can not be found");
+        }
+
+        int toIndex = lines.size();
+        if (to != null) {
+            toIndex = indexOf(lines, to);
+            Asserts.assertGreaterThan(toIndex, -1,
+                    "The line/pattern '" + to + "' until where the output should match can not be found");
+        }
+
+        List<String> subList = lines.subList(fromIndex, toIndex);
+        Asserts.assertFalse(subList.isEmpty(), "There are no lines to check");
+
+        subList.stream()
+               .filter(Pattern.compile(pattern).asPredicate().negate())
+               .findAny()
+               .ifPresent(line -> Asserts.assertTrue(false,
+                       "The line '" + line + "' does not match pattern '" + pattern + "'"));
+
+        return this;
+    }
+
+    /**
+     * Check if there is a line matching {@code regexp} and return its index
+     *
+     * @param regexp Matching pattern
+     * @return Index of first matching line
+     */
+    private int indexOf(List<String> lines, String regexp) {
+        Pattern pattern = Pattern.compile(regexp);
+        for (int i = 0; i < lines.size(); i++) {
+            if (pattern.matcher(lines.get(i)).matches()) {
+                return i;
+            }
+        }
+        return -1;
     }
 
 }
--- a/test/lib/jdk/test/lib/process/OutputBuffer.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/lib/jdk/test/lib/process/OutputBuffer.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -23,20 +23,19 @@
 
 package jdk.test.lib.process;
 
-public class OutputBuffer {
-  private final String stdout;
-  private final String stderr;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
 
-  /**
-   * Create an OutputBuffer, a class for storing and managing stdout and stderr
-   * results separately
-   *
-   * @param stdout stdout result
-   * @param stderr stderr result
-   */
-  public OutputBuffer(String stdout, String stderr) {
-    this.stdout = stdout;
-    this.stderr = stderr;
+public interface OutputBuffer {
+  public static class OutputBufferException extends RuntimeException {
+    private static final long serialVersionUID = 8528687792643129571L;
+
+    public OutputBufferException(Throwable cause) {
+      super(cause);
+    }
   }
 
   /**
@@ -44,16 +43,105 @@
    *
    * @return stdout result
    */
-  public String getStdout() {
-    return stdout;
-  }
-
+  public String getStdout();
   /**
    * Returns the stderr result
    *
    * @return stderr result
    */
-  public String getStderr() {
-    return stderr;
+  public String getStderr();
+  public int getExitValue();
+
+  public static OutputBuffer of(Process p) {
+    return new LazyOutputBuffer(p);
+  }
+
+  public static OutputBuffer of(String stdout, String stderr, int exitValue) {
+    return new EagerOutputBuffer(stdout, stderr, exitValue);
+  }
+
+  public static OutputBuffer of(String stdout, String stderr) {
+    return of(stdout, stderr, -1);
+  }
+
+  class LazyOutputBuffer implements OutputBuffer {
+    private static class StreamTask {
+      private final ByteArrayOutputStream buffer;
+      private final Future<Void> future;
+
+      private StreamTask(InputStream stream) {
+        this.buffer = new ByteArrayOutputStream();
+        this.future = new StreamPumper(stream, buffer).process();
+      }
+
+      public String get() {
+        try {
+          future.get();
+          return buffer.toString();
+        } catch (InterruptedException e) {
+          Thread.currentThread().interrupt();
+          throw new OutputBufferException(e);
+        } catch (ExecutionException | CancellationException e) {
+          throw new OutputBufferException(e);
+        }
+      }
+    }
+
+    private final StreamTask outTask;
+    private final StreamTask errTask;
+    private final Process p;
+
+    private LazyOutputBuffer(Process p) {
+      this.p = p;
+      outTask = new StreamTask(p.getInputStream());
+      errTask = new StreamTask(p.getErrorStream());
+    }
+
+    @Override
+    public String getStdout() {
+      return outTask.get();
+    }
+
+    @Override
+    public String getStderr() {
+      return errTask.get();
+    }
+
+    @Override
+    public int getExitValue() {
+      try {
+        return p.waitFor();
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+        throw new OutputBufferException(e);
+      }
+    }
+  }
+
+  class EagerOutputBuffer implements OutputBuffer {
+    private final String stdout;
+    private final String stderr;
+    private final int exitValue;
+
+    private EagerOutputBuffer(String stdout, String stderr, int exitValue) {
+      this.stdout = stdout;
+      this.stderr = stderr;
+      this.exitValue = exitValue;
+    }
+
+    @Override
+    public String getStdout() {
+      return stdout;
+    }
+
+    @Override
+    public String getStderr() {
+      return stderr;
+    }
+
+    @Override
+    public int getExitValue() {
+      return exitValue;
+    }
   }
 }
--- a/test/lib/jdk/test/lib/process/ProcessTools.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/lib/jdk/test/lib/process/ProcessTools.java	Fri Sep 07 15:46:39 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -23,7 +23,6 @@
 
 package jdk.test.lib.process;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -40,6 +39,9 @@
 import java.util.function.Predicate;
 import java.util.function.Consumer;
 import java.util.stream.Collectors;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 
 import jdk.test.lib.JDKToolFinder;
 import jdk.test.lib.Utils;
@@ -62,50 +64,6 @@
     }
 
     /**
-     * Pumps stdout and stderr from running the process into a String.
-     *
-     * @param processBuilder ProcessBuilder to run.
-     * @return Output from process.
-     * @throws IOException If an I/O error occurs.
-     */
-    public static OutputBuffer getOutput(ProcessBuilder processBuilder) throws IOException {
-        return getOutput(processBuilder.start());
-    }
-
-    /**
-     * Pumps stdout and stderr the running process into a String.
-     *
-     * @param process Process to pump.
-     * @return Output from process.
-     * @throws IOException If an I/O error occurs.
-     */
-    public static OutputBuffer getOutput(Process process) throws IOException {
-        ByteArrayOutputStream stderrBuffer = new ByteArrayOutputStream();
-        ByteArrayOutputStream stdoutBuffer = new ByteArrayOutputStream();
-        StreamPumper outPumper = new StreamPumper(process.getInputStream(), stdoutBuffer);
-        StreamPumper errPumper = new StreamPumper(process.getErrorStream(), stderrBuffer);
-        Thread outPumperThread = new Thread(outPumper);
-        Thread errPumperThread = new Thread(errPumper);
-
-        outPumperThread.setDaemon(true);
-        errPumperThread.setDaemon(true);
-
-        outPumperThread.start();
-        errPumperThread.start();
-
-        try {
-            process.waitFor();
-            outPumperThread.join();
-            errPumperThread.join();
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-            return null;
-        }
-
-        return new OutputBuffer(stdoutBuffer.toString(), stderrBuffer.toString());
-    }
-
-    /**
      * <p>Starts a process from its builder.</p>
      * <span>The default redirects of STDOUT and STDERR are started</span>
      * @param name The process name
@@ -201,7 +159,7 @@
                                        TimeUnit unit)
     throws IOException, InterruptedException, TimeoutException {
         System.out.println("["+name+"]:" + processBuilder.command().stream().collect(Collectors.joining(" ")));
-        Process p = processBuilder.start();
+        Process p = privilegedStart(processBuilder);
         StreamPumper stdout = new StreamPumper(p.getInputStream());
         StreamPumper stderr = new StreamPumper(p.getErrorStream());
 
@@ -389,11 +347,29 @@
      * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
      */
     public static OutputAnalyzer executeProcess(ProcessBuilder pb) throws Exception {
+        return executeProcess(pb, null);
+    }
+
+    /**
+     * Executes a process, pipe some text into its STDIN, waits for it
+     * to finish and returns the process output. The process will have exited
+     * before this method returns.
+     * @param pb The ProcessBuilder to execute.
+     * @param input The text to pipe into STDIN. Can be null.
+     * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
+     */
+    public static OutputAnalyzer executeProcess(ProcessBuilder pb, String input) throws Exception {
         OutputAnalyzer output = null;
         Process p = null;
         boolean failed = false;
         try {
-            p = pb.start();
+            p = privilegedStart(pb);
+            if (input != null) {
+               try (PrintStream ps = new PrintStream(p.getOutputStream())) {
+                   ps.print(input);
+               }
+            }
+
             output = new OutputAnalyzer(p);
             p.waitFor();
 
@@ -495,6 +471,17 @@
         return analyzer;
     }
 
+    private static Process privilegedStart(ProcessBuilder pb) throws IOException {
+        try {
+            return AccessController.doPrivileged(
+                (PrivilegedExceptionAction<Process>) () -> pb.start());
+        } catch (PrivilegedActionException e) {
+            @SuppressWarnings("unchecked")
+            IOException t = (IOException) e.getException();
+            throw t;
+        }
+    }
+
     private static class ProcessImpl extends Process {
 
         private final Process p;
--- a/test/lib/jdk/test/lib/process/StreamPumper.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/lib/jdk/test/lib/process/StreamPumper.java	Fri Sep 07 15:46:39 2018 -0700
@@ -41,14 +41,14 @@
     /**
      * Pump will be called by the StreamPumper to process the incoming data
      */
-    abstract public static class Pump {
+    public abstract static class Pump {
         abstract void register(StreamPumper d);
     }
 
     /**
      * OutputStream -> Pump adapter
      */
-    final public static class StreamPump extends Pump {
+    public final static class StreamPump extends Pump {
         private final OutputStream out;
         public StreamPump(OutputStream out) {
             this.out = out;
@@ -63,13 +63,13 @@
     /**
      * Used to process the incoming data line-by-line
      */
-    abstract public static class LinePump extends Pump {
+    public abstract static class LinePump extends Pump {
         @Override
         final void register(StreamPumper sp) {
             sp.addLineProcessor(this);
         }
 
-        abstract protected void processLine(String line);
+        protected abstract void processLine(String line);
     }
 
     private final InputStream in;
@@ -77,7 +77,6 @@
     private final Set<LinePump> linePumps = new HashSet<>();
 
     private final AtomicBoolean processing = new AtomicBoolean(false);
-    private final FutureTask<Void> processingTask = new FutureTask<>(this, null);
 
     public StreamPumper(InputStream in) {
         this.in = in;
@@ -108,7 +107,7 @@
             int linelen = 0;
 
             while ((len = is.read(buf)) > 0 && !Thread.interrupted()) {
-                for(OutputStream out : outStreams) {
+                for (OutputStream out : outStreams) {
                     out.write(buf, 0, len);
                 }
                 if (!linePumps.isEmpty()) {
@@ -125,9 +124,7 @@
                             if (linelen > 0) {
                                 lineBos.flush();
                                 final String line = lineBos.toString();
-                                linePumps.stream().forEach((lp) -> {
-                                    lp.processLine(line);
-                                });
+                                linePumps.forEach((lp) -> lp.processLine(line));
                                 lineBos.reset();
                                 linelen = 0;
                             }
@@ -149,7 +146,7 @@
         } catch (IOException e) {
             e.printStackTrace();
         } finally {
-            for(OutputStream out : outStreams) {
+            for (OutputStream out : outStreams) {
                 try {
                     out.flush();
                 } catch (IOException e) {}
@@ -168,30 +165,26 @@
         linePumps.add(lp);
     }
 
-    final public StreamPumper addPump(Pump ... pump) {
+    public final StreamPumper addPump(Pump ... pump) {
         if (processing.get()) {
             throw new IllegalStateException("Can not modify pumper while " +
                                             "processing is in progress");
         }
-        for(Pump p : pump) {
+        for (Pump p : pump) {
             p.register(this);
         }
         return this;
     }
 
-    final public Future<Void> process() {
+    public final Future<Void> process() {
         if (!processing.compareAndSet(false, true)) {
             throw new IllegalStateException("Can not re-run the processing");
         }
-        Thread t = new Thread(new Runnable() {
-            @Override
-            public void run() {
-                processingTask.run();
-            }
-        });
+        FutureTask<Void> result = new FutureTask<>(this, null);
+        Thread t = new Thread(result);
         t.setDaemon(true);
         t.start();
 
-        return processingTask;
+        return result;
     }
 }
--- a/test/lib/sun/hotspot/WhiteBox.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/lib/sun/hotspot/WhiteBox.java	Fri Sep 07 15:46:39 2018 -0700
@@ -536,4 +536,10 @@
 
   // Decoder
   public native void disableElfSectionCache();
+
+  // Resolved Method Table
+  public native int resolvedMethodRemovedCount();
+
+  // Protection Domain Table
+  public native int protectionDomainRemovedCount();
 }
--- a/test/lib/sun/hotspot/gc/GC.java	Wed Aug 29 09:45:58 2018 +0200
+++ b/test/lib/sun/hotspot/gc/GC.java	Fri Sep 07 15:46:39 2018 -0700
@@ -31,7 +31,7 @@
  */
 public enum GC {
     /*
-     * Enum values much match CollectedHeap::Name
+     * Enum values must match CollectedHeap::Name
      */
     Serial(1),
     Parallel(2),
@@ -49,7 +49,7 @@
     }
 
     /**
-     * @return true if this GC is supported by the VM
+     * @return true if this GC is supported by the VM, i.e., it is built into the VM.
      */
     public boolean isSupported() {
         return WB.isGCSupported(name);