Merge
authorprr
Thu, 13 Sep 2018 10:54:11 -0700
changeset 51922 16c6d8d35fd7
parent 51921 372cbac1a862 (current diff)
parent 51726 a3989376ade2 (diff)
child 51923 16a0f33a5052
Merge
make/jdk/src/classes/build/tools/hasher/Hasher.java
make/jdk/src/classes/build/tools/jarreorder/JarReorder.java
make/mapfiles/libjsig/mapfile-vers-solaris
src/java.desktop/windows/native/common/awt_makecube.cpp
test/hotspot/jtreg/vmTestbase/nsk/share/test/timeoutwatchdog/TimeoutHandler.java
test/hotspot/jtreg/vmTestbase/nsk/share/test/timeoutwatchdog/TimeoutWatchdog.java
test/hotspot/jtreg/vmTestbase/vm/share/gc/TriggerUnloadingByFillingHeap.java
test/hotspot/jtreg/vmTestbase/vm/share/vmstresser/CompileAndDeoptimize.java
test/hotspot/jtreg/vmTestbase/vm/share/vmstresser/MetaspaceStresser.java
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/com/sun/jdi/Redefine-g.sh
test/jdk/com/sun/jdi/RedefineAbstractClass.sh
test/jdk/com/sun/jdi/RedefineAddPrivateMethod.sh
test/jdk/com/sun/jdi/RedefineAnnotation.sh
test/jdk/com/sun/jdi/RedefineChangeClassOrder.sh
test/jdk/com/sun/jdi/RedefineClasses.sh
test/jdk/com/sun/jdi/RedefineClearBreakpoint.sh
test/jdk/com/sun/jdi/RedefineImplementor.sh
test/jdk/java/util/zip/ZipFile/deletetempjar.sh
test/jdk/javax/naming/module/basic.sh
test/jdk/lib/testlibrary/jdk/testlibrary/JDKToolFinder.java
test/jdk/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.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	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/.hgtags	Thu Sep 13 10:54:11 2018 -0700
@@ -510,3 +510,5 @@
 76072a077ee1d815152d45d1692c4b36c53c5c49 jdk-11+28
 492b366f8e5784cc4927c2c98f9b8a3f16c067eb jdk-12+8
 31b159f30fb281016c5f0c103552809aeda84063 jdk-12+9
+8f594f75e0547d4ca16649cb3501659e3155e81b jdk-12+10
+f0f5d23449d31f1b3580c8a73313918cafeaefd7 jdk-12+11
--- a/bin/idea.sh	Wed Sep 12 11:51:39 2018 +0530
+++ b/bin/idea.sh	Thu Sep 13 10:54:11 2018 -0700
@@ -113,21 +113,14 @@
   echo "FATAL: SPEC is empty" >&2; exit 1
 fi
 
-
-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 variables
 
 NUM_REPLACEMENTS=0
 
 replace_template_file() {
     for i in $(seq 1 $NUM_REPLACEMENTS); do
-      eval "sed -i \"s|\${FROM${i}}|\${TO${i}}|g\" $1"
+      eval "sed \"s|\${FROM${i}}|\${TO${i}}|g\" $1 > $1.tmp"
+      mv $1.tmp $1
     done
 }
 
@@ -154,7 +147,7 @@
 SOURCE_POSTFIX="\" isTestSource=\"false\" />"
 
 for root in $MODULE_ROOTS; do
-    SOURCES=$SOURCES"\n$SOURCE_PREFIX""$root""$SOURCE_POSTFIX"
+    SOURCES=$SOURCES" $SOURCE_PREFIX""$root""$SOURCE_POSTFIX"
 done
 
 add_replacement "###SOURCE_ROOTS###" "$SOURCES"
--- a/make/Init.gmk	Wed Sep 12 11:51:39 2018 +0530
+++ b/make/Init.gmk	Thu Sep 13 10:54:11 2018 -0700
@@ -240,6 +240,11 @@
     override BUILD_LOG_PIPE :=
   endif
 
+  ifeq ($(filter dist-clean, $(SEQUENTIAL_TARGETS)), dist-clean)
+    # We can't have a log file if we're about to remove it.
+    override BUILD_LOG_PIPE :=
+  endif
+
   ifeq ($(OUTPUT_SYNC_SUPPORTED), true)
     OUTPUT_SYNC_FLAG := -O$(OUTPUT_SYNC)
   endif
--- a/make/Main.gmk	Wed Sep 12 11:51:39 2018 +0530
+++ b/make/Main.gmk	Thu Sep 13 10:54:11 2018 -0700
@@ -1107,7 +1107,8 @@
 # directory was created by configure and now becomes empty, remove it as well.
 dist-clean: clean
 	($(CD) $(OUTPUTDIR) && \
-	    $(RM) -r *spec.gmk $(CONFIGURESUPPORT_OUTPUTDIR) Makefile compare.sh ide)
+	    $(RM) -r *spec.gmk $(CONFIGURESUPPORT_OUTPUTDIR) Makefile compare.sh ide \
+	    configure.log* build.log*)
 	$(if $(filter $(CONF_NAME),$(notdir $(OUTPUTDIR))), \
 	  if test "x`$(LS) $(OUTPUTDIR)`" != x; then \
 	    $(ECHO) "Warning: Not removing non-empty configuration directory for '$(CONF_NAME)'" ; \
--- a/make/SourceRevision.gmk	Wed Sep 12 11:51:39 2018 +0530
+++ b/make/SourceRevision.gmk	Thu Sep 13 10:54:11 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/ToolsJdk.gmk	Wed Sep 12 11:51:39 2018 +0530
+++ b/make/ToolsJdk.gmk	Thu Sep 13 10:54:11 2018 -0700
@@ -47,9 +47,6 @@
 TOOL_COMPILEPROPERTIES = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
     build.tools.compileproperties.CompileProperties
 
-TOOL_JARREORDER = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
-    build.tools.jarreorder.JarReorder
-
 TOOL_GENERATECHARACTER = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
     build.tools.generatecharacter.GenerateCharacter
 
@@ -67,9 +64,6 @@
 TOOL_GENERATECURRENCYDATA = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
     build.tools.generatecurrencydata.GenerateCurrencyData
 
-TOOL_HASHER = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
-    build.tools.hasher.Hasher
-
 TOOL_TZDB = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
     build.tools.tzdb.TzdbZoneRulesCompiler
 
@@ -109,10 +103,6 @@
 TOOL_GENERATELSREQUIVMAPS = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
     build.tools.generatelsrequivmaps.EquivMapsGenerator
 
-TOOL_GENMODULESXML = $(JAVA_SMALL) $(INTERIM_LANGTOOLS_BOOTCLASSPATH) \
-    -cp $(call PathList, $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes) \
-    build.tools.module.GenJdepsModulesXml
-
 TOOL_GENMODULEINFOSOURCE = $(JAVA_SMALL) $(INTERIM_LANGTOOLS_BOOTCLASSPATH) \
     -cp $(call PathList, $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes) \
     build.tools.module.GenModuleInfoSource
--- a/make/autoconf/basics.m4	Wed Sep 12 11:51:39 2018 +0530
+++ b/make/autoconf/basics.m4	Thu Sep 13 10:54:11 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/spec.gmk.in	Wed Sep 12 11:51:39 2018 +0530
+++ b/make/autoconf/spec.gmk.in	Thu Sep 13 10:54:11 2018 -0700
@@ -723,6 +723,7 @@
 FILE:=@FILE@
 DOT:=@DOT@
 HG:=@HG@
+GIT:=@GIT@
 OBJCOPY:=@OBJCOPY@
 SETFILE:=@SETFILE@
 XATTR:=@XATTR@
--- a/make/common/MakeBase.gmk	Wed Sep 12 11:51:39 2018 +0530
+++ b/make/common/MakeBase.gmk	Thu Sep 13 10:54:11 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
--- a/make/copy/Copy-java.base.gmk	Wed Sep 12 11:51:39 2018 +0530
+++ b/make/copy/Copy-java.base.gmk	Thu Sep 13 10:54:11 2018 -0700
@@ -183,7 +183,7 @@
 
 TARGETS += $(COPY_NET_PROPERTIES)
 
-ifeq ($(OPENJDK_TARGET_OS), solaris)
+ifneq ($(filter $(OPENJDK_TARGET_OS), solaris linux), )
   $(eval $(call SetupCopyFiles, COPY_SDP_CONF, \
       FILES := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/sdp/sdp.conf.template, \
       DEST := $(CONF_DST_DIR)/sdp, \
--- a/make/jdk/src/classes/build/tools/hasher/Hasher.java	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,320 +0,0 @@
-/*
- * Copyright (c) 2004, 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.  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 build.tools.hasher;
-
-import java.io.*;
-import java.util.*;
-
-
-/**
- * Reads a map in the form of a sequence of key/value-expression pairs from the
- * standard input, attempts to construct a hash map that fits within the given
- * table-size and chain-depth constraints, and, if successful, writes source
- * code to the standard output for a subclass of sun.util.PreHashedMap that
- * implements the map.
- *
- * @see sun.util.PreHashedMap
- *
- * @author Mark Reinhold
- */
-
-public class Hasher {
-
-    static final PrintStream out = System.out;
-    static final PrintStream err = System.err;
-
-    boolean verbose = false;
-
-    List<String> keys = new ArrayList<>();      // Key strings
-    List<String> values = new ArrayList<>();    // Value expressions
-    String pkg = null;                          // Package prefix for generated class
-    String cln = null;                          // Name of generated class
-    String vtype = "String";                    // Value type
-    int maxBits = 11;                           // lg table size
-    int maxDepth = 3;                           // Max chain depth
-    boolean inner = false;                      // Generating an inner class?
-    boolean empty = false;                      // Generating an empty table?
-
-    void usage() {
-        err.println("usage: java Hasher [options] [[pkgName.]ClassName]");
-        err.println("options:");
-        err.println("    -e           generate empty table (ignores value exprs)");
-        err.println("    -i           generate a static inner class");
-        err.println("    -md depth    max chain depth (default 3)");
-        err.println("    -mb bits     max index bits (lg of table size, default 10)");
-        err.println("    -t type      value type (default String)");
-        err.println("    -v           verbose");
-        err.println("Key/value-expression pairs are read from standard input");
-        err.println("If class name is given then source is written to standard output");
-        System.exit(1);
-    }
-
-    Hasher(String[] args) {
-        List<String> as = Arrays.asList(args);
-        for (Iterator<String> i = as.iterator(); i.hasNext();) {
-            String a = i.next();
-            if (a.equals("-e")) {
-                empty = true;
-            } else if (a.equals("-i")) {
-                inner = true;
-            } else if (a.equals("-v")) {
-                verbose = true;
-            } else if (a.equals("-md")) {
-                if (!i.hasNext())
-                    usage();
-                maxDepth = Integer.parseInt(i.next());
-            } else if (a.equals("-mb")) {
-                if (!i.hasNext())
-                    usage();
-                maxBits = Integer.parseInt(i.next());
-            } else if (a.equals("-t")) {
-                if (!i.hasNext())
-                    usage();
-                vtype = i.next();
-            } else if (a.startsWith("-")) {
-                usage();
-            } else {
-                int j = a.lastIndexOf('.');
-                if (j >= 0) {
-                    pkg = a.substring(0, j);
-                    cln = a.substring(j + 1);
-                } else {
-                    cln = a;
-                }
-            }
-        }
-        if (verbose)
-            err.println("pkg=" + pkg + ", cln=" + cln);
-    }
-
-    // Read keys and values
-    //
-    Hasher load() throws IOException {
-        BufferedReader br
-            = new BufferedReader(new InputStreamReader(System.in));
-        for (String ln; (ln = br.readLine()) != null;) {
-            String[] ws = ln.split(",?\\s+", 2);
-            String w = ws[0].replaceAll("\"", "");
-            if (keys.contains(w))
-                throw new RuntimeException("Duplicate word in input: " + w);
-            keys.add(w);
-            if (ws.length < 2)
-                throw new RuntimeException("Missing expression for key " + w);
-            values.add(ws[1]);
-        }
-        return this;
-    }
-
-    Object[] ht;                        // Hash table itself
-    int nb;                             // Number of bits (lg table size)
-    int md;                             // Maximum chain depth
-    int mask;                           // Hash-code mask
-    int shift;                          // Hash-code shift size
-
-    int hash(String w) {
-        return (w.hashCode() >> shift) & mask;
-    }
-
-    // Build a hash table of size 2^nb, shifting the hash code by s bits
-    //
-    void build(int nb, int s) {
-
-        this.nb = nb;
-        this.shift = s;
-        int n = 1 << nb;
-        this.mask = n - 1;
-        ht = new Object[n];
-        int nw = keys.size();
-
-        for (int i = 0; i < nw; i++) {
-            String w = keys.get(i);
-            String v = values.get(i);
-            int h = hash(w);
-            if (ht[h] == null)
-                ht[h] = new Object[] { w, v };
-            else
-                ht[h] = new Object[] { w, v, ht[h] };
-        }
-
-        this.md = 0;
-        for (int i = 0; i < n; i++) {
-            int d = 1;
-            for (Object[] a = (Object[])ht[i];
-                 a != null && a.length > 2;
-                 a = (Object[])a[2], d++);
-            this.md = Math.max(md, d);
-        }
-
-    }
-
-    Hasher build() {
-        // Iterate through acceptable table sizes
-        for (int nb = 2; nb < maxBits; nb++) {
-            // Iterate through possible shift sizes
-            for (int s = 0; s < (32 - nb); s++) {
-                build(nb, s);
-                if (verbose)
-                    err.println("nb=" + nb + " s=" + s + " md=" + md);
-                if (md <= maxDepth) {
-                    // Success
-                    out.flush();
-                    if (verbose) {
-                        if (cln != null)
-                            err.print(cln + ": ");
-                        err.println("Table size " + (1 << nb) + " (" + nb + " bits)"
-                                    + ", shift " + shift
-                                    + ", max chain depth " + md);
-                    }
-                    return this;
-                }
-            }
-        }
-        throw new RuntimeException("Cannot find a suitable size"
-                                   + " within given constraints");
-    }
-
-    // Look for the given key in the hash table
-    //
-    String get(String k) {
-        int h = hash(k);
-        Object[] a = (Object[])ht[h];
-        for (;;) {
-            if (a[0].equals(k))
-                return (String)a[1];
-            if (a.length < 3)
-                return null;
-            a = (Object[])a[2];
-        }
-    }
-
-    // Test that all input keys can be found in the table
-    //
-    Hasher test() {
-        if (verbose)
-            err.println();
-        for (int i = 0, n = keys.size(); i < n; i++) {
-            String w = keys.get(i);
-            String v = get(w);
-            if (verbose)
-                err.println(hash(w) + "\t" + w);
-            if (!v.equals(values.get(i)))
-                throw new Error("Incorrect value: " + w + " --> "
-                                + v + ", should be " + values.get(i));
-        }
-        return this;
-    }
-
-    String ind = "";                    // Indent prefix
-
-    // Generate code for a single table entry
-    //
-    void genEntry(Object[] a, int depth, PrintWriter pw) {
-        Object v = empty ? null : a[1];
-        pw.print("new Object[] { \"" + a[0] + "\", " + v);
-        if (a.length < 3) {
-            pw.print(" }");
-            return;
-        }
-        pw.println(",");
-        pw.print(ind + "                     ");
-        for (int i = 0; i < depth; i++)
-            pw.print("    ");
-        genEntry((Object[])a[2], depth + 1, pw);
-        pw.print(" }");
-    }
-
-    // Generate a PreHashedMap subclass from the computed hash table
-    //
-    Hasher generate() throws IOException {
-        if (cln == null)
-            return this;
-        PrintWriter pw
-            = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out)));
-
-        if (inner)
-            ind = "    ";
-
-        if (!inner && pkg != null) {
-            pw.println();
-            pw.println("package " + pkg + ";");
-            pw.println();
-        }
-
-        if (inner) {
-            pw.println(ind + "private static final class " + cln);
-        } else {
-            pw.println();
-            pw.println("public final class " + cln);
-        }
-        pw.println(ind + "    extends sun.util.PreHashedMap<" + vtype +">");
-        pw.println(ind + "{");
-
-        pw.println();
-        pw.println(ind + "    private static final int ROWS = "
-                   + ht.length + ";");
-        pw.println(ind + "    private static final int SIZE = "
-                   + keys.size() + ";");
-        pw.println(ind + "    private static final int SHIFT = "
-                   + shift + ";");
-        pw.println(ind + "    private static final int MASK = 0x"
-                   + Integer.toHexString(mask) + ";");
-        pw.println();
-
-        pw.println(ind + "    " + (inner ? "private " : "public ")
-                   + cln + "() {");
-        pw.println(ind + "        super(ROWS, SIZE, SHIFT, MASK);");
-        pw.println(ind + "    }");
-        pw.println();
-
-        pw.println(ind + "    protected void init(Object[] ht) {");
-        for (int i = 0; i < ht.length; i++) {
-            if (ht[i] == null)
-                continue;
-            Object[] a = (Object[])ht[i];
-            pw.print(ind + "        ht[" + i + "] = ");
-            genEntry(a, 0, pw);
-            pw.println(";");
-        }
-        pw.println(ind + "    }");
-        pw.println();
-
-        pw.println(ind + "}");
-        if (inner)
-            pw.println();
-
-        pw.close();
-        return this;
-    }
-
-    public static void main(String[] args) throws IOException {
-        new Hasher(args)
-            .load()
-            .build()
-            .test()
-            .generate();
-    }
-
-}
--- a/make/jdk/src/classes/build/tools/jarreorder/JarReorder.java	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,384 +0,0 @@
-/*
- * Copyright (c) 2000, 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.  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.
- */
-
-/*
- * Read an input file which is output from a java -verbose run,
- * combine with an argument list of files and directories, and
- * write a list of items to be included in a jar file.
- */
-package build.tools.jarreorder;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashSet;
-import java.io.PrintStream;
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-public class JarReorder {
-
-    // To deal with output
-    private PrintStream out;
-
-    private void usage() {
-        String help;
-        help =
-                "Usage:  jar JarReorder [-m] [-o <outputfile>] <order_list> <exclude_list> <file> ...\n"
-                + "   -m            activate module mode, where every direct sub\n"
-                + "                 directory of the current working directory\n"
-                + "                 will be assumed to be a separate source root\n"
-                + "   order_list    is a file containing names of files to load\n"
-                + "                 in order at the end of a jar file unless\n"
-                + "                 excluded in the exclude list.\n"
-                + "   exclude_list  is a file containing names of files/directories\n"
-                + "                 NOT to be included in a jar file.\n"
-                + "\n"
-                + "The order_list or exclude_list may be replaced by a \"-\" if no\n"
-                + "data is to be provided.\n"
-                + "\n"
-                + "   The remaining arguments are files or directories to be included\n"
-                + "   in a jar file, from which will be excluded those entries which\n"
-                + "   appear in the exclude list.\n";
-        System.err.println(help);
-    }
-
-
-    /*
-     * Create the file list to be included in a jar file, such that the
-     * list will appear in a specific order, and allowing certain
-     * files and directories to be excluded.
-     *
-     * Command path arguments are
-     *    - optional -m for module mode.
-     *    - optional -o outputfile
-     *    - name of a file containing a set of files to be included in a jar file.
-     *    - name of a file containing a set of files (or directories) to be
-     *      excluded from the jar file.
-     *    - names of files or directories to be searched for files to include
-     *      in the jar file.
-     */
-    public static void main(String[] args) {
-        JarReorder jr = new JarReorder();
-        jr.run(args);
-    }
-
-    private void run(String args[]) {
-
-        int arglen = args.length;
-        int argpos = 0;
-
-        boolean moduleMode = false;
-
-        if (arglen > 0) {
-            // Check for module mode
-            if (args[argpos].equals("-m")) {
-                moduleMode = true;
-                argpos++;
-                arglen--;
-            }
-            // Look for "-o outputfilename" option
-            if (arglen >= 2 && args[argpos].equals("-o")) {
-                try {
-                    out = new PrintStream(new FileOutputStream(args[argpos+1]));
-                } catch (FileNotFoundException e) {
-                    System.err.println("Error: " + e.getMessage());
-                    e.printStackTrace(System.err);
-                    System.exit(1);
-                }
-                argpos += 2;
-                arglen -= 2;
-            } else {
-                System.err.println("Error: Illegal arg count");
-                System.exit(1);
-            }
-        } else {
-            out = System.out;
-        }
-
-        // Should be 2 or more args left
-        if (arglen <= 2) {
-            usage();
-            System.exit(1);
-        }
-
-        // Read the ordered set of files to be included in rt.jar.
-        // Read the set of files/directories to be excluded from rt.jar.
-        String classListFile = args[argpos];
-        String excludeListFile = args[argpos + 1];
-        argpos += 2;
-        arglen -= 2;
-
-        // If we run module mode, this will contain the list of subdirs to use
-        // as source roots. Otherwise it will just contain the current working
-        // dir.
-        List<File> moduleDirs = findModuleDirs(moduleMode);
-
-        // Create 2 lists and a set of processed files
-        List<String> orderList = readListFromFile(classListFile, true, moduleDirs);
-        List<String> excludeList = readListFromFile(excludeListFile, false, moduleDirs);
-        Set<String> processed = new HashSet<String>();
-
-        // Create set of all files and directories excluded, then expand
-        //   that list completely
-        Set<String> excludeSet = new HashSet<String>(excludeList);
-        Set<String> allFilesExcluded = expand(null, excludeSet, processed);
-
-        // Indicate all these have been processed, orderList too, kept to end.
-        processed.addAll(orderList);
-
-        // The remaining arguments are names of files/directories to be included
-        // in the jar file.
-        Set<String> inputSet = new HashSet<String>();
-        for (int i = 0; i < arglen; ++i) {
-            String name = args[argpos + i];
-            for (File dir : moduleDirs) {
-                String cleanName = cleanPath(new File(dir, name));
-                if ( cleanName != null && cleanName.length() > 0 && !inputSet.contains(cleanName) ) {
-                    inputSet.add(cleanName);
-                }
-            }
-        }
-
-        // Expand file/directory input so we get a complete set (except ordered)
-        //   Should be everything not excluded and not in order list.
-        Set<String> allFilesIncluded = expand(null, inputSet, processed);
-
-        // Create simple sorted list so we can add ordered items at end.
-        List<String> allFiles = new ArrayList<String>(allFilesIncluded);
-        Collections.sort(allFiles);
-
-        // Now add the ordered set to the end of the list.
-        // Add in REVERSE ORDER, so that the first element is closest to
-        // the end (and the index).
-        for (int i = orderList.size() - 1; i >= 0; --i) {
-            String s = orderList.get(i);
-            if (allFilesExcluded.contains(s)) {
-                // Disable this warning until 8005688 is fixed
-                // System.err.println("Included order file " + s
-                //    + " is also excluded, skipping.");
-            } else if (new File(s).exists()) {
-                allFiles.add(s);
-            } else {
-                System.err.println("Included order file " + s
-                    + " missing, skipping.");
-            }
-        }
-
-        // Print final results.
-        for (String str : allFiles) {
-            // If running in module mode, each line must be prepended with a
-            // '-C dir ' which points to the source root where that file is
-            // found.
-            if (moduleMode) {
-                int firstPathSep = str.indexOf(File.separator);
-                String moduleDir;
-                if (firstPathSep < 0) {
-                    moduleDir = ".";
-                } else {
-                    moduleDir = str.substring(0, firstPathSep);
-                }
-                String filePath = str.substring(firstPathSep + 1);
-                out.println("-C " + moduleDir + " " + filePath);
-            } else {
-                out.println(str);
-            }
-        }
-        out.flush();
-        out.close();
-    }
-
-    /*
-     * Read a file containing a list of files and directories into a List.
-     */
-    private List<String> readListFromFile(String fileName,
-            boolean addClassSuffix, List<File> moduleDirs) {
-
-        BufferedReader br = null;
-        List<String> list = new ArrayList<String>();
-        // If you see "-" for the name, just assume nothing was provided.
-        if ("-".equals(fileName)) {
-            return list;
-        }
-        try {
-            br = new BufferedReader(new FileReader(fileName));
-            // Read the input file a path at a time. # in column 1 is a comment.
-            while (true) {
-                String path = br.readLine();
-                if (path == null) {
-                    break;
-                }
-                // Look for comments
-                path = path.trim();
-                if (path.length() == 0
-                        || path.charAt(0) == '#') {
-                    continue;
-                }
-                // Add trailing .class if necessary
-                if (addClassSuffix && !path.endsWith(".class")) {
-                    path = path + ".class";
-                }
-                // Look for file in each module source root
-                boolean pathFound = false;
-                for (File dir : moduleDirs) {
-                    File file = new File(dir, path);
-                    if (file.exists()) {
-                        pathFound = true;
-                        // Normalize the path
-                        String cleanPath = cleanPath(new File(dir, path));
-                        // Add to list
-                        if (cleanPath != null && cleanPath.length() > 0 && !list.contains(cleanPath)) {
-                            list.add(cleanPath);
-                        }
-                    }
-                }
-                if (!pathFound) {
-                    System.err.println("WARNING: Path does not exist as file or directory: " + path);
-                }
-            }
-            br.close();
-        } catch (FileNotFoundException e) {
-            System.err.println("Can't find file \"" + fileName + "\".");
-            System.exit(1);
-        } catch (IOException e) {
-            e.printStackTrace();
-            System.exit(2);
-        }
-        return list;
-    }
-
-    /*
-     * Expands inputSet (files or dirs) into full set of all files that
-     * can be found by recursively descending directories.
-     * @param dir root directory
-     * @param inputSet set of files or dirs to look into
-     * @param processed files or dirs already processed
-     * @return set of files
-     */
-    private Set<String> expand(File dir,
-            Set<String> inputSet,
-            Set<String> processed) {
-        Set<String> includedFiles = new HashSet<String>();
-        if (inputSet.isEmpty()) {
-            return includedFiles;
-        }
-        for (String name : inputSet) {
-            // Depending on start location
-            File f = (dir == null) ? new File(name)
-                    : new File(dir, name);
-            // Normalized path to use
-            String path = cleanPath(f);
-            if (path != null && path.length() > 0
-                    && !processed.contains(path)) {
-                if (f.isFile()) {
-                    // Not in the excludeList, add it to both lists
-                    includedFiles.add(path);
-                    processed.add(path);
-                } else if (f.isDirectory()) {
-                    // Add the directory entries
-                    String[] dirList = f.list();
-                    Set<String> dirInputSet = new HashSet<String>();
-                    for (String x : dirList) {
-                        dirInputSet.add(x);
-                    }
-                    // Process all entries in this directory
-                    Set<String> subList = expand(f, dirInputSet, processed);
-                    includedFiles.addAll(subList);
-                    processed.add(path);
-                }
-            }
-        }
-        return includedFiles;
-    }
-
-    /**
-     * Find all module sub directories to be used as source roots.
-     * @param moduleMode If true, assume sub directories are modules, otherwise
-     *                   just use current working directory.
-     * @return List of all found source roots
-     */
-    private List<File> findModuleDirs(boolean moduleMode) {
-        File cwd = new File(".");
-        List<File> moduleDirs = new ArrayList<File>();
-        if (moduleMode) {
-            for (File f : cwd.listFiles()) {
-                if (f.isDirectory()) {
-                    moduleDirs.add(f);
-                }
-            }
-        } else {
-            moduleDirs.add(cwd);
-        }
-        return moduleDirs;
-    }
-
-    private String cleanPath(File f) {
-        String path = f.getPath();
-        if (f.isFile()) {
-            path = cleanFilePath(path);
-        } else if (f.isDirectory()) {
-            path = cleanDirPath(path);
-        } else {
-            System.err.println("WARNING: Path does not exist as file or directory: " + path);
-            path = null;
-        }
-        return path;
-    }
-
-    private String cleanFilePath(String path) {
-        // Remove leading and trailing whitespace
-        path = path.trim();
-        // Make all / and \ chars one
-        if (File.separatorChar == '/') {
-            path = path.replace('\\', '/');
-        } else {
-            path = path.replace('/', '\\');
-        }
-        // Remove leading ./
-        while (path.startsWith("." + File.separator)) {
-            path = path.substring(2);
-        }
-        return path;
-    }
-
-    private String cleanDirPath(String path) {
-        path = cleanFilePath(path);
-        // Make sure it ends with a file separator
-        if (!path.endsWith(File.separator)) {
-            path = path + File.separator;
-        }
-        // Remove any /./ in the path.
-        if (path.endsWith(File.separator + "." + File.separator)) {
-            path = path.substring(0, path.length() - 2);
-        }
-        return path;
-    }
-
-}
--- a/make/langtools/intellij/template/runConfigurations/javac.xml	Wed Sep 12 11:51:39 2018 +0530
+++ b/make/langtools/intellij/template/runConfigurations/javac.xml	Thu Sep 13 10:54:11 2018 -0700
@@ -16,7 +16,7 @@
     <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" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/make/langtools/intellij/build.xml" target="build-all-classes" />
     </method>
   </configuration>
 </component>
--- a/make/langtools/intellij/template/runConfigurations/javadoc.xml	Wed Sep 12 11:51:39 2018 +0530
+++ b/make/langtools/intellij/template/runConfigurations/javadoc.xml	Thu Sep 13 10:54:11 2018 -0700
@@ -16,7 +16,7 @@
     <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" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/make/langtools/intellij/build.xml" target="build-all-classes" />
     </method>
   </configuration>
 </component>
--- a/make/langtools/intellij/template/runConfigurations/javap.xml	Wed Sep 12 11:51:39 2018 +0530
+++ b/make/langtools/intellij/template/runConfigurations/javap.xml	Thu Sep 13 10:54:11 2018 -0700
@@ -16,7 +16,7 @@
     <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" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/make/langtools/intellij/build.xml" target="build-all-classes" />
     </method>
   </configuration>
 </component>
--- a/make/langtools/intellij/template/runConfigurations/jshell.xml	Wed Sep 12 11:51:39 2018 +0530
+++ b/make/langtools/intellij/template/runConfigurations/jshell.xml	Thu Sep 13 10:54:11 2018 -0700
@@ -14,7 +14,7 @@
     <envs />
     <method>
       <option name="Make" enabled="false" />
-      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/.idea/build.xml" target="build-all-classes" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/make/langtools/intellij/build.xml" target="build-all-classes" />
     </method>
   </configuration>
 </component>
--- a/make/langtools/intellij/template/runConfigurations/sjavac.xml	Wed Sep 12 11:51:39 2018 +0530
+++ b/make/langtools/intellij/template/runConfigurations/sjavac.xml	Thu Sep 13 10:54:11 2018 -0700
@@ -16,7 +16,7 @@
     <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" />
+      <option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/make/langtools/intellij/build.xml" target="build-all-classes" />
     </method>
   </configuration>
 </component>
--- a/make/lib/CoreLibraries.gmk	Wed Sep 12 11:51:39 2018 +0530
+++ b/make/lib/CoreLibraries.gmk	Thu Sep 13 10:54:11 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/lib/Lib-java.base.gmk	Wed Sep 12 11:51:39 2018 +0530
+++ b/make/lib/Lib-java.base.gmk	Thu Sep 13 10:54:11 2018 -0700
@@ -128,14 +128,6 @@
 
 ifeq ($(OPENJDK_TARGET_OS_TYPE), unix)
   ifeq ($(STATIC_BUILD), false)
-
-    LIBJSIG_MAPFILE := $(wildcard $(TOPDIR)/make/mapfiles/libjsig/mapfile-vers-$(OPENJDK_TARGET_OS))
-
-    ifeq ($(OPENJDK_TARGET_OS), linux)
-      # FIXME: This is probably not what we want to do, but keep it now for compatibility.
-      LIBJSIG_CFLAGS := $(EXPORT_ALL_SYMBOLS)
-    endif
-
     $(eval $(call SetupJdkLibrary, BUILD_LIBJSIG, \
         NAME := jsig, \
         CFLAGS := $(CFLAGS_JDKLIB) $(LIBJSIG_CFLAGS), \
@@ -144,7 +136,6 @@
         LIBS_linux := $(LIBDL), \
         LIBS_solaris := $(LIBDL), \
         LIBS_aix := $(LIBDL), \
-        MAPFILE := $(LIBJSIG_MAPFILE), \
     ))
 
     TARGETS += $(BUILD_LIBJSIG)
--- a/make/mapfiles/libjsig/mapfile-vers-solaris	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-#
-# 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.
-#  
-#
-
-# Define library interface.
-
-SUNWprivate_1.1 {
-        global:
-            JVM_begin_signal_setting;
-            JVM_end_signal_setting;
-            JVM_get_signal_action;
-            sigaction;
-            signal;
-            sigset;
-        local:
-                *;
-};
--- a/src/hotspot/cpu/aarch64/aarch64.ad	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/cpu/aarch64/aarch64.ad	Thu Sep 13 10:54:11 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/assembler_aarch64.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -2356,7 +2356,7 @@
 
   // FMLA/FMLS - Vector - Scalar
   INSN(fmlavs, 0, 0b0001);
-  INSN(fmlsvs, 0, 0b0001);
+  INSN(fmlsvs, 0, 0b0101);
   // FMULX - Vector - Scalar
   INSN(fmulxvs, 1, 0b1001);
 
--- a/src/hotspot/cpu/ppc/assembler_ppc.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/cpu/ppc/assembler_ppc.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -521,6 +521,18 @@
     XXLOR_OPCODE   = (60u << OPCODE_SHIFT |  146u << 3),
     XXLXOR_OPCODE  = (60u << OPCODE_SHIFT |  154u << 3),
     XXLEQV_OPCODE  = (60u << OPCODE_SHIFT |  186u << 3),
+    XVDIVSP_OPCODE = (60u << OPCODE_SHIFT |   88u << 3),
+    XVDIVDP_OPCODE = (60u << OPCODE_SHIFT |  120u << 3),
+    XVABSSP_OPCODE = (60u << OPCODE_SHIFT |  409u << 2),
+    XVABSDP_OPCODE = (60u << OPCODE_SHIFT |  473u << 2),
+    XVNEGSP_OPCODE = (60u << OPCODE_SHIFT |  441u << 2),
+    XVNEGDP_OPCODE = (60u << OPCODE_SHIFT |  505u << 2),
+    XVSQRTSP_OPCODE= (60u << OPCODE_SHIFT |  139u << 2),
+    XVSQRTDP_OPCODE= (60u << OPCODE_SHIFT |  203u << 2),
+    XVADDDP_OPCODE = (60u << OPCODE_SHIFT |   96u << 3),
+    XVSUBDP_OPCODE = (60u << OPCODE_SHIFT |  104u << 3),
+    XVMULSP_OPCODE = (60u << OPCODE_SHIFT |   80u << 3),
+    XVMULDP_OPCODE = (60u << OPCODE_SHIFT |  112u << 3),
 
     // Vector Permute and Formatting
     VPKPX_OPCODE   = (4u  << OPCODE_SHIFT |  782u     ),
@@ -574,6 +586,7 @@
     VADDUBS_OPCODE = (4u  << OPCODE_SHIFT |  512u     ),
     VADDUWS_OPCODE = (4u  << OPCODE_SHIFT |  640u     ),
     VADDUHS_OPCODE = (4u  << OPCODE_SHIFT |  576u     ),
+    VADDFP_OPCODE  = (4u  << OPCODE_SHIFT |   10u     ),
     VSUBCUW_OPCODE = (4u  << OPCODE_SHIFT | 1408u     ),
     VSUBSHS_OPCODE = (4u  << OPCODE_SHIFT | 1856u     ),
     VSUBSBS_OPCODE = (4u  << OPCODE_SHIFT | 1792u     ),
@@ -581,9 +594,11 @@
     VSUBUBM_OPCODE = (4u  << OPCODE_SHIFT | 1024u     ),
     VSUBUWM_OPCODE = (4u  << OPCODE_SHIFT | 1152u     ),
     VSUBUHM_OPCODE = (4u  << OPCODE_SHIFT | 1088u     ),
+    VSUBUDM_OPCODE = (4u  << OPCODE_SHIFT | 1216u     ),
     VSUBUBS_OPCODE = (4u  << OPCODE_SHIFT | 1536u     ),
     VSUBUWS_OPCODE = (4u  << OPCODE_SHIFT | 1664u     ),
     VSUBUHS_OPCODE = (4u  << OPCODE_SHIFT | 1600u     ),
+    VSUBFP_OPCODE  = (4u  << OPCODE_SHIFT |   74u     ),
 
     VMULESB_OPCODE = (4u  << OPCODE_SHIFT |  776u     ),
     VMULEUB_OPCODE = (4u  << OPCODE_SHIFT |  520u     ),
@@ -592,7 +607,9 @@
     VMULOSB_OPCODE = (4u  << OPCODE_SHIFT |  264u     ),
     VMULOUB_OPCODE = (4u  << OPCODE_SHIFT |    8u     ),
     VMULOSH_OPCODE = (4u  << OPCODE_SHIFT |  328u     ),
+    VMULOSW_OPCODE = (4u  << OPCODE_SHIFT |  392u     ),
     VMULOUH_OPCODE = (4u  << OPCODE_SHIFT |   72u     ),
+    VMULUWM_OPCODE = (4u  << OPCODE_SHIFT |  137u     ),
     VMHADDSHS_OPCODE=(4u  << OPCODE_SHIFT |   32u     ),
     VMHRADDSHS_OPCODE=(4u << OPCODE_SHIFT |   33u     ),
     VMLADDUHM_OPCODE=(4u  << OPCODE_SHIFT |   34u     ),
@@ -602,6 +619,7 @@
     VMSUMSHS_OPCODE= (4u  << OPCODE_SHIFT |   41u     ),
     VMSUMUHM_OPCODE= (4u  << OPCODE_SHIFT |   38u     ),
     VMSUMUHS_OPCODE= (4u  << OPCODE_SHIFT |   39u     ),
+    VMADDFP_OPCODE = (4u  << OPCODE_SHIFT |   46u     ),
 
     VSUMSWS_OPCODE = (4u  << OPCODE_SHIFT | 1928u     ),
     VSUM2SWS_OPCODE= (4u  << OPCODE_SHIFT | 1672u     ),
@@ -657,6 +675,7 @@
     VSRAB_OPCODE   = (4u  << OPCODE_SHIFT |  772u     ),
     VSRAW_OPCODE   = (4u  << OPCODE_SHIFT |  900u     ),
     VSRAH_OPCODE   = (4u  << OPCODE_SHIFT |  836u     ),
+    VPOPCNTW_OPCODE= (4u  << OPCODE_SHIFT | 1923u     ),
 
     // Vector Floating-Point
     // not implemented yet
@@ -2059,6 +2078,7 @@
   inline void vaddubs(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vadduws(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vadduhs(  VectorRegister d, VectorRegister a, VectorRegister b);
+  inline void vaddfp(   VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vsubcuw(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vsubshs(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vsubsbs(  VectorRegister d, VectorRegister a, VectorRegister b);
@@ -2066,9 +2086,11 @@
   inline void vsububm(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vsubuwm(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vsubuhm(  VectorRegister d, VectorRegister a, VectorRegister b);
+  inline void vsubudm(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vsububs(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vsubuws(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vsubuhs(  VectorRegister d, VectorRegister a, VectorRegister b);
+  inline void vsubfp(   VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vmulesb(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vmuleub(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vmulesh(  VectorRegister d, VectorRegister a, VectorRegister b);
@@ -2076,7 +2098,9 @@
   inline void vmulosb(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vmuloub(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vmulosh(  VectorRegister d, VectorRegister a, VectorRegister b);
+  inline void vmulosw(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vmulouh(  VectorRegister d, VectorRegister a, VectorRegister b);
+  inline void vmuluwm(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vmhaddshs(VectorRegister d, VectorRegister a, VectorRegister b, VectorRegister c);
   inline void vmhraddshs(VectorRegister d,VectorRegister a, VectorRegister b, VectorRegister c);
   inline void vmladduhm(VectorRegister d, VectorRegister a, VectorRegister b, VectorRegister c);
@@ -2086,6 +2110,7 @@
   inline void vmsumshs( VectorRegister d, VectorRegister a, VectorRegister b, VectorRegister c);
   inline void vmsumuhm( VectorRegister d, VectorRegister a, VectorRegister b, VectorRegister c);
   inline void vmsumuhs( VectorRegister d, VectorRegister a, VectorRegister b, VectorRegister c);
+  inline void vmaddfp(  VectorRegister d, VectorRegister a, VectorRegister b, VectorRegister c);
   inline void vsumsws(  VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vsum2sws( VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vsum4sbs( VectorRegister d, VectorRegister a, VectorRegister b);
@@ -2146,6 +2171,7 @@
   inline void vsrab(    VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vsraw(    VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vsrah(    VectorRegister d, VectorRegister a, VectorRegister b);
+  inline void vpopcntw( VectorRegister d, VectorRegister b);
   // Vector Floating-Point not implemented yet
   inline void mtvscr(   VectorRegister b);
   inline void mfvscr(   VectorRegister d);
@@ -2168,6 +2194,18 @@
   inline void xxlor(    VectorSRegister d, VectorSRegister a, VectorSRegister b);
   inline void xxlxor(   VectorSRegister d, VectorSRegister a, VectorSRegister b);
   inline void xxleqv(   VectorSRegister d, VectorSRegister a, VectorSRegister b);
+  inline void xvdivsp(  VectorSRegister d, VectorSRegister a, VectorSRegister b);
+  inline void xvdivdp(  VectorSRegister d, VectorSRegister a, VectorSRegister b);
+  inline void xvabssp(  VectorSRegister d, VectorSRegister b);
+  inline void xvabsdp(  VectorSRegister d, VectorSRegister b);
+  inline void xvnegsp(  VectorSRegister d, VectorSRegister b);
+  inline void xvnegdp(  VectorSRegister d, VectorSRegister b);
+  inline void xvsqrtsp( VectorSRegister d, VectorSRegister b);
+  inline void xvsqrtdp( VectorSRegister d, VectorSRegister b);
+  inline void xvadddp(  VectorSRegister d, VectorSRegister a, VectorSRegister b);
+  inline void xvsubdp(  VectorSRegister d, VectorSRegister a, VectorSRegister b);
+  inline void xvmulsp(  VectorSRegister d, VectorSRegister a, VectorSRegister b);
+  inline void xvmuldp(  VectorSRegister d, VectorSRegister a, VectorSRegister b);
 
   // VSX Extended Mnemonics
   inline void xxspltd(  VectorSRegister d, VectorSRegister a, int x);
--- a/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -769,7 +769,19 @@
 inline void Assembler::xxlor(   VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XXLOR_OPCODE  | vsrt(d) | vsra(a) | vsrb(b)); }
 inline void Assembler::xxlxor(  VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XXLXOR_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
 inline void Assembler::xxleqv(  VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XXLEQV_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
-inline void Assembler::mtvrd(    VectorRegister d, Register a)               { emit_int32( MTVSRD_OPCODE  | vsrt(d->to_vsr()) | ra(a)); }
+inline void Assembler::xvdivsp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVDIVSP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
+inline void Assembler::xvdivdp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVDIVDP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
+inline void Assembler::xvabssp( VectorSRegister d, VectorSRegister b)                    { emit_int32( XVABSSP_OPCODE | vsrt(d) | vsrb(b)); }
+inline void Assembler::xvabsdp( VectorSRegister d, VectorSRegister b)                    { emit_int32( XVABSDP_OPCODE | vsrt(d) | vsrb(b)); }
+inline void Assembler::xvnegsp( VectorSRegister d, VectorSRegister b)                    { emit_int32( XVNEGSP_OPCODE | vsrt(d) | vsrb(b)); }
+inline void Assembler::xvnegdp( VectorSRegister d, VectorSRegister b)                    { emit_int32( XVNEGDP_OPCODE | vsrt(d) | vsrb(b)); }
+inline void Assembler::xvsqrtsp(VectorSRegister d, VectorSRegister b)                    { emit_int32( XVSQRTSP_OPCODE| vsrt(d) | vsrb(b)); }
+inline void Assembler::xvsqrtdp(VectorSRegister d, VectorSRegister b)                    { emit_int32( XVSQRTDP_OPCODE| vsrt(d) | vsrb(b)); }
+inline void Assembler::xvadddp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVADDDP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
+inline void Assembler::xvsubdp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVSUBDP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
+inline void Assembler::xvmulsp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMULSP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
+inline void Assembler::xvmuldp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMULDP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
+inline void Assembler::mtvrd(   VectorRegister d, Register a)               { emit_int32( MTVSRD_OPCODE  | vsrt(d->to_vsr()) | ra(a)); }
 inline void Assembler::mfvrd(   Register        a, VectorRegister d)         { emit_int32( MFVSRD_OPCODE  | vsrt(d->to_vsr()) | ra(a)); }
 inline void Assembler::mtvrwz(  VectorRegister  d, Register a)               { emit_int32( MTVSRWZ_OPCODE | vsrt(d->to_vsr()) | ra(a)); }
 inline void Assembler::mfvrwz(  Register        a, VectorRegister d)         { emit_int32( MFVSRWZ_OPCODE | vsrt(d->to_vsr()) | ra(a)); }
@@ -833,6 +845,7 @@
 inline void Assembler::vaddubs( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VADDUBS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vadduws( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VADDUWS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vadduhs( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VADDUHS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
+inline void Assembler::vaddfp(  VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VADDFP_OPCODE  | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vsubcuw( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSUBCUW_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vsubshs( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSUBSHS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vsubsbs( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSUBSBS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
@@ -840,9 +853,11 @@
 inline void Assembler::vsububm( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSUBUBM_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vsubuwm( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSUBUWM_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vsubuhm( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSUBUHM_OPCODE | vrt(d) | vra(a) | vrb(b)); }
+inline void Assembler::vsubudm( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSUBUDM_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vsububs( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSUBUBS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vsubuws( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSUBUWS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vsubuhs( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSUBUHS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
+inline void Assembler::vsubfp(  VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSUBFP_OPCODE  | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vmulesb( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VMULESB_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vmuleub( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VMULEUB_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vmulesh( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VMULESH_OPCODE | vrt(d) | vra(a) | vrb(b)); }
@@ -850,7 +865,9 @@
 inline void Assembler::vmulosb( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VMULOSB_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vmuloub( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VMULOUB_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vmulosh( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VMULOSH_OPCODE | vrt(d) | vra(a) | vrb(b)); }
+inline void Assembler::vmulosw( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VMULOSW_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vmulouh( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VMULOUH_OPCODE | vrt(d) | vra(a) | vrb(b)); }
+inline void Assembler::vmuluwm( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VMULUWM_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vmhaddshs(VectorRegister d,VectorRegister a, VectorRegister b, VectorRegister c) { emit_int32( VMHADDSHS_OPCODE | vrt(d) | vra(a) | vrb(b)| vrc(c)); }
 inline void Assembler::vmhraddshs(VectorRegister d,VectorRegister a,VectorRegister b, VectorRegister c) { emit_int32( VMHRADDSHS_OPCODE| vrt(d) | vra(a) | vrb(b)| vrc(c)); }
 inline void Assembler::vmladduhm(VectorRegister d,VectorRegister a, VectorRegister b, VectorRegister c) { emit_int32( VMLADDUHM_OPCODE | vrt(d) | vra(a) | vrb(b)| vrc(c)); }
@@ -860,6 +877,7 @@
 inline void Assembler::vmsumshs(VectorRegister d, VectorRegister a, VectorRegister b, VectorRegister c) { emit_int32( VMSUMSHS_OPCODE  | vrt(d) | vra(a) | vrb(b)| vrc(c)); }
 inline void Assembler::vmsumuhm(VectorRegister d, VectorRegister a, VectorRegister b, VectorRegister c) { emit_int32( VMSUMUHM_OPCODE  | vrt(d) | vra(a) | vrb(b)| vrc(c)); }
 inline void Assembler::vmsumuhs(VectorRegister d, VectorRegister a, VectorRegister b, VectorRegister c) { emit_int32( VMSUMUHS_OPCODE  | vrt(d) | vra(a) | vrb(b)| vrc(c)); }
+inline void Assembler::vmaddfp( VectorRegister d, VectorRegister a, VectorRegister b, VectorRegister c) { emit_int32( VMADDFP_OPCODE   | vrt(d) | vra(a) | vrb(b)| vrc(c)); }
 inline void Assembler::vsumsws( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSUMSWS_OPCODE  | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vsum2sws(VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSUM2SWS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vsum4sbs(VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSUM4SBS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
@@ -921,6 +939,7 @@
 inline void Assembler::vsrab(   VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSRAB_OPCODE    | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vsraw(   VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSRAW_OPCODE    | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vsrah(   VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSRAH_OPCODE    | vrt(d) | vra(a) | vrb(b)); }
+inline void Assembler::vpopcntw(VectorRegister d, VectorRegister b)                   { emit_int32( VPOPCNTW_OPCODE | vrt(d) | vrb(b)); }
 inline void Assembler::mtvscr(  VectorRegister b)                                     { emit_int32( MTVSCR_OPCODE   | vrb(b)); }
 inline void Assembler::mfvscr(  VectorRegister d)                                     { emit_int32( MFVSCR_OPCODE   | vrt(d)); }
 
--- a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp	Thu Sep 13 10:54:11 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/ppc.ad	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/cpu/ppc/ppc.ad	Thu Sep 13 10:54:11 2018 -0700
@@ -908,6 +908,7 @@
 // ----------------------------
 
 reg_class vs_reg(
+  // Attention: Only these ones are saved & restored at safepoint by RegisterSaver.
   VSR32,
   VSR33,
   VSR34,
@@ -928,18 +929,7 @@
   VSR49,
   VSR50,
   VSR51
-//  VSR52,     // nv!
-//  VSR53,     // nv!
-//  VSR54,     // nv!
-//  VSR55,     // nv!
-//  VSR56,     // nv!
-//  VSR57,     // nv!
-//  VSR58,     // nv!
-//  VSR59,     // nv!
-//  VSR60,     // nv!
-//  VSR61,     // nv!
-//  VSR62,     // nv!
-//  VSR63      // nv!
+  // VSR52-VSR63 // nv!
 );
 
  %}
@@ -2234,9 +2224,35 @@
   case Op_StrEquals:
     return SpecialStringEquals;
   case Op_StrIndexOf:
-    return SpecialStringIndexOf;
   case Op_StrIndexOfChar:
     return SpecialStringIndexOf;
+  case Op_AddVB:
+  case Op_AddVS:
+  case Op_AddVI:
+  case Op_AddVF:
+  case Op_AddVD:
+  case Op_SubVB:
+  case Op_SubVS:
+  case Op_SubVI:
+  case Op_SubVF:
+  case Op_SubVD:
+  case Op_MulVS:
+  case Op_MulVF:
+  case Op_MulVD:
+  case Op_DivVF:
+  case Op_DivVD:
+  case Op_AbsVF:
+  case Op_AbsVD:
+  case Op_NegVF:
+  case Op_NegVD:
+  case Op_SqrtVF:
+  case Op_SqrtVD:
+  case Op_AddVL:
+  case Op_SubVL:
+  case Op_MulVI:
+    return SuperwordUseVSX;
+  case Op_PopCountVI:
+    return (SuperwordUseVSX && UsePopCountInstruction);
   }
 
   return true;  // Per default match rules are supported.
@@ -10017,7 +10033,7 @@
 
 // Single-precision sqrt.
 instruct sqrtF_reg(regF dst, regF src) %{
-  match(Set dst (ConvD2F (SqrtD (ConvF2D src))));
+  match(Set dst (SqrtF src));
   predicate(VM_Version::has_fsqrts());
   ins_cost(DEFAULT_COST);
 
@@ -13989,6 +14005,303 @@
 %}
 
 
+//----------Vector Arithmetic Instructions--------------------------------------
+
+// Vector Addition Instructions
+
+instruct vadd16B_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (AddVB src1 src2));
+  predicate(n->as_Vector()->length() == 16);
+  format %{ "VADDUBM  $dst,$src1,$src2\t// add packed16B" %}
+  size(4);
+  ins_encode %{
+    __ vaddubm($dst$$VectorSRegister->to_vr(), $src1$$VectorSRegister->to_vr(), $src2$$VectorSRegister->to_vr());
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vadd8S_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (AddVS src1 src2));
+  predicate(n->as_Vector()->length() == 8);
+  format %{ "VADDUHM  $dst,$src1,$src2\t// add packed8S" %}
+  size(4);
+  ins_encode %{
+    __ vadduhm($dst$$VectorSRegister->to_vr(), $src1$$VectorSRegister->to_vr(), $src2$$VectorSRegister->to_vr());
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vadd4I_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (AddVI src1 src2));
+  predicate(n->as_Vector()->length() == 4);
+  format %{ "VADDUWM  $dst,$src1,$src2\t// add packed4I" %}
+  size(4);
+  ins_encode %{
+    __ vadduwm($dst$$VectorSRegister->to_vr(), $src1$$VectorSRegister->to_vr(), $src2$$VectorSRegister->to_vr());
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vadd4F_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (AddVF src1 src2));
+  predicate(n->as_Vector()->length() == 4);
+  format %{ "VADDFP  $dst,$src1,$src2\t// add packed4F" %}
+  size(4);
+  ins_encode %{
+    __ vaddfp($dst$$VectorSRegister->to_vr(), $src1$$VectorSRegister->to_vr(), $src2$$VectorSRegister->to_vr());
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vadd2L_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (AddVL src1 src2));
+  predicate(n->as_Vector()->length() == 2);
+  format %{ "VADDUDM  $dst,$src1,$src2\t// add packed2L" %}
+  size(4);
+  ins_encode %{
+    __ vaddudm($dst$$VectorSRegister->to_vr(), $src1$$VectorSRegister->to_vr(), $src2$$VectorSRegister->to_vr());
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vadd2D_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (AddVD src1 src2));
+  predicate(n->as_Vector()->length() == 2);
+  format %{ "XVADDDP  $dst,$src1,$src2\t// add packed2D" %}
+  size(4);
+  ins_encode %{
+    __ xvadddp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister);
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+// Vector Subtraction Instructions
+
+instruct vsub16B_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (SubVB src1 src2));
+  predicate(n->as_Vector()->length() == 16);
+  format %{ "VSUBUBM  $dst,$src1,$src2\t// sub packed16B" %}
+  size(4);
+  ins_encode %{
+    __ vsububm($dst$$VectorSRegister->to_vr(), $src1$$VectorSRegister->to_vr(), $src2$$VectorSRegister->to_vr());
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vsub8S_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (SubVS src1 src2));
+  predicate(n->as_Vector()->length() == 8);
+  format %{ "VSUBUHM  $dst,$src1,$src2\t// sub packed8S" %}
+  size(4);
+  ins_encode %{
+    __ vsubuhm($dst$$VectorSRegister->to_vr(), $src1$$VectorSRegister->to_vr(), $src2$$VectorSRegister->to_vr());
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vsub4I_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (SubVI src1 src2));
+  predicate(n->as_Vector()->length() == 4);
+  format %{ "VSUBUWM  $dst,$src1,$src2\t// sub packed4I" %}
+  size(4);
+  ins_encode %{
+    __ vsubuwm($dst$$VectorSRegister->to_vr(), $src1$$VectorSRegister->to_vr(), $src2$$VectorSRegister->to_vr());
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vsub4F_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (SubVF src1 src2));
+  predicate(n->as_Vector()->length() == 4);
+  format %{ "VSUBFP  $dst,$src1,$src2\t// sub packed4F" %}
+  size(4);
+  ins_encode %{
+    __ vsubfp($dst$$VectorSRegister->to_vr(), $src1$$VectorSRegister->to_vr(), $src2$$VectorSRegister->to_vr());
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vsub2L_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (SubVL src1 src2));
+  predicate(n->as_Vector()->length() == 2);
+  format %{ "VSUBUDM  $dst,$src1,$src2\t// sub packed2L" %}
+  size(4);
+  ins_encode %{
+    __ vsubudm($dst$$VectorSRegister->to_vr(), $src1$$VectorSRegister->to_vr(), $src2$$VectorSRegister->to_vr());
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vsub2D_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (SubVD src1 src2));
+  predicate(n->as_Vector()->length() == 2);
+  format %{ "XVSUBDP  $dst,$src1,$src2\t// sub packed2D" %}
+  size(4);
+  ins_encode %{
+    __ xvsubdp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister);
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+// Vector Multiplication Instructions
+
+instruct vmul8S_reg(vecX dst, vecX src1, vecX src2, vecX tmp) %{
+  match(Set dst (MulVS src1 src2));
+  predicate(n->as_Vector()->length() == 8);
+  effect(TEMP tmp);
+  format %{ "VSPLTISH  $tmp,0\t// mul packed8S" %}
+  format %{ "VMLADDUHM  $dst,$src1,$src2\t// mul packed8S" %}
+  size(8);
+  ins_encode %{
+    __ vspltish($tmp$$VectorSRegister->to_vr(), 0);
+    __ vmladduhm($dst$$VectorSRegister->to_vr(), $src1$$VectorSRegister->to_vr(), $src2$$VectorSRegister->to_vr(), $tmp$$VectorSRegister->to_vr());
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vmul4I_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (MulVI src1 src2));
+  predicate(n->as_Vector()->length() == 4);
+  format %{ "VMULUWM  $dst,$src1,$src2\t// mul packed4I" %}
+  size(4);
+  ins_encode %{
+    __ vmuluwm($dst$$VectorSRegister->to_vr(), $src1$$VectorSRegister->to_vr(), $src2$$VectorSRegister->to_vr());
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vmul4F_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (MulVF src1 src2));
+  predicate(n->as_Vector()->length() == 4);
+  format %{ "XVMULSP  $dst,$src1,$src2\t// mul packed4F" %}
+  size(4);
+  ins_encode %{
+    __ xvmulsp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister);
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vmul2D_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (MulVD src1 src2));
+  predicate(n->as_Vector()->length() == 2);
+  format %{ "XVMULDP  $dst,$src1,$src2\t// mul packed2D" %}
+  size(4);
+  ins_encode %{
+    __ xvmuldp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister);
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+// Vector Division Instructions
+
+instruct vdiv4F_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (DivVF src1 src2));
+  predicate(n->as_Vector()->length() == 4);
+  format %{ "XVDIVSP  $dst,$src1,$src2\t// div packed4F" %}
+  size(4);
+  ins_encode %{
+    __ xvdivsp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister);
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vdiv2D_reg(vecX dst, vecX src1, vecX src2) %{
+  match(Set dst (DivVD src1 src2));
+  predicate(n->as_Vector()->length() == 2);
+  format %{ "XVDIVDP  $dst,$src1,$src2\t// div packed2D" %}
+  size(4);
+  ins_encode %{
+    __ xvdivdp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister);
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+// Vector Absolute Instructions
+
+instruct vabs4F_reg(vecX dst, vecX src) %{
+  match(Set dst (AbsVF src));
+  predicate(n->as_Vector()->length() == 4);
+  format %{ "XVABSSP $dst,$src\t// absolute packed4F" %}
+  size(4);
+  ins_encode %{
+    __ xvabssp($dst$$VectorSRegister, $src$$VectorSRegister);
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vabs2D_reg(vecX dst, vecX src) %{
+  match(Set dst (AbsVD src));
+  predicate(n->as_Vector()->length() == 2);
+  format %{ "XVABSDP $dst,$src\t// absolute packed2D" %}
+  size(4);
+  ins_encode %{
+    __ xvabsdp($dst$$VectorSRegister, $src$$VectorSRegister);
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+// Vector Negate Instructions
+
+instruct vneg4F_reg(vecX dst, vecX src) %{
+  match(Set dst (NegVF src));
+  predicate(n->as_Vector()->length() == 4);
+  format %{ "XVNEGSP $dst,$src\t// negate packed4F" %}
+  size(4);
+  ins_encode %{
+    __ xvnegsp($dst$$VectorSRegister, $src$$VectorSRegister);
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vneg2D_reg(vecX dst, vecX src) %{
+  match(Set dst (NegVD src));
+  predicate(n->as_Vector()->length() == 2);
+  format %{ "XVNEGDP $dst,$src\t// negate packed2D" %}
+  size(4);
+  ins_encode %{
+    __ xvnegdp($dst$$VectorSRegister, $src$$VectorSRegister);
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+// Vector Square Root Instructions
+
+instruct vsqrt4F_reg(vecX dst, vecX src) %{
+  match(Set dst (SqrtVF src));
+  predicate(n->as_Vector()->length() == 4);
+  format %{ "XVSQRTSP $dst,$src\t// sqrt packed4F" %}
+  size(4);
+  ins_encode %{
+    __ xvsqrtsp($dst$$VectorSRegister, $src$$VectorSRegister);
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+instruct vsqrt2D_reg(vecX dst, vecX src) %{
+  match(Set dst (SqrtVD src));
+  predicate(n->as_Vector()->length() == 2);
+  format %{ "XVSQRTDP  $dst,$src\t// sqrt packed2D" %}
+  size(4);
+  ins_encode %{
+    __ xvsqrtdp($dst$$VectorSRegister, $src$$VectorSRegister);
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+// Vector Population Count Instructions
+
+instruct vpopcnt4I_reg(vecX dst, vecX src) %{
+  match(Set dst (PopCountVI src));
+  predicate(n->as_Vector()->length() == 4);
+  format %{ "VPOPCNTW $dst,$src\t// pop count packed4I" %}
+  size(4);
+  ins_encode %{
+    __ vpopcntw($dst$$VectorSRegister->to_vr(), $src$$VectorSRegister->to_vr());
+  %}
+  ins_pipe(pipe_class_default);
+%}
+
+
 //----------Overflow Math Instructions-----------------------------------------
 
 // Note that we have to make sure that XER.SO is reset before using overflow instructions.
--- a/src/hotspot/cpu/ppc/register_definitions_ppc.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/cpu/ppc/register_definitions_ppc.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -32,4 +32,6 @@
 
 REGISTER_DEFINITION(FloatRegister, fnoreg);
 
+REGISTER_DEFINITION(VectorRegister, vnoreg);
+
 REGISTER_DEFINITION(VectorSRegister, vsnoreg);
--- a/src/hotspot/cpu/ppc/register_ppc.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/cpu/ppc/register_ppc.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2017 SAP SE. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -26,11 +26,6 @@
 #include "precompiled.hpp"
 #include "register_ppc.hpp"
 
-const int ConcreteRegisterImpl::max_gpr = RegisterImpl::number_of_registers * 2;
-const int ConcreteRegisterImpl::max_fpr = ConcreteRegisterImpl::max_gpr +
-                                          FloatRegisterImpl::number_of_registers * 2;
-const int ConcreteRegisterImpl::max_cnd = ConcreteRegisterImpl::max_fpr +
-                                          ConditionRegisterImpl::number_of_registers;
 
 const char* RegisterImpl::name() const {
   const char* names[number_of_registers] = {
@@ -92,6 +87,12 @@
 
 // Method to convert a VectorRegister to a Vector-Scalar Register (VectorSRegister)
 VectorSRegister VectorRegisterImpl::to_vsr() const {
-  if (this == vnoreg) { return vsnoregi; }
+  if (this == vnoreg) { return vsnoreg; }
   return as_VectorSRegister(encoding() + 32);
 }
+
+// Method to convert a VectorSRegister to a Vector Register (VectorRegister)
+VectorRegister VectorSRegisterImpl::to_vr() const {
+  if (this == vsnoreg) { return vnoreg; }
+  return as_VectorRegister(encoding() - 32);
+}
--- a/src/hotspot/cpu/ppc/register_ppc.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/cpu/ppc/register_ppc.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2017 SAP SE. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -515,11 +515,15 @@
 
   // accessors
   int encoding() const { assert(is_valid(), "invalid register"); return value(); }
+  inline VMReg as_VMReg();
 
   // testers
   bool is_valid() const { return 0 <=  value() &&  value() < number_of_registers; }
 
   const char* name() const;
+
+  // convert to VR
+  VectorRegister to_vr() const;
 };
 
 // The Vector-Scalar (VSX) registers of the POWER architecture.
@@ -592,7 +596,7 @@
 CONSTANT_REGISTER_DECLARATION(VectorSRegister, VSR63, (63));
 
 #ifndef DONT_USE_REGISTER_DEFINES
-#define vsnoregi ((VectorSRegister)(vsnoreg_VectorSRegisterEnumValue))
+#define vsnoreg ((VectorSRegister)(vsnoreg_VectorSRegisterEnumValue))
 #define VSR0    ((VectorSRegister)(   VSR0_VectorSRegisterEnumValue))
 #define VSR1    ((VectorSRegister)(   VSR1_VectorSRegisterEnumValue))
 #define VSR2    ((VectorSRegister)(   VSR2_VectorSRegisterEnumValue))
@@ -668,21 +672,16 @@
 class ConcreteRegisterImpl : public AbstractRegisterImpl {
  public:
   enum {
+    max_gpr = RegisterImpl::number_of_registers * 2,
+    max_fpr = max_gpr + FloatRegisterImpl::number_of_registers * 2,
+    max_vsr = max_fpr + VectorSRegisterImpl::number_of_registers,
+    max_cnd = max_vsr + ConditionRegisterImpl::number_of_registers,
+    max_spr = max_cnd + SpecialRegisterImpl::number_of_registers,
     // This number must be large enough to cover REG_COUNT (defined by c2) registers.
     // There is no requirement that any ordering here matches any ordering c2 gives
     // it's optoregs.
-    number_of_registers =
-      ( RegisterImpl::number_of_registers +
-        FloatRegisterImpl::number_of_registers )
-      * 2                                          // register halves
-      + ConditionRegisterImpl::number_of_registers // condition code registers
-      + SpecialRegisterImpl::number_of_registers   // special registers
-      + VectorSRegisterImpl::number_of_registers   // VSX registers
+    number_of_registers = max_spr
   };
-
-  static const int max_gpr;
-  static const int max_fpr;
-  static const int max_cnd;
 };
 
 // Common register declarations used in assembler code.
--- a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -75,10 +75,12 @@
                          int* out_frame_size_in_bytes,
                          bool generate_oop_map,
                          int return_pc_adjustment,
-                         ReturnPCLocation return_pc_location);
+                         ReturnPCLocation return_pc_location,
+                         bool save_vectors = false);
   static void    restore_live_registers_and_pop_frame(MacroAssembler* masm,
                          int frame_size_in_bytes,
-                         bool restore_ctr);
+                         bool restore_ctr,
+                         bool save_vectors = false);
 
   static void push_frame_and_save_argument_registers(MacroAssembler* masm,
                          Register r_temp,
@@ -97,14 +99,16 @@
   // Constants and data structures:
 
   typedef enum {
-    int_reg           = 0,
-    float_reg         = 1,
-    special_reg       = 2
+    int_reg,
+    float_reg,
+    special_reg,
+    vs_reg
   } RegisterType;
 
   typedef enum {
     reg_size          = 8,
     half_reg_size     = reg_size / 2,
+    vs_reg_size       = 16
   } RegisterConstants;
 
   typedef struct {
@@ -115,15 +119,18 @@
 };
 
 
-#define RegisterSaver_LiveSpecialReg(regname) \
-  { RegisterSaver::special_reg, regname->encoding(), regname->as_VMReg() }
-
 #define RegisterSaver_LiveIntReg(regname) \
   { RegisterSaver::int_reg,     regname->encoding(), regname->as_VMReg() }
 
 #define RegisterSaver_LiveFloatReg(regname) \
   { RegisterSaver::float_reg,   regname->encoding(), regname->as_VMReg() }
 
+#define RegisterSaver_LiveSpecialReg(regname) \
+  { RegisterSaver::special_reg, regname->encoding(), regname->as_VMReg() }
+
+#define RegisterSaver_LiveVSReg(regname) \
+  { RegisterSaver::vs_reg,      regname->encoding(), regname->as_VMReg() }
+
 static const RegisterSaver::LiveRegType RegisterSaver_LiveRegs[] = {
   // Live registers which get spilled to the stack. Register
   // positions in this array correspond directly to the stack layout.
@@ -201,14 +208,42 @@
   RegisterSaver_LiveIntReg(   R28 ),
   RegisterSaver_LiveIntReg(   R29 ),
   RegisterSaver_LiveIntReg(   R30 ),
-  RegisterSaver_LiveIntReg(   R31 ), // must be the last register (see save/restore functions below)
+  RegisterSaver_LiveIntReg(   R31 )  // must be the last register (see save/restore functions below)
 };
 
+static const RegisterSaver::LiveRegType RegisterSaver_LiveVSRegs[] = {
+  //
+  // live vector scalar registers (optional, only these ones are used by C2):
+  //
+  RegisterSaver_LiveVSReg( VSR32 ),
+  RegisterSaver_LiveVSReg( VSR33 ),
+  RegisterSaver_LiveVSReg( VSR34 ),
+  RegisterSaver_LiveVSReg( VSR35 ),
+  RegisterSaver_LiveVSReg( VSR36 ),
+  RegisterSaver_LiveVSReg( VSR37 ),
+  RegisterSaver_LiveVSReg( VSR38 ),
+  RegisterSaver_LiveVSReg( VSR39 ),
+  RegisterSaver_LiveVSReg( VSR40 ),
+  RegisterSaver_LiveVSReg( VSR41 ),
+  RegisterSaver_LiveVSReg( VSR42 ),
+  RegisterSaver_LiveVSReg( VSR43 ),
+  RegisterSaver_LiveVSReg( VSR44 ),
+  RegisterSaver_LiveVSReg( VSR45 ),
+  RegisterSaver_LiveVSReg( VSR46 ),
+  RegisterSaver_LiveVSReg( VSR47 ),
+  RegisterSaver_LiveVSReg( VSR48 ),
+  RegisterSaver_LiveVSReg( VSR49 ),
+  RegisterSaver_LiveVSReg( VSR50 ),
+  RegisterSaver_LiveVSReg( VSR51 )
+};
+
+
 OopMap* RegisterSaver::push_frame_reg_args_and_save_live_registers(MacroAssembler* masm,
                          int* out_frame_size_in_bytes,
                          bool generate_oop_map,
                          int return_pc_adjustment,
-                         ReturnPCLocation return_pc_location) {
+                         ReturnPCLocation return_pc_location,
+                         bool save_vectors) {
   // Push an abi_reg_args-frame and store all registers which may be live.
   // If requested, create an OopMap: Record volatile registers as
   // callee-save values in an OopMap so their save locations will be
@@ -218,15 +253,16 @@
   // If return_pc_adjustment != 0 adjust the return pc by return_pc_adjustment.
   // Updated return pc is returned in R31 (if not return_pc_is_pre_saved).
 
-  int i;
-  int offset;
-
   // calcualte frame size
   const int regstosave_num       = sizeof(RegisterSaver_LiveRegs) /
                                    sizeof(RegisterSaver::LiveRegType);
-  const int register_save_size   = regstosave_num * reg_size;
+  const int vsregstosave_num     = save_vectors ? (sizeof(RegisterSaver_LiveVSRegs) /
+                                                   sizeof(RegisterSaver::LiveRegType))
+                                                : 0;
+  const int register_save_size   = regstosave_num * reg_size + vsregstosave_num * vs_reg_size;
   const int frame_size_in_bytes  = align_up(register_save_size, frame::alignment_in_bytes)
                                    + frame::abi_reg_args_size;
+
   *out_frame_size_in_bytes       = frame_size_in_bytes;
   const int frame_size_in_slots  = frame_size_in_bytes / sizeof(jint);
   const int register_save_offset = frame_size_in_bytes - register_save_size;
@@ -236,17 +272,18 @@
 
   BLOCK_COMMENT("push_frame_reg_args_and_save_live_registers {");
 
-  // Save some registers in the last slots of the not yet pushed frame so that we
-  // can use them as scratch regs.
-  __ std(R31, -  reg_size, R1_SP);
-  __ std(R30, -2*reg_size, R1_SP);
-  assert(-reg_size == register_save_offset - frame_size_in_bytes + ((regstosave_num-1)*reg_size),
-         "consistency check");
+  // push a new frame
+  __ push_frame(frame_size_in_bytes, noreg);
+
+  // Save some registers in the last (non-vector) slots of the new frame so we
+  // can use them as scratch regs or to determine the return pc.
+  __ std(R31, frame_size_in_bytes -   reg_size - vsregstosave_num * vs_reg_size, R1_SP);
+  __ std(R30, frame_size_in_bytes - 2*reg_size - vsregstosave_num * vs_reg_size, R1_SP);
 
   // save the flags
   // Do the save_LR_CR by hand and adjust the return pc if requested.
   __ mfcr(R30);
-  __ std(R30, _abi(cr), R1_SP);
+  __ std(R30, frame_size_in_bytes + _abi(cr), R1_SP);
   switch (return_pc_location) {
     case return_pc_is_lr: __ mflr(R31); break;
     case return_pc_is_pre_saved: assert(return_pc_adjustment == 0, "unsupported"); break;
@@ -257,14 +294,12 @@
     if (return_pc_adjustment != 0) {
       __ addi(R31, R31, return_pc_adjustment);
     }
-    __ std(R31, _abi(lr), R1_SP);
+    __ std(R31, frame_size_in_bytes + _abi(lr), R1_SP);
   }
 
-  // push a new frame
-  __ push_frame(frame_size_in_bytes, R30);
-
   // save all registers (ints and floats)
-  offset = register_save_offset;
+  int offset = register_save_offset;
+
   for (int i = 0; i < regstosave_num; i++) {
     int reg_num  = RegisterSaver_LiveRegs[i].reg_num;
     int reg_type = RegisterSaver_LiveRegs[i].reg_type;
@@ -302,6 +337,22 @@
     offset += reg_size;
   }
 
+  for (int i = 0; i < vsregstosave_num; i++) {
+    int reg_num  = RegisterSaver_LiveVSRegs[i].reg_num;
+    int reg_type = RegisterSaver_LiveVSRegs[i].reg_type;
+
+    __ li(R30, offset);
+    __ stxvd2x(as_VectorSRegister(reg_num), R30, R1_SP);
+
+    if (generate_oop_map) {
+      map->set_callee_saved(VMRegImpl::stack2reg(offset>>2),
+                            RegisterSaver_LiveVSRegs[i].vmreg);
+    }
+    offset += vs_reg_size;
+  }
+
+  assert(offset == frame_size_in_bytes, "consistency check");
+
   BLOCK_COMMENT("} push_frame_reg_args_and_save_live_registers");
 
   // And we're done.
@@ -313,18 +364,22 @@
 // saved.
 void RegisterSaver::restore_live_registers_and_pop_frame(MacroAssembler* masm,
                                                          int frame_size_in_bytes,
-                                                         bool restore_ctr) {
-  int i;
-  int offset;
+                                                         bool restore_ctr,
+                                                         bool save_vectors) {
   const int regstosave_num       = sizeof(RegisterSaver_LiveRegs) /
                                    sizeof(RegisterSaver::LiveRegType);
-  const int register_save_size   = regstosave_num * reg_size;
+  const int vsregstosave_num     = save_vectors ? (sizeof(RegisterSaver_LiveVSRegs) /
+                                                   sizeof(RegisterSaver::LiveRegType))
+                                                : 0;
+  const int register_save_size   = regstosave_num * reg_size + vsregstosave_num * vs_reg_size;
+
   const int register_save_offset = frame_size_in_bytes - register_save_size;
 
   BLOCK_COMMENT("restore_live_registers_and_pop_frame {");
 
   // restore all registers (ints and floats)
-  offset = register_save_offset;
+  int offset = register_save_offset;
+
   for (int i = 0; i < regstosave_num; i++) {
     int reg_num  = RegisterSaver_LiveRegs[i].reg_num;
     int reg_type = RegisterSaver_LiveRegs[i].reg_type;
@@ -356,14 +411,30 @@
     offset += reg_size;
   }
 
-  // pop the frame
-  __ pop_frame();
-
-  // restore the flags
-  __ restore_LR_CR(R31);
+  for (int i = 0; i < vsregstosave_num; i++) {
+    int reg_num  = RegisterSaver_LiveVSRegs[i].reg_num;
+    int reg_type = RegisterSaver_LiveVSRegs[i].reg_type;
+
+    __ li(R31, offset);
+    __ lxvd2x(as_VectorSRegister(reg_num), R31, R1_SP);
+
+    offset += vs_reg_size;
+  }
+
+  assert(offset == frame_size_in_bytes, "consistency check");
+
+  // restore link and the flags
+  __ ld(R31, frame_size_in_bytes + _abi(lr), R1_SP);
+  __ mtlr(R31);
+
+  __ ld(R31, frame_size_in_bytes + _abi(cr), R1_SP);
+  __ mtcr(R31);
 
   // restore scratch register's value
-  __ ld(R31, -reg_size, R1_SP);
+  __ ld(R31, frame_size_in_bytes - reg_size - vsregstosave_num * vs_reg_size, R1_SP);
+
+  // pop the frame
+  __ addi(R1_SP, R1_SP, frame_size_in_bytes);
 
   BLOCK_COMMENT("} restore_live_registers_and_pop_frame");
 }
@@ -447,15 +518,13 @@
 
 // Restore the registers that might be holding a result.
 void RegisterSaver::restore_result_registers(MacroAssembler* masm, int frame_size_in_bytes) {
-  int i;
-  int offset;
   const int regstosave_num       = sizeof(RegisterSaver_LiveRegs) /
                                    sizeof(RegisterSaver::LiveRegType);
-  const int register_save_size   = regstosave_num * reg_size;
+  const int register_save_size   = regstosave_num * reg_size; // VS registers not relevant here.
   const int register_save_offset = frame_size_in_bytes - register_save_size;
 
   // restore all result registers (ints and floats)
-  offset = register_save_offset;
+  int offset = register_save_offset;
   for (int i = 0; i < regstosave_num; i++) {
     int reg_num  = RegisterSaver_LiveRegs[i].reg_num;
     int reg_type = RegisterSaver_LiveRegs[i].reg_type;
@@ -479,6 +548,8 @@
     }
     offset += reg_size;
   }
+
+  assert(offset == frame_size_in_bytes, "consistency check");
 }
 
 // Is vector's size (in bytes) bigger than a size saved by default?
@@ -3109,12 +3180,14 @@
     __ tabort_();
   }
 
+  bool save_vectors = (poll_type == POLL_AT_VECTOR_LOOP);
+
   // Save registers, fpu state, and flags. Set R31 = return pc.
   map = RegisterSaver::push_frame_reg_args_and_save_live_registers(masm,
                                                                    &frame_size_in_bytes,
                                                                    /*generate_oop_map=*/ true,
                                                                    /*return_pc_adjustment=*/0,
-                                                                   return_pc_location);
+                                                                   return_pc_location, save_vectors);
 
   // The following is basically a call_VM. However, we need the precise
   // address of the call in order to generate an oopmap. Hence, we do all the
@@ -3148,7 +3221,7 @@
   // Exception pending
   RegisterSaver::restore_live_registers_and_pop_frame(masm,
                                                       frame_size_in_bytes,
-                                                      /*restore_ctr=*/true);
+                                                      /*restore_ctr=*/true, save_vectors);
 
   BLOCK_COMMENT("  Jump to forward_exception_entry.");
   // Jump to forward_exception_entry, with the issuing PC in LR
@@ -3175,7 +3248,7 @@
   // Normal exit, restore registers and exit.
   RegisterSaver::restore_live_registers_and_pop_frame(masm,
                                                       frame_size_in_bytes,
-                                                      /*restore_ctr=*/true);
+                                                      /*restore_ctr=*/true, save_vectors);
 
   __ blr();
 
--- a/src/hotspot/cpu/ppc/vmreg_ppc.inline.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/cpu/ppc/vmreg_ppc.inline.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2013 SAP SE. All rights reserved.
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -28,16 +28,21 @@
 
 inline VMReg RegisterImpl::as_VMReg() {
   if (this == noreg) return VMRegImpl::Bad();
+  // Two halfs, multiply by 2.
   return VMRegImpl::as_VMReg(encoding() << 1);
 }
 
-// Since we don't have two halfs here, don't multiply by 2.
-inline VMReg ConditionRegisterImpl::as_VMReg() {
+inline VMReg FloatRegisterImpl::as_VMReg() {
+  // Two halfs, multiply by 2.
+  return VMRegImpl::as_VMReg((encoding() << 1) + ConcreteRegisterImpl::max_gpr);
+}
+
+inline VMReg VectorSRegisterImpl::as_VMReg() {
   return VMRegImpl::as_VMReg((encoding()) + ConcreteRegisterImpl::max_fpr);
 }
 
-inline VMReg FloatRegisterImpl::as_VMReg() {
-  return VMRegImpl::as_VMReg((encoding() << 1) + ConcreteRegisterImpl::max_gpr);
+inline VMReg ConditionRegisterImpl::as_VMReg() {
+  return VMRegImpl::as_VMReg((encoding()) + ConcreteRegisterImpl::max_vsr);
 }
 
 inline VMReg SpecialRegisterImpl::as_VMReg() {
--- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -465,19 +465,8 @@
       z_xihf(r1, -1);
     }
   } else { // Distinct src and dst registers.
-    if (VM_Version::has_DistinctOpnds()) {
-      load_const_optimized(r1, -1);
-      z_xgrk(r1, r2, r1);
-    } else {
-      if (wide) {
-        z_lgr(r1, r2);
-        z_xilf(r1, -1);
-        z_xihf(r1, -1);
-      } else {
-        z_lr(r1, r2);
-        z_xilf(r1, -1);
-      }
-    }
+    load_const_optimized(r1, -1);
+    z_xgr(r1, r2);
   }
 }
 
@@ -1158,8 +1147,10 @@
 // Make sure to keep code size constant -> no value-dependent optimizations.
 // Do not kill condition code.
 void MacroAssembler::load_const(Register t, long x) {
-  Assembler::z_iihf(t, (int)(x >> 32));
-  Assembler::z_iilf(t, (int)(x & 0xffffffff));
+  // Note: Right shift is only cleanly defined for unsigned types
+  //       or for signed types with nonnegative values.
+  Assembler::z_iihf(t, (long)((unsigned long)x >> 32));
+  Assembler::z_iilf(t, (long)((unsigned long)x & 0xffffffffUL));
 }
 
 // Load a 32bit constant into a 64bit register, sign-extend or zero-extend.
@@ -1256,8 +1247,10 @@
 // CPU-version dependend patching of load_const.
 void MacroAssembler::patch_const(address a, long x) {
   assert(is_load_const(a), "not a load of a constant");
-  set_imm32((address)a, (int) ((x >> 32) & 0xffffffff));
-  set_imm32((address)(a + 6), (int)(x & 0xffffffff));
+  // Note: Right shift is only cleanly defined for unsigned types
+  //       or for signed types with nonnegative values.
+  set_imm32((address)a, (long)((unsigned long)x >> 32));
+  set_imm32((address)(a + 6), (long)((unsigned long)x & 0xffffffffUL));
 }
 
 // Patching the value of CPU version dependent load_const_32to64 sequence.
@@ -1461,13 +1454,17 @@
 
   // 64 bit value: | part1 | part2 | part3 | part4 |
   // At least one part is not zero!
-  int part1 = ((x >> 32) & 0xffff0000) >> 16;
-  int part2 = (x >> 32) & 0x0000ffff;
-  int part3 = (x & 0xffff0000) >> 16;
-  int part4 = (x & 0x0000ffff);
+  // Note: Right shift is only cleanly defined for unsigned types
+  //       or for signed types with nonnegative values.
+  int part1 = (int)((unsigned long)x >> 48) & 0x0000ffff;
+  int part2 = (int)((unsigned long)x >> 32) & 0x0000ffff;
+  int part3 = (int)((unsigned long)x >> 16) & 0x0000ffff;
+  int part4 = (int)x & 0x0000ffff;
+  int part12 = (int)((unsigned long)x >> 32);
+  int part34 = (int)x;
 
   // Lower word only (unsigned).
-  if ((part1 == 0) && (part2 == 0)) {
+  if (part12 == 0) {
     if (part3 == 0) {
       if (emit) z_llill(t, part4);
       return 4;
@@ -1476,12 +1473,12 @@
       if (emit) z_llilh(t, part3);
       return 4;
     }
-    if (emit) z_llilf(t, (int)(x & 0xffffffff));
+    if (emit) z_llilf(t, part34);
     return 6;
   }
 
   // Upper word only.
-  if ((part3 == 0) && (part4 == 0)) {
+  if (part34 == 0) {
     if (part1 == 0) {
       if (emit) z_llihl(t, part2);
       return 4;
@@ -1490,13 +1487,13 @@
       if (emit) z_llihh(t, part1);
       return 4;
     }
-    if (emit) z_llihf(t, (int)(x >> 32));
+    if (emit) z_llihf(t, part12);
     return 6;
   }
 
   // Lower word only (signed).
   if ((part1 == 0x0000ffff) && (part2 == 0x0000ffff) && ((part3 & 0x00008000) != 0)) {
-    if (emit) z_lgfi(t, (int)(x & 0xffffffff));
+    if (emit) z_lgfi(t, part34);
     return 6;
   }
 
@@ -1511,7 +1508,7 @@
       len += 4;
     }
   } else {
-    if (emit) z_llihf(t, (int)(x >> 32));
+    if (emit) z_llihf(t, part12);
     len += 6;
   }
 
@@ -1524,7 +1521,7 @@
       len += 4;
     }
   } else {
-    if (emit) z_iilf(t, (int)(x & 0xffffffff));
+    if (emit) z_iilf(t, part34);
     len += 6;
   }
   return len;
@@ -3374,13 +3371,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 +3406,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 +3454,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 +3468,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/sparc/macroAssembler_sparc.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.cpp	Thu Sep 13 10:54:11 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/x86/macroAssembler_x86.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp	Thu Sep 13 10:54:11 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
 
--- a/src/hotspot/share/c1/c1_LIRGenerator.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -3218,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/ci/ciMethodData.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/ci/ciMethodData.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -187,8 +187,13 @@
   for (uint row = 0; row < row_limit(); row++) {
     Klass* k = data->as_ReceiverTypeData()->receiver(row);
     if (k != NULL) {
-      ciKlass* klass = CURRENT_ENV->get_klass(k);
-      set_receiver(row, klass);
+      if (k->is_loader_alive()) {
+        ciKlass* klass = CURRENT_ENV->get_klass(k);
+        set_receiver(row, klass);
+      } else {
+        // With concurrent class unloading, the MDO could have stale metadata; override it
+        clear_row(row);
+      }
     }
   }
 }
--- a/src/hotspot/share/classfile/classListParser.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/classfile/classListParser.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/classfile/classLoaderData.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -157,6 +157,7 @@
   if (!h_class_loader.is_null()) {
     _class_loader = _handles.add(h_class_loader());
     _class_loader_klass = h_class_loader->klass();
+    initialize_name(h_class_loader);
   }
 
   if (!is_unsafe_anonymous) {
@@ -671,6 +672,15 @@
   }
 }
 
+// Let the GC read the holder without keeping it alive.
+oop ClassLoaderData::holder_no_keepalive() const {
+  if (!_holder.is_null()) {  // NULL class_loader
+    return _holder.peek();
+  } else {
+    return NULL;
+  }
+}
+
 // Unloading support
 bool ClassLoaderData::is_alive() const {
   bool alive = keep_alive()         // null class loader and incomplete unsafe anonymous klasses.
@@ -1068,33 +1078,38 @@
 // ClassLoaderData into the java/lang/ClassLoader object as a hidden field
 ClassLoaderData* ClassLoaderDataGraph::add_to_graph(Handle loader, bool is_unsafe_anonymous) {
 
+  assert_lock_strong(ClassLoaderDataGraph_lock);
 
   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.
 
-    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;
-      }
+  // First check if another thread beat us to creating the CLD and installing
+  // it into the loader while we were waiting for the lock.
+  if (!is_unsafe_anonymous && loader.not_null()) {
+    cld = java_lang_ClassLoader::loader_data_acquire(loader());
+    if (cld != NULL) {
+      return cld;
     }
   }
 
-  MutexLocker ml(ClassLoaderDataGraph_lock);
+  // We mustn't GC until we've installed the ClassLoaderData in the Graph since the CLD
+  // contains oops in _handles that must be walked.  GC doesn't walk CLD from the
+  // loader oop in all collections, particularly young collections.
+  NoSafepointVerifier no_safepoints;
 
-  // We won the race, and therefore the task of adding the data to the list of
-  // class loader data
+  cld = new ClassLoaderData(loader, is_unsafe_anonymous);
+
+  // First install the new CLD to the Graph.
   cld->set_next(_head);
   _head = cld;
+
+  // Next associate with the class_loader.
+  if (!is_unsafe_anonymous) {
+    // Use OrderAccess, since readers need to get the loader_data only after
+    // it's added to the Graph
+    java_lang_ClassLoader::release_set_loader_data(loader(), cld);
+  }
+
+  // Lastly log, if requested
   LogTarget(Trace, class, loader, data) lt;
   if (lt.is_enabled()) {
     ResourceMark rm;
@@ -1107,12 +1122,8 @@
 }
 
 ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool is_unsafe_anonymous) {
+  MutexLocker ml(ClassLoaderDataGraph_lock);
   ClassLoaderData* loader_data = add_to_graph(loader, is_unsafe_anonymous);
-  // Initialize _name and _name_and_id after the loader data is added to the
-  // CLDG because adding the Symbol for _name and _name_and_id might safepoint.
-  if (loader.not_null()) {
-    loader_data->initialize_name(loader);
-  }
   return loader_data;
 }
 
--- a/src/hotspot/share/classfile/classLoaderData.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/classfile/classLoaderData.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -307,8 +307,9 @@
   void accumulate_modified_oops()        { if (has_modified_oops()) _accumulated_modified_oops = true; }
   void clear_accumulated_modified_oops() { _accumulated_modified_oops = false; }
   bool has_accumulated_modified_oops()   { return _accumulated_modified_oops; }
+  oop holder_no_keepalive() const;
+
  private:
-
   void unload();
   bool keep_alive() const       { return _keep_alive > 0; }
 
@@ -336,6 +337,8 @@
   bool claimed() const { return _claimed == 1; }
   bool claim();
 
+  // Computes if the CLD is alive or not. This is safe to call in concurrent
+  // contexts.
   bool is_alive() const;
 
   // Accessors
@@ -377,6 +380,9 @@
   inline oop class_loader() const;
 
   // Returns true if this class loader data is for a loader going away.
+  // Note that this is only safe after the GC has computed if the CLD is
+  // unloading or not. In concurrent contexts where there are no such
+  // guarantees, is_alive() should be used instead.
   bool is_unloading() const     {
     assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded");
     return _unloading;
--- a/src/hotspot/share/classfile/classLoaderData.inline.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/classfile/classLoaderData.inline.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -34,7 +34,7 @@
 
 inline oop ClassLoaderData::class_loader() const {
   assert(!_unloading, "This oop is not available to unloading class loader data");
-  assert(_holder.is_null() || _holder.peek() != NULL , "This class loader data holder must be alive");
+  assert(_holder.is_null() || holder_no_keepalive() != NULL , "This class loader data holder must be alive");
   return _class_loader.resolve();
 }
 
@@ -46,7 +46,7 @@
   if (loader == NULL) {
     return ClassLoaderData::the_null_class_loader_data();
   }
-  return java_lang_ClassLoader::loader_data(loader);
+  return java_lang_ClassLoader::loader_data_acquire(loader);
 }
 
 inline ClassLoaderData* ClassLoaderData::class_loader_data(oop loader) {
@@ -60,7 +60,7 @@
   guarantee(loader() != NULL && oopDesc::is_oop(loader()), "Loader must be oop");
   // Gets the class loader data out of the java/lang/ClassLoader object, if non-null
   // it's already in the loader_data, so no need to add
-  ClassLoaderData* loader_data= java_lang_ClassLoader::loader_data(loader());
+  ClassLoaderData* loader_data= java_lang_ClassLoader::loader_data_acquire(loader());
   if (loader_data) {
      return loader_data;
   }
--- a/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -470,7 +470,7 @@
   void do_cld (ClassLoaderData* cld) {
 
     // We do not display unloading loaders, for now.
-    if (cld->is_unloading()) {
+    if (!cld->is_alive()) {
       return;
     }
 
--- a/src/hotspot/share/classfile/classLoaderStats.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/classfile/classLoaderStats.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -139,7 +139,7 @@
 
 
 void ClassLoaderStatsClosure::addEmptyParents(oop cl) {
-  while (cl != NULL && java_lang_ClassLoader::loader_data(cl) == NULL) {
+  while (cl != NULL && java_lang_ClassLoader::loader_data_acquire(cl) == NULL) {
     // This classloader has not loaded any classes
     ClassLoaderStats** cls_ptr = _stats->get(cl);
     if (cls_ptr == NULL) {
--- a/src/hotspot/share/classfile/compactHashtable.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/classfile/compactHashtable.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -282,7 +282,7 @@
   CompactHashtable_OopIterator(OopClosure *cl) : _closure(cl) {}
   inline void do_value(address base_address, u4 offset) const {
     narrowOop v = (narrowOop)offset;
-    oop obj = HeapShared::decode_with_archived_oop_encoding_mode(v);
+    oop obj = HeapShared::decode_from_archive(v);
     _closure->do_oop(&obj);
   }
 };
--- a/src/hotspot/share/classfile/compactHashtable.inline.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/classfile/compactHashtable.inline.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -48,7 +48,7 @@
 inline oop CompactHashtable<T, N>::decode_entry(CompactHashtable<oop, char>* const t,
                                                 u4 offset, const char* name, int len) {
   narrowOop v = (narrowOop)offset;
-  oop string = HeapShared::decode_with_archived_oop_encoding_mode(v);
+  oop string = HeapShared::decode_from_archive(v);
   if (java_lang_String::equals(string, (jchar*)name, len)) {
     return string;
   }
--- a/src/hotspot/share/classfile/javaClasses.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/classfile/javaClasses.cpp	Thu Sep 13 10:54:11 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
 
@@ -4023,9 +4027,9 @@
 int  java_lang_ClassLoader::nameAndId_offset = -1;
 int  java_lang_ClassLoader::unnamedModule_offset = -1;
 
-ClassLoaderData* java_lang_ClassLoader::loader_data(oop loader) {
+ClassLoaderData* java_lang_ClassLoader::loader_data_acquire(oop loader) {
   assert(loader != NULL && oopDesc::is_oop(loader), "loader must be oop");
-  return HeapAccess<>::load_at(loader, _loader_data_offset);
+  return HeapAccess<MO_ACQUIRE>::load_at(loader, _loader_data_offset);
 }
 
 ClassLoaderData* java_lang_ClassLoader::loader_data_raw(oop loader) {
@@ -4033,9 +4037,9 @@
   return RawAccess<>::load_at(loader, _loader_data_offset);
 }
 
-ClassLoaderData* java_lang_ClassLoader::cmpxchg_loader_data(ClassLoaderData* new_data, oop loader, ClassLoaderData* expected_data) {
+void java_lang_ClassLoader::release_set_loader_data(oop loader, ClassLoaderData* new_data) {
   assert(loader != NULL && oopDesc::is_oop(loader), "loader must be oop");
-  return HeapAccess<>::atomic_cmpxchg_at(new_data, loader, _loader_data_offset, expected_data);
+  HeapAccess<MO_RELEASE>::store_at(loader, _loader_data_offset, new_data);
 }
 
 #define CLASSLOADER_FIELDS_DO(macro) \
--- a/src/hotspot/share/classfile/javaClasses.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/classfile/javaClasses.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -1322,9 +1322,9 @@
   static void compute_offsets();
   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 
-  static ClassLoaderData* loader_data(oop loader);
+  static ClassLoaderData* loader_data_acquire(oop loader);
   static ClassLoaderData* loader_data_raw(oop loader);
-  static ClassLoaderData* cmpxchg_loader_data(ClassLoaderData* new_data, oop loader, ClassLoaderData* expected_data);
+  static void release_set_loader_data(oop loader, ClassLoaderData* new_data);
 
   static oop parent(oop loader);
   static oop name(oop loader);
--- a/src/hotspot/share/classfile/systemDictionary.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/classfile/systemDictionary.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -2028,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/verifier.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/classfile/verifier.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -130,7 +130,7 @@
   st->print_cr("End class verification for: %s", klassName);
 }
 
-bool Verifier::verify(InstanceKlass* klass, Verifier::Mode mode, bool should_verify_class, TRAPS) {
+bool Verifier::verify(InstanceKlass* klass, bool should_verify_class, TRAPS) {
   HandleMark hm(THREAD);
   ResourceMark rm(THREAD);
 
--- a/src/hotspot/share/classfile/verifier.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/classfile/verifier.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -42,16 +42,11 @@
     NO_RELAX_ACCESS_CTRL_CHECK_VERSION  = 52,
     DYNAMICCONSTANT_MAJOR_VERSION       = 55
   };
-  typedef enum { ThrowException, NoException } Mode;
 
-  /**
-   * Verify the bytecodes for a class.  If 'throw_exception' is true
-   * then the appropriate VerifyError or ClassFormatError will be thrown.
-   * Otherwise, no exception is thrown and the return indicates the
-   * error.
-   */
+  // Verify the bytecodes for a class.
+  static bool verify(InstanceKlass* klass, bool should_verify_class, TRAPS);
+
   static void log_end_verification(outputStream* st, const char* klassName, Symbol* exception_name, TRAPS);
-  static bool verify(InstanceKlass* klass, Mode mode, bool should_verify_class, TRAPS);
 
   // Return false if the class is loaded by the bootstrap loader,
   // or if defineClass was called requesting skipping verification
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -1950,12 +1950,8 @@
 };
 
 size_t G1CollectedHeap::recalculate_used() const {
-  double recalculate_used_start = os::elapsedTime();
-
   SumUsedClosure blk;
   heap_region_iterate(&blk);
-
-  g1_policy()->phase_times()->record_evac_fail_recalc_used_time((os::elapsedTime() - recalculate_used_start) * 1000.0);
   return blk.result();
 }
 
@@ -3013,7 +3009,10 @@
         g1_policy()->phase_times()->record_start_new_cset_time_ms((os::elapsedTime() - start) * 1000.0);
 
         if (evacuation_failed()) {
+          double recalculate_used_start = os::elapsedTime();
           set_used(recalculate_used());
+          g1_policy()->phase_times()->record_evac_fail_recalc_used_time((os::elapsedTime() - recalculate_used_start) * 1000.0);
+
           if (_archive_allocator != NULL) {
             _archive_allocator->clear_used();
           }
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -1385,11 +1385,7 @@
   void print_cset_rsets() PRODUCT_RETURN;
   void print_all_rsets() PRODUCT_RETURN;
 
-public:
   size_t pending_card_num();
-
-private:
-  size_t _max_heap_capacity;
 };
 
 class G1ParEvacuateFollowersClosure : public VoidClosure {
--- a/src/hotspot/share/gc/g1/g1OopClosures.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/gc/g1/g1OopClosures.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -54,8 +54,8 @@
   template <class T>
   inline void handle_non_cset_obj_common(InCSetState const state, T* p, oop const obj);
 public:
-  // This closure needs special handling for InstanceRefKlass.
-  virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
+  virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
+
   void set_region(HeapRegion* from) { _from = from; }
 
   inline void trim_queue_partially();
@@ -98,6 +98,9 @@
   virtual void do_oop(oop* p)          { do_oop_work(p); }
   virtual void do_oop(narrowOop* p)    { do_oop_work(p); }
 
+  // We need to do reference discovery while processing evacuated objects.
+  virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
+
   void set_ref_discoverer(ReferenceDiscoverer* rd) {
     set_ref_discoverer_internal(rd);
   }
@@ -201,8 +204,7 @@
     _worker_i(worker_i) {
   }
 
-  // This closure needs special handling for InstanceRefKlass.
-  virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
+  virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
 
   template <class T> void do_oop_work(T* p);
   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
@@ -219,8 +221,8 @@
   template <class T> void do_oop_work(T* p);
   virtual void do_oop(oop* p)       { do_oop_work(p); }
   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
-  // This closure needs special handling for InstanceRefKlass.
-  virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
+
+  virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
 };
 
 #endif // SHARE_VM_GC_G1_G1OOPCLOSURES_HPP
--- a/src/hotspot/share/gc/parallel/psCompactionManager.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/gc/parallel/psCompactionManager.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -183,7 +183,7 @@
 void InstanceClassLoaderKlass::oop_pc_follow_contents(oop obj, ParCompactionManager* cm) {
   InstanceKlass::oop_pc_follow_contents(obj, cm);
 
-  ClassLoaderData * const loader_data = java_lang_ClassLoader::loader_data(obj);
+  ClassLoaderData * const loader_data = java_lang_ClassLoader::loader_data_acquire(obj);
   if (loader_data != NULL) {
     cm->follow_class_loader(loader_data);
   }
--- a/src/hotspot/share/gc/shared/c1/barrierSetC1.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/gc/shared/c1/barrierSetC1.cpp	Thu Sep 13 10:54:11 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/c2/barrierSetC2.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -190,6 +190,8 @@
 
   virtual void clone(GraphKit* kit, Node* src, Node* dst, Node* size, bool is_array) const;
 
+  virtual Node* resolve(GraphKit* kit, Node* n, DecoratorSet decorators) const { return n; }
+
   // These are general helper methods used by C2
   virtual bool array_copy_requires_gc_barriers(BasicType type) const { return false; }
 
--- a/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -466,9 +466,9 @@
 
   bool do_entry(oop const& key, ClassLoaderStats* const& cls) {
     const ClassLoaderData* this_cld = cls->_class_loader != NULL ?
-      java_lang_ClassLoader::loader_data(cls->_class_loader) : (ClassLoaderData*)NULL;
+      java_lang_ClassLoader::loader_data_acquire(cls->_class_loader) : NULL;
     const ClassLoaderData* parent_cld = cls->_parent != NULL ?
-      java_lang_ClassLoader::loader_data(cls->_parent) : (ClassLoaderData*)NULL;
+      java_lang_ClassLoader::loader_data_acquire(cls->_parent) : NULL;
     EventClassLoaderStatistics event;
     event.set_classLoader(this_cld);
     event.set_parentClassLoader(parent_cld);
--- a/src/hotspot/share/memory/filemap.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/memory/filemap.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -854,7 +854,7 @@
   if (with_current_oop_encoding_mode) {
     return (address)CompressedOops::decode_not_null(offset_of_space(spc));
   } else {
-    return (address)HeapShared::decode_with_archived_oop_encoding_mode(offset_of_space(spc));
+    return (address)HeapShared::decode_from_archive(offset_of_space(spc));
   }
 }
 
@@ -880,7 +880,7 @@
     CDSFileMapRegion* si = space_at(i);
     size_t size = si->_used;
     if (size > 0) {
-      address s = start_address_with_current_oop_encoding_mode(si);
+      address s = start_address_as_decoded_with_current_oop_encoding_mode(si);
       address e = s + size;
       if (start > s) {
         start = s;
@@ -972,21 +972,20 @@
   HeapShared::init_narrow_oop_decoding(narrow_oop_base() + delta, narrow_oop_shift());
 
   CDSFileMapRegion* si = space_at(MetaspaceShared::first_string);
-  address relocated_strings_bottom = start_address_with_archived_oop_encoding_mode(si);
-  if (!is_aligned(relocated_strings_bottom + delta, HeapRegion::GrainBytes)) {
+  address relocated_strings_bottom = start_address_as_decoded_from_archive(si);
+  if (!is_aligned(relocated_strings_bottom, HeapRegion::GrainBytes)) {
     // Align the bottom of the string regions at G1 region boundary. This will avoid
     // the situation where the highest open region and the lowest string region sharing
     // the same G1 region. Otherwise we will fail to map the open regions.
     size_t align = size_t(relocated_strings_bottom) % HeapRegion::GrainBytes;
     delta -= align;
-    assert(is_aligned(relocated_strings_bottom + delta, HeapRegion::GrainBytes), "must be");
-
     log_info(cds)("CDS heap data need to be relocated lower by a further " SIZE_FORMAT
-                  " bytes to be aligned with HeapRegion::GrainBytes", align);
-
+                  " bytes to " INTX_FORMAT " to be aligned with HeapRegion::GrainBytes", align, delta);
     HeapShared::init_narrow_oop_decoding(narrow_oop_base() + delta, narrow_oop_shift());
     _heap_pointers_need_patching = true;
+    relocated_strings_bottom = start_address_as_decoded_from_archive(si);
   }
+  assert(is_aligned(relocated_strings_bottom, HeapRegion::GrainBytes), "must be");
 
   // First, map string regions as closed archive heap regions.
   // GC does not write into the regions.
@@ -1032,7 +1031,7 @@
     si = space_at(i);
     size_t size = si->_used;
     if (size > 0) {
-      HeapWord* start = (HeapWord*)start_address_with_archived_oop_encoding_mode(si);
+      HeapWord* start = (HeapWord*)start_address_as_decoded_from_archive(si);
       regions[region_num] = MemRegion(start, size / HeapWordSize);
       region_num ++;
       log_info(cds)("Trying to map heap data: region[%d] at " INTPTR_FORMAT ", size = " SIZE_FORMAT_W(8) " bytes",
@@ -1242,7 +1241,7 @@
   if (MetaspaceShared::is_heap_region(idx)) {
     assert(DumpSharedSpaces, "The following doesn't work at runtime");
     return si->_used > 0 ?
-          (char*)start_address_with_current_oop_encoding_mode(si) : NULL;
+          (char*)start_address_as_decoded_with_current_oop_encoding_mode(si) : NULL;
   } else {
     return si->_addr._base;
   }
--- a/src/hotspot/share/memory/filemap.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/memory/filemap.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -335,12 +335,12 @@
   }
 
   // The starting address of spc, as calculated with CompressedOop::decode_non_null()
-  address start_address_with_current_oop_encoding_mode(CDSFileMapRegion* spc) {
+  address start_address_as_decoded_with_current_oop_encoding_mode(CDSFileMapRegion* spc) {
     return decode_start_address(spc, true);
   }
 
-  // The starting address of spc, as calculated with HeapShared::decode_with_archived_oop_encoding_mode()
-  address start_address_with_archived_oop_encoding_mode(CDSFileMapRegion* spc) {
+  // The starting address of spc, as calculated with HeapShared::decode_from_archive()
+  address start_address_as_decoded_from_archive(CDSFileMapRegion* spc) {
     return decode_start_address(spc, false);
   }
 
--- a/src/hotspot/share/memory/heapShared.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/memory/heapShared.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -45,8 +45,6 @@
 int HeapShared::_num_archived_subgraph_info_records = 0;
 Array<ArchivedKlassSubGraphInfoRecord>* HeapShared::_archived_subgraph_info_records = NULL;
 
-// Currently there is only one class mirror (ArchivedModuleGraph) with archived
-// sub-graphs.
 KlassSubGraphInfo* HeapShared::find_subgraph_info(Klass* k) {
   KlassSubGraphInfo* info = _subgraph_info_list;
   while (info != NULL) {
@@ -145,6 +143,13 @@
     return;
   }
 
+  if (log_is_enabled(Debug, cds, heap)) {
+    if (!_subgraph_object_klasses->contains(relocated_k)) {
+      ResourceMark rm;
+      log_debug(cds, heap)("Adding klass %s", orig_k->external_name());
+    }
+  }
+
   _subgraph_object_klasses->append_if_missing(relocated_k);
 }
 
@@ -153,7 +158,7 @@
   _k = info->klass();
   _next = NULL;
   _entry_field_records = NULL;
-  _subgraph_klasses = NULL;
+  _subgraph_object_klasses = NULL;
 
   // populate the entry fields
   GrowableArray<juint>* entry_fields = info->subgraph_entry_fields();
@@ -168,20 +173,20 @@
   }
 
   // the Klasses of the objects in the sub-graphs
-  GrowableArray<Klass*>* subgraph_klasses = info->subgraph_object_klasses();
-  if (subgraph_klasses != NULL) {
-    int num_subgraphs_klasses = subgraph_klasses->length();
-    _subgraph_klasses =
+  GrowableArray<Klass*>* subgraph_object_klasses = info->subgraph_object_klasses();
+  if (subgraph_object_klasses != NULL) {
+    int num_subgraphs_klasses = subgraph_object_klasses->length();
+    _subgraph_object_klasses =
       MetaspaceShared::new_ro_array<Klass*>(num_subgraphs_klasses);
     for (int i = 0; i < num_subgraphs_klasses; i++) {
-      Klass* subgraph_k = subgraph_klasses->at(i);
+      Klass* subgraph_k = subgraph_object_klasses->at(i);
       if (log_is_enabled(Info, cds, heap)) {
         ResourceMark rm;
         log_info(cds, heap)(
-          "Archived object klass (%d): %s in %s sub-graphs",
-          i, subgraph_k->external_name(), _k->external_name());
+          "Archived object klass %s (%2d) => %s",
+          _k->external_name(), i, subgraph_k->external_name());
       }
-      _subgraph_klasses->at_put(i, subgraph_k);
+      _subgraph_object_klasses->at_put(i, subgraph_k);
     }
   }
 }
@@ -194,8 +199,7 @@
 // - A list of klasses that need to be loaded/initialized before archived
 //   java object sub-graph can be accessed at runtime.
 //
-// The records are saved in the archive file and reloaded at runtime. Currently
-// there is only one class mirror (ArchivedModuleGraph) with archived sub-graphs.
+// The records are saved in the archive file and reloaded at runtime.
 //
 // Layout of the archived subgraph info records:
 //
@@ -273,9 +277,8 @@
     return; // no subgraph info records
   }
 
-  // Initialize from archived data. Currently only ArchivedModuleGraph
-  // has archived object subgraphs, which is used during VM initialization
-  // time when bootstraping the system modules. No lock is needed.
+  // Initialize from archived data. Currently this is done only
+  // during VM initialization time. No lock is needed.
   Thread* THREAD = Thread::current();
   for (int i = 0; i < _archived_subgraph_info_records->length(); i++) {
     ArchivedKlassSubGraphInfoRecord* record = _archived_subgraph_info_records->adr_at(i);
@@ -284,7 +287,7 @@
       // Found the archived subgraph info record for the requesting klass.
       // Load/link/initialize the klasses of the objects in the subgraph.
       // NULL class loader is used.
-      Array<Klass*>* klasses = record->subgraph_klasses();
+      Array<Klass*>* klasses = record->subgraph_object_klasses();
       if (klasses != NULL) {
         for (i = 0; i < klasses->length(); i++) {
           Klass* obj_k = klasses->at(i);
@@ -339,15 +342,19 @@
 
 class WalkOopAndArchiveClosure: public BasicOopIterateClosure {
   int _level;
+  bool _record_klasses_only;
   KlassSubGraphInfo* _subgraph_info;
   oop _orig_referencing_obj;
   oop _archived_referencing_obj;
+  Thread* _thread;
  public:
-  WalkOopAndArchiveClosure(int level, KlassSubGraphInfo* subgraph_info,
-           oop orig, oop archived) : _level(level),
-                                     _subgraph_info(subgraph_info),
-                                     _orig_referencing_obj(orig),
-                                     _archived_referencing_obj(archived) {}
+  WalkOopAndArchiveClosure(int level, bool record_klasses_only,
+                           KlassSubGraphInfo* subgraph_info,
+                           oop orig, oop archived, TRAPS) :
+    _level(level), _record_klasses_only(record_klasses_only),
+    _subgraph_info(subgraph_info),
+    _orig_referencing_obj(orig), _archived_referencing_obj(archived),
+    _thread(THREAD) {}
   void do_oop(narrowOop *p) { WalkOopAndArchiveClosure::do_oop_work(p); }
   void do_oop(      oop *p) { WalkOopAndArchiveClosure::do_oop_work(p); }
 
@@ -355,89 +362,105 @@
   template <class T> void do_oop_work(T *p) {
     oop obj = RawAccess<>::oop_load(p);
     if (!CompressedOops::is_null(obj)) {
-      // A java.lang.Class instance can not be included in an archived
-      // object sub-graph.
-      if (java_lang_Class::is_instance(obj)) {
-        log_error(cds, heap)("Unknown java.lang.Class object is in the archived sub-graph\n");
-        vm_exit(1);
-      }
+      assert(!MetaspaceShared::is_archive_object(obj),
+             "original objects must not point to archived objects");
 
-      LogTarget(Debug, cds, heap) log;
-      LogStream ls(log);
-      outputStream* out = &ls;
-      {
+      size_t field_delta = pointer_delta(p, _orig_referencing_obj, sizeof(char));
+      T* new_p = (T*)(address(_archived_referencing_obj) + field_delta);
+      Thread* THREAD = _thread;
+
+      if (!_record_klasses_only && log_is_enabled(Debug, cds, heap)) {
         ResourceMark rm;
-        log.print("(%d) %s <--- referenced from:  %s",
-                  _level, obj->klass()->external_name(),
-                  CompressedOops::is_null(_orig_referencing_obj) ?
-                         "" : _orig_referencing_obj->klass()->external_name());
-        obj->print_on(out);
-      }
-
-      if (MetaspaceShared::is_archive_object(obj)) {
-        // The current oop is an archived oop, nothing needs to be done
-        log.print("--- object is already archived ---");
-        return;
+        log_debug(cds, heap)("(%d) %s[" SIZE_FORMAT "] ==> " PTR_FORMAT " size %d %s", _level,
+                             _orig_referencing_obj->klass()->external_name(), field_delta,
+                             p2i(obj), obj->size() * HeapWordSize, obj->klass()->external_name());
+        LogTarget(Trace, cds, heap) log;
+        LogStream out(log);
+        obj->print_on(&out);
       }
 
-      size_t field_delta = pointer_delta(
-        p, _orig_referencing_obj, sizeof(char));
-      T* new_p = (T*)(address(_archived_referencing_obj) + field_delta);
-      oop archived = MetaspaceShared::find_archived_heap_object(obj);
-      if (archived != NULL) {
-        // There is an archived copy existing, update reference to point
-        // to the archived copy
-        RawAccess<IS_NOT_NULL>::oop_store(new_p, archived);
-        log.print(
-          "--- found existing archived copy, store archived " PTR_FORMAT " in " PTR_FORMAT,
-          p2i(archived), p2i(new_p));
-        return;
-      }
+      oop archived = HeapShared::archive_reachable_objects_from(_level + 1, _subgraph_info, obj, THREAD);
+      assert(archived != NULL, "VM should have exited with unarchivable objects for _level > 1");
+      assert(MetaspaceShared::is_archive_object(archived), "must be");
 
-      int l = _level + 1;
-      Thread* THREAD = Thread::current();
-      // Archive the current oop before iterating through its references
-      archived = MetaspaceShared::archive_heap_object(obj, THREAD);
-      if (archived == NULL) {
-        ResourceMark rm;
-        LogTarget(Error, cds, heap) log_err;
-        LogStream ls_err(log_err);
-        outputStream* out_err = &ls_err;
-        log_err.print("Failed to archive %s object ("
-                      PTR_FORMAT "), size[" SIZE_FORMAT "] in sub-graph",
-                      obj->klass()->external_name(), p2i(obj), (size_t)obj->size());
-        obj->print_on(out_err);
-        vm_exit(1);
+      if (!_record_klasses_only) {
+        // Update the reference in the archived copy of the referencing object.
+        log_debug(cds, heap)("(%d) updating oop @[" PTR_FORMAT "] " PTR_FORMAT " ==> " PTR_FORMAT,
+                             _level, p2i(new_p), p2i(obj), p2i(archived));
+        RawAccess<IS_NOT_NULL>::oop_store(new_p, archived);
       }
-      assert(MetaspaceShared::is_archive_object(archived), "must be archived");
-      log.print("=== archiving oop " PTR_FORMAT " ==> " PTR_FORMAT,
-                 p2i(obj), p2i(archived));
-
-      // Following the references in the current oop and archive any
-      // encountered objects during the process
-      WalkOopAndArchiveClosure walker(l, _subgraph_info, obj, archived);
-      obj->oop_iterate(&walker);
-
-      // Update the reference in the archived copy of the referencing object
-      RawAccess<IS_NOT_NULL>::oop_store(new_p, archived);
-      log.print("=== store archived " PTR_FORMAT " in " PTR_FORMAT,
-                p2i(archived), p2i(new_p));
-
-      // Add the klass to the list of classes that need to be loaded before
-      // module system initialization
-      Klass *orig_k = obj->klass();
-      Klass *relocated_k = archived->klass();
-      _subgraph_info->add_subgraph_object_klass(orig_k, relocated_k);
     }
   }
 };
 
+// (1) If orig_obj has not been archived yet, archive it.
+// (2) If orig_obj has not been seen yet (since start_recording_subgraph() was called),
+//     trace all  objects that are reachable from it, and make sure these objects are archived.
+// (3) Record the klasses of all orig_obj and all reachable objects.
+oop HeapShared::archive_reachable_objects_from(int level, KlassSubGraphInfo* subgraph_info, oop orig_obj, TRAPS) {
+  assert(orig_obj != NULL, "must be");
+  assert(!MetaspaceShared::is_archive_object(orig_obj), "sanity");
+
+  // java.lang.Class instances cannot be included in an archived
+  // object sub-graph.
+  if (java_lang_Class::is_instance(orig_obj)) {
+    log_error(cds, heap)("(%d) Unknown java.lang.Class object is in the archived sub-graph", level);
+    vm_exit(1);
+  }
+
+  oop archived_obj = MetaspaceShared::find_archived_heap_object(orig_obj);
+  if (java_lang_String::is_instance(orig_obj) && archived_obj != NULL) {
+    // To save time, don't walk strings that are already archived. They just contain
+    // pointers to a type array, whose klass doesn't need to be recorded.
+    return archived_obj;
+  }
+
+  if (has_been_seen_during_subgraph_recording(orig_obj)) {
+    // orig_obj has already been archived and traced. Nothing more to do.
+    return archived_obj;
+  } else {
+    set_has_been_seen_during_subgraph_recording(orig_obj);
+  }
+
+  bool record_klasses_only = (archived_obj != NULL);
+  if (archived_obj == NULL) {
+    ++_num_new_archived_objs;
+    archived_obj = MetaspaceShared::archive_heap_object(orig_obj, THREAD);
+    if (archived_obj == NULL) {
+      // Skip archiving the sub-graph referenced from the current entry field.
+      ResourceMark rm;
+      log_error(cds, heap)(
+        "Cannot archive the sub-graph referenced from %s object ("
+        PTR_FORMAT ") size %d, skipped.",
+        orig_obj->klass()->external_name(), p2i(orig_obj), orig_obj->size() * HeapWordSize);
+      if (level == 1) {
+        // Don't archive a subgraph root that's too big. For archives static fields, that's OK
+        // as the Java code will take care of initializing this field dynamically.
+        return NULL;
+      } else {
+        // We don't know how to handle an object that has been archived, but some of its reachable
+        // objects cannot be archived. Bail out for now. We might need to fix this in the future if
+        // we have a real use case.
+        vm_exit(1);
+      }
+    }
+  }
+
+  assert(archived_obj != NULL, "must be");
+  Klass *orig_k = orig_obj->klass();
+  Klass *relocated_k = archived_obj->klass();
+  subgraph_info->add_subgraph_object_klass(orig_k, relocated_k);
+
+  WalkOopAndArchiveClosure walker(level, record_klasses_only, subgraph_info, orig_obj, archived_obj, THREAD);
+  orig_obj->oop_iterate(&walker);
+  return archived_obj;
+}
+
 //
 // Start from the given static field in a java mirror and archive the
 // complete sub-graph of java heap objects that are reached directly
 // or indirectly from the starting object by following references.
-// Currently, only ArchivedModuleGraph class instance (mirror) has archived
-// object subgraphs. Sub-graph archiving restrictions (current):
+// Sub-graph archiving restrictions (current):
 //
 // - All classes of objects in the archived sub-graph (including the
 //   entry class) must be boot class only.
@@ -461,20 +484,19 @@
 // archive the sub-graph of objects starting from each reference.
 //
 // 4) Updates the pointer in the archived copy of referencing object to
-//    point to the current archived object.
+// point to the current archived object.
 //
 // 5) The Klass of the current java object is added to the list of Klasses
 // for loading and initialzing before any object in the archived graph can
 // be accessed at runtime.
 //
-void HeapShared::archive_reachable_objects_from_static_field(Klass *k,
+void HeapShared::archive_reachable_objects_from_static_field(InstanceKlass *k,
+                                                             const char* klass_name,
                                                              int field_offset,
-                                                             BasicType field_type,
+                                                             const char* field_name,
                                                              TRAPS) {
   assert(DumpSharedSpaces, "dump time only");
-  assert(k->is_instance_klass(), "sanity");
-  assert(InstanceKlass::cast(k)->is_shared_boot_class(),
-         "must be boot class");
+  assert(k->is_shared_boot_class(), "must be boot class");
 
   oop m = k->java_mirror();
   oop archived_m = MetaspaceShared::find_archived_heap_object(m);
@@ -482,58 +504,160 @@
     return;
   }
 
-  if (field_type == T_OBJECT || field_type == T_ARRAY) {
-    // obtain k's subGraph Info
-    KlassSubGraphInfo* subgraph_info = get_subgraph_info(k);
+  KlassSubGraphInfo* subgraph_info = get_subgraph_info(k);
+  oop f = m->obj_field(field_offset);
 
-    // get the object referenced by the field
-    oop f = m->obj_field(field_offset);
-    if (!CompressedOops::is_null(f)) {
-      LogTarget(Debug, cds, heap) log;
-      LogStream ls(log);
-      outputStream* out = &ls;
-      log.print("Start from: ");
-      f->print_on(out);
+  log_debug(cds, heap)("Start archiving from: %s::%s (" PTR_FORMAT ")", klass_name, field_name, p2i(f));
 
-      // get the archived copy of the field referenced object
-      oop af = MetaspaceShared::archive_heap_object(f, THREAD);
-      if (af == NULL) {
-        // Skip archiving the sub-graph referenced from the current entry field.
-        ResourceMark rm;
-        log_info(cds, heap)(
-          "Cannot archive the sub-graph referenced from %s object ("
-          PTR_FORMAT ") size[" SIZE_FORMAT "], skipped.",
-          f->klass()->external_name(), p2i(f), (size_t)f->size());
-        return;
-      }
-      if (!MetaspaceShared::is_archive_object(f)) {
-        WalkOopAndArchiveClosure walker(1, subgraph_info, f, af);
-        f->oop_iterate(&walker);
-      }
+  if (!CompressedOops::is_null(f)) {
+    if (log_is_enabled(Trace, cds, heap)) {
+      LogTarget(Trace, cds, heap) log;
+      LogStream out(log);
+      f->print_on(&out);
+    }
 
-      // The field value is not preserved in the archived mirror.
+    oop af = archive_reachable_objects_from(1, subgraph_info, f, CHECK);
+
+    if (af == NULL) {
+      log_error(cds, heap)("Archiving failed %s::%s (some reachable objects cannot be archived)",
+                           klass_name, field_name);
+    } else {
+      // Note: the field value is not preserved in the archived mirror.
       // Record the field as a new subGraph entry point. The recorded
       // information is restored from the archive at runtime.
       subgraph_info->add_subgraph_entry_field(field_offset, af);
-      Klass *relocated_k = af->klass();
-      Klass *orig_k = f->klass();
-      subgraph_info->add_subgraph_object_klass(orig_k, relocated_k);
-      ResourceMark rm;
-      log_info(cds, heap)(
-          "Archived the sub-graph referenced from %s object " PTR_FORMAT,
-          f->klass()->external_name(), p2i(f));
-    } else {
-      // The field contains null, we still need to record the entry point,
-      // so it can be restored at runtime.
-      subgraph_info->add_subgraph_entry_field(field_offset, NULL);
+      log_info(cds, heap)("Archived field %s::%s => " PTR_FORMAT, klass_name, field_name, p2i(af));
     }
   } else {
-    ShouldNotReachHere();
+    // The field contains null, we still need to record the entry point,
+    // so it can be restored at runtime.
+    subgraph_info->add_subgraph_entry_field(field_offset, NULL);
+  }
+}
+
+#ifndef PRODUCT
+class VerifySharedOopClosure: public BasicOopIterateClosure {
+ private:
+  bool _is_archived;
+
+ public:
+  VerifySharedOopClosure(bool is_archived) : _is_archived(is_archived) {}
+
+  void do_oop(narrowOop *p) { VerifySharedOopClosure::do_oop_work(p); }
+  void do_oop(      oop *p) { VerifySharedOopClosure::do_oop_work(p); }
+
+ protected:
+  template <class T> void do_oop_work(T *p) {
+    oop obj = RawAccess<>::oop_load(p);
+    if (!CompressedOops::is_null(obj)) {
+      HeapShared::verify_reachable_objects_from(obj, _is_archived);
+    }
+  }
+};
+
+void HeapShared::verify_subgraph_from_static_field(InstanceKlass* k, int field_offset) {
+  assert(DumpSharedSpaces, "dump time only");
+  assert(k->is_shared_boot_class(), "must be boot class");
+
+  oop m = k->java_mirror();
+  oop archived_m = MetaspaceShared::find_archived_heap_object(m);
+  if (CompressedOops::is_null(archived_m)) {
+    return;
+  }
+  oop f = m->obj_field(field_offset);
+  if (!CompressedOops::is_null(f)) {
+    verify_subgraph_from(f);
   }
 }
 
+void HeapShared::verify_subgraph_from(oop orig_obj) {
+  oop archived_obj = MetaspaceShared::find_archived_heap_object(orig_obj);
+  if (archived_obj == NULL) {
+    // It's OK for the root of a subgraph to be not archived. See comments in
+    // archive_reachable_objects_from().
+    return;
+  }
+
+  // Verify that all objects reachable from orig_obj are archived.
+  init_seen_objects_table();
+  verify_reachable_objects_from(orig_obj, false);
+  delete_seen_objects_table();
+
+  // Note: we could also verify that all objects reachable from the archived
+  // copy of orig_obj can only point to archived objects, with:
+  //      init_seen_objects_table();
+  //      verify_reachable_objects_from(archived_obj, true);
+  //      init_seen_objects_table();
+  // but that's already done in G1HeapVerifier::verify_archive_regions so we
+  // won't do it here.
+}
+
+void HeapShared::verify_reachable_objects_from(oop obj, bool is_archived) {
+  _num_total_verifications ++;
+  if (!has_been_seen_during_subgraph_recording(obj)) {
+    set_has_been_seen_during_subgraph_recording(obj);
+
+    if (is_archived) {
+      assert(MetaspaceShared::is_archive_object(obj), "must be");
+      assert(MetaspaceShared::find_archived_heap_object(obj) == NULL, "must be");
+    } else {
+      assert(!MetaspaceShared::is_archive_object(obj), "must be");
+      assert(MetaspaceShared::find_archived_heap_object(obj) != NULL, "must be");
+    }
+
+    VerifySharedOopClosure walker(is_archived);
+    obj->oop_iterate(&walker);
+  }
+}
+#endif
+
+HeapShared::SeenObjectsTable* HeapShared::_seen_objects_table = NULL;
+int HeapShared::_num_new_walked_objs;
+int HeapShared::_num_new_archived_objs;
+int HeapShared::_num_old_recorded_klasses;
+
+int HeapShared::_num_total_subgraph_recordings = 0;
+int HeapShared::_num_total_walked_objs = 0;
+int HeapShared::_num_total_archived_objs = 0;
+int HeapShared::_num_total_recorded_klasses = 0;
+int HeapShared::_num_total_verifications = 0;
+
+bool HeapShared::has_been_seen_during_subgraph_recording(oop obj) {
+  return _seen_objects_table->get(obj) != NULL;
+}
+
+void HeapShared::set_has_been_seen_during_subgraph_recording(oop obj) {
+  assert(!has_been_seen_during_subgraph_recording(obj), "sanity");
+  _seen_objects_table->put(obj, true);
+  ++ _num_new_walked_objs;
+}
+
+void HeapShared::start_recording_subgraph(InstanceKlass *k, const char* class_name) {
+  log_info(cds, heap)("Start recording subgraph(s) for archived fields in %s", class_name);
+  init_seen_objects_table();
+  _num_new_walked_objs = 0;
+  _num_new_archived_objs = 0;
+  _num_old_recorded_klasses = get_subgraph_info(k)->num_subgraph_object_klasses();
+}
+
+void HeapShared::done_recording_subgraph(InstanceKlass *k, const char* class_name) {
+  int num_new_recorded_klasses = get_subgraph_info(k)->num_subgraph_object_klasses() -
+    _num_old_recorded_klasses;
+  log_info(cds, heap)("Done recording subgraph(s) for archived fields in %s: "
+                      "walked %d objs, archived %d new objs, recorded %d classes",
+                      class_name, _num_new_walked_objs, _num_new_archived_objs,
+                      num_new_recorded_klasses);
+
+  delete_seen_objects_table();
+
+  _num_total_subgraph_recordings ++;
+  _num_total_walked_objs      += _num_new_walked_objs;
+  _num_total_archived_objs    += _num_new_archived_objs;
+  _num_total_recorded_klasses +=  num_new_recorded_klasses;
+}
+
 struct ArchivableStaticFieldInfo {
-  const char* class_name;
+  const char* klass_name;
   const char* field_name;
   InstanceKlass* klass;
   int offset;
@@ -553,39 +677,37 @@
   {"java/lang/module/Configuration",           "EMPTY_CONFIGURATION"},
 };
 
-const static int num_archivable_static_fields = sizeof(archivable_static_fields) / sizeof(ArchivableStaticFieldInfo);
+const static int num_archivable_static_fields =
+  sizeof(archivable_static_fields) / sizeof(ArchivableStaticFieldInfo);
 
 class ArchivableStaticFieldFinder: public FieldClosure {
   InstanceKlass* _ik;
   Symbol* _field_name;
   bool _found;
   int _offset;
-  BasicType _type;
 public:
   ArchivableStaticFieldFinder(InstanceKlass* ik, Symbol* field_name) :
-    _ik(ik), _field_name(field_name), _found(false), _offset(-1), _type(T_ILLEGAL) {}
+    _ik(ik), _field_name(field_name), _found(false), _offset(-1) {}
 
   virtual void do_field(fieldDescriptor* fd) {
     if (fd->name() == _field_name) {
       assert(!_found, "fields cannot be overloaded");
+      assert(fd->field_type() == T_OBJECT || fd->field_type() == T_ARRAY, "can archive only obj or array fields");
       _found = true;
       _offset = fd->offset();
-      _type = fd->field_type();
-      assert(_type == T_OBJECT || _type == T_ARRAY, "can archive only obj or array fields");
     }
   }
   bool found()     { return _found;  }
   int offset()     { return _offset; }
-  BasicType type() { return _type;   }
 };
 
 void HeapShared::init_archivable_static_fields(Thread* THREAD) {
   for (int i = 0; i < num_archivable_static_fields; i++) {
     ArchivableStaticFieldInfo* info = &archivable_static_fields[i];
-    TempNewSymbol class_name =  SymbolTable::new_symbol(info->class_name, THREAD);
+    TempNewSymbol klass_name =  SymbolTable::new_symbol(info->klass_name, THREAD);
     TempNewSymbol field_name =  SymbolTable::new_symbol(info->field_name, THREAD);
 
-    Klass* k = SystemDictionary::resolve_or_null(class_name, THREAD);
+    Klass* k = SystemDictionary::resolve_or_null(klass_name, THREAD);
     assert(k != NULL && !HAS_PENDING_EXCEPTION, "class must exist");
     InstanceKlass* ik = InstanceKlass::cast(k);
 
@@ -595,15 +717,50 @@
 
     info->klass = ik;
     info->offset = finder.offset();
-    info->type = finder.type();
   }
 }
 
-void HeapShared::archive_module_graph_objects(Thread* THREAD) {
-  for (int i = 0; i < num_archivable_static_fields; i++) {
+void HeapShared::archive_static_fields(Thread* THREAD) {
+  // For each class X that has one or more archived fields:
+  // [1] Dump the subgraph of each archived field
+  // [2] Create a list of all the class of the objects that can be reached
+  //     by any of these static fields.
+  //     At runtime, these classes are initialized before X's archived fields
+  //     are restored by HeapShared::initialize_from_archived_subgraph().
+  int i;
+  for (i = 0; i < num_archivable_static_fields; ) {
     ArchivableStaticFieldInfo* info = &archivable_static_fields[i];
-    archive_reachable_objects_from_static_field(info->klass, info->offset, info->type, CHECK);
+    const char* klass_name = info->klass_name;
+    start_recording_subgraph(info->klass, klass_name);
+
+    // If you have specified consecutive fields of the same klass in
+    // archivable_static_fields[], these will be archived in the same
+    // {start_recording_subgraph ... done_recording_subgraph} pass to
+    // save time.
+    for (; i < num_archivable_static_fields; i++) {
+      ArchivableStaticFieldInfo* f = &archivable_static_fields[i];
+      if (f->klass_name != klass_name) {
+        break;
+      }
+      archive_reachable_objects_from_static_field(f->klass, f->klass_name,
+                                                  f->offset, f->field_name, CHECK);
+    }
+    done_recording_subgraph(info->klass, klass_name);
   }
+
+  log_info(cds, heap)("Performed subgraph records = %d times", _num_total_subgraph_recordings);
+  log_info(cds, heap)("Walked %d objects", _num_total_walked_objs);
+  log_info(cds, heap)("Archived %d objects", _num_total_archived_objs);
+  log_info(cds, heap)("Recorded %d klasses", _num_total_recorded_klasses);
+
+
+#ifndef PRODUCT
+  for (int i = 0; i < num_archivable_static_fields; i++) {
+    ArchivableStaticFieldInfo* f = &archivable_static_fields[i];
+    verify_subgraph_from_static_field(f->klass, f->offset);
+  }
+  log_info(cds, heap)("Verified %d references", _num_total_verifications);
+#endif
 }
 
 // At dump-time, find the location of all the non-null oop pointers in an archived heap
@@ -677,7 +834,7 @@
     narrowOop* p = _start + offset;
     narrowOop v = *p;
     assert(!CompressedOops::is_null(v), "null oops should have been filtered out at dump time");
-    oop o = HeapShared::decode_with_archived_oop_encoding_mode(v);
+    oop o = HeapShared::decode_from_archive(v);
     RawAccess<IS_NOT_NULL>::oop_store(p, o);
     return true;
   }
--- a/src/hotspot/share/memory/heapShared.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/memory/heapShared.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -26,12 +26,14 @@
 #define SHARE_VM_MEMORY_HEAPSHARED_HPP
 
 #include "classfile/systemDictionary.hpp"
+#include "memory/allocation.hpp"
 #include "memory/universe.hpp"
 #include "oops/objArrayKlass.hpp"
 #include "oops/oop.hpp"
 #include "oops/typeArrayKlass.hpp"
 #include "utilities/bitMap.hpp"
 #include "utilities/growableArray.hpp"
+#include "utilities/resourceHash.hpp"
 
 #if INCLUDE_CDS_JAVA_HEAP
 // A dump time sub-graph info for Klass _k. It includes the entry points
@@ -74,6 +76,10 @@
   }
   void add_subgraph_entry_field(int static_field_offset, oop v);
   void add_subgraph_object_klass(Klass *orig_k, Klass *relocated_k);
+  int num_subgraph_object_klasses() {
+    return _subgraph_object_klasses == NULL ? 0 :
+           _subgraph_object_klasses->length();
+  }
 };
 
 // An archived record of object sub-graphs reachable from static
@@ -89,20 +95,21 @@
 
   // klasses of objects in archived sub-graphs referenced from the entry points
   // (static fields) in the containing class
-  Array<Klass*>* _subgraph_klasses;
+  Array<Klass*>* _subgraph_object_klasses;
  public:
   ArchivedKlassSubGraphInfoRecord() :
-    _next(NULL), _k(NULL), _entry_field_records(NULL), _subgraph_klasses(NULL) {}
+    _next(NULL), _k(NULL), _entry_field_records(NULL), _subgraph_object_klasses(NULL) {}
   void init(KlassSubGraphInfo* info);
   Klass* klass() { return _k; }
   ArchivedKlassSubGraphInfoRecord* next() { return _next; }
   void set_next(ArchivedKlassSubGraphInfoRecord* next) { _next = next; }
   Array<juint>*  entry_field_records() { return _entry_field_records; }
-  Array<Klass*>* subgraph_klasses() { return _subgraph_klasses; }
+  Array<Klass*>* subgraph_object_klasses() { return _subgraph_object_klasses; }
 };
 #endif // INCLUDE_CDS_JAVA_HEAP
 
 class HeapShared: AllStatic {
+  friend class VerifySharedOopClosure;
  private:
 #if INCLUDE_CDS_JAVA_HEAP
   // This is a list of subgraph infos built at dump time while
@@ -117,7 +124,12 @@
   // Archive object sub-graph starting from the given static field
   // in Klass k's mirror.
   static void archive_reachable_objects_from_static_field(
-    Klass* k, int field_ofset, BasicType field_type, TRAPS);
+    InstanceKlass* k, const char* klass_name,
+    int field_offset, const char* field_name, TRAPS);
+  static void verify_subgraph_from_static_field(
+    InstanceKlass* k, int field_offset) PRODUCT_RETURN;
+
+  static void verify_reachable_objects_from(oop obj, bool is_archived) PRODUCT_RETURN;
 
   static KlassSubGraphInfo* find_subgraph_info(Klass *k);
   static KlassSubGraphInfo* get_subgraph_info(Klass *k);
@@ -125,10 +137,53 @@
 
   static size_t build_archived_subgraph_info_records(int num_records);
 
-  // Used by decode_with_archived_oop_encoding_mode
+  // Used by decode_from_archive
   static address _narrow_oop_base;
   static int     _narrow_oop_shift;
 
+  static bool oop_equals(oop const& p1, oop const& p2) {
+    return primitive_equals<oop>(p1, p2);
+  }
+
+  static unsigned oop_hash(oop const& p) {
+    return primitive_hash<address>((address)p);
+  }
+
+  typedef ResourceHashtable<oop, bool,
+      HeapShared::oop_hash,
+      HeapShared::oop_equals,
+      15889, // prime number
+      ResourceObj::C_HEAP> SeenObjectsTable;
+
+  static SeenObjectsTable *_seen_objects_table;
+
+  static void init_seen_objects_table() {
+    assert(_seen_objects_table == NULL, "must be");
+    _seen_objects_table = new (ResourceObj::C_HEAP, mtClass)SeenObjectsTable();
+  }
+  static void delete_seen_objects_table() {
+    assert(_seen_objects_table != NULL, "must be");
+    delete _seen_objects_table;
+    _seen_objects_table = NULL;
+  }
+
+  // Statistics (for one round of start_recording_subgraph ... done_recording_subgraph)
+  static int _num_new_walked_objs;
+  static int _num_new_archived_objs;
+  static int _num_old_recorded_klasses;
+
+  // Statistics (for all archived subgraphs)
+  static int _num_total_subgraph_recordings;
+  static int _num_total_walked_objs;
+  static int _num_total_archived_objs;
+  static int _num_total_recorded_klasses;
+  static int _num_total_verifications;
+
+  static void start_recording_subgraph(InstanceKlass *k, const char* klass_name);
+  static void done_recording_subgraph(InstanceKlass *k, const char* klass_name);
+
+  static bool has_been_seen_during_subgraph_recording(oop obj);
+  static void set_has_been_seen_during_subgraph_recording(oop obj);
 #endif // INCLUDE_CDS_JAVA_HEAP
  public:
   static char* read_archived_subgraph_infos(char* buffer) NOT_CDS_JAVA_HEAP_RETURN_(buffer);
@@ -139,7 +194,7 @@
   // than Universe::narrow_oop_{base,shift} -- see FileMapInfo::map_heap_regions_impl.
   // To decode them, do not use CompressedOops::decode_not_null. Use this
   // function instead.
-  inline static oop decode_with_archived_oop_encoding_mode(narrowOop v) NOT_CDS_JAVA_HEAP_RETURN_(NULL);
+  inline static oop decode_from_archive(narrowOop v) NOT_CDS_JAVA_HEAP_RETURN_(NULL);
 
   static void init_narrow_oop_decoding(address base, int shift) NOT_CDS_JAVA_HEAP_RETURN;
 
@@ -147,10 +202,12 @@
                                                     size_t oopmap_in_bits) NOT_CDS_JAVA_HEAP_RETURN;
 
   static void init_archivable_static_fields(Thread* THREAD) NOT_CDS_JAVA_HEAP_RETURN;
-  static void archive_module_graph_objects(Thread* THREAD) NOT_CDS_JAVA_HEAP_RETURN;
+  static void archive_static_fields(Thread* THREAD) NOT_CDS_JAVA_HEAP_RETURN;
 
 #if INCLUDE_CDS_JAVA_HEAP
   static ResourceBitMap calculate_oopmap(MemRegion region);
+  static oop archive_reachable_objects_from(int level, KlassSubGraphInfo* subgraph_info, oop orig_obj, TRAPS);
+  static void verify_subgraph_from(oop orig_obj) PRODUCT_RETURN;
 #endif
 };
 #endif // SHARE_VM_MEMORY_HEAPSHARED_HPP
--- a/src/hotspot/share/memory/heapShared.inline.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/memory/heapShared.inline.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -30,7 +30,7 @@
 
 #if INCLUDE_CDS_JAVA_HEAP
 
-inline oop HeapShared::decode_with_archived_oop_encoding_mode(narrowOop v) {
+inline oop HeapShared::decode_from_archive(narrowOop v) {
   assert(!CompressedOops::is_null(v), "narrow oop value can never be zero");
   oop result = (oop)(void*)((uintptr_t)_narrow_oop_base + ((uintptr_t)v << _narrow_oop_shift));
   assert(check_obj_alignment(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
--- a/src/hotspot/share/memory/metaspaceShared.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/memory/metaspaceShared.cpp	Thu Sep 13 10:54:11 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;
@@ -1880,7 +1881,7 @@
 
   MetaspaceShared::archive_klass_objects(THREAD);
 
-  HeapShared::archive_module_graph_objects(THREAD);
+  HeapShared::archive_static_fields(THREAD);
 
   G1CollectedHeap::heap()->end_archive_alloc_range(open_archive,
                                                    os::vm_allocation_granularity());
@@ -1940,8 +1941,10 @@
 }
 
 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);
+    oop obj = HeapShared::decode_from_archive(v);
     return G1CollectedHeap::heap()->materialize_archived_object(obj);
   }
   return NULL;
@@ -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
 
@@ -2017,7 +2021,7 @@
              "Archived heap object is not allowed");
       assert(MetaspaceShared::open_archive_heap_region_mapped(),
              "Open archive heap region is not mapped");
-      *p = HeapShared::decode_with_archived_oop_encoding_mode(o);
+      *p = HeapShared::decode_from_archive(o);
     }
   }
 
--- a/src/hotspot/share/memory/metaspaceShared.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/memory/metaspaceShared.hpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/memory/universe.cpp	Thu Sep 13 10:54:11 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
     {
--- a/src/hotspot/share/oops/instanceKlass.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/oops/instanceKlass.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -643,7 +643,7 @@
   if (!is_not_initialized()) return;  // note: not equivalent to is_initialized()
 
   ClassState old_state = init_state();
-  link_class_impl(true, THREAD);
+  link_class_impl(THREAD);
   if (HAS_PENDING_EXCEPTION) {
     CLEAR_PENDING_EXCEPTION;
     // Abort if linking the class throws an exception.
@@ -681,11 +681,9 @@
 }
 
 
-bool InstanceKlass::verify_code(bool throw_verifyerror, TRAPS) {
+bool InstanceKlass::verify_code(TRAPS) {
   // 1) Verify the bytecodes
-  Verifier::Mode mode =
-    throw_verifyerror ? Verifier::ThrowException : Verifier::NoException;
-  return Verifier::verify(this, mode, should_verify_class(), THREAD);
+  return Verifier::verify(this, should_verify_class(), THREAD);
 }
 
 
@@ -700,7 +698,7 @@
 void InstanceKlass::link_class(TRAPS) {
   assert(is_loaded(), "must be loaded");
   if (!is_linked()) {
-    link_class_impl(true, CHECK);
+    link_class_impl(CHECK);
   }
 }
 
@@ -709,12 +707,12 @@
 bool InstanceKlass::link_class_or_fail(TRAPS) {
   assert(is_loaded(), "must be loaded");
   if (!is_linked()) {
-    link_class_impl(false, CHECK_false);
+    link_class_impl(CHECK_false);
   }
   return is_linked();
 }
 
-bool InstanceKlass::link_class_impl(bool throw_verifyerror, TRAPS) {
+bool InstanceKlass::link_class_impl(TRAPS) {
   if (DumpSharedSpaces && is_in_error_state()) {
     // This is for CDS dumping phase only -- we use the in_error_state to indicate that
     // the class has failed verification. Throwing the NoClassDefFoundError here is just
@@ -756,7 +754,7 @@
     }
 
     InstanceKlass* ik_super = InstanceKlass::cast(super_klass);
-    ik_super->link_class_impl(throw_verifyerror, CHECK_false);
+    ik_super->link_class_impl(CHECK_false);
   }
 
   // link all interfaces implemented by this class before linking this class
@@ -764,7 +762,7 @@
   int num_interfaces = interfaces->length();
   for (int index = 0; index < num_interfaces; index++) {
     InstanceKlass* interk = interfaces->at(index);
-    interk->link_class_impl(throw_verifyerror, CHECK_false);
+    interk->link_class_impl(CHECK_false);
   }
 
   // in case the class is linked in the process of linking its superclasses
@@ -794,7 +792,7 @@
     if (!is_linked()) {
       if (!is_rewritten()) {
         {
-          bool verify_ok = verify_code(throw_verifyerror, THREAD);
+          bool verify_ok = verify_code(THREAD);
           if (!verify_ok) {
             return false;
           }
--- a/src/hotspot/share/oops/instanceKlass.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/oops/instanceKlass.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -1285,8 +1285,8 @@
 private:
   void fence_and_clear_init_lock();
 
-  bool link_class_impl                           (bool throw_verifyerror, TRAPS);
-  bool verify_code                               (bool throw_verifyerror, TRAPS);
+  bool link_class_impl                           (TRAPS);
+  bool verify_code                               (TRAPS);
   void initialize_impl                           (TRAPS);
   void initialize_super_interfaces               (TRAPS);
   void eager_initialize_impl                     ();
--- a/src/hotspot/share/oops/instanceRefKlass.inline.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/oops/instanceRefKlass.inline.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -98,12 +98,14 @@
 
 template <typename T, class OopClosureType, class Contains>
 void InstanceRefKlass::oop_oop_iterate_fields(oop obj, OopClosureType* closure, Contains& contains) {
+  assert(closure->ref_discoverer() == NULL, "ReferenceDiscoverer should not be set");
   do_referent<T>(obj, closure, contains);
   do_discovered<T>(obj, closure, contains);
 }
 
 template <typename T, class OopClosureType, class Contains>
 void InstanceRefKlass::oop_oop_iterate_fields_except_referent(oop obj, OopClosureType* closure, Contains& contains) {
+  assert(closure->ref_discoverer() == NULL, "ReferenceDiscoverer should not be set");
   do_discovered<T>(obj, closure, contains);
 }
 
--- a/src/hotspot/share/oops/klass.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/oops/klass.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -656,8 +656,9 @@
   virtual MetaspaceObj::Type type() const { return ClassType; }
 
   // Iff the class loader (or mirror for unsafe anonymous classes) is alive the
-  // Klass is considered alive.  Has already been marked as unloading.
-  bool is_loader_alive() const { return !class_loader_data()->is_unloading(); }
+  // Klass is considered alive. This is safe to call before the CLD is marked as
+  // unloading, and hence during concurrent class unloading.
+  bool is_loader_alive() const { return class_loader_data()->is_alive(); }
 
   // Load the klass's holder as a phantom. This is useful when a weak Klass
   // pointer has been "peeked" and then must be kept alive before it may
--- a/src/hotspot/share/opto/graphKit.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/opto/graphKit.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -1698,6 +1698,14 @@
   return _barrier_set->clone(this, src, dst, size, is_array);
 }
 
+Node* GraphKit::access_resolve(Node* n, DecoratorSet decorators) {
+  // Use stronger ACCESS_WRITE|ACCESS_READ by default.
+  if ((decorators & (ACCESS_READ | ACCESS_WRITE)) == 0) {
+    decorators |= ACCESS_READ | ACCESS_WRITE;
+  }
+  return _barrier_set->resolve(this, n, decorators);
+}
+
 //-------------------------array_element_address-------------------------
 Node* GraphKit::array_element_address(Node* ary, Node* idx, BasicType elembt,
                                       const TypeInt* sizetype, Node* ctrl) {
@@ -3233,6 +3241,8 @@
 
   assert(dead_locals_are_killed(), "should kill locals before sync. point");
 
+  obj = access_resolve(obj, ACCESS_READ | ACCESS_WRITE);
+
   // Box the stack location
   Node* box = _gvn.transform(new BoxLockNode(next_monitor()));
   Node* mem = reset_memory();
@@ -3950,6 +3960,8 @@
    *   dst[i_char++] = (char)(src[i_byte] & 0xff);
    * }
    */
+  src = access_resolve(src, ACCESS_READ);
+  dst = access_resolve(dst, ACCESS_WRITE);
   add_predicate();
   RegionNode* head = new RegionNode(3);
   head->init_req(1, control());
--- a/src/hotspot/share/opto/graphKit.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/opto/graphKit.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -637,6 +637,8 @@
 
   void access_clone(Node* ctl, Node* src, Node* dst, Node* size, bool is_array);
 
+  Node* access_resolve(Node* n, DecoratorSet decorators);
+
   // Return addressing for an array element.
   Node* array_element_address(Node* ary, Node* idx, BasicType elembt,
                               // Optional constraint on the array size:
--- a/src/hotspot/share/opto/library_call.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/opto/library_call.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -1103,6 +1103,9 @@
   arg1 = must_be_not_null(arg1, true);
   arg2 = must_be_not_null(arg2, true);
 
+  arg1 = access_resolve(arg1, ACCESS_READ);
+  arg2 = access_resolve(arg2, ACCESS_READ);
+
   // Get start addr and length of first argument
   Node* arg1_start  = array_element_address(arg1, intcon(0), T_BYTE);
   Node* arg1_cnt    = load_array_length(arg1);
@@ -1130,6 +1133,9 @@
     arg1 = must_be_not_null(arg1, true);
     arg2 = must_be_not_null(arg2, true);
 
+    arg1 = access_resolve(arg1, ACCESS_READ);
+    arg2 = access_resolve(arg2, ACCESS_READ);
+
     // Get start addr and length of first argument
     Node* arg1_start  = array_element_address(arg1, intcon(0), T_BYTE);
     Node* arg1_cnt    = load_array_length(arg1);
@@ -1170,6 +1176,9 @@
   Node* arg1 = argument(0);
   Node* arg2 = argument(1);
 
+  arg1 = access_resolve(arg1, ACCESS_READ);
+  arg2 = access_resolve(arg2, ACCESS_READ);
+
   const TypeAryPtr* mtype = (ae == StrIntrinsicNode::UU) ? TypeAryPtr::CHARS : TypeAryPtr::BYTES;
   set_result(_gvn.transform(new AryEqNode(control(), memory(mtype), arg1, arg2, ae)));
   clear_upper_avx();
@@ -1196,6 +1205,7 @@
   if (stopped()) {
     return true;
   }
+  ba = access_resolve(ba, ACCESS_READ);
   Node* ba_start = array_element_address(ba, offset, T_BYTE);
   Node* result = new HasNegativesNode(control(), memory(TypeAryPtr::BYTES), ba_start, len);
   set_result(_gvn.transform(result));
@@ -1266,6 +1276,9 @@
   src = must_be_not_null(src, true);
   tgt = must_be_not_null(tgt, true);
 
+  src = access_resolve(src, ACCESS_READ);
+  tgt = access_resolve(tgt, ACCESS_READ);
+
   // Get start addr and length of source string
   Node* src_start = array_element_address(src, intcon(0), T_BYTE);
   Node* src_count = load_array_length(src);
@@ -1313,6 +1326,9 @@
   src = must_be_not_null(src, true);
   tgt = must_be_not_null(tgt, true);
 
+  src = access_resolve(src, ACCESS_READ);
+  tgt = access_resolve(tgt, ACCESS_READ);
+
   // Multiply byte array index by 2 if String is UTF16 encoded
   Node* src_offset = (ae == StrIntrinsicNode::LL) ? from_index : _gvn.transform(new LShiftINode(from_index, intcon(1)));
   src_count = _gvn.transform(new SubINode(src_count, from_index));
@@ -1399,6 +1415,7 @@
   Node* max         = argument(3);
 
   src = must_be_not_null(src, true);
+  src = access_resolve(src, ACCESS_READ);
 
   Node* src_offset = _gvn.transform(new LShiftINode(from_index, intcon(1)));
   Node* src_start = array_element_address(src, src_offset, T_BYTE);
@@ -1489,6 +1506,9 @@
     return true;
   }
 
+  src = access_resolve(src, ACCESS_READ);
+  dst = access_resolve(dst, ACCESS_WRITE);
+
   Node* src_start = array_element_address(src, src_offset, src_elem);
   Node* dst_start = array_element_address(dst, dst_offset, dst_elem);
   // 'src_start' points to src array + scaled offset
@@ -1579,6 +1599,7 @@
     AllocateArrayNode* alloc = tightly_coupled_allocation(newcopy, NULL);
 
     // Calculate starting addresses.
+    value = access_resolve(value, ACCESS_READ);
     Node* src_start = array_element_address(value, offset, T_CHAR);
     Node* dst_start = basic_plus_adr(newcopy, arrayOopDesc::base_offset_in_bytes(T_BYTE));
 
@@ -1662,6 +1683,9 @@
   }
 
   if (!stopped()) {
+    src = access_resolve(src, ACCESS_READ);
+    dst = access_resolve(dst, ACCESS_READ);
+
     // Calculate starting addresses.
     Node* src_start = array_element_address(src, src_begin, T_BYTE);
     Node* dst_start = array_element_address(dst, dst_begin, T_CHAR);
@@ -1730,6 +1754,7 @@
   }
 
   value = must_be_not_null(value, true);
+  value = access_resolve(value, is_store ? ACCESS_WRITE : ACCESS_READ);
 
   Node* adr = array_element_address(value, index, T_CHAR);
   if (adr->is_top()) {
@@ -3661,6 +3686,8 @@
       Node* orig_tail = _gvn.transform(new SubINode(orig_length, start));
       Node* moved = generate_min_max(vmIntrinsics::_min, orig_tail, length);
 
+      original = access_resolve(original, ACCESS_READ);
+
       // Generate a direct call to the right arraycopy function(s).
       // We know the copy is disjoint but we might not know if the
       // oop stores need checking.
@@ -4303,6 +4330,7 @@
         if (is_obja != NULL) {
           PreserveJVMState pjvms2(this);
           set_control(is_obja);
+          obj = access_resolve(obj, ACCESS_READ);
           // Generate a direct call to the right arraycopy function(s).
           Node* alloc = tightly_coupled_allocation(alloc_obj, NULL);
           ArrayCopyNode* ac = ArrayCopyNode::make(this, true, obj, intcon(0), alloc_obj, intcon(0), obj_length, alloc != NULL, false);
@@ -4779,7 +4807,10 @@
     return true;
   }
 
-  ArrayCopyNode* ac = ArrayCopyNode::make(this, true, src, src_offset, dest, dest_offset, length, alloc != NULL, negative_length_guard_generated,
+  Node* new_src = access_resolve(src, ACCESS_READ);
+  Node* new_dest = access_resolve(dest, ACCESS_WRITE);
+
+  ArrayCopyNode* ac = ArrayCopyNode::make(this, true, new_src, src_offset, new_dest, dest_offset, length, alloc != NULL, negative_length_guard_generated,
                                           // Create LoadRange and LoadKlass nodes for use during macro expansion here
                                           // so the compiler has a chance to eliminate them: during macro expansion,
                                           // we have to set their control (CastPP nodes are eliminated).
@@ -4892,6 +4923,9 @@
   src = must_be_not_null(src, true);
   dst = must_be_not_null(dst, true);
 
+  src = access_resolve(src, ACCESS_READ);
+  dst = access_resolve(dst, ACCESS_WRITE);
+
   const Type* src_type = src->Value(&_gvn);
   const Type* dst_type = dst->Value(&_gvn);
   const TypeAryPtr* top_src = src_type->isa_aryptr();
@@ -4947,6 +4981,10 @@
   x = must_be_not_null(x, true);
   y = must_be_not_null(y, true);
 
+  x = access_resolve(x, ACCESS_READ);
+  y = access_resolve(y, ACCESS_READ);
+  z = access_resolve(z, ACCESS_WRITE);
+
   const Type* x_type = x->Value(&_gvn);
   const Type* y_type = y->Value(&_gvn);
   const TypeAryPtr* top_x = x_type->isa_aryptr();
@@ -5055,6 +5093,9 @@
   x = must_be_not_null(x, true);
   z = must_be_not_null(z, true);
 
+  x = access_resolve(x, ACCESS_READ);
+  z = access_resolve(z, ACCESS_WRITE);
+
   const Type* x_type = x->Value(&_gvn);
   const Type* z_type = z->Value(&_gvn);
   const TypeAryPtr* top_x = x_type->isa_aryptr();
@@ -5104,6 +5145,9 @@
 
   out = must_be_not_null(out, true);
 
+  in = access_resolve(in, ACCESS_READ);
+  out = access_resolve(out, ACCESS_WRITE);
+
   const Type* out_type = out->Value(&_gvn);
   const Type* in_type = in->Value(&_gvn);
   const TypeAryPtr* top_out = out_type->isa_aryptr();
@@ -5153,6 +5197,11 @@
   Node* inv  = argument(4);
   Node* m    = argument(6);
 
+  a = access_resolve(a, ACCESS_READ);
+  b = access_resolve(b, ACCESS_READ);
+  n = access_resolve(n, ACCESS_READ);
+  m = access_resolve(m, ACCESS_WRITE);
+
   const Type* a_type = a->Value(&_gvn);
   const TypeAryPtr* top_a = a_type->isa_aryptr();
   const Type* b_type = b->Value(&_gvn);
@@ -5212,6 +5261,10 @@
   Node* inv  = argument(3);
   Node* m    = argument(5);
 
+  a = access_resolve(a, ACCESS_READ);
+  n = access_resolve(n, ACCESS_READ);
+  m = access_resolve(m, ACCESS_WRITE);
+
   const Type* a_type = a->Value(&_gvn);
   const TypeAryPtr* top_a = a_type->isa_aryptr();
   const Type* n_type = a->Value(&_gvn);
@@ -5357,6 +5410,7 @@
 
   // 'src_start' points to src array + scaled offset
   src = must_be_not_null(src, true);
+  src = access_resolve(src, ACCESS_READ);
   Node* src_start = array_element_address(src, offset, src_elem);
 
   // We assume that range check is done by caller.
@@ -5446,11 +5500,13 @@
 
   // 'src_start' points to src array + scaled offset
   src = must_be_not_null(src, true);
+  src = access_resolve(src, ACCESS_READ);
   Node* src_start = array_element_address(src, offset, src_elem);
 
   // static final int[] byteTable in class CRC32C
   Node* table = get_table_from_crc32c_class(callee()->holder());
   table = must_be_not_null(table, true);
+  table = access_resolve(table, ACCESS_READ);
   Node* table_start = array_element_address(table, intcon(0), T_INT);
 
   // We assume that range check is done by caller.
@@ -5495,6 +5551,7 @@
   // static final int[] byteTable in class CRC32C
   Node* table = get_table_from_crc32c_class(callee()->holder());
   table = must_be_not_null(table, true);
+  table = access_resolve(table, ACCESS_READ);
   Node* table_start = array_element_address(table, intcon(0), T_INT);
 
   // Call the stub.
@@ -5538,6 +5595,7 @@
   }
 
   // 'src_start' points to src array + scaled offset
+  src = access_resolve(src, ACCESS_READ);
   Node* src_start = array_element_address(src, offset, src_elem);
 
   // We assume that range check is done by caller.
@@ -5741,6 +5799,9 @@
   src = must_be_not_null(src, true);
   dest = must_be_not_null(dest, true);
 
+  src = access_resolve(src, ACCESS_READ);
+  dest = access_resolve(dest, ACCESS_WRITE);
+
   // (1) src and dest are arrays.
   const Type* src_type = src->Value(&_gvn);
   const Type* dest_type = dest->Value(&_gvn);
@@ -5814,6 +5875,9 @@
   src = must_be_not_null(src, false);
   dest = must_be_not_null(dest, false);
 
+  src = access_resolve(src, ACCESS_READ);
+  dest = access_resolve(dest, ACCESS_WRITE);
+
   // (1) src and dest are arrays.
   const Type* src_type = src->Value(&_gvn);
   const Type* dest_type = dest->Value(&_gvn);
@@ -5859,6 +5923,7 @@
   // similarly, get the start address of the r vector
   Node* objRvec = load_field_from_object(cipherBlockChaining_object, "r", "[B", /*is_exact*/ false);
   if (objRvec == NULL) return false;
+  objRvec = access_resolve(objRvec, ACCESS_WRITE);
   Node* r_start = array_element_address(objRvec, intcon(0), T_BYTE);
 
   Node* cbcCrypt;
@@ -5907,6 +5972,10 @@
   Node* dest = argument(4);
   Node* dest_offset = argument(5);
 
+  src = access_resolve(src, ACCESS_READ);
+  dest = access_resolve(dest, ACCESS_WRITE);
+  counterMode_object = access_resolve(counterMode_object, ACCESS_WRITE);
+
   // (1) src and dest are arrays.
   const Type* src_type = src->Value(&_gvn);
   const Type* dest_type = dest->Value(&_gvn);
@@ -5947,10 +6016,12 @@
   // similarly, get the start address of the r vector
   Node* obj_counter = load_field_from_object(counterMode_object, "counter", "[B", /*is_exact*/ false);
   if (obj_counter == NULL) return false;
+  obj_counter = access_resolve(obj_counter, ACCESS_WRITE);
   Node* cnt_start = array_element_address(obj_counter, intcon(0), T_BYTE);
 
   Node* saved_encCounter = load_field_from_object(counterMode_object, "encryptedCounter", "[B", /*is_exact*/ false);
   if (saved_encCounter == NULL) return false;
+  saved_encCounter = access_resolve(saved_encCounter, ACCESS_WRITE);
   Node* saved_encCounter_start = array_element_address(saved_encCounter, intcon(0), T_BYTE);
   Node* used = field_address_from_object(counterMode_object, "used", "I", /*is_exact*/ false);
 
@@ -5991,6 +6062,7 @@
   if (objAESCryptKey == NULL) return (Node *) NULL;
 
   // now have the array, need to get the start address of the K array
+  objAESCryptKey = access_resolve(objAESCryptKey, ACCESS_READ);
   Node* k_start = array_element_address(objAESCryptKey, intcon(0), T_INT);
   return k_start;
 }
@@ -6002,6 +6074,7 @@
   if (objAESCryptKey == NULL) return (Node *) NULL;
 
   // now have the array, need to get the start address of the lastKey array
+  objAESCryptKey = access_resolve(objAESCryptKey, ACCESS_READ);
   Node* original_k_start = array_element_address(objAESCryptKey, intcon(0), T_BYTE);
   return original_k_start;
 }
@@ -6132,6 +6205,10 @@
   subkeyH = must_be_not_null(subkeyH, true);
   data = must_be_not_null(data, true);
 
+  state = access_resolve(state, ACCESS_WRITE);
+  subkeyH = access_resolve(subkeyH, ACCESS_READ);
+  data = access_resolve(data, ACCESS_READ);
+
   Node* state_start  = array_element_address(state, intcon(0), T_LONG);
   assert(state_start, "state is NULL");
   Node* subkeyH_start  = array_element_address(subkeyH, intcon(0), T_LONG);
@@ -6206,6 +6283,7 @@
   }
   // 'src_start' points to src array + offset
   src = must_be_not_null(src, true);
+  src = access_resolve(src, ACCESS_READ);
   Node* src_start = array_element_address(src, ofs, src_elem);
   Node* state = NULL;
   address stubAddr;
@@ -6273,6 +6351,7 @@
   }
   // 'src_start' points to src array + offset
   src = must_be_not_null(src, false);
+  src = access_resolve(src, ACCESS_READ);
   Node* src_start = array_element_address(src, ofs, src_elem);
 
   const char* klass_SHA_name = NULL;
@@ -6355,6 +6434,7 @@
   if (sha_state == NULL) return (Node *) NULL;
 
   // now have the array, need to get the start address of the state array
+  sha_state = access_resolve(sha_state, ACCESS_WRITE);
   Node* state = array_element_address(sha_state, intcon(0), T_INT);
   return state;
 }
@@ -6366,6 +6446,7 @@
   if (sha_state == NULL) return (Node *) NULL;
 
   // now have the array, need to get the start address of the state array
+  sha_state = access_resolve(sha_state, ACCESS_WRITE);
   Node* state = array_element_address(sha_state, intcon(0), T_LONG);
   return state;
 }
--- a/src/hotspot/share/opto/phaseX.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/opto/phaseX.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -1889,13 +1889,23 @@
       } else if( n->is_Region() ) { // Unreachable region
         // Note: nn == C->top()
         n->set_req(0, NULL);        // Cut selfreference
-        // Eagerly remove dead phis to avoid phis copies creation.
-        for (DUIterator i = n->outs(); n->has_out(i); i++) {
-          Node* m = n->out(i);
-          if( m->is_Phi() ) {
-            assert(type(m) == Type::TOP, "Unreachable region should not have live phis.");
-            replace_node(m, nn);
-            --i; // deleted this phi; rescan starting with next position
+        bool progress = true;
+        uint max = n->outcnt();
+        DUIterator i;
+        while (progress) {
+          progress = false;
+          // Eagerly remove dead phis to avoid phis copies creation.
+          for (i = n->outs(); n->has_out(i); i++) {
+            Node* m = n->out(i);
+            if (m->is_Phi()) {
+              assert(type(m) == Type::TOP, "Unreachable region should not have live phis.");
+              replace_node(m, nn);
+              if (max != n->outcnt()) {
+                progress = true;
+                i = n->refresh_out_pos(i);
+                max = n->outcnt();
+              }
+            }
           }
         }
       }
--- a/src/hotspot/share/opto/stringopts.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/opto/stringopts.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -1212,6 +1212,7 @@
     kit.set_control(loop);
     Node* sizeTable = fetch_static_field(kit, size_table_field);
 
+    sizeTable = kit.access_resolve(sizeTable, ACCESS_READ);
     Node* value = kit.load_array_element(NULL, sizeTable, index, TypeAryPtr::INTS);
     C->record_for_igvn(value);
     Node* limit = __ CmpI(phi, value);
@@ -1547,6 +1548,7 @@
 // Compress copy contents of the byte/char String str into dst_array starting at index start.
 Node* PhaseStringOpts::copy_string(GraphKit& kit, Node* str, Node* dst_array, Node* dst_coder, Node* start) {
   Node* src_array = kit.load_String_value(kit.control(), str);
+  src_array = kit.access_resolve(src_array, ACCESS_READ);
 
   IdealKit ideal(&kit, true, true);
   IdealVariable count(ideal); __ declarations_done();
--- a/src/hotspot/share/opto/subnode.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/opto/subnode.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/prims/jvmtiEnter.xsl	Thu Sep 13 10:54:11 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/jvmtiGetLoadedClasses.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -129,7 +129,7 @@
     // requested, so only need to walk this loader's ClassLoaderData
     // dictionary, or the NULL ClassLoaderData dictionary for bootstrap loader.
     if (loader != NULL) {
-      ClassLoaderData* data = java_lang_ClassLoader::loader_data(loader);
+      ClassLoaderData* data = java_lang_ClassLoader::loader_data_acquire(loader);
       // ClassLoader may not be used yet for loading.
       if (data != NULL && data->dictionary() != NULL) {
         data->dictionary()->all_entries_do(&closure);
--- a/src/hotspot/share/prims/jvmtiRawMonitor.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/prims/jvmtiRawMonitor.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -264,7 +264,6 @@
 
 // Any JavaThread will enter here with state _thread_blocked
 int JvmtiRawMonitor::raw_enter(TRAPS) {
-  TEVENT (raw_enter) ;
   void * Contended ;
 
   // don't enter raw monitor if thread is being externally suspended, it will
@@ -341,7 +340,6 @@
 // Used mainly for JVMTI raw monitor implementation
 // Also used for JvmtiRawMonitor::wait().
 int JvmtiRawMonitor::raw_exit(TRAPS) {
-  TEVENT (raw_exit) ;
   if (THREAD != _owner) {
     return OM_ILLEGAL_MONITOR_STATE;
   }
@@ -360,7 +358,6 @@
 // All JavaThreads will enter here with state _thread_blocked
 
 int JvmtiRawMonitor::raw_wait(jlong millis, bool interruptible, TRAPS) {
-  TEVENT (raw_wait) ;
   if (THREAD != _owner) {
     return OM_ILLEGAL_MONITOR_STATE;
   }
@@ -406,7 +403,6 @@
 }
 
 int JvmtiRawMonitor::raw_notify(TRAPS) {
-  TEVENT (raw_notify) ;
   if (THREAD != _owner) {
     return OM_ILLEGAL_MONITOR_STATE;
   }
@@ -415,7 +411,6 @@
 }
 
 int JvmtiRawMonitor::raw_notifyAll(TRAPS) {
-  TEVENT (raw_notifyAll) ;
   if (THREAD != _owner) {
     return OM_ILLEGAL_MONITOR_STATE;
   }
--- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp	Thu Sep 13 10:54:11 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();
 
@@ -1232,8 +1231,7 @@
       // verifier. Please, refer to jvmtiThreadState.hpp for the detailed
       // description.
       RedefineVerifyMark rvm(the_class, scratch_class, state);
-      Verifier::verify(
-        scratch_class, Verifier::ThrowException, true, THREAD);
+      Verifier::verify(scratch_class, true, THREAD);
     }
 
     if (HAS_PENDING_EXCEPTION) {
@@ -1264,7 +1262,7 @@
       // verify what we have done during constant pool merging
       {
         RedefineVerifyMark rvm(the_class, scratch_class, state);
-        Verifier::verify(scratch_class, Verifier::ThrowException, true, THREAD);
+        Verifier::verify(scratch_class, true, THREAD);
       }
 
       if (HAS_PENDING_EXCEPTION) {
--- a/src/hotspot/share/prims/jvmtiTagMap.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/prims/jvmtiTagMap.cpp	Thu Sep 13 10:54:11 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/whitebox.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/prims/whitebox.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -1504,7 +1504,7 @@
 
   oop class_loader_oop = JNIHandles::resolve(class_loader);
   ClassLoaderData* cld = class_loader_oop != NULL
-      ? java_lang_ClassLoader::loader_data(class_loader_oop)
+      ? java_lang_ClassLoader::loader_data_acquire(class_loader_oop)
       : ClassLoaderData::the_null_class_loader_data();
 
   void* metadata = MetadataFactory::new_array<u1>(cld, WhiteBox::array_bytes_to_length((size_t)size), thread);
@@ -1515,7 +1515,7 @@
 WB_ENTRY(void, WB_FreeMetaspace(JNIEnv* env, jobject wb, jobject class_loader, jlong addr, jlong size))
   oop class_loader_oop = JNIHandles::resolve(class_loader);
   ClassLoaderData* cld = class_loader_oop != NULL
-      ? java_lang_ClassLoader::loader_data(class_loader_oop)
+      ? java_lang_ClassLoader::loader_data_acquire(class_loader_oop)
       : ClassLoaderData::the_null_class_loader_data();
 
   MetadataFactory::free_array(cld, (Array<u1>*)(uintptr_t)addr);
--- a/src/hotspot/share/runtime/arguments.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/runtime/arguments.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -574,6 +574,9 @@
   { "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) },
+  { "SyncVerbose",                   JDK_Version::undefined(), JDK_Version::jdk(12), JDK_Version::jdk(13) },
+  { "SyncFlags",                     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() },
@@ -3977,7 +3980,7 @@
     }
   }
 #ifdef COMPILER2
-  if (!UseBiasedLocking || EmitSync != 0) {
+  if (!UseBiasedLocking) {
     UseOptoBiasInlining = false;
   }
 #endif
--- a/src/hotspot/share/runtime/globals.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/runtime/globals.hpp	Thu Sep 13 10:54:11 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)                                                \
                                                                             \
@@ -845,11 +841,6 @@
                 "The check is performed on GuaranteedSafepointInterval.")   \
                 range(0, 100)                                               \
                                                                             \
-  experimental(intx, SyncFlags, 0, "(Unsafe, Unstable) "                    \
-               "Experimental Sync flags")                                   \
-                                                                            \
-  experimental(intx, SyncVerbose, 0, "(Unstable)")                          \
-                                                                            \
   experimental(intx, hashCode, 5,                                           \
                "(Unstable) select hashCode generation algorithm")           \
                                                                             \
--- a/src/hotspot/share/runtime/java.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/runtime/java.cpp	Thu Sep 13 10:54:11 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());
   }
 
--- a/src/hotspot/share/runtime/objectMonitor.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/runtime/objectMonitor.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -529,7 +529,7 @@
   // timer scalability issues we see on some platforms as we'd only have one thread
   // -- the checker -- parked on a timer.
 
-  if ((SyncFlags & 16) == 0 && nxt == NULL && _EntryList == NULL) {
+  if (nxt == NULL && _EntryList == NULL) {
     // Try to assume the role of responsible thread for the monitor.
     // CONSIDER:  ST vs CAS vs { if (Responsible==null) Responsible=Self }
     Atomic::replace_if_null(Self, &_Responsible);
@@ -546,7 +546,6 @@
   // to defer the state transitions until absolutely necessary,
   // and in doing so avoid some transitions ...
 
-  TEVENT(Inflated enter - Contention);
   int nWakeups = 0;
   int recheckInterval = 1;
 
@@ -555,13 +554,8 @@
     if (TryLock(Self) > 0) break;
     assert(_owner != Self, "invariant");
 
-    if ((SyncFlags & 2) && _Responsible == NULL) {
-      Atomic::replace_if_null(Self, &_Responsible);
-    }
-
     // park self
-    if (_Responsible == Self || (SyncFlags & 1)) {
-      TEVENT(Inflated enter - park TIMED);
+    if (_Responsible == Self) {
       Self->_ParkEvent->park((jlong) recheckInterval);
       // Increase the recheckInterval, but clamp the value.
       recheckInterval *= 8;
@@ -569,7 +563,6 @@
         recheckInterval = MAX_RECHECK_INTERVAL;
       }
     } else {
-      TEVENT(Inflated enter - park UNTIMED);
       Self->_ParkEvent->park();
     }
 
@@ -580,7 +573,7 @@
     // Note that the counter is not protected by a lock or updated by atomics.
     // That is by design - we trade "lossy" counters which are exposed to
     // races during updates for a lower probe effect.
-    TEVENT(Inflated enter - Futile wakeup);
+
     // This PerfData object can be used in parallel with a safepoint.
     // See the work around in PerfDataManager::destroy().
     OM_PERFDATA_OP(FutileWakeups, inc());
@@ -675,9 +668,6 @@
   // monitorexit.  Recall too, that in 1-0 mode monitorexit does not necessarily
   // execute a serializing instruction.
 
-  if (SyncFlags & 8) {
-    OrderAccess::fence();
-  }
   return;
 }
 
@@ -707,8 +697,6 @@
     if (TryLock(Self) > 0) break;
     if (TrySpin(Self) > 0) break;
 
-    TEVENT(Wait Reentry - parking);
-
     // State transition wrappers around park() ...
     // ReenterI() wisely defers state transitions until
     // it's clear we must park the thread.
@@ -719,11 +707,7 @@
       // cleared by handle_special_suspend_equivalent_condition()
       // or java_suspend_self()
       jt->set_suspend_equivalent();
-      if (SyncFlags & 1) {
-        Self->_ParkEvent->park((jlong)MAX_RECHECK_INTERVAL);
-      } else {
-        Self->_ParkEvent->park();
-      }
+      Self->_ParkEvent->park();
 
       // were we externally suspended while we were waiting?
       for (;;) {
@@ -744,7 +728,6 @@
     // Note that the counter is not protected by a lock or updated by atomics.
     // That is by design - we trade "lossy" counters which are exposed to
     // races during updates for a lower probe effect.
-    TEVENT(Wait Reentry - futile wakeup);
     ++nWakeups;
 
     // Assuming this is not a spurious wakeup we'll normally
@@ -795,7 +778,6 @@
     if (SelfNode == _EntryList) _EntryList = nxt;
     assert(nxt == NULL || nxt->TState == ObjectWaiter::TS_ENTER, "invariant");
     assert(prv == NULL || prv->TState == ObjectWaiter::TS_ENTER, "invariant");
-    TEVENT(Unlink from EntryList);
   } else {
     assert(SelfNode->TState == ObjectWaiter::TS_CXQ, "invariant");
     // Inopportune interleaving -- Self is still on the cxq.
@@ -834,7 +816,6 @@
       assert(q->_next == p, "invariant");
       q->_next = p->_next;
     }
-    TEVENT(Unlink from cxq);
   }
 
 #ifdef ASSERT
@@ -923,7 +904,6 @@
       // way we should encounter this situation is in the presence of
       // unbalanced JNI locking. TODO: CheckJNICalls.
       // See also: CR4414101
-      TEVENT(Exit - Throw IMSX);
       assert(false, "Non-balanced monitor enter/exit! Likely JNI locking");
       return;
     }
@@ -931,15 +911,12 @@
 
   if (_recursions != 0) {
     _recursions--;        // this is simple recursive enter
-    TEVENT(Inflated exit - recursive);
     return;
   }
 
   // Invariant: after setting Responsible=null an thread must execute
   // a MEMBAR or other serializing instruction before fetching EntryList|cxq.
-  if ((SyncFlags & 4) == 0) {
-    _Responsible = NULL;
-  }
+  _Responsible = NULL;
 
 #if INCLUDE_JFR
   // get the owner's thread id for the MonitorEnter event
@@ -968,10 +945,8 @@
       OrderAccess::release_store(&_owner, (void*)NULL);   // drop the lock
       OrderAccess::storeload();                        // See if we need to wake a successor
       if ((intptr_t(_EntryList)|intptr_t(_cxq)) == 0 || _succ != NULL) {
-        TEVENT(Inflated exit - simple egress);
         return;
       }
-      TEVENT(Inflated exit - complex egress);
       // Other threads are blocked trying to acquire the lock.
 
       // Normally the exiting thread is responsible for ensuring succession,
@@ -1013,14 +988,12 @@
       if (!Atomic::replace_if_null(THREAD, &_owner)) {
         return;
       }
-      TEVENT(Exit - Reacquired);
     } else {
       if ((intptr_t(_EntryList)|intptr_t(_cxq)) == 0 || _succ != NULL) {
         OrderAccess::release_store(&_owner, (void*)NULL);   // drop the lock
         OrderAccess::storeload();
         // Ratify the previously observed values.
         if (_cxq == NULL || _succ != NULL) {
-          TEVENT(Inflated exit - simple egress);
           return;
         }
 
@@ -1036,12 +1009,8 @@
         //     we could simply unpark() the lead thread and return
         //     without having set _succ.
         if (!Atomic::replace_if_null(THREAD, &_owner)) {
-          TEVENT(Inflated exit - reacquired succeeded);
           return;
         }
-        TEVENT(Inflated exit - reacquired failed);
-      } else {
-        TEVENT(Inflated exit - complex egress);
       }
     }
 
@@ -1168,7 +1137,6 @@
       if (u == w) break;
       w = u;
     }
-    TEVENT(Inflated exit - drain cxq into EntryList);
 
     assert(w != NULL, "invariant");
     assert(_EntryList == NULL, "invariant");
@@ -1272,7 +1240,6 @@
     if (2 == Mode) OrderAccess::storeload();
     if (!jSelf->is_external_suspend()) return false;
     // We raced a suspension -- fall thru into the slow path
-    TEVENT(ExitSuspendEquivalent - raced);
     jSelf->set_suspend_equivalent();
   }
   return jSelf->handle_special_suspend_equivalent_condition();
@@ -1300,10 +1267,6 @@
   OrderAccess::release_store(&_owner, (void*)NULL);
   OrderAccess::fence();                               // ST _owner vs LD in unpark()
 
-  if (SafepointMechanism::poll(Self)) {
-    TEVENT(unpark before SAFEPOINT);
-  }
-
   DTRACE_MONITOR_PROBE(contended__exit, this, object(), Self);
   Trigger->unpark();
 
@@ -1372,7 +1335,6 @@
         _owner = THREAD;  /* Convert from basiclock addr to Thread addr */  \
         _recursions = 0;                                                    \
       } else {                                                              \
-        TEVENT(Throw IMSX);                                                 \
         THROW(vmSymbols::java_lang_IllegalMonitorStateException());         \
       }                                                                     \
     }                                                                       \
@@ -1382,7 +1344,6 @@
 // TODO-FIXME: remove check_slow() -- it's likely dead.
 
 void ObjectMonitor::check_slow(TRAPS) {
-  TEVENT(check_slow - throw IMSX);
   assert(THREAD != _owner && !THREAD->is_lock_owned((address) _owner), "must not be owner");
   THROW_MSG(vmSymbols::java_lang_IllegalMonitorStateException(), "current thread not owner");
 }
@@ -1444,13 +1405,10 @@
     if (event.should_commit()) {
       post_monitor_wait_event(&event, this, 0, millis, false);
     }
-    TEVENT(Wait - Throw IEX);
     THROW(vmSymbols::java_lang_InterruptedException());
     return;
   }
 
-  TEVENT(Wait);
-
   assert(Self->_Stalled == 0, "invariant");
   Self->_Stalled = intptr_t(this);
   jt->set_current_waiting_monitor(this);
@@ -1474,9 +1432,8 @@
   AddWaiter(&node);
   Thread::SpinRelease(&_WaitSetLock);
 
-  if ((SyncFlags & 4) == 0) {
-    _Responsible = NULL;
-  }
+  _Responsible = NULL;
+
   intptr_t save = _recursions; // record the old recursion count
   _waiters++;                  // increment the number of waiters
   _recursions = 0;             // set the recursion level to be 1
@@ -1622,16 +1579,11 @@
   assert(_succ != Self, "invariant");
   assert(((oop)(object()))->mark() == markOopDesc::encode(this), "invariant");
 
-  if (SyncFlags & 32) {
-    OrderAccess::fence();
-  }
-
   // check if the notification happened
   if (!WasNotified) {
     // no, it could be timeout or Thread.interrupt() or both
     // check for interrupt event, otherwise it is timeout
     if (interruptible && Thread::is_interrupted(Self, true) && !HAS_PENDING_EXCEPTION) {
-      TEVENT(Wait - throw IEX from epilog);
       THROW(vmSymbols::java_lang_InterruptedException());
     }
   }
@@ -1652,7 +1604,6 @@
   Thread::SpinAcquire(&_WaitSetLock, "WaitSet - notify");
   ObjectWaiter * iterator = DequeueWaiter();
   if (iterator != NULL) {
-    TEVENT(Notify1 - Transfer);
     guarantee(iterator->TState == ObjectWaiter::TS_WAIT, "invariant");
     guarantee(iterator->_notified == 0, "invariant");
     // Disposition - what might we do with iterator ?
@@ -1759,14 +1710,11 @@
 // Note: We can also detect many such problems with a "minimum wait".
 // When the "minimum wait" is set to a small non-zero timeout value
 // and the program does not hang whereas it did absent "minimum wait",
-// that suggests a lost wakeup bug. The '-XX:SyncFlags=1' option uses
-// a "minimum wait" for all park() operations; see the recheckInterval
-// variable and MAX_RECHECK_INTERVAL.
+// that suggests a lost wakeup bug.
 
 void ObjectMonitor::notify(TRAPS) {
   CHECK_OWNER();
   if (_WaitSet == NULL) {
-    TEVENT(Empty-Notify);
     return;
   }
   DTRACE_MONITOR_PROBE(notify, this, object(), THREAD);
@@ -1785,7 +1733,6 @@
 void ObjectMonitor::notifyAll(TRAPS) {
   CHECK_OWNER();
   if (_WaitSet == NULL) {
-    TEVENT(Empty-NotifyAll);
     return;
   }
 
@@ -1912,14 +1859,12 @@
 
   if (Knob_SuccRestrict && _succ != NULL) return 0;
   if (Knob_OState && NotRunnable (Self, (Thread *) _owner)) {
-    TEVENT(Spin abort - notrunnable [TOP]);
     return 0;
   }
 
   int MaxSpin = Knob_MaxSpinners;
   if (MaxSpin >= 0) {
     if (_Spinner > MaxSpin) {
-      TEVENT(Spin abort -- too many spinners);
       return 0;
     }
     // Slightly racy, but benign ...
@@ -1956,7 +1901,6 @@
     // We periodically check to see if there's a safepoint pending.
     if ((ctr & 0xFF) == 0) {
       if (SafepointMechanism::poll(Self)) {
-        TEVENT(Spin: safepoint);
         goto Abort;           // abrupt spin egress
       }
       if (Knob_UsePause & 1) SpinPause();
@@ -2029,7 +1973,6 @@
       // * exit spin without prejudice.
       // * Since CAS is high-latency, retry again immediately.
       prv = ox;
-      TEVENT(Spin: cas failed);
       if (caspty == -2) break;
       if (caspty == -1) goto Abort;
       ctr -= caspty;
@@ -2038,7 +1981,6 @@
 
     // Did lock ownership change hands ?
     if (ox != prv && prv != NULL) {
-      TEVENT(spin: Owner changed)
       if (oxpty == -2) break;
       if (oxpty == -1) goto Abort;
       ctr -= oxpty;
@@ -2050,7 +1992,6 @@
     // Spinning while the owner is OFFPROC is idiocy.
     // Consider: ctr -= RunnablePenalty ;
     if (Knob_OState && NotRunnable (Self, ox)) {
-      TEVENT(Spin abort - notrunnable);
       goto Abort;
     }
     if (sss && _succ == NULL) _succ = Self;
@@ -2059,7 +2000,6 @@
   // Spin failed with prejudice -- reduce _SpinDuration.
   // TODO: Use an AIMD-like policy to adjust _SpinDuration.
   // AIMD is globally stable.
-  TEVENT(Spin failure);
   {
     int x = _SpinDuration;
     if (x > 0) {
--- a/src/hotspot/share/runtime/objectMonitor.hpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/runtime/objectMonitor.hpp	Thu Sep 13 10:54:11 2018 -0700
@@ -321,21 +321,4 @@
   bool      ExitSuspendEquivalent(JavaThread * Self);
 };
 
-#undef TEVENT
-#define TEVENT(nom) { if (SyncVerbose) FEVENT(nom); }
-
-#define FEVENT(nom)                             \
-  {                                             \
-    static volatile int ctr = 0;                \
-    int v = ++ctr;                              \
-    if ((v & (v - 1)) == 0) {                   \
-      tty->print_cr("INFO: " #nom " : %d", v);  \
-      tty->flush();                             \
-    }                                           \
-  }
-
-#undef  TEVENT
-#define TEVENT(nom) {;}
-
-
 #endif // SHARE_VM_RUNTIME_OBJECTMONITOR_HPP
--- a/src/hotspot/share/runtime/synchronizer.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/runtime/synchronizer.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -320,7 +320,6 @@
     // swing the displaced header from the BasicLock back to the mark.
     assert(dhw->is_neutral(), "invariant");
     if (object->cas_set_mark(dhw, mark) == mark) {
-      TEVENT(fast_exit: release stack-lock);
       return;
     }
   }
@@ -345,7 +344,6 @@
     // be visible <= the ST performed by the CAS.
     lock->set_displaced_header(mark);
     if (mark == obj()->cas_set_mark((markOop) lock, mark)) {
-      TEVENT(slow_enter: release stacklock);
       return;
     }
     // Fall through to inflate() ...
@@ -388,7 +386,6 @@
 //  5) lock lock2
 // NOTE: must use heavy weight monitor to handle complete_exit/reenter()
 intptr_t ObjectSynchronizer::complete_exit(Handle obj, TRAPS) {
-  TEVENT(complete_exit);
   if (UseBiasedLocking) {
     BiasedLocking::revoke_and_rebias(obj, false, THREAD);
     assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
@@ -403,7 +400,6 @@
 
 // NOTE: must use heavy weight monitor to handle complete_exit/reenter()
 void ObjectSynchronizer::reenter(Handle obj, intptr_t recursion, TRAPS) {
-  TEVENT(reenter);
   if (UseBiasedLocking) {
     BiasedLocking::revoke_and_rebias(obj, false, THREAD);
     assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
@@ -420,7 +416,6 @@
 // NOTE: must use heavy weight monitor to handle jni monitor enter
 void ObjectSynchronizer::jni_enter(Handle obj, TRAPS) {
   // the current locking is from JNI instead of Java code
-  TEVENT(jni_enter);
   if (UseBiasedLocking) {
     BiasedLocking::revoke_and_rebias(obj, false, THREAD);
     assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
@@ -432,7 +427,6 @@
 
 // NOTE: must use heavy weight monitor to handle jni monitor exit
 void ObjectSynchronizer::jni_exit(oop obj, Thread* THREAD) {
-  TEVENT(jni_exit);
   if (UseBiasedLocking) {
     Handle h_obj(THREAD, obj);
     BiasedLocking::revoke_and_rebias(h_obj, false, THREAD);
@@ -460,8 +454,6 @@
   _obj = obj;
 
   if (_dolock) {
-    TEVENT(ObjectLocker);
-
     ObjectSynchronizer::fast_enter(_obj, &_lock, false, _thread);
   }
 }
@@ -482,7 +474,6 @@
     assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
   }
   if (millis < 0) {
-    TEVENT(wait - throw IAX);
     THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "timeout value is negative");
   }
   ObjectMonitor* monitor = ObjectSynchronizer::inflate(THREAD,
@@ -505,7 +496,6 @@
     assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
   }
   if (millis < 0) {
-    TEVENT(wait - throw IAX);
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "timeout value is negative");
   }
   ObjectSynchronizer::inflate(THREAD,
@@ -608,7 +598,6 @@
     if (its > 10000 || !os::is_MP()) {
       if (its & 1) {
         os::naked_yield();
-        TEVENT(Inflate: INFLATING - yield);
       } else {
         // Note that the following code attenuates the livelock problem but is not
         // a complete remedy.  A more complete solution would require that the inflating
@@ -641,7 +630,6 @@
           }
         }
         Thread::muxRelease(gInflationLocks + ix);
-        TEVENT(Inflate: INFLATING - yield/park);
       }
     } else {
       SpinPause();       // SMP-polite spinning
@@ -703,7 +691,6 @@
   value &= markOopDesc::hash_mask;
   if (value == 0) value = 0xBAD;
   assert(value != markOopDesc::no_hash, "invariant");
-  TEVENT(hashCode: GENERATE);
   return value;
 }
 
@@ -1154,7 +1141,6 @@
       Thread::muxRelease(&gListLock);
       Self->omFreeProvision += 1 + (Self->omFreeProvision/2);
       if (Self->omFreeProvision > MAXPRIVATE) Self->omFreeProvision = MAXPRIVATE;
-      TEVENT(omFirst - reprovision);
 
       const int mx = MonitorBound;
       if (mx > 0 && (gMonitorPopulation-gMonitorFreeCount) > mx) {
@@ -1232,7 +1218,6 @@
     temp[_BLOCKSIZE - 1].FreeNext = gFreeList;
     gFreeList = temp + 1;
     Thread::muxRelease(&gListLock);
-    TEVENT(Allocate block of monitors);
   }
 }
 
@@ -1317,7 +1302,6 @@
       guarantee(s->object() == NULL, "invariant");
       guarantee(!s->is_busy(), "invariant");
       s->set_owner(NULL);   // redundant but good hygiene
-      TEVENT(omFlush - Move one);
     }
     guarantee(tail != NULL && list != NULL, "invariant");
   }
@@ -1357,7 +1341,6 @@
   }
 
   Thread::muxRelease(&gListLock);
-  TEVENT(omFlush);
 }
 
 static void post_monitor_inflate_event(EventJavaMonitorInflate* event,
@@ -1422,7 +1405,6 @@
     // Currently, we spin/yield/park and poll the markword, waiting for inflation to finish.
     // We could always eliminate polling by parking the thread on some auxiliary list.
     if (mark == markOopDesc::INFLATING()) {
-      TEVENT(Inflate: spin while INFLATING);
       ReadStableMark(object);
       continue;
     }
@@ -1515,7 +1497,6 @@
       // Hopefully the performance counters are allocated on distinct cache lines
       // to avoid false sharing on MP systems ...
       OM_PERFDATA_OP(Inflations, inc());
-      TEVENT(Inflate: overwrite stacklock);
       if (log_is_enabled(Debug, monitorinflation)) {
         if (object->is_instance()) {
           ResourceMark rm;
@@ -1566,7 +1547,6 @@
     // Hopefully the performance counters are allocated on distinct
     // cache lines to avoid false sharing on MP systems ...
     OM_PERFDATA_OP(Inflations, inc());
-    TEVENT(Inflate: overwrite neutral);
     if (log_is_enabled(Debug, monitorinflation)) {
       if (object->is_instance()) {
         ResourceMark rm;
@@ -1633,7 +1613,6 @@
     // Deflate the monitor if it is no longer being used
     // It's idle - scavenge and return to the global free list
     // plain old deflation ...
-    TEVENT(deflate_idle_monitors - scavenge1);
     if (log_is_enabled(Debug, monitorinflation)) {
       if (obj->is_instance()) {
         ResourceMark rm;
@@ -1719,7 +1698,6 @@
   ObjectMonitor * freeHeadp = NULL;  // Local SLL of scavenged monitors
   ObjectMonitor * freeTailp = NULL;
 
-  TEVENT(deflate_idle_monitors);
   // Prevent omFlush from changing mids in Thread dtor's during deflation
   // And in case the vm thread is acquiring a lock during a safepoint
   // See e.g. 6320749
--- a/src/hotspot/share/runtime/thread.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/runtime/thread.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -4736,7 +4736,6 @@
   }
 
   // Slow-path : We've encountered contention -- Spin/Yield/Block strategy.
-  TEVENT(SpinAcquire - ctx);
   int ctr = 0;
   int Yields = 0;
   for (;;) {
@@ -4831,7 +4830,6 @@
     return;
   }
 
-  TEVENT(muxAcquire - Contention);
   ParkEvent * const Self = Thread::current()->_MuxEvent;
   assert((intptr_t(Self) & LOCKBIT) == 0, "invariant");
   for (;;) {
@@ -4877,7 +4875,6 @@
     return;
   }
 
-  TEVENT(muxAcquire - Contention);
   ParkEvent * ReleaseAfter = NULL;
   if (ev == NULL) {
     ev = ReleaseAfter = ParkEvent::Allocate(NULL);
--- a/src/hotspot/share/runtime/threadHeapSampler.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/hotspot/share/runtime/threadHeapSampler.cpp	Thu Sep 13 10:54:11 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/java.base/share/classes/java/lang/ModuleLayer.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/share/classes/java/lang/ModuleLayer.java	Thu Sep 13 10:54:11 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
@@ -790,8 +790,7 @@
             // push in reverse order
             for (int i = layer.parents.size() - 1; i >= 0; i--) {
                 ModuleLayer parent = layer.parents.get(i);
-                if (!visited.contains(parent)) {
-                    visited.add(parent);
+                if (visited.add(parent)) {
                     stack.push(parent);
                 }
             }
--- a/src/java.base/share/classes/java/lang/String.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/share/classes/java/lang/String.java	Thu Sep 13 10:54:11 2018 -0700
@@ -40,12 +40,15 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
+import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 import jdk.internal.HotSpotIntrinsicCandidate;
 import jdk.internal.vm.annotation.Stable;
 
+import static java.util.function.Predicate.not;
+
 /**
  * The {@code String} class represents character strings. All
  * string literals in Java programs, such as {@code "abc"}, are
@@ -2755,12 +2758,9 @@
         return indexOfNonWhitespace() == length();
     }
 
-    private int indexOfNonWhitespace() {
-        if (isLatin1()) {
-            return StringLatin1.indexOfNonWhitespace(value);
-        } else {
-            return StringUTF16.indexOfNonWhitespace(value);
-        }
+    private Stream<String> lines(int maxLeading, int maxTrailing) {
+        return isLatin1() ? StringLatin1.lines(value, maxLeading, maxTrailing)
+                          : StringUTF16.lines(value, maxLeading, maxTrailing);
     }
 
     /**
@@ -2794,8 +2794,181 @@
      * @since 11
      */
     public Stream<String> lines() {
-        return isLatin1() ? StringLatin1.lines(value)
-                          : StringUTF16.lines(value);
+        return lines(0, 0);
+    }
+
+    /**
+     * Adjusts the indentation of each line of this string based on the value of
+     * {@code n}, and normalizes line termination characters.
+     * <p>
+     * This string is conceptually separated into lines using
+     * {@link String#lines()}. Each line is then adjusted as described below
+     * and then suffixed with a line feed {@code "\n"} (U+000A). The resulting
+     * lines are then concatenated and returned.
+     * <p>
+     * If {@code n > 0} then {@code n} spaces (U+0020) are inserted at the
+     * beginning of each line. {@link String#isBlank() Blank lines} are
+     * unaffected.
+     * <p>
+     * If {@code n < 0} then up to {@code n}
+     * {@link Character#isWhitespace(int) white space characters} are removed
+     * from the beginning of each line. If a given line does not contain
+     * sufficient white space then all leading
+     * {@link Character#isWhitespace(int) white space characters} are removed.
+     * Each white space character is treated as a single character. In
+     * particular, the tab character {@code "\t"} (U+0009) is considered a
+     * single character; it is not expanded.
+     * <p>
+     * If {@code n == 0} then the line remains unchanged. However, line
+     * terminators are still normalized.
+     * <p>
+     *
+     * @param n  number of leading
+     *           {@link Character#isWhitespace(int) white space characters}
+     *           to add or remove
+     *
+     * @return string with indentation adjusted and line endings normalized
+     *
+     * @see String#lines()
+     * @see String#isBlank()
+     * @see Character#isWhitespace(int)
+     *
+     * @since 12
+     */
+    public String indent(int n) {
+        return isEmpty() ? "" :  indent(n, false);
+    }
+
+    private String indent(int n, boolean removeBlanks) {
+        Stream<String> stream = removeBlanks ? lines(Integer.MAX_VALUE, Integer.MAX_VALUE)
+                                             : lines();
+        if (n > 0) {
+            final String spaces = " ".repeat(n);
+            stream = stream.map(s -> s.isBlank() ? s : spaces + s);
+        } else if (n == Integer.MIN_VALUE) {
+            stream = stream.map(s -> s.stripLeading());
+        } else if (n < 0) {
+            stream = stream.map(s -> s.substring(Math.min(-n, s.indexOfNonWhitespace())));
+        }
+        return stream.collect(Collectors.joining("\n", "", "\n"));
+    }
+
+    private int indexOfNonWhitespace() {
+        return isLatin1() ? StringLatin1.indexOfNonWhitespace(value)
+                          : StringUTF16.indexOfNonWhitespace(value);
+    }
+
+    private int lastIndexOfNonWhitespace() {
+        return isLatin1() ? StringLatin1.lastIndexOfNonWhitespace(value)
+                          : StringUTF16.lastIndexOfNonWhitespace(value);
+    }
+
+    /**
+     * Removes vertical and horizontal white space margins from around the
+     * essential body of a multi-line string, while preserving relative
+     * indentation.
+     * <p>
+     * This string is first conceptually separated into lines as if by
+     * {@link String#lines()}.
+     * <p>
+     * Then, the <i>minimum indentation</i> (min) is determined as follows. For
+     * each non-blank line (as defined by {@link String#isBlank()}), the
+     * leading {@link Character#isWhitespace(int) white space} characters are
+     * counted. The <i>min</i> value is the smallest of these counts.
+     * <p>
+     * For each non-blank line, <i>min</i> leading white space characters are
+     * removed. Each white space character is treated as a single character. In
+     * particular, the tab character {@code "\t"} (U+0009) is considered a
+     * single character; it is not expanded.
+     * <p>
+     * Leading and trailing blank lines, if any, are removed. Trailing spaces are
+     * preserved.
+     * <p>
+     * Each line is suffixed with a line feed character {@code "\n"} (U+000A).
+     * <p>
+     * Finally, the lines are concatenated into a single string and returned.
+     *
+     * @apiNote
+     * This method's primary purpose is to shift a block of lines as far as
+     * possible to the left, while preserving relative indentation. Lines
+     * that were indented the least will thus have no leading white space.
+     *
+     * Example:
+     * <blockquote><pre>
+     * `
+     *      This is the first line
+     *          This is the second line
+     * `.align();
+     *
+     * returns
+     * This is the first line
+     *     This is the second line
+     * </pre></blockquote>
+     *
+     * @return string with margins removed and line terminators normalized
+     *
+     * @see String#lines()
+     * @see String#isBlank()
+     * @see String#indent(int)
+     * @see Character#isWhitespace(int)
+     *
+     * @since 12
+     */
+    public String align() {
+        return align(0);
+    }
+
+    /**
+     * Removes vertical and horizontal white space margins from around the
+     * essential body of a multi-line string, while preserving relative
+     * indentation and with optional indentation adjustment.
+     * <p>
+     * Invoking this method is equivalent to:
+     * <blockquote>
+     *  {@code this.align().indent(n)}
+     * </blockquote>
+     *
+     * @apiNote
+     * Examples:
+     * <blockquote><pre>
+     * `
+     *      This is the first line
+     *          This is the second line
+     * `.align(0);
+     *
+     * returns
+     * This is the first line
+     *     This is the second line
+     *
+     *
+     * `
+     *    This is the first line
+     *       This is the second line
+     * `.align(4);
+     * returns
+     *     This is the first line
+     *         This is the second line
+     * </pre></blockquote>
+     *
+     * @param n  number of leading white space characters
+     *           to add or remove
+     *
+     * @return string with margins removed, indentation adjusted and
+     *         line terminators normalized
+     *
+     * @see String#align()
+     *
+     * @since 12
+     */
+    public String align(int n) {
+        if (isEmpty()) {
+            return "";
+        }
+        int outdent = lines().filter(not(String::isBlank))
+                             .mapToInt(String::indexOfNonWhitespace)
+                             .min()
+                             .orElse(0);
+        return indent(n - outdent, true);
     }
 
     /**
--- a/src/java.base/share/classes/java/lang/StringLatin1.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/share/classes/java/lang/StringLatin1.java	Thu Sep 13 10:54:11 2018 -0700
@@ -545,7 +545,7 @@
         int length = value.length;
         int left = 0;
         while (left < length) {
-            char ch = (char)(value[left] & 0xff);
+            char ch = getChar(value, left);
             if (ch != ' ' && ch != '\t' && !Character.isWhitespace(ch)) {
                 break;
             }
@@ -558,7 +558,7 @@
         int length = value.length;
         int right = length;
         while (0 < right) {
-            char ch = (char)(value[right - 1] & 0xff);
+            char ch = getChar(value, right - 1);
             if (ch != ' ' && ch != '\t' && !Character.isWhitespace(ch)) {
                 break;
             }
@@ -573,7 +573,8 @@
             return "";
         }
         int right = lastIndexOfNonWhitespace(value);
-        return ((left > 0) || (right < value.length)) ? newString(value, left, right - left) : null;
+        boolean ifChanged = (left > 0) || (right < value.length);
+        return ifChanged ? newString(value, left, right - left) : null;
     }
 
     public static String stripLeading(byte[] value) {
@@ -597,11 +598,7 @@
         private int index;        // current index, modified on advance/split
         private final int fence;  // one past last index
 
-        LinesSpliterator(byte[] value) {
-            this(value, 0, value.length);
-        }
-
-        LinesSpliterator(byte[] value, int start, int length) {
+        private LinesSpliterator(byte[] value, int start, int length) {
             this.value = value;
             this.index = start;
             this.fence = start + length;
@@ -609,7 +606,7 @@
 
         private int indexOfLineSeparator(int start) {
             for (int current = start; current < fence; current++) {
-                byte ch = value[current];
+                char ch = getChar(value, current);
                 if (ch == '\n' || ch == '\r') {
                     return current;
                 }
@@ -619,9 +616,9 @@
 
         private int skipLineSeparator(int start) {
             if (start < fence) {
-                if (value[start] == '\r') {
+                if (getChar(value, start) == '\r') {
                     int next = start + 1;
-                    if (next < fence && value[next] == '\n') {
+                    if (next < fence && getChar(value, next) == '\n') {
                         return next + 1;
                     }
                 }
@@ -680,10 +677,80 @@
         public int characteristics() {
             return Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL;
         }
+
+        static LinesSpliterator spliterator(byte[] value) {
+            return new LinesSpliterator(value, 0, value.length);
+        }
+
+        static LinesSpliterator spliterator(byte[] value, int leading, int trailing) {
+            int length = value.length;
+            int left = 0;
+            int index;
+            for (int l = 0; l < leading; l++) {
+                index = skipBlankForward(value, left, length);
+                if (index == left) {
+                    break;
+                }
+                left = index;
+            }
+            int right = length;
+            for (int t = 0; t < trailing; t++) {
+                index = skipBlankBackward(value, left, right);
+                if (index == right) {
+                    break;
+                }
+                right = index;
+            }
+            return new LinesSpliterator(value, left, right - left);
+        }
+
+        private static int skipBlankForward(byte[] value, int start, int length) {
+            int index = start;
+            while (index < length) {
+                char ch = getChar(value, index++);
+                if (ch == '\n') {
+                    return index;
+                }
+                if (ch == '\r') {
+                    if (index < length && getChar(value, index) == '\n') {
+                        return index + 1;
+                    }
+                    return index;
+                }
+                if (ch != ' ' && ch != '\t' && !Character.isWhitespace(ch)) {
+                    return start;
+                }
+            }
+            return length;
+        }
+
+        private static int skipBlankBackward(byte[] value, int start, int fence) {
+            int index = fence;
+            if (start < index && getChar(value, index - 1) == '\n') {
+                index--;
+            }
+            if (start < index && getChar(value, index - 1) == '\r') {
+                index--;
+            }
+            while (start < index) {
+                char ch = getChar(value, --index);
+                if (ch == '\r' || ch == '\n') {
+                    return index + 1;
+                }
+                if (ch != ' ' && ch != '\t' && !Character.isWhitespace(ch)) {
+                    return fence;
+                }
+            }
+            return start;
+        }
     }
 
-    static Stream<String> lines(byte[] value) {
-        return StreamSupport.stream(new LinesSpliterator(value), false);
+    static Stream<String> lines(byte[] value, int leading, int trailing) {
+        if (leading == 0 && trailing == 0) {
+            return StreamSupport.stream(LinesSpliterator.spliterator(value), false);
+        } else {
+            return StreamSupport.stream(LinesSpliterator.spliterator(value, leading, trailing), false);
+        }
     }
 
     public static void putChar(byte[] val, int index, int c) {
--- a/src/java.base/share/classes/java/lang/StringUTF16.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/share/classes/java/lang/StringUTF16.java	Thu Sep 13 10:54:11 2018 -0700
@@ -859,7 +859,6 @@
             null;
     }
 
-
     public static int indexOfNonWhitespace(byte[] value) {
         int length = value.length >> 1;
         int left = 0;
@@ -874,7 +873,7 @@
     }
 
     public static int lastIndexOfNonWhitespace(byte[] value) {
-        int length = value.length >> 1;
+        int length = value.length >>> 1;
         int right = length;
         while (0 < right) {
             int codepoint = codePointBefore(value, right);
@@ -887,17 +886,18 @@
     }
 
     public static String strip(byte[] value) {
-        int length = value.length >> 1;
+        int length = value.length >>> 1;
         int left = indexOfNonWhitespace(value);
         if (left == length) {
             return "";
         }
         int right = lastIndexOfNonWhitespace(value);
-        return ((left > 0) || (right < length)) ? newString(value, left, right - left) : null;
+        boolean ifChanged = (left > 0) || (right < length);
+        return ifChanged ? newString(value, left, right - left) : null;
     }
 
     public static String stripLeading(byte[] value) {
-        int length = value.length >> 1;
+        int length = value.length >>> 1;
         int left = indexOfNonWhitespace(value);
         if (left == length) {
             return "";
@@ -906,7 +906,7 @@
     }
 
     public static String stripTrailing(byte[] value) {
-        int length = value.length >> 1;
+        int length = value.length >>> 1;
         int right = lastIndexOfNonWhitespace(value);
         if (right == 0) {
             return "";
@@ -919,11 +919,7 @@
         private int index;        // current index, modified on advance/split
         private final int fence;  // one past last index
 
-        LinesSpliterator(byte[] value) {
-            this(value, 0, value.length >>> 1);
-        }
-
-        LinesSpliterator(byte[] value, int start, int length) {
+        private LinesSpliterator(byte[] value, int start, int length) {
             this.value = value;
             this.index = start;
             this.fence = start + length;
@@ -1002,10 +998,80 @@
         public int characteristics() {
             return Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL;
         }
+
+        static LinesSpliterator spliterator(byte[] value) {
+            return new LinesSpliterator(value, 0, value.length >>> 1);
+        }
+
+        static LinesSpliterator spliterator(byte[] value, int leading, int trailing) {
+            int length = value.length >>> 1;
+            int left = 0;
+            int index;
+            for (int l = 0; l < leading; l++) {
+                index = skipBlankForward(value, left, length);
+                if (index == left) {
+                    break;
+                }
+                left = index;
+            }
+            int right = length;
+            for (int t = 0; t < trailing; t++) {
+                index = skipBlankBackward(value, left, right);
+                if (index == right) {
+                    break;
+                }
+                right = index;
+            }
+            return new LinesSpliterator(value, left, right - left);
+        }
+
+        private static int skipBlankForward(byte[] value, int start, int length) {
+            int index = start;
+            while (index < length) {
+                char ch = getChar(value, index++);
+                if (ch == '\n') {
+                    return index;
+                }
+                if (ch == '\r') {
+                    if (index < length && getChar(value, index) == '\n') {
+                        return index + 1;
+                    }
+                    return index;
+                }
+                if (ch != ' ' && ch != '\t' && !Character.isWhitespace(ch)) {
+                    return start;
+                }
+            }
+            return length;
+        }
+
+        private static int skipBlankBackward(byte[] value, int start, int fence) {
+            int index = fence;
+            if (start < index && getChar(value, index - 1) == '\n') {
+                index--;
+            }
+            if (start < index && getChar(value, index - 1) == '\r') {
+                index--;
+            }
+            while (start < index) {
+                char ch = getChar(value, --index);
+                if (ch == '\r' || ch == '\n') {
+                    return index + 1;
+                }
+                if (ch != ' ' && ch != '\t' && !Character.isWhitespace(ch)) {
+                    return fence;
+                }
+            }
+            return start;
+        }
     }
 
-    static Stream<String> lines(byte[] value) {
-        return StreamSupport.stream(new LinesSpliterator(value), false);
+    static Stream<String> lines(byte[] value, int leading, int trailing) {
+        if (leading == 0 && trailing == 0) {
+            return StreamSupport.stream(LinesSpliterator.spliterator(value), false);
+        } else {
+            return StreamSupport.stream(LinesSpliterator.spliterator(value, leading, trailing), false);
+        }
     }
 
     private static void putChars(byte[] val, int index, char[] str, int off, int end) {
--- a/src/java.base/share/classes/java/lang/module/Configuration.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/share/classes/java/lang/module/Configuration.java	Thu Sep 13 10:54:11 2018 -0700
@@ -601,8 +601,7 @@
                 // push in reverse order
                 for (int i = layer.parents.size() - 1; i >= 0; i--) {
                     Configuration parent = layer.parents.get(i);
-                    if (!visited.contains(parent)) {
-                        visited.add(parent);
+                    if (visited.add(parent)) {
                         stack.push(parent);
                     }
                 }
--- a/src/java.base/share/classes/java/net/CookieManager.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/share/classes/java/net/CookieManager.java	Thu Sep 13 10:54:11 2018 -0700
@@ -241,7 +241,7 @@
         }
 
         // apply sort rule (RFC 2965 sec. 3.3.4)
-        List<String> cookieHeader = sortByPath(cookies);
+        List<String> cookieHeader = sortByPathAndAge(cookies);
 
         return Map.of("Cookie", cookieHeader);
     }
@@ -402,11 +402,12 @@
 
 
     /*
-     * sort cookies with respect to their path: those with more specific Path attributes
-     * precede those with less specific, as defined in RFC 2965 sec. 3.3.4
+     * sort cookies with respect to their path and age: those with more longer Path attributes
+     * precede those with shorter, as defined in RFC 6265. Cookies with the same length
+     * path are distinguished by creation time (older first). Method made PP to enable testing.
      */
-    private List<String> sortByPath(List<HttpCookie> cookies) {
-        Collections.sort(cookies, new CookiePathComparator());
+    static List<String> sortByPathAndAge(List<HttpCookie> cookies) {
+        Collections.sort(cookies, new CookieComparator());
 
         List<String> cookieHeader = new java.util.ArrayList<>();
         for (HttpCookie cookie : cookies) {
@@ -424,22 +425,36 @@
     }
 
 
-    static class CookiePathComparator implements Comparator<HttpCookie> {
+    // Comparator compares the length of the path. Longer paths should precede shorter ones.
+    // As per rfc6265 cookies with equal path lengths sort on creation time.
+
+    static class CookieComparator implements Comparator<HttpCookie> {
         public int compare(HttpCookie c1, HttpCookie c2) {
             if (c1 == c2) return 0;
             if (c1 == null) return -1;
             if (c2 == null) return 1;
 
-            // path rule only applies to the cookies with same name
-            if (!c1.getName().equals(c2.getName())) return 0;
+            String p1 = c1.getPath();
+            String p2 = c2.getPath();
+            p1 = (p1 == null) ? "" : p1;
+            p2 = (p2 == null) ? "" : p2;
+            int len1 = p1.length();
+            int len2 = p2.length();
+            if (len1 > len2)
+                return -1;
+            if (len2 > len1)
+                return 1;
 
-            // those with more specific Path attributes precede those with less specific
-            if (c1.getPath().startsWith(c2.getPath()))
+            // Check creation time. Sort older first
+            long creation1 = c1.getCreationTime();
+            long creation2 = c2.getCreationTime();
+            if (creation1 < creation2) {
                 return -1;
-            else if (c2.getPath().startsWith(c1.getPath()))
+            }
+            if (creation1 > creation2) {
                 return 1;
-            else
-                return 0;
+            }
+            return 0;
         }
     }
 }
--- a/src/java.base/share/classes/java/net/HttpCookie.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/share/classes/java/net/HttpCookie.java	Thu Sep 13 10:54:11 2018 -0700
@@ -142,6 +142,13 @@
     }
 
     private HttpCookie(String name, String value, String header) {
+        this(name, value, header, System.currentTimeMillis());
+    }
+
+    /**
+     * Package private for testing purposes.
+     */
+    HttpCookie(String name, String value, String header, long creationTime) {
         name = name.trim();
         if (name.length() == 0 || !isToken(name) || name.charAt(0) == '$') {
             throw new IllegalArgumentException("Illegal cookie name");
@@ -152,7 +159,7 @@
         toDiscard = false;
         secure = false;
 
-        whenCreated = System.currentTimeMillis();
+        whenCreated = creationTime;
         portlist = null;
         this.header = header;
     }
@@ -756,6 +763,11 @@
             throw new RuntimeException(e.getMessage());
         }
     }
+    // ---------------- Package private operations --------------
+
+    long getCreationTime() {
+        return whenCreated;
+    }
 
     // ---------------- Private operations --------------
 
--- a/src/java.base/share/classes/java/net/URLClassLoader.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/share/classes/java/net/URLClassLoader.java	Thu Sep 13 10:54:11 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/charset/Charset-X-Coder.java.template	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/share/classes/java/nio/charset/Charset-X-Coder.java.template	Thu Sep 13 10:54:11 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/security/SecureClassLoader.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/share/classes/java/security/SecureClassLoader.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/share/classes/java/util/Calendar.java	Thu Sep 13 10:54:11 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/java/util/ServiceLoader.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/share/classes/java/util/ServiceLoader.java	Thu Sep 13 10:54:11 2018 -0700
@@ -938,8 +938,7 @@
                     List<ModuleLayer> parents = layer.parents();
                     for (int i = parents.size() - 1; i >= 0; i--) {
                         ModuleLayer parent = parents.get(i);
-                        if (!visited.contains(parent)) {
-                            visited.add(parent);
+                        if (visited.add(parent)) {
                             stack.push(parent);
                         }
                     }
--- a/src/java.base/share/classes/java/util/stream/DistinctOps.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/share/classes/java/util/stream/DistinctOps.java	Thu Sep 13 10:54:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, 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
@@ -170,8 +170,7 @@
 
                         @Override
                         public void accept(T t) {
-                            if (!seen.contains(t)) {
-                                seen.add(t);
+                            if (seen.add(t)) {
                                 downstream.accept(t);
                             }
                         }
--- a/src/java.base/share/classes/sun/security/ssl/PskKeyExchangeModesExtension.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/share/classes/sun/security/ssl/PskKeyExchangeModesExtension.java	Thu Sep 13 10:54:11 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");
Binary file src/java.base/share/lib/security/cacerts has changed
--- a/src/java.base/share/native/libjava/io_util.c	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/share/native/libjava/io_util.c	Thu Sep 13 10:54:11 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/unix/native/libjsig/jsig.c	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.base/unix/native/libjsig/jsig.c	Thu Sep 13 10:54:11 2018 -0700
@@ -29,6 +29,18 @@
  * Used for signal-chaining. See RFE 4381843.
  */
 
+#include "jni.h"
+
+#ifdef SOLARIS
+/* Our redeclarations of the system functions must not have a less
+ * restrictive linker scoping, so we have to declare them as JNIEXPORT
+ * before including signal.h */
+#include "sys/signal.h"
+JNIEXPORT void (*signal(int sig, void (*disp)(int)))(int);
+JNIEXPORT void (*sigset(int sig, void (*disp)(int)))(int);
+JNIEXPORT int sigaction(int sig, const struct sigaction *act, struct sigaction *oact);
+#endif
+
 #include <dlfcn.h>
 #include <errno.h>
 #include <pthread.h>
@@ -208,7 +220,7 @@
   }
 }
 
-sa_handler_t signal(int sig, sa_handler_t disp) {
+JNIEXPORT sa_handler_t signal(int sig, sa_handler_t disp) {
   if (sig < 0 || sig >= MAX_SIGNALS) {
     errno = EINVAL;
     return SIG_ERR;
@@ -217,7 +229,7 @@
   return set_signal(sig, disp, false);
 }
 
-sa_handler_t sigset(int sig, sa_handler_t disp) {
+JNIEXPORT sa_handler_t sigset(int sig, sa_handler_t disp) {
 #ifdef _ALLBSD_SOURCE
   printf("sigset() is not supported by BSD");
   exit(0);
@@ -243,7 +255,7 @@
   return (*os_sigaction)(sig, act, oact);
 }
 
-int sigaction(int sig, const struct sigaction *act, struct sigaction *oact) {
+JNIEXPORT int sigaction(int sig, const struct sigaction *act, struct sigaction *oact) {
   int res;
   bool sigused;
   struct sigaction oldAct;
--- a/src/java.desktop/share/native/libmlib_image/mlib_ImageLookUp_Bit.c	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.desktop/share/native/libmlib_image/mlib_ImageLookUp_Bit.c	Thu Sep 13 10:54:11 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.desktop/windows/native/common/awt_makecube.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,442 +0,0 @@
-/*
- * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
- * 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.
- */
-
-#include "awt.h"
-#include "awt_image.h"
-
-extern "C" {
-#include "img_colors.h"
-} // extern "C"
-
-char *programname = "awt_makecube";
-
-unsigned char cube[LOOKUPSIZE * LOOKUPSIZE * LOOKUPSIZE];
-
-unsigned char reds[256], greens[256], blues[256], indices[256];
-int num_colors;
-
-PALETTEENTRY sysPal[256];
-
-int sys2cmap[256];
-int cmap2sys[256];
-int error[256];
-
-int cmapsize = 0;
-int virtcubesize = 0;
-int makecube_verbose = 0;
-
-void printPalette(char *label, HPALETTE hPal);
-
-void usage(char *errmsg)
-{
-    fprintf(stderr, "%s\n", errmsg);
-    fprintf(stderr, "usage: %s [-cmapsize N] [-cubesize N]\n", programname);
-    fprintf(stderr, "\t-cmapsize N   set the number of colors to allocate\n");
-    fprintf(stderr, "\t              in the colormap (2 <= N <= 256)\n");
-    fprintf(stderr, "\t-cubesize N   set the size of the cube of colors to\n");
-    fprintf(stderr, "                scan as potential entries in the cmap\n");
-    fprintf(stderr, "                (N must be a power of 2 and <= 32)\n");
-    exit(1);
-}
-
-void setsyscolor(int index, int red, int green, int blue)
-{
-    if (index >= 0) {
-        if (sysPal[index].peFlags != 0) {
-            usage("Internal error: system palette conflict");
-        }
-    } else {
-        for (int i = 0; i < 256; i++) {
-            if (sysPal[i].peFlags != 0) {
-                if (sysPal[i].peRed   == red &&
-                    sysPal[i].peGreen == green &&
-                    sysPal[i].peBlue  == blue)
-                {
-                    // Already there.  Ignore it.
-                    return;
-                }
-            } else if (index < 0) {
-                index = i;
-            }
-        }
-        if (index < 0) {
-            usage("Internal error: ran out of system palette entries");
-        }
-    }
-    sysPal[index].peRed   = red;
-    sysPal[index].peGreen = green;
-    sysPal[index].peBlue  = blue;
-    sysPal[index].peFlags = 1;
-}
-
-void addcmapcolor(int red, int green, int blue)
-{
-    for (int i = 0; i < num_colors; i++) {
-        if (red == reds[i] && green == greens[i] && blue == blues[i]) {
-            return;
-        }
-    }
-    if (num_colors >= cmapsize) {
-        usage("Internal error: more than cmapsize static colors defined");
-    }
-    reds[num_colors]   = red;
-    greens[num_colors] = green;
-    blues[num_colors]  = blue;
-    num_colors++;
-}
-
-int main(int argc, char **argv)
-{
-    int i;
-
-    programname = argv[0];
-
-    for (i = 1; i < argc; i++) {
-        if (strcmp(argv[i], "-cmapsize") == 0) {
-            if (i++ >= argc) {
-                usage("no argument to -cmapsize");
-            }
-            cmapsize = atoi(argv[i]);
-            if (cmapsize <= 2 || cmapsize > 256) {
-                usage("colormap size must be between 2 and 256");
-            }
-        } else if (strcmp(argv[1], "-cubesize") == 0) {
-            if (i++ >= argc) {
-                usage("no argument to -cubesize");
-            }
-            virtcubesize = atoi(argv[i]);
-            if (virtcubesize == 0 ||
-                (virtcubesize & (virtcubesize - 1)) != 0 ||
-                virtcubesize > 32)
-            {
-                usage("cube size must by a power of 2 <= 32");
-            }
-        } else if (strcmp(argv[i], "-verbose") == 0) {
-            makecube_verbose = 1;
-        } else {
-            usage("unknown argument");
-        }
-    }
-
-    if (cmapsize == 0) {
-        cmapsize = CMAPSIZE;
-    }
-    if (virtcubesize == 0) {
-        virtcubesize = VIRTCUBESIZE;
-    }
-
-    if (0) {  // For testing
-        HDC hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
-        HPALETTE hPal = CreateHalftonePalette(hDC);
-        printPalette("Halftone palette for current display", hPal);
-        printPalette("Stock DEFAULT_PALETTE", (HPALETTE)GetStockObject(DEFAULT_PALETTE));
-        BITMAPINFOHEADER bmInfo = {
-            sizeof(BITMAPINFOHEADER), 1, 1, 1, 8, BI_RGB, 0, 1000, 1000, 0, 0
-            };
-        HBITMAP hBitmap = CreateDIBitmap(hDC, &bmInfo,
-                                         0, NULL, NULL, DIB_RGB_COLORS);
-        HDC hMemDC = CreateCompatibleDC(hDC);
-        SelectObject(hDC, hBitmap);
-        hPal = CreateHalftonePalette(hMemDC);
-        printPalette("Halftone palette for 8-bit DIBitmap", hPal);
-        exit(0);
-    }
-
-    // Allocate Windows static system colors.
-    {
-        PALETTEENTRY palEntries[256];
-        HPALETTE hPal = (HPALETTE)GetStockObject(DEFAULT_PALETTE);
-        int n = GetPaletteEntries(hPal, 0, 256, palEntries);
-        for (i = 0; i < n; i++) {
-            addcmapcolor(palEntries[i].peRed,
-                         palEntries[i].peGreen,
-                         palEntries[i].peBlue);
-            setsyscolor((i < n / 2) ? i : i + (256 - n),
-                        palEntries[i].peRed,
-                        palEntries[i].peGreen,
-                        palEntries[i].peBlue);
-        }
-    }
-
-    // Allocate java.awt.Color constant colors.
-    addcmapcolor(  0,   0,   0);        // black
-    addcmapcolor(255, 255, 255);        // white
-    addcmapcolor(255,   0,   0);        // red
-    addcmapcolor(  0, 255,   0);        // green
-    addcmapcolor(  0,   0, 255);        // blue
-    addcmapcolor(255, 255,   0);        // yellow
-    addcmapcolor(255,   0, 255);        // magenta
-    addcmapcolor(  0, 255, 255);        // cyan
-    addcmapcolor(192, 192, 192);        // lightGray
-    addcmapcolor(128, 128, 128);        // gray
-    addcmapcolor( 64,  64,  64);        // darkGray
-    addcmapcolor(255, 175, 175);        // pink
-    addcmapcolor(255, 200,   0);        // orange
-
-    img_makePalette(cmapsize, virtcubesize, LOOKUPSIZE,
-                    50.0f, 250.0f,
-                    num_colors, TRUE, reds, greens, blues, cube);
-
-    if (makecube_verbose) {
-        fprintf(stderr, "Calculated colormap:\n");
-        for (i = 0; i < cmapsize; i++) {
-            fprintf(stderr, "%3d:(%3d,%3d,%3d)   ",
-                    i, reds[i], greens[i], blues[i]);
-        }
-        fprintf(stderr, "\n");
-    }
-
-    // Now simulate adding the halftone palette to the system
-    // palette to get an idea of palette ordering.
-    {
-        int cubevals[6] = {0, 44, 86, 135, 192, 255};
-        for (int b = 0; b < 6; b++) {
-            for (int g = 0; g < 6; g++) {
-                for (int r = 0; r < 6; r++) {
-                    setsyscolor(-1, cubevals[r], cubevals[g], cubevals[b]);
-                }
-            }
-        }
-        int grayvals[26] = {  0,  17,  24,  30,  37,  44,  52,  60,
-                             68,  77,  86,  95, 105, 114, 125, 135,
-                            146, 157, 168, 180, 192, 204, 216, 229,
-                            242, 255 };
-        for (i = 0; i < 26; i++) {
-            setsyscolor(-1, grayvals[i], grayvals[i], grayvals[i]);
-        }
-    }
-
-    if (makecube_verbose) {
-        fprintf(stderr, "System palette with simulated halftone palette:\n");
-        for (i = 0; i < 256; i++) {
-            fprintf(stderr, "%3d:(%3d,%3d,%3d)   ",
-                    i, sysPal[i].peRed, sysPal[i].peGreen, sysPal[i].peBlue);
-        }
-    }
-
-    if (makecube_verbose) {
-        HDC hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
-        HPALETTE hPal = CreateHalftonePalette(hDC);
-        SelectPalette(hDC, hPal, FALSE);
-        RealizePalette(hDC);
-        PALETTEENTRY palEntries[256];
-        int n = GetSystemPaletteEntries(hDC, 0, 256, palEntries);
-        fprintf(stderr,
-                "realized halftone palette reads back %d entries\n", n);
-        int broken = 0;
-        for (i = 0; i < 256; i++) {
-            char *msg1 = "";
-            char *msg2 = "";
-            if (palEntries[i].peRed != sysPal[i].peRed ||
-                palEntries[i].peGreen != sysPal[i].peGreen ||
-                palEntries[i].peBlue != sysPal[i].peBlue)
-            {
-                msg1 = "no sysPal match!";
-                if (sysPal[i].peFlags == 0) {
-                    msg2 = "(OK)";
-                } else {
-                    broken++;
-                }
-            } else if (sysPal[i].peFlags == 0) {
-                msg1 = "no sysPal entry...";
-            }
-            fprintf(stderr,
-                    "palEntries[%3d] = (%3d, %3d, %3d), flags = %d  %s %s\n",
-                    i,
-                    palEntries[i].peRed,
-                    palEntries[i].peGreen,
-                    palEntries[i].peBlue,
-                    palEntries[i].peFlags, msg1, msg2);
-        }
-        fprintf(stderr, "%d broken entries\n", broken);
-    }
-
-#if 0
-#define BIGERROR (255 * 255 * 255)
-
-    for (i = 0; i < 256; i++) {
-        sys2cmap[i] = -1;
-        cmap2sys[i] = -1;
-        error[i] = BIGERROR;
-        // error[i] = -1 means cmap[i] is locked to cmap2sys[i]
-        // error[i] >= 0 means cmap[i] may lock to cmap2sys[i] on this run
-    }
-
-    int nummapped;
-    int totalmapped = 0;
-    do {
-        int maxerror = BIGERROR;
-        for (i = 0; i < 256; i++) {
-            if (sysPal[i].peFlags == 0 || sys2cmap[i] >= 0) {
-                continue;
-            }
-            int red   = sysPal[i].peRed;
-            int green = sysPal[i].peGreen;
-            int blue  = sysPal[i].peBlue;
-            int e = maxerror;
-            int ix = -1;
-            for (int j = 0; j < 256; j++) {
-                if (error[j] < 0) {
-                    continue;
-                }
-                int t = red - reds[j];
-                int d = t * t;
-                t = green - greens[j];
-                d += t * t;
-                t = blue - blues[j];
-                d += t * t;
-                if (d < e) {
-                    e = d;
-                    ix = j;
-                }
-            }
-            if (ix >= 0) {
-                if (e < error[ix]) {
-                    if (cmap2sys[ix] >= 0) {
-                        // To be fair we will not accept any matches
-                        // looser than this former match that we just
-                        // displaced with a better match.
-                        if (maxerror > error[ix]) {
-                            maxerror = error[ix];
-                        }
-                        sys2cmap[cmap2sys[ix]] = -1;
-                    }
-                    error[ix] = e;
-                    sys2cmap[i] = ix;
-                    cmap2sys[ix] = i;
-                }
-            }
-        }
-        nummapped = 0;
-        for (i = 0; i < 256; i++) {
-            if (error[i] >= 0) {
-                if (error[i] >= maxerror) {
-                    // Throw this one back to be fair to a displaced entry.
-                    error[i] = BIGERROR;
-                    sys2cmap[cmap2sys[i]] = -1;
-                    cmap2sys[i] = -1;
-                    continue;
-                }
-                error[i] = -1;
-                nummapped++;
-            }
-        }
-        totalmapped += nummapped;
-        if (makecube_verbose) {
-            fprintf(stderr, "%3d colors mapped (%3d total), maxerror = %d\n",
-                    nummapped, totalmapped, maxerror);
-        }
-    } while (nummapped != 0);
-
-    for (i = 0; i < 256; i++) {
-        if (cmap2sys[i] < 0) {
-            for (int j = 0; j < 256; j++) {
-                if (sys2cmap[j] < 0) {
-                    cmap2sys[i] = j;
-                    sys2cmap[j] = i;
-                    break;
-                }
-            }
-            if (j == 256) {
-                usage("Internal error: no unused system entry for cmap entry!\n");
-            }
-        }
-    }
-#else
-    for (i = 0; i < 256; i++) {
-        if (i < 10) {
-            sys2cmap[i] = i;
-            cmap2sys[i] = i;
-        } else if (i < 20) {
-            sys2cmap[256 - 20 + i] = i;
-            cmap2sys[i] = 256 - 20 + i;
-        } else {
-            sys2cmap[i - 10] = i;
-            cmap2sys[i] = i - 10;
-        }
-    }
-#endif
-
-    if (makecube_verbose) {
-        fprintf(stderr, "cmap2sys mapping: \n");
-        for (i = 0; i < 256; i++) {
-            fprintf(stderr, "%4d", cmap2sys[i]);
-            if (sys2cmap[cmap2sys[i]] != i) {
-                usage("Internal error: bad system palette back pointer!\n");
-            }
-        }
-        fprintf(stderr, "\n");
-    }
-
-    printf("unsigned char awt_reds[256] = {");
-    for (i = 0; i < 256; i++) {
-        if ((i & 0xf) == 0) printf("\n\t");
-        printf("%3d,", reds[sys2cmap[i]]);
-    }
-    printf("\n};\n");
-    printf("unsigned char awt_greens[256] = {");
-    for (i = 0; i < 256; i++) {
-        if ((i & 0xf) == 0) printf("\n\t");
-        printf("%3d,", greens[sys2cmap[i]]);
-    }
-    printf("\n};\n");
-    printf("unsigned char awt_blues[256] = {");
-    for (i = 0; i < 256; i++) {
-        if ((i & 0xf) == 0) printf("\n\t");
-        printf("%3d,", blues[sys2cmap[i]]);
-    }
-    printf("\n};\n");
-    fflush(stdout);
-    return 0;
-}
-
-void printPalette(char *label, HPALETTE hPal)
-{
-    PALETTEENTRY palEntries[256];
-    fprintf(stderr, "%s (0x%08x):\n", label, hPal);
-    int n = GetPaletteEntries(hPal, 0, 256, palEntries);
-    for (int i = 0; i < n; i++) {
-        fprintf(stderr, "palEntries[%3d] = (%3d, %3d, %3d), flags = %d\n",
-                i,
-                palEntries[i].peRed,
-                palEntries[i].peGreen,
-                palEntries[i].peBlue,
-                palEntries[i].peFlags);
-    }
-}
-
-/* This helps eliminate any dependence on javai.dll at build time. */
-int
-jio_fprintf (FILE *handle, const char *format, ...)
-{
-    int len;
-
-    va_list args;
-    va_start(args, format);
-    len = vfprintf(handle, format, args);
-    va_end(args);
-
-    return len;
-}
--- a/src/java.naming/share/classes/com/sun/jndi/ldap/LdapClient.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/java.naming/share/classes/com/sun/jndi/ldap/LdapClient.java	Thu Sep 13 10:54:11 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
@@ -115,7 +115,7 @@
     boolean isLdapv3;         // Used by LdapCtx
     int referenceCount = 1;   // Used by LdapCtx for check for sharing
 
-    Connection conn;  // Connection to server; has reader thread
+    final Connection conn;  // Connection to server; has reader thread
                       // used by LdapCtx for StartTLS
 
     final private PoolCallback pcb;
@@ -433,19 +433,16 @@
             (new Throwable()).printStackTrace();
         }
 
-        if (referenceCount <= 0 && conn != null) {
+        if (referenceCount <= 0) {
             if (debug > 0) System.err.println("LdapClient: closed connection " + this);
             if (!pooled) {
                 // Not being pooled; continue with closing
                 conn.cleanup(reqCtls, false);
-                conn = null;
             } else {
                 // Pooled
-
                 // Is this a real close or a request to return conn to pool
                 if (hardClose) {
                     conn.cleanup(reqCtls, false);
-                    conn = null;
                     pcb.removePooledConnection(this);
                 } else {
                     pcb.releasePooledConnection(this);
@@ -461,16 +458,13 @@
         if (debug > 1) {
             System.err.println("LdapClient: forceClose() of " + this);
         }
-
-        if (conn != null) {
-            if (debug > 0) System.err.println(
-                "LdapClient: forced close of connection " + this);
-            conn.cleanup(null, false);
-            conn = null;
-
-            if (cleanPool) {
-                pcb.removePooledConnection(this);
-            }
+        if (debug > 0) {
+            System.err.println(
+                    "LdapClient: forced close of connection " + this);
+        }
+        conn.cleanup(null, false);
+        if (cleanPool) {
+            pcb.removePooledConnection(this);
         }
     }
 
@@ -568,7 +562,7 @@
      * Abandon the search operation and remove it from the message queue.
      */
     void clearSearchReply(LdapResult res, Control[] ctls) {
-        if (res != null && conn != null) {
+        if (res != null) {
 
             // Only send an LDAP abandon operation when clearing the search
             // reply from a one-level or subtree search.
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiledClass.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiledClass.java	Thu Sep 13 10:54:11 2018 -0700
@@ -74,7 +74,7 @@
             this.dependentMethods = new ArrayList<>();
             this.classId = classId;
             this.type = type;
-            this.metadataName = type.isUnsafeAnonymous() ? "anon<" + classId + ">" : type.getName();
+            this.metadataName = type.isAnonymous() ? "anon<" + classId + ">" : type.getName();
             this.gotIndex = binaryContainer.addTwoSlotKlassSymbol(metadataName);
             this.compiledMethodsOffset = -1; // Not compiled classes do not have compiled methods.
             this.dependentMethodsOffset = -1;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java	Thu Sep 13 10:54:11 2018 -0700
@@ -167,7 +167,8 @@
     public boolean isPreview(Feature feature) {
         if (feature == Feature.SWITCH_EXPRESSION ||
             feature == Feature.SWITCH_MULTIPLE_CASE_LABELS ||
-            feature == Feature.SWITCH_RULE)
+            feature == Feature.SWITCH_RULE ||
+            feature == Feature.RAW_STRING_LITERALS)
             return true;
         //Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing).
         //When real preview features will be added, this method can be implemented to return 'true'
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Thu Sep 13 10:54:11 2018 -0700
@@ -183,7 +183,8 @@
         IMPORT_ON_DEMAND_OBSERVABLE_PACKAGES(JDK1_2, JDK8),
         SWITCH_MULTIPLE_CASE_LABELS(JDK12, Fragments.FeatureMultipleCaseLabels, DiagKind.PLURAL),
         SWITCH_RULE(JDK12, Fragments.FeatureSwitchRules, DiagKind.PLURAL),
-        SWITCH_EXPRESSION(JDK12, Fragments.FeatureSwitchExpressions, DiagKind.PLURAL);
+        SWITCH_EXPRESSION(JDK12, Fragments.FeatureSwitchExpressions, DiagKind.PLURAL),
+        RAW_STRING_LITERALS(JDK12, Fragments.FeatureRawStringLiterals, DiagKind.PLURAL);
 
         enum DiagKind {
             NORMAL,
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Thu Sep 13 10:54:11 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/ArgumentAttr.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java	Thu Sep 13 10:54:11 2018 -0700
@@ -280,8 +280,9 @@
         if (!res.kind.isResolutionError()) {
             tree.sym = res;
         }
-        if (res.kind.isResolutionTargetError() ||
-                res.type != null && res.type.hasTag(FORALL) ||
+        if (res.kind.isResolutionTargetError()) {
+             tree.setOverloadKind(JCMemberReference.OverloadKind.ERROR);
+        } else if (res.type != null && res.type.hasTag(FORALL) ||
                 (res.flags() & Flags.VARARGS) != 0 ||
                 (TreeInfo.isStaticSelector(exprTree, tree.name.table.names) &&
                 exprTree.type.isRaw() && !exprTree.type.hasTag(ARRAY))) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Thu Sep 13 10:54:11 2018 -0700
@@ -169,7 +169,7 @@
                         @Override
                         public void setOverloadKind(OverloadKind overloadKind) {
                             OverloadKind previous = t.getOverloadKind();
-                            if (previous == null) {
+                            if (previous == null || previous == OverloadKind.ERROR) {
                                 t.setOverloadKind(overloadKind);
                             } else {
                                 Assert.check(previous == overloadKind);
@@ -1240,7 +1240,7 @@
             Type descType = types.findDescriptorType(pt);
             List<Type> freeArgVars = inferenceContext.freeVarsIn(descType.getParameterTypes());
             if (freeArgVars.nonEmpty() &&
-                    tree.getOverloadKind() == JCMemberReference.OverloadKind.OVERLOADED) {
+                    tree.getOverloadKind() != JCMemberReference.OverloadKind.UNOVERLOADED) {
                 stuckVars.addAll(freeArgVars);
                 depVars.addAll(inferenceContext.freeVarsIn(descType.getReturnType()));
             }
@@ -1305,7 +1305,7 @@
         @Override
         public void visitReference(JCMemberReference tree) {
             super.visitReference(tree);
-            if (tree.getOverloadKind() == JCMemberReference.OverloadKind.OVERLOADED) {
+            if (tree.getOverloadKind() != JCMemberReference.OverloadKind.UNOVERLOADED) {
                 stuck = true;
             }
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Thu Sep 13 10:54:11 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/jvm/ClassReader.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Sep 13 10:54:11 2018 -0700
@@ -2466,6 +2466,9 @@
     }
 
     private List<Type> adjustMethodParams(long flags, List<Type> args) {
+        if (args.isEmpty()) {
+            return args;
+        }
         boolean isVarargs = (flags & VARARGS) != 0;
         if (isVarargs) {
             Type varargsElem = args.last();
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java	Thu Sep 13 10:54:11 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/parser/JavaTokenizer.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java	Thu Sep 13 10:54:11 2018 -0700
@@ -646,6 +646,59 @@
                         lexError(pos, Errors.UnclosedStrLit);
                     }
                     break loop;
+                case '`':
+                    checkSourceLevel(pos, Feature.RAW_STRING_LITERALS);
+                    // Ensure that the backtick was not a Unicode escape sequence
+                    if (reader.peekBack() != '`') {
+                        reader.scanChar();
+                        lexError(pos, Errors.UnicodeBacktick);
+                        break loop;
+                    }
+                    // Turn off unicode processsing and save previous state
+                    boolean oldState = reader.setUnicodeConversion(false);
+                    // Count the number of backticks in the open quote sequence
+                    int openCount = reader.skipRepeats();
+                    // Skip last backtick
+                    reader.scanChar();
+                    while (reader.bp < reader.buflen) {
+                        // If potential close quote sequence
+                        if (reader.ch == '`') {
+                            // Count number of backticks in sequence
+                            int closeCount = reader.skipRepeats();
+                            // If the counts match we can exit the raw string literal
+                            if (openCount == closeCount) {
+                                break;
+                            }
+                            // Emit non-close backtick sequence
+                            for (int i = 0; i <= closeCount; i++) {
+                                reader.putChar('`', false);
+                            }
+                            // Skip last backtick
+                            reader.scanChar();
+                        } else if (reader.ch == LF) {
+                            reader.putChar(true);
+                            processLineTerminator(pos, reader.bp);
+                        } else if (reader.ch == CR) {
+                            if (reader.peekChar() == LF) {
+                                reader.scanChar();
+                            }
+                            // Translate CR and CRLF sequences to LF
+                            reader.putChar('\n', true);
+                            processLineTerminator(pos, reader.bp);
+                        } else {
+                            reader.putChar(true);
+                        }
+                    }
+                    // Restore unicode processsing
+                    reader.setUnicodeConversion(oldState);
+                    // Ensure the close quote was encountered
+                    if (reader.bp == reader.buflen) {
+                        lexError(pos, Errors.UnclosedStrLit);
+                    } else {
+                        tk = TokenKind.STRINGLITERAL;
+                        reader.scanChar();
+                    }
+                    break loop;
                 default:
                     if (isSpecial(reader.ch)) {
                         scanOperator();
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/UnicodeReader.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/UnicodeReader.java	Thu Sep 13 10:54:11 2018 -0700
@@ -64,6 +64,10 @@
      */
     protected int unicodeConversionBp = -1;
 
+    /** Control conversion of unicode characters
+     */
+    protected boolean unicodeConversion = true;
+
     protected Log log;
     protected Names names;
 
@@ -154,11 +158,17 @@
         return new String(sbuf, 0, sp);
     }
 
+    protected boolean setUnicodeConversion(boolean newState) {
+        boolean oldState = unicodeConversion;
+        unicodeConversion = newState;
+        return oldState;
+    }
+
     /** Convert unicode escape; bp points to initial '\' character
      *  (Spec 3.3).
      */
     protected void convertUnicode() {
-        if (ch == '\\' && unicodeConversionBp != bp) {
+        if (ch == '\\' && unicodeConversion && unicodeConversionBp != bp ) {
             bp++; ch = buf[bp];
             if (ch == 'u') {
                 do {
@@ -254,6 +264,24 @@
         return buf[bp + 1];
     }
 
+    protected char peekBack() {
+        return buf[bp];
+    }
+
+    /**
+     * Skips consecutive occurrences of the current character, leaving bp positioned
+     * at the last occurrence. Returns the occurrence count.
+     */
+    protected int skipRepeats() {
+        int start = bp;
+        while (bp < buflen) {
+            if (buf[bp] != buf[bp + 1])
+                break;
+            bp++;
+        }
+        return bp - start;
+    }
+
     /**
      * Returns a copy of the input buffer, up to its inputLength.
      * Unicode escape sequences are not translated.
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Sep 13 10:54:11 2018 -0700
@@ -1232,6 +1232,9 @@
 compiler.err.unclosed.str.lit=\
     unclosed string literal
 
+compiler.err.unicode.backtick=\
+    attempt to use \\u0060 as a raw string literal delimiter
+
 # 0: string
 compiler.err.unsupported.encoding=\
     unsupported encoding: {0}
@@ -2826,6 +2829,9 @@
 compiler.misc.feature.switch.expressions=\
     switch expressions
 
+compiler.misc.feature.raw.string.literals=\
+    raw string literals
+
 compiler.warn.underscore.as.identifier=\
     as of release 9, ''_'' is a keyword, and may not be used as an identifier
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Sep 13 10:54:11 2018 -0700
@@ -2217,7 +2217,8 @@
 
         public enum OverloadKind {
             OVERLOADED,
-            UNOVERLOADED
+            UNOVERLOADED,
+            ERROR
         }
 
         /**
--- a/src/jdk.internal.ed/share/classes/jdk/internal/editor/external/ExternalEditor.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.internal.ed/share/classes/jdk/internal/editor/external/ExternalEditor.java	Thu Sep 13 10:54:11 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.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectType.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectType.java	Thu Sep 13 10:54:11 2018 -0700
@@ -110,6 +110,21 @@
     @Override
     ResolvedJavaMethod getClassInitializer();
 
+    /**
+     * Checks whether this type is an unsafe anonymous class.
+     *
+     * @return {@code true} if this type is an unsafe anonymous class
+     */
     boolean isUnsafeAnonymous();
 
+    /**
+     * Checks whether this type is an unsafe anonymous class.
+     * This method is here to maintain compatibility with JDK11.
+     *
+     * @return {@code true} if this type is an unsafe anonymous class
+     */
+    default boolean isAnonymous() {
+      return isUnsafeAnonymous();
+    }
+
 }
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java	Thu Sep 13 10:54:11 2018 -0700
@@ -325,9 +325,6 @@
                 }
             } else {
                 jf = new JarFile(f, false, ZipFile.OPEN_READ, version);
-                if (!jf.isMultiRelease()) {
-                    throw new MultiReleaseException("err.multirelease.option.exists", f.getName());
-                }
             }
             return jf;
         }
--- a/test/hotspot/gtest/utilities/test_singleWriterSynchronizer.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/gtest/utilities/test_singleWriterSynchronizer.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -54,13 +54,16 @@
   {}
 
   virtual void main_run() {
-    uintx iterations = 0;
+    size_t iterations = 0;
+    size_t values_changed = 0;
     while (OrderAccess::load_acquire(_continue_running) != 0) {
+      { ThreadBlockInVM tbiv(this); } // Safepoint check outside critical section.
       ++iterations;
       SingleWriterSynchronizer::CriticalSection cs(_synchronizer);
       uintx value = OrderAccess::load_acquire(_synchronized_value);
+      uintx new_value = value;
       for (uint i = 0; i < reader_iterations; ++i) {
-        uintx new_value = OrderAccess::load_acquire(_synchronized_value);
+        new_value = OrderAccess::load_acquire(_synchronized_value);
         // A reader can see either the value it first read after
         // entering the critical section, or that value + 1.  No other
         // values are possible.
@@ -68,8 +71,12 @@
           ASSERT_EQ((value + 1), new_value);
         }
       }
+      if (value != new_value) {
+        ++values_changed;
+      }
     }
-    tty->print_cr("reader iterations: " UINTX_FORMAT, iterations);
+    tty->print_cr("reader iterations: " SIZE_FORMAT ", changes: " SIZE_FORMAT,
+                  iterations, values_changed);
   }
 };
 
@@ -93,13 +100,14 @@
     while (OrderAccess::load_acquire(_continue_running) != 0) {
       ++*_synchronized_value;
       _synchronizer->synchronize();
+      { ThreadBlockInVM tbiv(this); } // Safepoint check.
     }
     tty->print_cr("writer iterations: " UINTX_FORMAT, *_synchronized_value);
   }
 };
 
 const uint nreaders = 5;
-const uint milliseconds_to_run = 3000;
+const uint milliseconds_to_run = 1000;
 
 TEST_VM(TestSingleWriterSynchronizer, stress) {
   Semaphore post;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/ProblemList-Xcomp.txt	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,31 @@
+#
+# 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.
+#
+
+#############################################################################
+#
+# List of quarantined tests for testing in Xcomp mode.
+#
+#############################################################################
+
+vmTestbase/vm/mlvm/meth/stress/jni/nativeAndMH/Test.java 8208235 solaris-all
+runtime/appcds/cacheObject/DifferentHeapSizes.java 8210102 solaris-all
--- a/test/hotspot/jtreg/ProblemList-graal.txt	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/ProblemList-graal.txt	Thu Sep 13 10:54:11 2018 -0700
@@ -147,9 +147,6 @@
 
 vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/TestDescription.java         8051349   generic-all
 
-runtime/appcds/cacheObject/ArchivedModuleCompareTest.java                          8209534   generic-all
-runtime/appcds/cacheObject/ArchivedModuleComboTest.java                            8209534   generic-all
-
 serviceability/jvmti/FieldAccessWatch/FieldAccessWatch.java                        8202482   generic-all
 
 compiler/stable/TestStableBoolean.java                           8204347   generic-all
--- a/test/hotspot/jtreg/ProblemList.txt	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/ProblemList.txt	Thu Sep 13 10:54:11 2018 -0700
@@ -181,7 +181,6 @@
 vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted003/TestDescription.java 6606767 generic-all
 vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted004/TestDescription.java 7013634,6606767 generic-all
 vmTestbase/nsk/jvmti/ThreadStart/threadstart001/TestDescription.java 8016181 generic-all
-vmTestbase/nsk/jvmti/scenarios/allocation/AP10/ap10t001/TestDescription.java 8210131 generic-all
 vmTestbase/nsk/jvmti/scenarios/extension/EX03/ex03t001/TestDescription.java 8173658 generic-all
 vmTestbase/nsk/jvmti/scenarios/hotswap/HS102/hs102t002/TestDescription.java 8204506,8203350 generic-all
 vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t001/hs204t001.java 6813266 generic-all
@@ -215,11 +214,4 @@
 
 vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn001/forceEarlyReturn001.java 7199837 generic-all
 
-vmTestbase/metaspace/stressHierarchy/stressHierarchy007/TestDescription.java 8208697 generic-all
-vmTestbase/metaspace/stressHierarchy/stressHierarchy008/TestDescription.java 8208697 generic-all
-vmTestbase/metaspace/stressHierarchy/stressHierarchy009/TestDescription.java 8208697 generic-all
-vmTestbase/metaspace/stressHierarchy/stressHierarchy010/TestDescription.java 8208697 generic-all
-vmTestbase/metaspace/stressHierarchy/stressHierarchy011/TestDescription.java 8208697 generic-all
-vmTestbase/metaspace/stressHierarchy/stressHierarchy012/TestDescription.java 8208697 generic-all
-
 #############################################################################
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/c2/TestUnreachableRegionDuringCCP.java	Thu Sep 13 10:54:11 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.
+ */
+
+/**
+ * @test
+ * @bug 8210387
+ * @summary Test removal of unreachable regions during CCP.
+ * @library /test/lib
+ * @run main/othervm -Xcomp -XX:-TieredCompilation
+ *                   -XX:CompileOnly=compiler.c2.TestUnreachableRegionDuringCCP::test
+ *                   compiler.c2.TestUnreachableRegionDuringCCP
+ */
+
+package compiler.c2;
+
+import jdk.test.lib.Asserts;
+
+public class TestUnreachableRegionDuringCCP {
+    static int iFld1 = -1;
+    static int iFld2 = -1;
+    static int iArrFld[] = new int[100];
+
+    public static void test() {
+        int i = 1;
+        do {
+            iArrFld[i] = iFld1;
+            iFld1 = 42;
+            for (int j = 1; j < 5; j++) {
+                if (i != 0) {
+                    return; // Always returns
+                }
+                iFld2 += j;
+            }
+        } while (++i < 10);
+    }
+
+    public static void main(String[] args) {
+        test();
+        Asserts.assertEQ(iFld1, 42);
+        Asserts.assertEQ(iFld2, -1);
+        Asserts.assertEQ(iArrFld[1], -1);
+    }
+}
--- a/test/hotspot/jtreg/gc/g1/mixedgc/TestLogging.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/gc/g1/mixedgc/TestLogging.java	Thu Sep 13 10:54:11 2018 -0700
@@ -166,7 +166,14 @@
         System.out.println("Allocating new objects to provoke mixed GC");
         // allocate more objects to provoke GC
         for (int i = 0; i < (TestLogging.ALLOCATION_COUNT * 20); i++) {
-            newObjects.add(new byte[TestLogging.ALLOCATION_SIZE]);
+            try {
+                newObjects.add(new byte[TestLogging.ALLOCATION_SIZE]);
+            } catch (OutOfMemoryError e) {
+                newObjects.clear();
+                WB.youngGC();
+                WB.youngGC();
+                break;
+            }
         }
         // check that liveOldObjects still alive
         Asserts.assertTrue(WB.isObjectInOldGen(liveOldObjects),
--- a/test/hotspot/jtreg/gc/g1/mixedgc/TestOldGenCollectionUsage.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/gc/g1/mixedgc/TestOldGenCollectionUsage.java	Thu Sep 13 10:54:11 2018 -0700
@@ -33,7 +33,7 @@
  * @modules java.management
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
- * @run main/othervm -Xbootclasspath/a:. -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -verbose:gc -XX:SurvivorRatio=1 -Xmx12m -Xms12m -XX:MaxTenuringThreshold=1 -XX:InitiatingHeapOccupancyPercent=100 -XX:-G1UseAdaptiveIHOP -XX:G1MixedGCCountTarget=4 -XX:MaxGCPauseMillis=30000 -XX:G1HeapRegionSize=1m -XX:G1HeapWastePercent=0 -XX:G1MixedGCLiveThresholdPercent=100 TestOldGenCollectionUsage
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -verbose:gc -XX:SurvivorRatio=1 -Xmx14m -Xms14m -XX:MaxTenuringThreshold=1 -XX:InitiatingHeapOccupancyPercent=100 -XX:-G1UseAdaptiveIHOP -XX:G1MixedGCCountTarget=4 -XX:MaxGCPauseMillis=30000 -XX:G1HeapRegionSize=1m -XX:G1HeapWastePercent=0 -XX:G1MixedGCLiveThresholdPercent=100 TestOldGenCollectionUsage
  */
 
 import jdk.test.lib.Asserts;
@@ -209,7 +209,15 @@
             // Provoke a mixed collection. G1MixedGCLiveThresholdPercent=100
             // guarantees that full old gen regions will be included.
             for (int i = 0; i < (ALLOCATION_COUNT * 20); i++) {
-                newObjects.add(new byte[ALLOCATION_SIZE]);
+                try {
+                    newObjects.add(new byte[ALLOCATION_SIZE]);
+                } catch (OutOfMemoryError e) {
+                    newObjects.clear();
+                    WB.youngGC();
+                    WB.youngGC();
+                    System.out.println("OutOfMemoryError is reported, stop allocating new objects");
+                    break;
+                }
             }
             // check that liveOldObjects still alive
             Asserts.assertTrue(WB.isObjectInOldGen(liveOldObjects),
--- a/test/hotspot/jtreg/runtime/Dictionary/CleanProtectionDomain.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/runtime/Dictionary/CleanProtectionDomain.java	Thu Sep 13 10:54:11 2018 -0700
@@ -45,6 +45,7 @@
     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
                                   "-Xlog:protectiondomain+table=debug",
                                   "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
+                                  "-XX:+UnlockDiagnosticVMOptions",
                                   "-XX:+WhiteBoxAPI",
                                   "-Xbootclasspath/a:.",
                                   Test.class.getName());
@@ -70,13 +71,20 @@
 
       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);
+      int cnt = 0;
+      while (true) {
+        if (cnt++ % 30 == 0) {
+          System.gc();
+        }
+        removedCount = wb.resolvedMethodRemovedCount();
+        if (removedCountOrig != removedCount) {
+          break;
+        }
+        Thread.sleep(100);
+      }
     }
 
     private static class TestClassLoader extends ClassLoader {
--- a/test/hotspot/jtreg/runtime/MemberName/MemberNameLeak.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/runtime/MemberName/MemberNameLeak.java	Thu Sep 13 10:54:11 2018 -0700
@@ -56,19 +56,26 @@
           mh.invokeExact(leak);
         }
 
-        System.gc();  // make mh unused
-
         // Wait until ServiceThread cleans ResolvedMethod table
-        do {
+        int cnt = 0;
+        while (true) {
+          if (cnt++ % 30 == 0) {
+            System.gc();  // make mh unused
+          }
           removedCount = wb.resolvedMethodRemovedCount();
-        } while (removedCountOrig == removedCount);
+          if (removedCountOrig != removedCount) {
+            break;
+          }
+          Thread.sleep(100);
+        }
       }
     }
 
     public static void test(String gc) throws Throwable {
-       // Run this Leak class with logging
+        // Run this Leak class with logging
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
                                       "-Xlog:membername+table=trace",
+                                      "-XX:+UnlockDiagnosticVMOptions",
                                       "-XX:+WhiteBoxAPI",
                                       "-Xbootclasspath/a:.",
                                       gc, Leak.class.getName());
--- a/test/hotspot/jtreg/runtime/Thread/ThreadPriorities.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/runtime/Thread/ThreadPriorities.java	Thu Sep 13 10:54:11 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/appcds/cacheObject/CheckArchivedModuleApp.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/runtime/appcds/cacheObject/CheckArchivedModuleApp.java	Thu Sep 13 10:54:11 2018 -0700
@@ -47,8 +47,16 @@
            throw new RuntimeException(
                "FAILED. Incorrect argument length: " + args.length);
         }
+
         boolean expectArchivedDescriptors = "yes".equals(args[0]);
         boolean expectArchivedConfiguration = "yes".equals(args[1]);
+        // -XX:+EnableJVMCI adds extra system modules, in which case the system
+        // module objects are not archived.
+        if (wb.getBooleanVMFlag("EnableJVMCI")) {
+            expectArchivedDescriptors = false;
+            expectArchivedConfiguration = false;
+        }
+
         checkModuleDescriptors(expectArchivedDescriptors);
         checkConfiguration(expectArchivedConfiguration);
         checkEmptyConfiguration(expectArchivedConfiguration);
--- a/test/hotspot/jtreg/runtime/appcds/cacheObject/DifferentHeapSizes.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/runtime/appcds/cacheObject/DifferentHeapSizes.java	Thu Sep 13 10:54:11 2018 -0700
@@ -40,6 +40,8 @@
 import jdk.test.lib.cds.CDSTestUtils;
 
 public class DifferentHeapSizes {
+    static final String DEDUP = "-XX:+UseStringDeduplication"; // This increases code coverage.
+
     static class Scenario {
         int dumpSize;   // in MB
         int runSizes[]; // in MB
@@ -59,7 +61,6 @@
     };
 
     public static void main(String[] args) throws Exception {
-        String dedup = "-XX:+UseStringDeduplication"; // This increases code coverage.
         JarBuilder.getOrCreateHelloJar();
         String appJar = TestCommon.getTestJar("hello.jar");
         String appClasses[] = TestCommon.list("Hello");
@@ -71,7 +72,7 @@
             for (int runSize : s.runSizes) {
                 String runXmx = "-Xmx" + runSize + "m";
                 CDSTestUtils.Result result = TestCommon.run("-cp", appJar, "-showversion",
-                        "-Xlog:cds", runXmx, dedup, "Hello");
+                        "-Xlog:cds", runXmx, DEDUP, "Hello");
                 if (runSize < 32768) {
                     result
                         .assertNormalExit("Hello World")
@@ -80,21 +81,49 @@
                             out.shouldNotContain(CDSTestUtils.MSG_RANGE_ALREADT_IN_USE);
                         });
                 } else {
-                    result.assertAbnormalExit("Unable to use shared archive: UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.");
+                    result.assertAbnormalExit(CDSTestUtils.MSG_COMPRESSION_MUST_BE_USED);
                 }
             }
         }
-        String flag = "HeapBaseMinAddress";
-        String xxflag = "-XX:" + flag + "=";
-        String mx = "-Xmx128m";
-        long base = WhiteBox.getWhiteBox().getSizeTVMFlag(flag).longValue();
+
+        // Test various settings of -XX:HeapBaseMinAddress that would trigger
+        // "CDS heap data need to be relocated because the desired range ... is outside of the heap"
+        long default_base = WhiteBox.getWhiteBox().getSizeTVMFlag("HeapBaseMinAddress").longValue();
+        long M = 1024 * 1024;
+        long bases[] = new long[] {
+            /* dump xmx */   /* run xmx */   /* dump base */             /* run base */
+            128 * M,         128 * M,        default_base,               default_base + 256L * 1024 * 1024,
+            128 * M,         16376 * M,      0x0000000119200000L,        -1,
+        };
+
+        for (int i = 0; i < bases.length; i += 4) {
+            String dump_xmx  = getXmx(bases[i+0]);
+            String run_xmx   = getXmx(bases[i+1]);
+            String dump_base = getHeapBaseMinAddress(bases[i+2]);
+            String run_base  = getHeapBaseMinAddress(bases[i+3]);
 
-        TestCommon.dump(appJar, appClasses, mx, xxflag + base);
-        TestCommon.run("-cp", appJar, "-showversion", "-Xlog:cds", mx, xxflag + (base + 256 * 1024 * 1024), dedup, "Hello")
-            .assertNormalExit("Hello World")
-            .assertNormalExit(out -> {
-                    out.shouldNotContain(CDSTestUtils.MSG_RANGE_NOT_WITHIN_HEAP);
-                    out.shouldNotContain(CDSTestUtils.MSG_RANGE_ALREADT_IN_USE);
-                });
+            TestCommon.dump(appJar, appClasses, dump_xmx, dump_base);
+            TestCommon.run("-cp", appJar, "-showversion", "-Xlog:cds", run_xmx, run_base, DEDUP, "Hello")
+                .assertNormalExit("Hello World")
+                .assertNormalExit(out -> {
+                        out.shouldNotContain(CDSTestUtils.MSG_RANGE_NOT_WITHIN_HEAP);
+                        out.shouldNotContain(CDSTestUtils.MSG_RANGE_ALREADT_IN_USE);
+                    });
+        }
+    }
+
+    static String getXmx(long value) {
+        if (value < 0) {
+            return "-showversion"; // This is a harmless command line arg
+        } else {
+            return "-Xmx" + (value / 1024 / 1024) + "m";
+        }
+    }
+    static String getHeapBaseMinAddress(long value) {
+        if (value < 0) {
+            return "-showversion"; // This is a harmless command line arg
+        } else {
+            return "-XX:HeapBaseMinAddress=0x" + Long.toHexString(value);
+        }
     }
 }
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddModules.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddModules.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddOpens.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddReads.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ExportModule.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/MainModuleOnly.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP.java	Thu Sep 13 10:54:11 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/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitor.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitor.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorGCTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorTest.java	Thu Sep 13 10:54:11 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();
--- a/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java	Thu Sep 13 10:54:11 2018 -0700
@@ -40,7 +40,6 @@
 import jdk.test.lib.apps.LingeredAppWithDeadlock;
 
 import jdk.test.lib.Utils;
-import jdk.test.lib.Platform;
 import jdk.test.lib.JDKToolLauncher;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
--- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/common/PerformChecksHelper.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/common/PerformChecksHelper.java	Thu Sep 13 10:54:11 2018 -0700
@@ -137,10 +137,10 @@
                 }
             }
         } catch (OutOfMemoryError e) {
-            if (e.getMessage().trim().toLowerCase().contains("metadata")) {
-                System.out.println("Got OOME in metaspace in PerformChecksHelper.callMethods(Class clazz). " +
-                                "This happened because reflection generates a too many accessors. " +
-                                "There is nothing we can do with it, so we are just suppressing.");
+            if (e.getMessage().trim().toLowerCase().contains("metaspace")) {
+                // avoid string concatenation, which may create more classes.
+                System.out.println("Got OOME in metaspace in PerformChecksHelper.callMethods(Class clazz). ");
+                System.out.println("This is possible with -triggerUnloadingByFillingMetaspace");
             } else {
                 throw e;
             }
--- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/common/StressHierarchyBaseClass.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/common/StressHierarchyBaseClass.java	Thu Sep 13 10:54:11 2018 -0700
@@ -39,15 +39,13 @@
 import nsk.share.test.ExecutionController;
 import nsk.share.test.Stresser;
 import nsk.share.test.TestBase;
-import nsk.share.test.timeoutwatchdog.TimeoutHandler;
-import nsk.share.test.timeoutwatchdog.TimeoutWatchdog;
 
 
 /**
  * Superclass for StressHierarchy* tests. It provides util methods to create and load
  * classes hierarchy and perform checks.
  */
-abstract public class StressHierarchyBaseClass extends TestBase implements TimeoutHandler {
+abstract public class StressHierarchyBaseClass extends TestBase {
 
     protected static String[] args;
 
@@ -101,7 +99,6 @@
             long startTimeStamp = System.currentTimeMillis();
             ExecutionController stresser = new Stresser(args);
             stresser.start(1);
-            TimeoutWatchdog.watch(stresser, this);
             TreeDescriptor treeDescriptor = GenerateHierarchyHelper.generateHierarchy(treeDepth, minLevelSize, maxLevelSize, hierarchyType);
             Tree tree = buildTree(treeDescriptor);
             System.out.println("Generating took " + ((System.currentTimeMillis() - startTimeStamp)/1000) +" sec");
@@ -128,12 +125,6 @@
         }
     }
 
-    @Override
-    public void handleTimeout() {
-        System.out.println("Shutting down vm because of time expired.");
-        System.exit(95);
-    }
-
     abstract protected void runTestLogic(Tree tree, ExecutionController stresser) throws Throwable;
 
     private Tree buildTree(TreeDescriptor treeDescriptor) throws MalformedURLException,
--- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy012/TestDescription.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy012/TestDescription.java	Thu Sep 13 10:54:11 2018 -0700
@@ -37,7 +37,7 @@
  * @comment generate and compile metaspace.stressHierarchy.common.HumongousClass
  * @run driver metaspace.stressHierarchy.common.GenClassesBuilder
  * @run main/othervm
- *      -XX:MaxMetaspaceSize=450m
+ *      -XX:MaxMetaspaceSize=250m
  *      -Xss10m
  *      -Xbootclasspath/a:.
  *      -XX:+UnlockDiagnosticVMOptions
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects002/referringObjects002.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects002/referringObjects002.java	Thu Sep 13 10:54:11 2018 -0700
@@ -118,7 +118,8 @@
         // + 'includedIntoReferrersCountTypes.size()' referrers was additionally created
         // +1 referrer is classloader
         // +1 referrer is debugee class unloader
-        int expectedReferrersCount = createInstances + HeapwalkingDebuggee.includedIntoReferrersCountTypes.size() + 2;
+        // +1 self-reference from this_class index
+        int expectedReferrersCount = createInstances + HeapwalkingDebuggee.includedIntoReferrersCountTypes.size() + 3;
 
         ClassObjectReference classObjectReference = debuggee.classByName(className).classObject();
 
@@ -132,7 +133,8 @@
         // Only this referrers should left:
         // 1 referrer is classloader
         // 1 referrer is debugee class unloader
-        expectedReferrersCount = 2;
+        // 1 self-reference from this_class index
+        expectedReferrersCount = 3;
 
         checkClassObjectReferrersCount(classObjectReference, expectedReferrersCount);
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.cpp	Thu Sep 13 10:54:11 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 @@
         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;
@@ -185,6 +171,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassPrepare/classprep001/classprep001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassPrepare/classprep001/classprep001.cpp	Thu Sep 13 10:54:11 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
@@ -257,8 +244,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;
@@ -333,6 +319,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk001/clrbrk001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk001/clrbrk001.cpp	Thu Sep 13 10:54:11 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
@@ -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;
@@ -131,8 +117,7 @@
 
 JNIEXPORT void JNICALL
 Java_nsk_jvmti_ClearBreakpoint_clrbrk001_getReady(JNIEnv *env, jclass cls, jint i) {
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-         "trial", "(I)I");
+    mid = env->GetStaticMethodID(cls, "trial", "(I)I");
     if (mid == NULL) {
         printf("Cannot find method \"trial(I)I\"\n");
         result = STATUS_FAILED;
@@ -213,6 +198,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk002/clrbrk002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk002/clrbrk002.cpp	Thu Sep 13 10:54:11 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,8 +107,7 @@
         return result;
     }
 
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-         "run", "([Ljava/lang/String;Ljava/io/PrintStream;)I");
+    mid = env->GetStaticMethodID(cls, "run", "([Ljava/lang/String;Ljava/io/PrintStream;)I");
     if (mid == NULL) {
         printf("Cannot find method run\n");
         return STATUS_FAILED;
@@ -158,6 +143,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk005/clrbrk005.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk005/clrbrk005.cpp	Thu Sep 13 10:54:11 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,8 +105,7 @@
         return result;
     }
 
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-         "checkPoint", "()V");
+    mid = env->GetStaticMethodID(cls, "checkPoint", "()V");
     if (mid == 0) {
         printf("Cannot find Method ID for method checkPoint\n");
         return STATUS_FAILED;
@@ -153,6 +138,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw001/clrfldw001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw001/clrfldw001.cpp	Thu Sep 13 10:54:11 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,14 +61,12 @@
     field fld = fields[ind];
     const char *msg;
 
-    cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, fld.klass));
+    cls = env->FindClass(fld.klass);
     if (fld.fid == NULL) {
         if (fld.stat) {
-            fields[ind].fid = JNI_ENV_PTR(env)->
-                    GetStaticFieldID(JNI_ENV_ARG(env, cls), fld.name, fld.sig);
+            fields[ind].fid = env->GetStaticFieldID(cls, fld.name, fld.sig);
         } else {
-            fields[ind].fid = JNI_ENV_PTR(env)->
-                    GetFieldID(JNI_ENV_ARG(env, cls), fld.name, fld.sig);
+            fields[ind].fid = env->GetFieldID(cls, fld.name, fld.sig);
         }
     }
 
@@ -123,8 +108,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;
@@ -191,7 +175,7 @@
         jobject obj) {
     jint val;
 
-    val = JNI_ENV_PTR(env)->GetIntField(JNI_ENV_ARG(env, obj), fields[0].fid);
+    val = env->GetIntField(obj, fields[0].fid);
 }
 
 JNIEXPORT void JNICALL
@@ -216,6 +200,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw002/clrfldw002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw002/clrfldw002.cpp	Thu Sep 13 10:54:11 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 @@
     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;
@@ -128,10 +114,8 @@
     jvmtiError err;
     jfieldID fid1, fid2;
 
-    fid1 = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG(env, cls),
-        "fld1", "I");
-    fid2 = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG(env, cls),
-        "fld2", "I");
+    fid1 = env->GetStaticFieldID(cls, "fld1", "I");
+    fid2 = env->GetStaticFieldID(cls, "fld2", "I");
 
     if (!caps.can_generate_field_access_events) {
         err = jvmti->ClearFieldAccessWatch(cls, fid1);
@@ -169,6 +153,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw001/clrfmodw001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw001/clrfmodw001.cpp	Thu Sep 13 10:54:11 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,14 +61,12 @@
     field fld = fields[ind];
     const char *msg;
 
-    cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, fld.klass));
+    cls = env->FindClass(fld.klass);
     if (fld.fid == NULL) {
         if (fld.stat) {
-            fields[ind].fid = JNI_ENV_PTR(env)->
-                GetStaticFieldID(JNI_ENV_ARG(env, cls), fld.name, fld.sig);
+            fields[ind].fid = env->GetStaticFieldID(cls, fld.name, fld.sig);
         } else {
-            fields[ind].fid = JNI_ENV_PTR(env)->
-                GetFieldID(JNI_ENV_ARG(env, cls), fld.name, fld.sig);
+            fields[ind].fid = env->GetFieldID(cls, fld.name, fld.sig);
         }
     }
 
@@ -123,8 +108,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;
@@ -185,7 +169,7 @@
 }
 
 JNIEXPORT void JNICALL Java_nsk_jvmti_ClearFieldModificationWatch_clrfmodw001_touchfld0(JNIEnv *env, jobject obj) {
-    JNI_ENV_PTR(env)->SetIntField(JNI_ENV_ARG(env, obj), fields[0].fid, 2000);
+    env->SetIntField(obj, fields[0].fid, 2000);
 }
 
 JNIEXPORT void JNICALL
@@ -208,6 +192,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw002/clrfmodw002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw002/clrfmodw002.cpp	Thu Sep 13 10:54:11 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,8 +59,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;
@@ -129,10 +115,8 @@
     jvmtiError err;
     jfieldID fid1, fid2;
 
-    fid1 = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG(env, cls),
-        "fld1", "I");
-    fid2 = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG(env, cls),
-        "fld2", "I");
+    fid1 = env->GetStaticFieldID(cls, "fld1", "I");
+    fid2 = env->GetStaticFieldID(cls, "fld2", "I");
 
     if (!caps.can_generate_field_modification_events) {
         printf("Warning: ClearFieldModificationWatch is not implemented\n");
@@ -172,6 +156,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CreateRawMonitor/crrawmon001/crrawmon001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CreateRawMonitor/crrawmon001/crrawmon001.cpp	Thu Sep 13 10:54:11 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
@@ -96,8 +83,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/CreateRawMonitor/crrawmon002/crrawmon002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CreateRawMonitor/crrawmon002/crrawmon002.cpp	Thu Sep 13 10:54:11 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/Deallocate/dealloc001/dealloc001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Deallocate/dealloc001/dealloc001.cpp	Thu Sep 13 10:54:11 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;
@@ -103,6 +89,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon001/drrawmon001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon001/drrawmon001.cpp	Thu Sep 13 10:54:11 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
@@ -109,8 +96,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/DestroyRawMonitor/drrawmon003/drrawmon003.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon003/drrawmon003.cpp	Thu Sep 13 10:54:11 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
@@ -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;
@@ -124,6 +110,4 @@
     return PASSED;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon004/drrawmon004.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon004/drrawmon004.cpp	Thu Sep 13 10:54:11 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;
@@ -105,6 +91,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Exception/exception001/exception001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Exception/exception001/exception001.cpp	Thu Sep 13 10:54:11 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 @@
     if (printdump == JNI_TRUE) {
         printf(">>> retrieving Exception info ...\n");
     }
-    cls = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG((JNIEnv *)env, exception));
+    cls = env->GetObjectClass(exception);
     err = jvmti_env->GetClassSignature(cls, &ex.name, &generic);
     if (err != JVMTI_ERROR_NONE) {
         printf("(GetClassSignature) unexpected error: %s (%d)\n",
@@ -204,8 +191,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;
@@ -263,26 +249,22 @@
         return result;
     }
 
-    clz = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/Exception/exception001c"));
+    clz = env->FindClass("nsk/jvmti/Exception/exception001c");
     if (clz == NULL) {
         printf("Cannot find exception001c class!\n");
         return STATUS_FAILED;
     }
-    clz = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/Exception/exception001b"));
+    clz = env->FindClass("nsk/jvmti/Exception/exception001b");
     if (clz == NULL) {
         printf("Cannot find exception001b class!\n");
         return STATUS_FAILED;
     }
-    clz = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/Exception/exception001a"));
+    clz = env->FindClass("nsk/jvmti/Exception/exception001a");
     if (clz == NULL) {
         printf("Cannot find exception001a class!\n");
         return STATUS_FAILED;
     }
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, clz),
-        "run", "()V");
+    mid = env->GetStaticMethodID(clz, "run", "()V");
     if (mid == NULL) {
         printf("Cannot find method run!\n");
         return STATUS_FAILED;
@@ -304,7 +286,7 @@
         result = STATUS_FAILED;
     }
 
-    JNI_ENV_PTR(env)->CallStaticVoidMethod(JNI_ENV_ARG(env, clz), mid);
+    env->CallStaticVoidMethod(clz, mid);
 
     err = jvmti->SetEventNotificationMode(JVMTI_DISABLE,
             JVMTI_EVENT_EXCEPTION, thread);
@@ -322,6 +304,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ExceptionCatch/excatch001/excatch001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ExceptionCatch/excatch001/excatch001.cpp	Thu Sep 13 10:54:11 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
@@ -90,7 +77,7 @@
     if (printdump == JNI_TRUE) {
         printf(">>> retrieving ExceptionCatch info ...\n");
     }
-    cls = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG((JNIEnv *)env, exception));
+    cls = env->GetObjectClass(exception);
     err = jvmti_env->GetClassSignature(cls, &ex.name, &generic);
     if (err != JVMTI_ERROR_NONE) {
         printf("(GetClassSignature#e) unexpected error: %s (%d)\n",
@@ -163,8 +150,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;
@@ -221,26 +207,22 @@
         return result;
     }
 
-    clz = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/ExceptionCatch/excatch001c"));
+    clz = env->FindClass("nsk/jvmti/ExceptionCatch/excatch001c");
     if (clz == NULL) {
         printf("Cannot find excatch001c class!\n");
         return STATUS_FAILED;
     }
-    clz = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/ExceptionCatch/excatch001b"));
+    clz = env->FindClass("nsk/jvmti/ExceptionCatch/excatch001b");
     if (clz == NULL) {
         printf("Cannot find excatch001b class!\n");
         return STATUS_FAILED;
     }
-    clz = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/ExceptionCatch/excatch001a"));
+    clz = env->FindClass("nsk/jvmti/ExceptionCatch/excatch001a");
     if (clz == NULL) {
         printf("Cannot find excatch001a class!\n");
         return STATUS_FAILED;
     }
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, clz),
-        "run", "()V");
+    mid = env->GetStaticMethodID(clz, "run", "()V");
     if (mid == NULL) {
         printf("Cannot find method run!\n");
         return STATUS_FAILED;
@@ -256,7 +238,7 @@
         result = STATUS_FAILED;
     }
 
-    JNI_ENV_PTR(env)->CallStaticVoidMethod(JNI_ENV_ARG(env, clz), mid);
+    env->CallStaticVoidMethod(clz, mid);
 
     err = jvmti->SetEventNotificationMode(JVMTI_DISABLE,
             JVMTI_EVENT_EXCEPTION_CATCH, NULL);
@@ -274,6 +256,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FieldAccess/fieldacc001/fieldacc001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FieldAccess/fieldacc001/fieldacc001.cpp	Thu Sep 13 10:54:11 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
@@ -258,8 +245,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;
@@ -323,8 +309,7 @@
     if (printdump == JNI_TRUE) {
         printf(">>> setting field access watches ...\n");
     }
-    cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/FieldAccess/fieldacc001a"));
+    cls = env->FindClass("nsk/jvmti/FieldAccess/fieldacc001a");
     if (cls == NULL) {
         printf("Cannot find fieldacc001a class!\n");
         result = STATUS_FAILED;
@@ -332,11 +317,11 @@
     }
     for (i = 0; i < sizeof(watches)/sizeof(watch_info); i++) {
         if (watches[i].is_static == JNI_TRUE) {
-            watches[i].fid = JNI_ENV_PTR(env)->GetStaticFieldID(
-                JNI_ENV_ARG(env, cls), watches[i].f_name, watches[i].f_sig);
+            watches[i].fid = env->GetStaticFieldID(
+                cls, watches[i].f_name, watches[i].f_sig);
         } else {
-            watches[i].fid = JNI_ENV_PTR(env)->GetFieldID(
-                JNI_ENV_ARG(env, cls), watches[i].f_name, watches[i].f_sig);
+            watches[i].fid = env->GetFieldID(
+                cls, watches[i].f_name, watches[i].f_sig);
         }
         if (watches[i].fid == NULL) {
             printf("Cannot find field \"%s\"!\n", watches[i].f_name);
@@ -367,6 +352,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FieldAccess/fieldacc002/fieldacc002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FieldAccess/fieldacc002/fieldacc002.cpp	Thu Sep 13 10:54:11 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
@@ -257,8 +244,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;
@@ -321,8 +307,7 @@
         printf(">>> setting field access watches ...\n");
     }
 
-    cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/FieldAccess/fieldacc002a"));
+    cls = env->FindClass("nsk/jvmti/FieldAccess/fieldacc002a");
     if (cls == NULL) {
         printf("Cannot find fieldacc002a class!\n");
         result = STATUS_FAILED;
@@ -330,11 +315,11 @@
     }
     for (i = 0; i < sizeof(watches)/sizeof(watch_info); i++) {
         if (watches[i].is_static == JNI_TRUE) {
-            watches[i].fid = JNI_ENV_PTR(env)->GetStaticFieldID(
-                JNI_ENV_ARG(env, cls), watches[i].f_name, watches[i].f_sig);
+            watches[i].fid = env->GetStaticFieldID(
+                cls, watches[i].f_name, watches[i].f_sig);
         } else {
-            watches[i].fid = JNI_ENV_PTR(env)->GetFieldID(
-                JNI_ENV_ARG(env, cls), watches[i].f_name, watches[i].f_sig);
+            watches[i].fid = env->GetFieldID(
+                cls, watches[i].f_name, watches[i].f_sig);
         }
         if (watches[i].fid == NULL) {
             printf("Cannot find field \"%s\"!\n", watches[i].f_name);
@@ -368,44 +353,33 @@
         printf(">>> accessing fields ...\n");
     }
 
-    cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/FieldAccess/fieldacc002a"));
+    cls = env->FindClass("nsk/jvmti/FieldAccess/fieldacc002a");
     if (cls == NULL) {
         printf("Cannot find fieldacc002a class!\n");
         return STATUS_FAILED;
     }
 
-    JNI_ENV_PTR(env)->GetStaticBooleanField(JNI_ENV_ARG(env, cls),
-        watches[0].fid);
-    JNI_ENV_PTR(env)->GetStaticByteField(JNI_ENV_ARG(env, cls),
-        watches[1].fid);
-    JNI_ENV_PTR(env)->GetStaticShortField(JNI_ENV_ARG(env, cls),
-        watches[2].fid);
-    JNI_ENV_PTR(env)->GetStaticIntField(JNI_ENV_ARG(env, cls),
-        watches[3].fid);
-    JNI_ENV_PTR(env)->GetStaticLongField(JNI_ENV_ARG(env, cls),
-        watches[4].fid);
-    JNI_ENV_PTR(env)->GetStaticFloatField(JNI_ENV_ARG(env, cls),
-        watches[5].fid);
-    JNI_ENV_PTR(env)->GetStaticDoubleField(JNI_ENV_ARG(env, cls),
-        watches[6].fid);
-    JNI_ENV_PTR(env)->GetStaticCharField(JNI_ENV_ARG(env, cls),
-        watches[7].fid);
-    JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG(env, cls),
-        watches[8].fid);
-    JNI_ENV_PTR(env)->GetStaticObjectField(JNI_ENV_ARG(env, cls),
-        watches[9].fid);
+    env->GetStaticBooleanField(cls, watches[0].fid);
+    env->GetStaticByteField(cls, watches[1].fid);
+    env->GetStaticShortField(cls, watches[2].fid);
+    env->GetStaticIntField(cls, watches[3].fid);
+    env->GetStaticLongField(cls, watches[4].fid);
+    env->GetStaticFloatField(cls, watches[5].fid);
+    env->GetStaticDoubleField(cls, watches[6].fid);
+    env->GetStaticCharField(cls, watches[7].fid);
+    env->GetStaticObjectField(cls, watches[8].fid);
+    env->GetStaticObjectField(cls, watches[9].fid);
 
-    JNI_ENV_PTR(env)->GetBooleanField(JNI_ENV_ARG(env, obj), watches[10].fid);
-    JNI_ENV_PTR(env)->GetByteField(JNI_ENV_ARG(env, obj), watches[11].fid);
-    JNI_ENV_PTR(env)->GetShortField(JNI_ENV_ARG(env, obj), watches[12].fid);
-    JNI_ENV_PTR(env)->GetIntField(JNI_ENV_ARG(env, obj), watches[13].fid);
-    JNI_ENV_PTR(env)->GetLongField(JNI_ENV_ARG(env, obj), watches[14].fid);
-    JNI_ENV_PTR(env)->GetFloatField(JNI_ENV_ARG(env, obj), watches[15].fid);
-    JNI_ENV_PTR(env)->GetDoubleField(JNI_ENV_ARG(env, obj), watches[16].fid);
-    JNI_ENV_PTR(env)->GetCharField(JNI_ENV_ARG(env, obj), watches[17].fid);
-    JNI_ENV_PTR(env)->GetObjectField(JNI_ENV_ARG(env, obj), watches[18].fid);
-    JNI_ENV_PTR(env)->GetObjectField(JNI_ENV_ARG(env, obj), watches[19].fid);
+    env->GetBooleanField(obj, watches[10].fid);
+    env->GetByteField(obj, watches[11].fid);
+    env->GetShortField(obj, watches[12].fid);
+    env->GetIntField(obj, watches[13].fid);
+    env->GetLongField(obj, watches[14].fid);
+    env->GetFloatField(obj, watches[15].fid);
+    env->GetDoubleField(obj, watches[16].fid);
+    env->GetCharField(obj, watches[17].fid);
+    env->GetObjectField(obj, watches[18].fid);
+    env->GetObjectField(obj, watches[19].fid);
 
     if (printdump == JNI_TRUE) {
         printf(">>> ... done\n");
@@ -419,6 +393,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FieldAccess/fieldacc003/fieldacc003.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FieldAccess/fieldacc003/fieldacc003.cpp	Thu Sep 13 10:54:11 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
@@ -237,8 +224,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;
@@ -302,18 +288,18 @@
         printf(">>> setting field access watches ...\n");
     }
     for (i = 0; i < sizeof(watches)/sizeof(watch_info); i++) {
-        cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, watches[i].f_cls));
+        cls = env->FindClass(watches[i].f_cls);
         if (cls == NULL) {
             printf("Cannot find %s class!\n", watches[i].f_cls);
             result = STATUS_FAILED;
             return;
         }
         if (watches[i].is_static == JNI_TRUE) {
-            watches[i].fid = JNI_ENV_PTR(env)->GetStaticFieldID(
-                JNI_ENV_ARG(env, cls), watches[i].f_name, watches[i].f_sig);
+            watches[i].fid = env->GetStaticFieldID(
+                cls, watches[i].f_name, watches[i].f_sig);
         } else {
-            watches[i].fid = JNI_ENV_PTR(env)->GetFieldID(
-                JNI_ENV_ARG(env, cls), watches[i].f_name, watches[i].f_sig);
+            watches[i].fid = env->GetFieldID(
+                cls, watches[i].f_name, watches[i].f_sig);
         }
         if (watches[i].fid == NULL) {
             printf("Cannot get field ID for \"%s:%s\"\n",
@@ -345,6 +331,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FieldAccess/fieldacc004/fieldacc004.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FieldAccess/fieldacc004/fieldacc004.cpp	Thu Sep 13 10:54:11 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
@@ -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;
@@ -288,18 +274,18 @@
         printf(">>> setting field access watches ...\n");
     }
     for (i = 0; i < sizeof(watches)/sizeof(watch_info); i++) {
-        cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, watches[i].f_cls));
+        cls = env->FindClass(watches[i].f_cls);
         if (cls == NULL) {
             printf("Cannot find %s class!\n", watches[i].f_cls);
             result = STATUS_FAILED;
             return;
         }
         if (watches[i].is_static == JNI_TRUE) {
-            watches[i].fid = JNI_ENV_PTR(env)->GetStaticFieldID(
-                JNI_ENV_ARG(env, cls), watches[i].f_name, watches[i].f_sig);
+            watches[i].fid = env->GetStaticFieldID(
+                cls, watches[i].f_name, watches[i].f_sig);
         } else {
-            watches[i].fid = JNI_ENV_PTR(env)->GetFieldID(
-                JNI_ENV_ARG(env, cls), watches[i].f_name, watches[i].f_sig);
+            watches[i].fid = env->GetFieldID(
+                cls, watches[i].f_name, watches[i].f_sig);
         }
         if (watches[i].fid == NULL) {
             printf("Cannot get field ID for \"%s:%s\"\n",
@@ -331,6 +317,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FieldModification/fieldmod001/fieldmod001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FieldModification/fieldmod001/fieldmod001.cpp	Thu Sep 13 10:54:11 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
@@ -170,8 +157,7 @@
         return (v1.d == v2.d);
     case 'L':
     case '[':
-        return (JNI_TRUE ==
-            JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, v1.l), v2.l));
+        return env->IsSameObject(v1.l, v2.l);
     case 'Z':
         return (v1.z == v2.z);
     case 'B':
@@ -335,8 +321,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;
@@ -400,8 +385,7 @@
     if (printdump == JNI_TRUE) {
         printf(">>> setting field modification watches ...\n");
     }
-    cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/FieldModification/fieldmod001a"));
+    cls = env->FindClass("nsk/jvmti/FieldModification/fieldmod001a");
     if (cls == NULL) {
         printf("Cannot find fieldmod001a class!\n");
         result = STATUS_FAILED;
@@ -409,11 +393,11 @@
     }
     for (i = 0; i < sizeof(watches)/sizeof(watch_info); i++) {
         if (watches[i].is_static == JNI_TRUE) {
-            watches[i].fid = JNI_ENV_PTR(env)->GetStaticFieldID(
-                JNI_ENV_ARG(env, cls), watches[i].f_name, watches[i].f_sig);
+            watches[i].fid = env->GetStaticFieldID(
+                cls, watches[i].f_name, watches[i].f_sig);
         } else {
-            watches[i].fid = JNI_ENV_PTR(env)->GetFieldID(
-                JNI_ENV_ARG(env, cls), watches[i].f_name, watches[i].f_sig);
+            watches[i].fid = env->GetFieldID(
+                cls, watches[i].f_name, watches[i].f_sig);
         }
         if (watches[i].fid == NULL) {
             printf("Cannot get field ID for \"%s:%s\"\n",
@@ -468,6 +452,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FieldModification/fieldmod002/fieldmod002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FieldModification/fieldmod002/fieldmod002.cpp	Thu Sep 13 10:54:11 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
@@ -170,8 +157,7 @@
         return (v1.d == v2.d);
     case 'L':
     case '[':
-        return (JNI_TRUE ==
-            JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, v1.l), v2.l));
+        return env->IsSameObject(v1.l, v2.l);
     case 'Z':
         return (v1.z == v2.z);
     case 'B':
@@ -218,8 +204,7 @@
                TranslateError(err), err);
         result = STATUS_FAILED;
     }
-    err = jvmti_env->GetMethodName(method,
-        &watch.m_name, &watch.m_sig, &generic);
+    err = jvmti_env->GetMethodName(method, &watch.m_name, &watch.m_sig, &generic);
     if (err != JVMTI_ERROR_NONE) {
         printf("(GetMethodName) unexpected error: %s (%d)\n",
                TranslateError(err), err);
@@ -335,8 +320,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;
@@ -402,8 +386,7 @@
     if (printdump == JNI_TRUE) {
         printf(">>> setting field modification watches ...\n");
     }
-    cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/FieldModification/fieldmod002a"));
+    cls = env->FindClass("nsk/jvmti/FieldModification/fieldmod002a");
     if (cls == NULL) {
         printf("Cannot find fieldmod001a class!\n");
         result = STATUS_FAILED;
@@ -411,11 +394,11 @@
     }
     for (i = 0; i < sizeof(watches)/sizeof(watch_info); i++) {
         if (watches[i].is_static == JNI_TRUE) {
-            watches[i].fid = JNI_ENV_PTR(env)->GetStaticFieldID(
-                JNI_ENV_ARG(env, cls), watches[i].f_name, watches[i].f_sig);
+            watches[i].fid = env->GetStaticFieldID(
+                cls, watches[i].f_name, watches[i].f_sig);
         } else {
-            watches[i].fid = JNI_ENV_PTR(env)->GetFieldID(
-                JNI_ENV_ARG(env, cls), watches[i].f_name, watches[i].f_sig);
+            watches[i].fid = env->GetFieldID(
+                cls, watches[i].f_name, watches[i].f_sig);
         }
         if (watches[i].fid == NULL) {
             printf("Cannot get field ID for \"%s:%s\"\n",
@@ -433,16 +416,11 @@
         }
     }
 
-    ctor = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls),
-        "<init>", "()V");
-    obj1 = JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env,
-        JNI_ENV_PTR(env)->NewObject(JNI_ENV_ARG(env, cls), ctor)));
-    obj2 = JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env,
-        JNI_ENV_PTR(env)->NewObject(JNI_ENV_ARG(env, cls), ctor)));
-    arr1 = (jintArray) JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env,
-        JNI_ENV_PTR(env)->NewIntArray(JNI_ENV_ARG(env, (jsize)1))));
-    arr2 = (jintArray) JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env,
-        JNI_ENV_PTR(env)->NewIntArray(JNI_ENV_ARG(env, (jsize)1))));
+    ctor = env->GetMethodID(cls, "<init>", "()V");
+    obj1 = env->NewGlobalRef(env->NewObject(cls, ctor));
+    obj2 = env->NewGlobalRef(env->NewObject(cls, ctor));
+    arr1 = (jintArray) env->NewGlobalRef(env->NewIntArray((jsize) 1));
+    arr2 = (jintArray) env->NewGlobalRef(env->NewIntArray((jsize) 1));
 
     watches[0].val.z = JNI_TRUE;
     watches[1].val.b = 1;
@@ -480,60 +458,37 @@
         return PASSED;
     }
 
-
-
     if (printdump == JNI_TRUE) {
         printf(">>> modifying fields ...\n");
     }
 
-    cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/FieldModification/fieldmod002a"));
+    cls = env->FindClass("nsk/jvmti/FieldModification/fieldmod002a");
     if (cls == NULL) {
         printf("Cannot find fieldmod001a class!\n");
         return STATUS_FAILED;
     }
 
-    JNI_ENV_PTR(env)->SetStaticBooleanField(JNI_ENV_ARG(env, cls),
-        watches[0].fid, watches[0].val.z);
-    JNI_ENV_PTR(env)->SetStaticByteField(JNI_ENV_ARG(env, cls),
-        watches[1].fid, watches[1].val.b);
-    JNI_ENV_PTR(env)->SetStaticShortField(JNI_ENV_ARG(env, cls),
-        watches[2].fid, watches[2].val.s);
-    JNI_ENV_PTR(env)->SetStaticIntField(JNI_ENV_ARG(env, cls),
-        watches[3].fid, watches[3].val.i);
-    JNI_ENV_PTR(env)->SetStaticLongField(JNI_ENV_ARG(env, cls),
-        watches[4].fid, watches[4].val.j);
-    JNI_ENV_PTR(env)->SetStaticFloatField(JNI_ENV_ARG(env, cls),
-        watches[5].fid, watches[5].val.f);
-    JNI_ENV_PTR(env)->SetStaticDoubleField(JNI_ENV_ARG(env, cls),
-        watches[6].fid, watches[6].val.d);
-    JNI_ENV_PTR(env)->SetStaticCharField(JNI_ENV_ARG(env, cls),
-        watches[7].fid, watches[7].val.c);
-    JNI_ENV_PTR(env)->SetStaticObjectField(JNI_ENV_ARG(env, cls),
-        watches[8].fid, watches[8].val.l);
-    JNI_ENV_PTR(env)->SetStaticObjectField(JNI_ENV_ARG(env, cls),
-        watches[9].fid, watches[9].val.l);
+    env->SetStaticBooleanField(cls, watches[0].fid, watches[0].val.z);
+    env->SetStaticByteField(cls, watches[1].fid, watches[1].val.b);
+    env->SetStaticShortField(cls, watches[2].fid, watches[2].val.s);
+    env->SetStaticIntField(cls, watches[3].fid, watches[3].val.i);
+    env->SetStaticLongField(cls, watches[4].fid, watches[4].val.j);
+    env->SetStaticFloatField(cls, watches[5].fid, watches[5].val.f);
+    env->SetStaticDoubleField(cls, watches[6].fid, watches[6].val.d);
+    env->SetStaticCharField(cls, watches[7].fid, watches[7].val.c);
+    env->SetStaticObjectField(cls, watches[8].fid, watches[8].val.l);
+    env->SetStaticObjectField(cls, watches[9].fid, watches[9].val.l);
 
-    JNI_ENV_PTR(env)->SetBooleanField(JNI_ENV_ARG(env, obj),
-        watches[10].fid, watches[10].val.z);
-    JNI_ENV_PTR(env)->SetByteField(JNI_ENV_ARG(env, obj),
-        watches[11].fid, watches[11].val.b);
-    JNI_ENV_PTR(env)->SetShortField(JNI_ENV_ARG(env, obj),
-        watches[12].fid, watches[12].val.s);
-    JNI_ENV_PTR(env)->SetIntField(JNI_ENV_ARG(env, obj),
-        watches[13].fid, watches[13].val.i);
-    JNI_ENV_PTR(env)->SetLongField(JNI_ENV_ARG(env, obj),
-        watches[14].fid, watches[14].val.j);
-    JNI_ENV_PTR(env)->SetFloatField(JNI_ENV_ARG(env, obj),
-        watches[15].fid, watches[15].val.f);
-    JNI_ENV_PTR(env)->SetDoubleField(JNI_ENV_ARG(env, obj),
-        watches[16].fid, watches[16].val.d);
-    JNI_ENV_PTR(env)->SetCharField(JNI_ENV_ARG(env, obj),
-        watches[17].fid, watches[17].val.c);
-    JNI_ENV_PTR(env)->SetObjectField(JNI_ENV_ARG(env, obj),
-        watches[18].fid, watches[18].val.l);
-    JNI_ENV_PTR(env)->SetObjectField(JNI_ENV_ARG(env, obj),
-        watches[19].fid, watches[19].val.l);
+    env->SetBooleanField(obj, watches[10].fid, watches[10].val.z);
+    env->SetByteField(obj, watches[11].fid, watches[11].val.b);
+    env->SetShortField(obj, watches[12].fid, watches[12].val.s);
+    env->SetIntField(obj, watches[13].fid, watches[13].val.i);
+    env->SetLongField(obj, watches[14].fid, watches[14].val.j);
+    env->SetFloatField(obj, watches[15].fid, watches[15].val.f);
+    env->SetDoubleField(obj, watches[16].fid, watches[16].val.d);
+    env->SetCharField(obj, watches[17].fid, watches[17].val.c);
+    env->SetObjectField(obj, watches[18].fid, watches[18].val.l);
+    env->SetObjectField(obj, watches[19].fid, watches[19].val.l);
 
     if (printdump == JNI_TRUE) {
         printf(">>> ... done\n");
@@ -547,6 +502,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FramePop/framepop001/framepop001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FramePop/framepop001/framepop001.cpp	Thu Sep 13 10:54:11 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
@@ -188,8 +175,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;
@@ -249,8 +235,7 @@
         return result;
     }
 
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-         "chain", "()V");
+    mid = env->GetStaticMethodID(cls, "chain", "()V");
     if (mid == 0) {
         printf("Cannot find Method ID for method chain\n");
         return STATUS_FAILED;
@@ -276,20 +261,18 @@
         result = STATUS_FAILED;
     }
 
-    clz = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/FramePop/framepop001a"));
+    clz = env->FindClass("nsk/jvmti/FramePop/framepop001a");
     if (clz == NULL) {
         printf("Cannot find framepop001a class!\n");
         result = STATUS_FAILED;
         return STATUS_FAILED;
     }
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, clz),
-        "dummy", "()V");
+    mid = env->GetStaticMethodID(clz, "dummy", "()V");
     if (mid == 0) {
         printf("Cannot find Method ID for method dummy\n");
         return STATUS_FAILED;
     }
-    JNI_ENV_PTR(env)->CallStaticVoidMethod(JNI_ENV_ARG(env, clz), mid);
+    env->CallStaticVoidMethod(clz, mid);
 
     if (eventsCount != eventsExpected) {
         printf("Wrong number of frame pop events: %" PRIuPTR ", expected: %" PRIuPTR "\n",
@@ -300,6 +283,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FramePop/framepop002/framepop002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/FramePop/framepop002/framepop002.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -29,21 +29,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
 
 #define PASSED 0
 #define STATUS_FAILED 2
@@ -139,8 +126,7 @@
     int i, count = 0;
 
     for (i = 0; i < thr_count; i++) {
-        if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, threads[i].thread),
-                thr) == JNI_TRUE) {
+        if (env->IsSameObject(threads[i].thread, thr)) {
             break;
         }
     }
@@ -184,8 +170,7 @@
     int i;
 
     for (i = 0; i < thr_count; i++) {
-        if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, threads[i].thread),
-                thr) == JNI_TRUE) {
+        if (env->IsSameObject(threads[i].thread, thr)) {
             break;
         }
     }
@@ -332,8 +317,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;
@@ -436,6 +420,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAllThreads/allthr001/allthr001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAllThreads/allthr001/allthr001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAllThreads/allthr002/allthr002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize001/argsize001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize002/argsize002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAvailableProcessors/getavailproc001/getavailproc001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes001/bytecodes001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes002/bytecodes002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes003/bytecodes003.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCapabilities/getcaps001/getcaps001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCapabilities/getcaps002/getcaps002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld005/getclfld005.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld006/getclfld006.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld007/getclfld007.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr001/getclsldr001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr002/getclsldr002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr003/getclsldr003.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss001/clsldrclss001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss002/clsldrclss002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd005/getclmthd005.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd006/getclmthd006.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd007/getclmthd007.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf004/getclmdf004.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf005/getclmdf005.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf006/getclmdf006.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf007/getclmdf007.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig004/getclsig004.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig005/getclsig005.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig006/getclsig006.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat005/getclstat005.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat006/getclstat006.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat007/getclstat007.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentContendedMonitor/contmon001/contmon001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentContendedMonitor/contmon002/contmon002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentContendedMonitor/contmon003/contmon003.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentThreadCpuTime/curthrcputime001/curthrcputime001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentThreadCpuTimerInfo/curthrtimerinfo001/curthrtimerinfo001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetEnv/GetEnv001/GetEnv001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetEnvironmentLocalStorage/getenvstor001/getenvstor001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetErrorName/geterrname001/geterrname001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetErrorName/geterrname002/geterrname002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetExtensionEvents/extevents001/extevents001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetExtensionFunctions/extfuncs001/extfuncs001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl001/getfldecl001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl002/getfldecl002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl004/getfldecl004.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf003/getfldmdf003.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf004/getfldmdf004.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm003/getfldnm003.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm004/getfldnm004.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm005/getfldnm005.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameCount/framecnt001/framecnt001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameCount/framecnt002/framecnt002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameCount/framecnt003/framecnt003.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameLocation/frameloc001/frameloc001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameLocation/frameloc002/frameloc002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFrameLocation/frameloc003/frameloc003.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf005/getintrf005.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf006/getintrf006.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf007/getintrf007.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt001/getjlocfmt001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt002/getjlocfmt002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab001/getjniftab001.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -32,27 +32,7 @@
 #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
-    #define JNI_ENV_ARG1(x)
-  #else
-    #define JNI_ENV_ARG1(x) x
-  #endif
-#endif
 
 #define PASSED  0
 #define STATUS_FAILED  2
@@ -95,16 +75,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 +96,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 +113,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 +131,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 +197,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 +206,4 @@
     return JNI_OK;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab002/getjniftab002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab002/getjniftab002.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -27,27 +27,7 @@
 #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
-    #define JNI_ENV_ARG1(x)
-  #else
-    #define JNI_ENV_ARG1(x) x
-  #endif
-#endif
 
 #define PASSED  0
 #define STATUS_FAILED  2
@@ -100,9 +80,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()) != 0)
         printf("(%s,%d): Warning: DetachCurrentThread() returns: %d\n\
 \tcheck with the detached main thread skipped\n",
             __FILE__, __LINE__, err);
@@ -111,9 +89,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 +119,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 +130,4 @@
     return JNI_OK;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab001/linetab001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab001/linetab001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab002/linetab002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab003/linetab003.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss001/loadedclss001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss002/loadedclss002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariable/getlocal001/getlocal001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariable/getlocal002/getlocal002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab001/localtab001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab002/localtab002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab003/localtab003.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab004/localtab004.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab005/localtab005.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMaxLocals/maxloc001/maxloc001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMaxLocals/maxloc002/maxloc002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls001/declcls001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls002/declcls002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls003/declcls003.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodLocation/methloc001/methloc001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodLocation/methloc002/methloc002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodModifiers/methmod001/methmod001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodModifiers/methmod002/methmod002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname001/methname001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname002/methname002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname003/methname003.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectHashCode/objhashcode001/objhashcode001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage001/objmonusage001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage002/objmonusage002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage003/objmonusage003.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage004/objmonusage004.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage005/objmonusage005.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage006/objmonusage006.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectSize/objsize001/objsize001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectsWithTags/objwithtags001/objwithtags001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf001/ownmoninf001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf002/ownmoninf002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf003/ownmoninf003.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPhase/getphase001/getphase001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPhase/getphase002/getphase002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPotentialCapabilities/getpotcaps001/getpotcaps001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex001/srcdebugex001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex002/srcdebugex002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex003/srcdebugex003.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn004/getsrcfn004.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn005/getsrcfn005.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn006/getsrcfn006.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr001/getstacktr001.cpp	Thu Sep 13 10:54:11 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
@@ -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;
 }
@@ -186,6 +171,4 @@
     }
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr002/getstacktr002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr002/getstacktr002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr003/getstacktr003.cpp	Thu Sep 13 10:54:11 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
@@ -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;
@@ -235,6 +220,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr004/getstacktr004.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr004/getstacktr004.cpp	Thu Sep 13 10:54:11 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
@@ -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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr005/getstacktr005.cpp	Thu Sep 13 10:54:11 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
@@ -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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr006/getstacktr006.cpp	Thu Sep 13 10:54:11 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
@@ -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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr007/getstacktr007.cpp	Thu Sep 13 10:54:11 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
@@ -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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr008/getstacktr008.cpp	Thu Sep 13 10:54:11 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
@@ -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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetStackTrace/getstacktr009/getstacktr009.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops001/getsysprops001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops002/getsysprops002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop001/getsysprop001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop002/getsysprop002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTag/gettag001/gettag001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime001/thrcputime001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime002/thrcputime002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTimerInfo/thrtimerinfo001/thrtimerinfo001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupChildren/getthrdgrpchld001/getthrdgrpchld001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo001/thrgrpinfo001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo002/thrgrpinfo002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadInfo/thrinfo001/thrinfo001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadInfo/thrinfo002/thrinfo002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadLocalStorage/getthrdstor001/getthrdstor001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat001/thrstat001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat002/thrstat002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat003/thrstat003.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat004/thrstat004.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat005/thrstat005.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTime/gettime001/gettime001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTimerInfo/timerinfo001/timerinfo001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp001/topthrgrp001.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp002/topthrgrp002.cpp	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetVersionNumber/getvern001/getvern001.cpp	Thu Sep 13 10:54:11 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/InterruptThread/intrpthrd002/intrpthrd002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/InterruptThread/intrpthrd002/intrpthrd002.cpp	Thu Sep 13 10:54:11 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/InterruptThread/intrpthrd003/intrpthrd003.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/InterruptThread/intrpthrd003/intrpthrd003.cpp	Thu Sep 13 10:54:11 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,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;
@@ -140,6 +126,4 @@
     return JNI_FALSE;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsArrayClass/isarray004/isarray004.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsArrayClass/isarray004/isarray004.cpp	Thu Sep 13 10:54:11 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/IsArrayClass/isarray005/isarray005.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsArrayClass/isarray005/isarray005.cpp	Thu Sep 13 10:54:11 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;
@@ -125,6 +111,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsFieldSynthetic/isfldsin002/isfldsin002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsFieldSynthetic/isfldsin002/isfldsin002.cpp	Thu Sep 13 10:54:11 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;
@@ -116,7 +102,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;
@@ -168,6 +154,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsFieldSynthetic/isfldsin003/isfldsin003.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsFieldSynthetic/isfldsin003/isfldsin003.cpp	Thu Sep 13 10:54:11 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
@@ -81,15 +68,7 @@
         printdump = JNI_TRUE;
     }
 
-    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (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;
-    }
-
-    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,8 +120,7 @@
     }
 
     for (i = 0; i < sizeof(fields) / sizeof(field_info); i++) {
-        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",
                    i, fields[i].name, fields[i].sig);
@@ -175,6 +153,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsInterface/isintrf004/isintrf004.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsInterface/isintrf004/isintrf004.cpp	Thu Sep 13 10:54:11 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/IsInterface/isintrf005/isintrf005.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsInterface/isintrf005/isintrf005.cpp	Thu Sep 13 10:54:11 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;
@@ -123,6 +109,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodNative/isnative001/isnative001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodNative/isnative001/isnative001.cpp	Thu Sep 13 10:54:11 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,9 +75,9 @@
     jboolean is_native;
 
     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);
@@ -129,8 +115,7 @@
     checkMeth(env, cls, "nmeth", "()V", 0, JNI_TRUE);
     checkMeth(env, cls, "check", "()I", 1, JNI_TRUE);
 
-    clsId = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/IsMethodNative/isnative001$Inn"));
+    clsId = env->FindClass("nsk/jvmti/IsMethodNative/isnative001$Inn");
     if (clsId == NULL) {
         printf("Cannot find nsk.jvmti.IsMethodNative.isnative001$Inn class!\n");
         return STATUS_FAILED;
@@ -141,6 +126,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodNative/isnative002/isnative002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodNative/isnative002/isnative002.cpp	Thu Sep 13 10:54:11 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/IsMethodSynthetic/issynth001/issynth001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodSynthetic/issynth001/issynth001.cpp	Thu Sep 13 10:54:11 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
@@ -93,8 +80,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,11 +135,9 @@
         cl = ((methods[i].class_id == 1) ? cls1 :
                 ((methods[i].class_id == 2) ? cls2 : cls3));
         if (methods[i].is_static == JNI_TRUE) {
-            mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cl),
-                methods[i].name, methods[i].signature);
+            mid = env->GetStaticMethodID(cl, methods[i].name, methods[i].signature);
         } else {
-            mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cl),
-                methods[i].name, methods[i].signature);
+            mid = env->GetMethodID(cl, methods[i].name, methods[i].signature);
         }
         if (mid == NULL) {
             printf("Cannot find MethodID for \"%s%s\"\n",
@@ -190,6 +174,4 @@
 Java_nsk_jvmti_IsMethodSynthetic_issynth001a_nmeth(JNIEnv *env, jclass cls) {
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodSynthetic/issynth002/issynth002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodSynthetic/issynth002/issynth002.cpp	Thu Sep 13 10:54:11 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;
@@ -116,8 +102,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 find method \"<init>()V\"!\n");
         return STATUS_FAILED;
@@ -156,6 +141,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/MethodEntry/mentry001/mentry001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/MethodEntry/mentry001/mentry001.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -29,21 +29,7 @@
 #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
@@ -170,8 +156,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;
@@ -240,14 +225,13 @@
 Java_nsk_jvmti_MethodEntry_mentry001_check(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("Cannot find metod \"dummy()\"!\n");
         return STATUS_FAILED;
     }
 
-    JNI_ENV_PTR(env)->CallStaticVoidMethod(JNI_ENV_ARG(env, cls), mid);
+    env->CallStaticVoidMethod(cls, mid);
     if (eventsCount != eventsExpected) {
         printf("Wrong number of MethodEntry events: %" PRIuPTR ", expected: %" PRIuPTR "\n",
             eventsCount, eventsExpected);
@@ -279,6 +263,4 @@
     }
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/MethodEntry/mentry002/mentry002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/MethodEntry/mentry002/mentry002.cpp	Thu Sep 13 10:54:11 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
@@ -91,8 +78,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;
@@ -150,8 +136,7 @@
         return;
     }
 
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-            "emptyMethod", "()V");
+    mid = env->GetStaticMethodID(cls, "emptyMethod", "()V");
     if (mid == NULL) {
         printf("Cannot find Method ID for emptyMethod\n");
         result = STATUS_FAILED;
@@ -198,6 +183,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/MethodExit/mexit001/mexit001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/MethodExit/mexit001/mexit001.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -29,21 +29,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
@@ -172,8 +159,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;
@@ -252,21 +238,19 @@
         return result;
     }
 
-    clz = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/MethodExit/mexit001a"));
+    clz = env->FindClass("nsk/jvmti/MethodExit/mexit001a");
     if (clz == NULL) {
         printf("Cannot find nsk.jvmti.MethodExit.mexit001a class!\n");
         return STATUS_FAILED;
     }
 
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, clz),
-        "dummy", "()V");
+    mid = env->GetStaticMethodID(clz, "dummy", "()V");
     if (mid == NULL) {
         printf("Cannot find metod \"dummy()\"!\n");
         return STATUS_FAILED;
     }
 
-    JNI_ENV_PTR(env)->CallStaticVoidMethod(JNI_ENV_ARG(env, clz), mid);
+    env->CallStaticVoidMethod(clz, mid);
 
     err = jvmti->SetEventNotificationMode(JVMTI_DISABLE,
             JVMTI_EVENT_METHOD_EXIT, NULL);
@@ -289,6 +273,4 @@
     printf("Executing chain()\n");
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/MethodExit/mexit002/mexit002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/MethodExit/mexit002/mexit002.cpp	Thu Sep 13 10:54:11 2018 -0700
@@ -29,21 +29,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
@@ -172,8 +159,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;
@@ -230,15 +216,13 @@
         return result;
     }
 
-    clz = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/MethodExit/mexit002a"));
+    clz = env->FindClass("nsk/jvmti/MethodExit/mexit002a");
     if (clz == NULL) {
         printf("Failed to find class \"mexit002a\"!\n");
         return STATUS_FAILED;
     }
 
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, clz),
-        "dummy", "()V");
+    mid = env->GetStaticMethodID(clz, "dummy", "()V");
     if (mid == NULL) {
         printf("Failed to get method \"dummy\"!\n");
         return STATUS_FAILED;
@@ -254,7 +238,7 @@
         result = STATUS_FAILED;
     }
 
-    JNI_ENV_PTR(env)->CallStaticVoidMethod(JNI_ENV_ARG(env, clz), mid);
+    env->CallStaticVoidMethod(clz, mid);
 
     err = jvmti->SetEventNotificationMode(JVMTI_DISABLE,
             JVMTI_EVENT_METHOD_EXIT, NULL);
@@ -279,6 +263,4 @@
     }
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop001/nframepop001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop001/nframepop001.cpp	Thu Sep 13 10:54:11 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 @@
         jmethodID method, jboolean wasPopedByException) {
     jvmtiError err;
 
-    popThread = JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG((JNIEnv *)env,
-        thread));
+    popThread = env->NewGlobalRef(thread);
 
     err = jvmti_env->GetMethodDeclaringClass(method, &popClass);
     if (err != JVMTI_ERROR_NONE) {
@@ -72,8 +58,7 @@
                TranslateError(err), err);
         result = STATUS_FAILED;
     }
-    popClass = (jclass) JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG((JNIEnv *)env,
-        popClass));
+    popClass = (jclass) env->NewGlobalRef(popClass);
 
     popMethod = method;
     popFlag = wasPopedByException;
@@ -95,8 +80,7 @@
     jvmtiError err;
 
     if (method == mid1 || method == mid2) {
-        currThread = JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG((JNIEnv *)env,
-            thread));
+        currThread = env->NewGlobalRef(thread);
 
         err = jvmti_env->GetMethodDeclaringClass(
             method, &currClass);
@@ -105,8 +89,7 @@
                    TranslateError(err), err);
             result = STATUS_FAILED;
         }
-        currClass = (jclass) JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG((JNIEnv *)env,
-            currClass));
+        currClass = (jclass) env->NewGlobalRef(currClass);
 
         currMethod = method;
 
@@ -147,8 +130,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;
@@ -215,16 +197,14 @@
         }
     }
 
-    mid1 = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cl),
-        "meth01", "(I)V");
+    mid1 = env->GetMethodID(cl, "meth01", "(I)V");
     if (mid1 == NULL) {
         printf("Cannot find method \"meth01\"\n");
         result = STATUS_FAILED;
         return;
     }
 
-    mid2 = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cl),
-        "meth02", "(I)V");
+    mid2 = env->GetMethodID(cl, "meth02", "(I)V");
     if (mid2 == NULL) {
         printf("Cannot find method \"meth02\"\n");
         result = STATUS_FAILED;
@@ -259,19 +239,17 @@
         result = STATUS_FAILED;
     }
 
-    currThread = JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env, thr));
+    currThread = env->NewGlobalRef(thr);
 
-    currClass = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
-        "nsk/jvmti/NotifyFramePop/nframepop001a"));
+    currClass = env->FindClass("nsk/jvmti/NotifyFramePop/nframepop001a");
     if (currClass == NULL) {
         printf("Cannot find nsk.jvmti.NotifyFramePop.nframepop001a class!\n");
         result = STATUS_FAILED;
         return;
     }
-    currClass = (jclass) JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env, currClass));
+    currClass = (jclass) env->NewGlobalRef(currClass);
 
-    currMethod = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, currClass),
-        "run", "()V");
+    currMethod = env->GetMethodID(currClass, "run", "()V");
     if (currMethod == NULL) {
         printf("Cannot find method \"run\"\n");
         result = STATUS_FAILED;
@@ -310,14 +288,12 @@
         return;
     }
 
-    if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, currThread),
-            popThread) != JNI_TRUE) {
+    if (!env->IsSameObject(currThread, popThread)) {
         printf("Point %d: thread is not the same as expected\n", point);
         result = STATUS_FAILED;
     }
 
-    if (JNI_ENV_PTR(env)->IsSameObject(JNI_ENV_ARG(env, currClass),
-            popClass) != JNI_TRUE) {
+    if (!env->IsSameObject(currClass, popClass)) {
         printf("Point %d: class is not the same as expected\n", point);
         result = STATUS_FAILED;
     }
@@ -352,6 +328,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop002/nframepop002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop002/nframepop002.cpp	Thu Sep 13 10:54:11 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;
@@ -123,6 +109,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop003/nframepop003.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop003/nframepop003.cpp	Thu Sep 13 10:54:11 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/PopFrame/popframe001/popframe001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe001/popframe001.cpp	Thu Sep 13 10:54:11 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
@@ -195,8 +182,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 JNI_OK;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe002/popframe002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe002/popframe002.cpp	Thu Sep 13 10:54:11 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
@@ -211,8 +198,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;
@@ -268,6 +254,4 @@
     return JNI_OK;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003/popframe003.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003/popframe003.cpp	Thu Sep 13 10:54:11 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
@@ -196,8 +183,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;
@@ -258,6 +244,4 @@
     return JNI_OK;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe004/popframe004.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe004/popframe004.cpp	Thu Sep 13 10:54:11 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
@@ -220,8 +207,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;
@@ -289,12 +275,10 @@
 
 void nativeMeth2(JNIEnv *env, jobject obj, jint vrb,
         jobject frameThr) {
-    jclass cls =
-        JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, frameThr));
+    jclass cls = env->GetObjectClass(frameThr);
     jmethodID mid = NULL;
 
-    if ((mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls),
-        "activeMethod", "()V")) == NULL) {
+    if ((mid = env->GetMethodID(cls, "activeMethod", "()V")) == NULL) {
         printf("TEST FAILURE: nativeMeth2(): Unable to get method ID\n");
         tot_result = STATUS_FAILED;
         return;
@@ -303,7 +287,7 @@
         printf("nativeMeth2(): calling the Java activeMethod()\n");
         fflush(stdout);
     }
-    JNI_ENV_PTR(env)->CallVoidMethod(JNI_ENV_ARG(env, frameThr), mid);
+    env->CallVoidMethod(frameThr, mid);
 }
 
 JNIEXPORT void JNICALL
@@ -316,6 +300,4 @@
     nativeMeth2(env, obj, vrb, frameThr);
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe006/popframe006.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe006/popframe006.cpp	Thu Sep 13 10:54:11 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
@@ -364,8 +351,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;
@@ -435,39 +421,35 @@
         return;
     }
 
-    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_run = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz),
-        "run", "()V");
+    mid_run = env->GetMethodID(clazz, "run", "()V");
     if (mid_run == NULL) {
         printf("Cannot find Method ID for method \"run\"\n");
         result = STATUS_FAILED;
         return;
     }
 
-    mid_A = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, clazz),
-        "A", "()V");
+    mid_A = env->GetStaticMethodID(clazz, "A", "()V");
     if (mid_A == NULL) {
         printf("Cannot find Method ID for method \"A\"\n");
         result = STATUS_FAILED;
         return;
     }
 
-    mid_B = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, clazz),
-        "B", "()V");
+    mid_B = env->GetStaticMethodID(clazz, "B", "()V");
     if (mid_B == NULL) {
         printf("Cannot find Method ID for method \"B\"\n");
         result = STATUS_FAILED;
         return;
     }
 
-    mid_C = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, clazz),
-        "C", "()V");
+    mid_C = env->GetStaticMethodID(clazz, "C", "()V");
     if (mid_C == NULL) {
         printf("Cannot find Method ID for method \"C\"\n");
         result = STATUS_FAILED;
@@ -529,6 +511,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe007/popframe007.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe007/popframe007.cpp	Thu Sep 13 10:54:11 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
@@ -103,8 +90,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,15 +152,14 @@
         return;
     }
 
-    clazz = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, thr));
+    clazz = env->GetObjectClass(thr);
     if (clazz == NULL) {
         printf("Cannot get class of the thread object\n");
         result = STATUS_FAILED;
         return;
     }
 
-    mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, clazz),
-        "C", "()V");
+    mid = env->GetStaticMethodID(clazz, "C", "()V");
     if (mid == NULL) {
         printf("Cannot find Method ID for method \"C\"\n");
         result = STATUS_FAILED;
@@ -206,10 +191,8 @@
 JNIEXPORT void JNICALL
 Java_nsk_jvmti_PopFrame_popframe007_B(JNIEnv *env, jclass cls) {
     if (mid != NULL) {
-        JNI_ENV_PTR(env)->CallStaticVoidMethod(JNI_ENV_ARG(env, cls), mid);
+        env->CallStaticVoidMethod(cls, mid);
     }
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe008/popframe008.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe008/popframe008.cpp	Thu Sep 13 10:54:11 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
@@ -212,8 +199,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;
@@ -279,22 +265,21 @@
         return;
     }
 
-    clazz = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, thr));
+    clazz = env->GetObjectClass(thr);
     if (clazz == NULL) {
         printf("Cannot get class of the thread object\n");
         result = STATUS_FAILED;
         return;
     }
 
-    midD = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz), "D", "()V");
+    midD = env->GetMethodID(clazz, "D", "()V");
     if (midD == NULL) {
         printf("Cannot get Method ID for method \"D\"\n");
         result = STATUS_FAILED;
         return;
     }
 
-    midRun = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz),
-        "run", "()V");
+    midRun = env->GetMethodID(clazz, "run", "()V");
     if (midRun == NULL) {
         printf("Cannot get Method ID for method \"run\"\n");
         result = STATUS_FAILED;
@@ -328,6 +313,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe009/popframe009.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe009/popframe009.cpp	Thu Sep 13 10:54:11 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
@@ -182,8 +169,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;
@@ -251,8 +237,7 @@
         return;
     }
 
-    midCheckPoint = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-         "checkPoint", "()V");
+    midCheckPoint = env->GetStaticMethodID(cls, "checkPoint", "()V");
     if (midCheckPoint == NULL) {
         printf("Cannot find Method ID for method checkPoint\n");
         result = STATUS_FAILED;
@@ -426,21 +411,19 @@
         result = STATUS_FAILED;
     }
 
-    midFibonacci = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
-        "fibonacci", "(I)I");
+    midFibonacci = env->GetStaticMethodID(cls, "fibonacci", "(I)I");
     if (midFibonacci == NULL) {
         printf("Cannot get method ID for method \"fibonacci\"\n");
         result = STATUS_FAILED;
     }
 
-    clazz = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, thr));
+    clazz = env->GetObjectClass(thr);
     if (clazz == NULL) {
         printf("Cannot get class of thread object\n");
         return STATUS_FAILED;
     }
 
-    midRun = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz),
-        "run", "()V");
+    midRun = env->GetMethodID(clazz, "run", "()V");
     if (midRun == NULL) {
         printf("Cannot get method ID for \"run\"\n");
         return STATUS_FAILED;
@@ -608,6 +591,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe010/popframe010.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe010/popframe010.cpp	Thu Sep 13 10:54:11 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
@@ -249,8 +236,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;
@@ -314,16 +300,14 @@
         return;
     }
 
-    midRun = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls),
-         "run", "()V");
+    midRun = env->GetMethodID(cls, "run", "()V");
     if (midRun == NULL) {
         printf("Cannot find Method ID for method run\n");
         result = STATUS_FAILED;
         return;
     }
 
-    midCheckPoint = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls),
-         "checkPoint", "()V");
+    midCheckPoint = env->GetMethodID(cls, "checkPoint", "()V");
     if (midCheckPoint == NULL) {
         printf("Cannot find Method ID for method checkPoint\n");
         result = STATUS_FAILED;
@@ -359,6 +343,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe011/popframe011.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe011/popframe011.cpp	Thu Sep 13 10:54:11 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
@@ -257,8 +244,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;
@@ -314,6 +300,4 @@
     return JNI_OK;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter001/rawmonenter001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter001/rawmonenter001.cpp	Thu Sep 13 10:54:11 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
@@ -119,8 +106,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;
@@ -194,6 +180,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter002/rawmonenter002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter002/rawmonenter002.cpp	Thu Sep 13 10:54:11 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;
@@ -105,6 +91,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter003/rawmonenter003.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter003/rawmonenter003.cpp	Thu Sep 13 10:54:11 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;
@@ -107,6 +93,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter004/rawmonenter004.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter004/rawmonenter004.cpp	Thu Sep 13 10:54:11 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,15 +123,14 @@
         return STATUS_FAILED;
     }
 
-    threads_limit = JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, threads));
+    threads_limit = env->GetArrayLength(threads);
 
     if (printdump == JNI_TRUE) {
         printf(">>> starting %d threads ...\n", threads_limit);
     }
 
     for (i = 0; i < threads_limit; i++) {
-        thr = JNI_ENV_PTR(env)->GetObjectArrayElement(JNI_ENV_ARG(env,
-            threads), i);
+        thr = env->GetObjectArrayElement(threads, i);
         err = jvmti->RunAgentThread(thr, increment_thread, NULL,
                                     JVMTI_THREAD_NORM_PRIORITY);
         if (err != JVMTI_ERROR_NONE) {
@@ -192,6 +177,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit001/rawmonexit001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit001/rawmonexit001.cpp	Thu Sep 13 10:54:11 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
@@ -132,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;
@@ -220,6 +206,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit002/rawmonexit002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit002/rawmonexit002.cpp	Thu Sep 13 10:54:11 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;
@@ -105,6 +91,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit003/rawmonexit003.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit003/rawmonexit003.cpp	Thu Sep 13 10:54:11 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;
@@ -107,6 +93,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit005/rawmonexit005.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit005/rawmonexit005.cpp	Thu Sep 13 10:54:11 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;
@@ -114,6 +100,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy001/rawmnntfy001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy001/rawmnntfy001.cpp	Thu Sep 13 10:54:11 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
@@ -145,8 +132,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;
@@ -246,6 +232,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy002/rawmnntfy002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy002/rawmnntfy002.cpp	Thu Sep 13 10:54:11 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;
@@ -105,6 +91,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy003/rawmnntfy003.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy003/rawmnntfy003.cpp	Thu Sep 13 10:54:11 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;
@@ -107,6 +93,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy004/rawmnntfy004.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy004/rawmnntfy004.cpp	Thu Sep 13 10:54:11 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,6 +99,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall001/rawmnntfyall001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall001/rawmnntfyall001.cpp	Thu Sep 13 10:54:11 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
@@ -145,8 +132,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;
@@ -246,6 +232,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall002/rawmnntfyall002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall002/rawmnntfyall002.cpp	Thu Sep 13 10:54:11 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;
@@ -105,6 +91,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall003/rawmnntfyall003.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall003/rawmnntfyall003.cpp	Thu Sep 13 10:54:11 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;
@@ -107,6 +93,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall004/rawmnntfyall004.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall004/rawmnntfyall004.cpp	Thu Sep 13 10:54:11 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,6 +99,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait001/rawmnwait001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait001/rawmnwait001.cpp	Thu Sep 13 10:54:11 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;
@@ -247,6 +233,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait002/rawmnwait002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait002/rawmnwait002.cpp	Thu Sep 13 10:54:11 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;
@@ -106,6 +92,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait003/rawmnwait003.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait003/rawmnwait003.cpp	Thu Sep 13 10:54:11 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;
@@ -108,6 +94,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait004/rawmnwait004.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait004/rawmnwait004.cpp	Thu Sep 13 10:54:11 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;
@@ -114,6 +100,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait005/rawmnwait005.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait005/rawmnwait005.cpp	Thu Sep 13 10:54:11 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;
@@ -300,6 +286,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine/stressRedefine.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine/stressRedefine.cpp	Thu Sep 13 10:54:11 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
@@ -53,8 +40,7 @@
     jint res;
     jvmtiError err;
 
-    if ((res = JNI_ENV_PTR(vm)->GetEnv(JNI_ENV_ARG(vm, (void **) &jvmti),
-            JVMTI_VERSION_1_1)) != JNI_OK) {
+    if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
         printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
         return JNI_ERR;
     }
@@ -104,11 +90,8 @@
 
 /* filling the structure jvmtiClassDefinition */
     classDef.klass = redefCls;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, classBytes));
-    classDef.class_bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, classBytes),
-            NULL);
+    classDef.class_byte_count = env->GetArrayLength(classBytes);
+    classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL);
 
     if (fl == 2) {
         printf(">>>>>>>> Invoke RedefineClasses():\n");
@@ -128,6 +111,4 @@
     return PASSED;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass001/redefclass001.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass001/redefclass001.cpp	Thu Sep 13 10:54:11 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
@@ -64,8 +51,7 @@
     jint res;
     jvmtiError err;
 
-    if ((res = JNI_ENV_PTR(vm)->GetEnv(JNI_ENV_ARG(vm, (void **) &jvmti),
-            JVMTI_VERSION_1_1)) != JNI_OK) {
+    if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
         printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
         return JNI_ERR;
     }
@@ -115,11 +101,8 @@
 
 /* filling the structure jvmtiClassDefinition */
     classDef.klass = redefCls;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, classBytes));
-    classDef.class_bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, classBytes),
-            NULL);
+    classDef.class_byte_count = env->GetArrayLength(classBytes);
+    classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL);
 
     if (fl == 2) {
         printf(">>>>>>>> Invoke RedefineClasses():\n");
@@ -139,6 +122,4 @@
     return PASSED;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass002/redefclass002.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass002/redefclass002.cpp	Thu Sep 13 10:54:11 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
@@ -64,8 +51,7 @@
     jint res;
     jvmtiError err;
 
-    if ((res = JNI_ENV_PTR(vm)->GetEnv(JNI_ENV_ARG(vm, (void **) &jvmti),
-            JVMTI_VERSION_1_1)) != JNI_OK) {
+    if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
         printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
         return JNI_ERR;
     }
@@ -155,10 +141,8 @@
 
 /* filling the structure jvmtiClassDefinition */
     classDef.klass = redefCls;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, classBytes));
-    classDef.class_bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, classBytes), NULL);
+    classDef.class_byte_count = env->GetArrayLength(classBytes);
+    classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL);
 
     if (vrb == 1)
         printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
@@ -175,6 +159,4 @@
     return PASSED;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass003/redefclass003.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass003/redefclass003.cpp	Thu Sep 13 10:54:11 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 STATUS_FAILED 2
 #define PASSED 0
@@ -66,8 +53,7 @@
     jint res;
     jvmtiError err;
 
-    if ((res = JNI_ENV_PTR(vm)->GetEnv(JNI_ENV_ARG(vm, (void **) &jvmti),
-            JVMTI_VERSION_1_1)) != JNI_OK) {
+    if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
         printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
         return JNI_ERR;
     }
@@ -118,10 +104,8 @@
 
 /* filling the structure jvmtiClassDefinition */
     classDef.klass = redefCls;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, classBytes));
-    classDef.class_bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, classBytes), NULL);
+    classDef.class_byte_count = env->GetArrayLength(classBytes);
+    classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL);
 
     if (vrb == 1)
         printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
@@ -153,23 +137,19 @@
     jint intFld;
     jlong longFld;
 
-    if ((fid = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG(env, redefCls),
-        "intComplNewFld", "I")) == NULL) {
+    if ((fid = env->GetStaticFieldID(redefCls, "intComplNewFld", "I")) == NULL) {
         printf("%s: Failed to get the field ID for the static field \"intComplNewFld\"\n",
             __FILE__);
         return STATUS_FAILED;
     }
-    intFld = JNI_ENV_PTR(env)->GetStaticIntField(JNI_ENV_ARG(env, redefCls),
-        fid);
+    intFld = env->GetStaticIntField(redefCls, fid);
 
-    if ((fid = JNI_ENV_PTR(env)->GetStaticFieldID(JNI_ENV_ARG(env, redefCls),
-        "longComplNewFld", "J")) == NULL) {
+    if ((fid = env->GetStaticFieldID(redefCls, "longComplNewFld", "J")) == NULL) {
         printf("%s: Failed to get the field ID for the static field \"longComplNewFld\"\n",
             __FILE__);
         return STATUS_FAILED;
     }
-    longFld = JNI_ENV_PTR(env)->GetStaticLongField(JNI_ENV_ARG(env, redefCls),
-        fid);
+    longFld = env->GetStaticLongField(redefCls, fid);
 
     if (intFld != 33 || longFld != 44) {
         printf("Completely new static variable has not assigned its default value:\n");
@@ -184,6 +164,4 @@
     }
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass004/redefclass004.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass004/redefclass004.cpp	Thu Sep 13 10:54:11 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 STATUS_FAILED 2
 #define PASSED 0
@@ -71,8 +58,7 @@
     jint res;
     jvmtiError err;
 
-    if ((res = JNI_ENV_PTR(vm)->GetEnv(JNI_ENV_ARG(vm, (void **) &jvmti),
-            JVMTI_VERSION_1_1)) != JNI_OK) {
+    if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
         printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
         return JNI_ERR;
     }
@@ -123,10 +109,8 @@
 
 /* fill the structure jvmtiClassDefinition */
     classDef.klass = redefCls;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, classBytes));
-    classDef.class_bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, classBytes), NULL);
+    classDef.class_byte_count = env->GetArrayLength(classBytes);
+    classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL);
 
     if (vrb == 1)
         printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
@@ -154,8 +138,7 @@
 JNIEXPORT jint JNICALL
 Java_nsk_jvmti_RedefineClasses_redefclass004_checkNewFields(JNIEnv *env,
         jobject obj, jint vrb, jobject redefObj) {
-    jclass redefCls =
-        JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, redefObj));
+    jclass redefCls = env->GetObjectClass(redefObj);
     jfieldID fid;
     jint intFld;
     jlong longFld;
@@ -163,34 +146,29 @@
     const char *strFld = NULL;
 
 /* get value of new instance field "intComplNewFld" */
-    if ((fid = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG(env, redefCls),
-        "intComplNewFld", "I")) == NULL) {
+    if ((fid = env->GetFieldID(redefCls, "intComplNewFld", "I")) == NULL) {
         printf("%s: Failed to get the field ID for the field \"intComplNewFld\"\n",
             __FILE__);
         return STATUS_FAILED;
     }
-    intFld = JNI_ENV_PTR(env)->GetIntField(JNI_ENV_ARG(env, redefObj), fid);
+    intFld = env->GetIntField(redefObj, fid);
 
 /* get value of new instance field "longComplNewFld" */
-    if ((fid = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG(env, redefCls),
-        "longComplNewFld", "J")) == NULL) {
+    if ((fid = env->GetFieldID(redefCls, "longComplNewFld", "J")) == NULL) {
         printf("%s: Failed to get the field ID for the field \"longComplNewFld\"\n",
             __FILE__);
         return STATUS_FAILED;
     }
-    longFld = JNI_ENV_PTR(env)->GetLongField(JNI_ENV_ARG(env, redefObj), fid);
+    longFld = env->GetLongField(redefObj, fid);
 
 /* get value of new instance field "stringComplNewFld" */
-    if ((fid = JNI_ENV_PTR(env)->GetFieldID(JNI_ENV_ARG(env, redefCls),
-        "stringComplNewFld", "Ljava/lang/String;")) == NULL) {
+    if ((fid = env->GetFieldID(redefCls, "stringComplNewFld", "Ljava/lang/String;")) == NULL) {
         printf("%s: Failed to get the field ID for the field \"stringComplNewFld\"\n",
             __FILE__);
         return STATUS_FAILED;
     }
-    stringObj = (jstring) JNI_ENV_PTR(env)->GetObjectField(JNI_ENV_ARG(env,
-        redefObj), fid);
-    strFld = JNI_ENV_PTR(env)->GetStringUTFChars(JNI_ENV_ARG(env,
-        stringObj), 0);
+    stringObj = (jstring) env->GetObjectField(redefObj, fid);
+    strFld = env->GetStringUTFChars(stringObj, 0);
 
     if (intFld != INTFLD || longFld != LONGFLD ||
         strcmp(strFld, STRFLD) != 0) {
@@ -201,8 +179,7 @@
         printf(",\texpected %" LL "d\n", LONGFLD);
         printf("\tstringComplNewFld = \"%s\",\texpected \"%s\"\n",
             strFld, STRFLD);
-        JNI_ENV_PTR(env)->ReleaseStringUTFChars(JNI_ENV_ARG(env,
-            stringObj), strFld);
+        env->ReleaseStringUTFChars(stringObj, strFld);
         return STATUS_FAILED;
     } else {
         if (vrb == 1)
@@ -210,12 +187,9 @@
 \tstringComplNewFld = \"%s\"\n\tintComplNewFld = %d\n\
 \tlongComplNewFld = %" LL "d\n",
                 strFld, intFld, longFld);
-        JNI_ENV_PTR(env)->ReleaseStringUTFChars(JNI_ENV_ARG(env,
-            stringObj), strFld);
+        env->ReleaseStringUTFChars(stringObj, strFld);
         return PASSED;
     }
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass005/redefclass005.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass005/redefclass005.cpp	Thu Sep 13 10:54:11 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
@@ -119,8 +106,7 @@
     jint res;
     jvmtiError err;
 
-    if ((res = JNI_ENV_PTR(vm)->GetEnv(JNI_ENV_ARG(vm, (void **) &jvmti),
-            JVMTI_VERSION_1_1)) != JNI_OK) {
+    if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
         printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
         return JNI_ERR;
     }
@@ -213,10 +199,8 @@
 
 /* filling the structure jvmtiClassDefinition */
     classDef.klass = redefCls;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, classBytes));
-    classDef.class_bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, classBytes), NULL);
+    classDef.class_byte_count = env->GetArrayLength(classBytes);
+    classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL);
 
     set_watch_ev(1); /* watch JVMTI events */
 
@@ -250,6 +234,4 @@
     return(result);
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass006/redefclass006.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass006/redefclass006.cpp	Thu Sep 13 10:54:11 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
@@ -64,8 +51,7 @@
     jint res;
     jvmtiError err;
 
-    if ((res = JNI_ENV_PTR(vm)->GetEnv(JNI_ENV_ARG(vm, (void **) &jvmti),
-            JVMTI_VERSION_1_1)) != JNI_OK) {
+    if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
         printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
         return JNI_ERR;
     }
@@ -132,8 +118,7 @@
         case 2:
             /* partly fill the structure jvmtiClassDefinition */
             classDef.klass = redefCls;
-            classDef.class_byte_count =
-                JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, classBytes));
+            classDef.class_byte_count = env->GetArrayLength(classBytes);
             classDef.class_bytes = NULL;
             classDefPtr = &classDef;
             break;
@@ -150,6 +135,4 @@
     return PASSED;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass008/redefclass008.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass008/redefclass008.cpp	Thu Sep 13 10:54:11 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 BP_NUM 5 /* overall number of breakpoints */
 
@@ -90,8 +77,7 @@
     jint res;
     jvmtiError err;
 
-    if ((res = JNI_ENV_PTR(vm)->GetEnv(JNI_ENV_ARG(vm, (void **) &jvmti),
-            JVMTI_VERSION_1_1)) != JNI_OK) {
+    if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
         printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
         return JNI_ERR;
     }
@@ -146,25 +132,24 @@
         return PASSED;
     }
 
-    redefCls =
-        JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, redefObj));
+    redefCls = env->GetObjectClass(redefObj);
 
     for (i=0; i<BP_NUM; i++) {
 /* get the JNI method ID for a method with name m_name and
    signature m_sign */
         if (breakpoints[i].inst) { /* an instance method */
-            if ((breakpoints[i].mid =
-                    JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, redefCls),
-                    breakpoints[i].m_name, breakpoints[i].m_sign)) == NULL) {
+            breakpoints[i].mid = env->GetMethodID(
+                redefCls, breakpoints[i].m_name, breakpoints[i].m_sign);
+            if (breakpoints[i].mid == NULL) {
                 printf("%s: Failed to get the method ID for the instance method\
  \"%s\" with signature \"%s\"\n",
                     __FILE__, breakpoints[i].m_name, breakpoints[i].m_sign);
                 return STATUS_FAILED;
             }
         } else {                   /* a static method */
-            if ((breakpoints[i].mid =
-                    JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, redefCls),
-                    breakpoints[i].m_name, breakpoints[i].m_sign)) == NULL) {
+            breakpoints[i].mid = env->GetStaticMethodID(
+                redefCls, breakpoints[i].m_name, breakpoints[i].m_sign);
+            if (breakpoints[i].mid == NULL) {
                 printf("%s: Failed to get the method ID for the static method\
  \"%s\" with signature \"%s\"\n",
                     __FILE__, breakpoints[i].m_name, breakpoints[i].m_sign);
@@ -215,10 +200,8 @@
 
 /* fill the structure jvmtiClassDefinition */
     classDef.klass = redefCls;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, classBytes));
-    classDef.class_bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, classBytes), NULL);
+    classDef.class_byte_count = env->GetArrayLength(classBytes);
+    classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL);
 
     if (vrb == 1)
         printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
@@ -246,26 +229,25 @@
         return PASSED;
     }
 
-    redefCls =
-        JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, redefObj));
+    redefCls = env->GetObjectClass(redefObj);
 
 /* all breakpoints should be cleared after the redefinition */
     for (i=0; i<BP_NUM; i++) {
 /* get again the JNI method ID for a method with name m_name and
    signature m_sign */
         if (breakpoints[i].inst) { /* an instance method */
-            if ((breakpoints[i].mid =
-                    JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, redefCls),
-                    breakpoints[i].m_name, breakpoints[i].m_sign)) == NULL) {
+            breakpoints[i].mid = env->GetMethodID(
+                redefCls, breakpoints[i].m_name, breakpoints[i].m_sign);
+            if (breakpoints[i].mid == NULL) {
                 printf("%s: getResult: Failed to get the method ID for the instance method\
  \"%s\" with signature \"%s\"\n",
                     __FILE__, breakpoints[i].m_name, breakpoints[i].m_sign);
                 return STATUS_FAILED;
             }
         } else {                   /* a static method */
-            if ((breakpoints[i].mid =
-                    JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, redefCls),
-                    breakpoints[i].m_name, breakpoints[i].m_sign)) == NULL) {
+            breakpoints[i].mid = env->GetStaticMethodID(
+                redefCls, breakpoints[i].m_name, breakpoints[i].m_sign);
+            if (breakpoints[i].mid == NULL) {
                 printf("%s: getResult: Failed to get the method ID for the static method\
  \"%s\" with signature \"%s\"\n",
                     __FILE__, breakpoints[i].m_name, breakpoints[i].m_sign);
@@ -303,6 +285,4 @@
     return totRes;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass009/redefclass009.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass009/redefclass009.cpp	Thu Sep 13 10:54:11 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 METH_NUM 4 /* overall number of methods */
 
@@ -127,8 +114,7 @@
     jint res;
     jvmtiError err;
 
-    if ((res = JNI_ENV_PTR(vm)->GetEnv(JNI_ENV_ARG(vm, (void **) &jvmti),
-            JVMTI_VERSION_1_1)) != JNI_OK) {
+    if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
         printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
         return JNI_ERR;
     }
@@ -178,16 +164,15 @@
     }
 
     for (i=0; i<METH_NUM; i++) {
-/* get the JNI method ID for a method with name m_name and
-   signature m_sign */
-        if (methodsInfo[i].inst) /* an instance method */
-            methodsInfo[i].mid =
-                JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, redefCls),
+      /* get the JNI method ID for a method with name m_name and
+         signature m_sign */
+        if (methodsInfo[i].inst) { /* an instance method */
+            methodsInfo[i].mid = env->GetMethodID(redefCls,
                 methodsInfo[i].m_name, methodsInfo[i].m_sign);
-        else                     /* a static method */
-            methodsInfo[i].mid =
-                JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, redefCls),
+        } else {                    /* a static method */
+            methodsInfo[i].mid = env->GetStaticMethodID(redefCls,
                 methodsInfo[i].m_name, methodsInfo[i].m_sign);
+        }
         if (methodsInfo[i].mid == NULL) {
             printf("%s: Failed to get the method ID for the%s%s method\
  \"%s\", signature \"%s\"\n",
@@ -196,7 +181,7 @@
             return STATUS_FAILED;
         }
 
-/* get the LocalVariableTable attribute */
+        /* get the LocalVariableTable attribute */
         if ((err = (jvmti->GetLocalVariableTable(methodsInfo[i].mid,
                 &count, &lv_table))) != JVMTI_ERROR_NONE) {
             printf("%s: Failed to call GetLocalVariableTable(): error=%d: %s\n",
@@ -250,9 +235,8 @@
 JNIEXPORT jint JNICALL
 Java_nsk_jvmti_RedefineClasses_redefclass009_checkOrigAttr(JNIEnv *env,
         jclass cls, jobject redefObj) {
-    jclass redefCls =
-        JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, redefObj));
-/* check only the number of local variables */
+    jclass redefCls = env->GetObjectClass(redefObj);
+    /* check only the number of local variables */
     return checkAttr(env, redefCls, origMethInfo, 0, 0);
 }
 
@@ -271,12 +255,10 @@
         return PASSED;
     }
 
-/* fill the structure jvmtiClassDefinition */
+    /* fill the structure jvmtiClassDefinition */
     classDef.klass = redefCls;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, classBytes));
-    classDef.class_bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, classBytes), NULL);
+    classDef.class_byte_count = env->GetArrayLength(classBytes);
+    classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL);
 
     if (vrb)
         printf("\n>>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
@@ -296,12 +278,8 @@
 JNIEXPORT jint JNICALL
 Java_nsk_jvmti_RedefineClasses_redefclass009_getResult(JNIEnv *env,
         jclass cls, jint vrb, jobject redefObj) {
-    jclass redefCls =
-        JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, redefObj));
-
+    jclass redefCls = env->GetObjectClass(redefObj);
     return checkAttr(env, redefCls, redefMethInfo, vrb, 1);
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass010/redefclass010.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass010/redefclass010.cpp	Thu Sep 13 10:54:11 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 METH_NUM 4 /* overall number of methods */
 
@@ -106,8 +93,7 @@
     jint res;
     jvmtiError err;
 
-    if ((res = JNI_ENV_PTR(vm)->GetEnv(JNI_ENV_ARG(vm, (void **) &jvmti),
-            JVMTI_VERSION_1_1)) != JNI_OK) {
+    if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
         printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
         return JNI_ERR;
     }
@@ -156,16 +142,15 @@
     }
 
     for (i=0; i<METH_NUM; i++) {
-/* get the JNI method ID for a method with name m_name and
-   signature m_sign */
-        if (methodsInfo[i].inst) /* an instance method */
-            methodsInfo[i].mid =
-                JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, redefCls),
+        /* get the JNI method ID for a method with name m_name and
+           signature m_sign */
+        if (methodsInfo[i].inst) { /* an instance method */
+            methodsInfo[i].mid = env->GetMethodID(redefCls,
                     methodsInfo[i].m_name, methodsInfo[i].m_sign);
-        else                     /* a static method */
-            methodsInfo[i].mid =
-                JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, redefCls),
+        } else {                   /* a static method */
+            methodsInfo[i].mid = env->GetStaticMethodID(redefCls,
                     methodsInfo[i].m_name, methodsInfo[i].m_sign);
+        }
         if (methodsInfo[i].mid == NULL) {
             printf("%s: Failed to get the method ID for the%s%s method\
  \"%s\", signature \"%s\"\n",
@@ -174,7 +159,7 @@
             return STATUS_FAILED;
         }
 
-/* get the LineNumberTable attribute */
+        /* get the LineNumberTable attribute */
         if ((err = (jvmti->GetLineNumberTable(methodsInfo[i].mid,
                 &count, &ln_table))) != JVMTI_ERROR_NONE) {
             printf("%s: Failed to call GetLineNumberTable(): error=%d: %s\n",
@@ -228,9 +213,7 @@
 JNIEXPORT jint JNICALL
 Java_nsk_jvmti_RedefineClasses_redefclass010_checkOrigAttr(JNIEnv *env,
         jclass cls, jobject redefObj) {
-    jclass redefCls =
-        JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, redefObj));
-
+    jclass redefCls = env->GetObjectClass(redefObj);
     return checkAttr(env, redefCls, origMethInfo, 2);
 }
 
@@ -249,12 +232,10 @@
         return PASSED;
     }
 
-/* fill the structure jvmtiClassDefinition */
+    /* fill the structure jvmtiClassDefinition */
     classDef.klass = redefCls;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, classBytes));
-    classDef.class_bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, classBytes), NULL);
+    classDef.class_byte_count = env->GetArrayLength(classBytes);
+    classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL);
 
     if (vrb)
         printf("\n>>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
@@ -274,12 +255,8 @@
 JNIEXPORT jint JNICALL
 Java_nsk_jvmti_RedefineClasses_redefclass010_getResult(JNIEnv *env,
     jclass cls, jint vrb, jobject redefObj) {
-    jclass redefCls =
-        JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, redefObj));
-
+    jclass redefCls = env->GetObjectClass(redefObj);
     return checkAttr(env, redefCls, redefMethInfo, vrb);
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass011/redefclass011.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass011/redefclass011.cpp	Thu Sep 13 10:54:11 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,10 +103,8 @@
     }
 
     classDef.klass = NULL;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, bytes));
-    classDef.class_bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, bytes), NULL);
+    classDef.class_byte_count = env->GetArrayLength(bytes);
+    classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, NULL);
 
     if (printdump == JNI_TRUE) {
         printf(">>> invalid class check ...\n");
@@ -142,6 +126,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass012/redefclass012.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass012/redefclass012.cpp	Thu Sep 13 10:54:11 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;
@@ -118,10 +104,8 @@
     }
 
     classDef.klass = cls;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, jbytes));
-    bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, jbytes), NULL);
+    classDef.class_byte_count = env->GetArrayLength(jbytes);
+    bytes = (unsigned char *) env->GetByteArrayElements(jbytes, NULL);
 
     /* put 0,0 into version fields */
     bytes[4] = 0;
@@ -151,6 +135,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass013/redefclass013.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass013/redefclass013.cpp	Thu Sep 13 10:54:11 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;
@@ -118,10 +104,8 @@
     }
 
     classDef.klass = cls;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, jbytes));
-    bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, jbytes), NULL);
+    classDef.class_byte_count = env->GetArrayLength(jbytes);
+    bytes = (unsigned char *) env->GetByteArrayElements(jbytes, NULL);
 
     /* put 0 into magic field */
     bytes[0] = 0;
@@ -151,6 +135,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass014/redefclass014.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass014/redefclass014.cpp	Thu Sep 13 10:54:11 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,10 +109,8 @@
     }
 
     classDef.klass = cls;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, bytes));
-    classDef.class_bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, bytes), NULL);
+    classDef.class_byte_count = env->GetArrayLength(bytes);
+    classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, NULL);
 
     if (printdump == JNI_TRUE) {
         printf(">>> circularity error check ...\n");
@@ -150,6 +134,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass015/redefclass015.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass015/redefclass015.cpp	Thu Sep 13 10:54:11 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,10 +103,8 @@
     }
 
     classDef.klass = clazz;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, bytes));
-    classDef.class_bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, bytes), NULL);
+    classDef.class_byte_count = env->GetArrayLength(bytes);
+    classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, NULL);
 
     if (printdump == JNI_TRUE) {
         printf(">>> verify error check ...\n");
@@ -142,6 +126,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass016/redefclass016.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass016/redefclass016.cpp	Thu Sep 13 10:54:11 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
@@ -157,11 +144,8 @@
     bpeakpointsCount++;
 
     classDef.klass = klass;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG((JNIEnv *)env, classBytes));
-    bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG((JNIEnv *)env,
-            classBytes), NULL);
+    classDef.class_byte_count = env->GetArrayLength(classBytes);
+    bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL);
 
     for (i = 0; i < classDef.class_byte_count - 3; i++) {
         if (((jint)bytes[i+3] |
@@ -219,8 +203,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;
@@ -292,14 +275,14 @@
         !caps.can_get_line_numbers ||
         !caps.can_access_local_variables) return;
 
-    mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz), "run", "()V");
+    mid = env->GetMethodID(clazz, "run", "()V");
     if (mid == NULL) {
         printf("Cannot find Method ID for method run\n");
         result = STATUS_FAILED;
         return;
     }
 
-    classBytes = (jbyteArray) JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env, bytes));
+    classBytes = (jbyteArray) env->NewGlobalRef(bytes);
 
     err = jvmti->GetLineNumberTable(mid, &entryCount, &lines);
     if (err != JVMTI_ERROR_NONE) {
@@ -353,6 +336,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass017/redefclass017.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass017/redefclass017.cpp	Thu Sep 13 10:54:11 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,11 +62,9 @@
     }
 
     classDef.klass = klass;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG((JNIEnv *)env, classBytes));
+    classDef.class_byte_count = env->GetArrayLength(classBytes);
     classDef.class_bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG((JNIEnv *)env,
-            classBytes), NULL);
+        env->GetByteArrayElements(classBytes, NULL);
 
     if (printdump == JNI_TRUE) {
         printf(">>> bp: about to call RedefineClasses\n");
@@ -112,8 +97,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;
@@ -173,15 +157,14 @@
     if (!caps.can_redefine_classes ||
         !caps.can_generate_breakpoint_events) 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 run\n");
         result = STATUS_FAILED;
         return;
     }
 
-    classBytes = (jbyteArray) JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env, bytes));
+    classBytes = (jbyteArray) env->NewGlobalRef(bytes);
 
     err = jvmti->SetBreakpoint(mid, 0);
     if (err != JVMTI_ERROR_NONE) {
@@ -205,6 +188,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass018/redefclass018.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass018/redefclass018.cpp	Thu Sep 13 10:54:11 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,11 +65,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);
+    classDef.class_byte_count = env->GetArrayLength(classBytes);
+    classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL);
 
     if (printdump == JNI_TRUE) {
         printf(">>> about to call RedefineClasses\n");
@@ -115,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;
@@ -177,7 +160,7 @@
     if (!caps.can_redefine_classes ||
         !caps.can_generate_exception_events) return;
 
-    classBytes = (jbyteArray) JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env, bytes));
+    classBytes = (jbyteArray) env->NewGlobalRef(bytes);
 
     if ((err = (jvmti->GetCurrentThread(&thread))) != JVMTI_ERROR_NONE) {
         printf("Failed to get current thread: %s (%d)\n", TranslateError(err), err);
@@ -199,6 +182,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass019/redefclass019.cpp	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass019/redefclass019.cpp	Thu Sep 13 10:54:11 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
@@ -316,11 +303,9 @@
     }
 
     classDef.klass = klass;
-    classDef.class_byte_count =
-        JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG((JNIEnv *)env, classBytes));
+    classDef.class_byte_count = env->GetArrayLength(classBytes);
     classDef.class_bytes = (unsigned char *)
-        JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG((JNIEnv *)env,
-            classBytes), NULL);
+        env->GetByteArrayElements(classBytes, NULL);
 
     if (printdump == JNI_TRUE) {
         printf(">>> about to call RedefineClasses\n");
@@ -381,8 +366,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;
@@ -455,18 +439,16 @@
         !caps.can_get_line_numbers ||
         !caps.can_access_local_variables) return;
 
-    classBytes = (jbyteArray) JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env, bytes));
+    classBytes = (jbyteArray) env->NewGlobalRef(bytes);
 
-    midRun = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz),
-         "run", "()V");
+    midRun = env->GetMethodID(clazz, "run", "()V");
     if (midRun == NULL) {
         printf("Cannot find Method ID for method run\n");
         result = STATUS_FAILED;
         return;
     }
 
-    midCheckPoint = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz),
-         "checkPoint", "()V");
+    midCheckPoint = env->GetMethodID(clazz, "checkPoint", "()V");
     if (midCheckPoint == NULL) {
         printf("Cannot find Method ID for method checkPoint\n");
         result = STATUS_FAILED;
@@ -511,6 +493,4 @@
     return result;
 }
 
-#ifdef __cplusplus
 }
-#endif
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/classload/GeneratingClassLoader.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/classload/GeneratingClassLoader.java	Thu Sep 13 10:54:11 2018 -0700
@@ -119,8 +119,6 @@
                         return bytecode;
                 } catch (UnsupportedEncodingException e) {
                         throw new TestBug(e);
-                } catch (IOException e) {
-                        throw new TestBug(e);
                 }
         }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/test/timeoutwatchdog/TimeoutHandler.java	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +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 nsk.share.test.timeoutwatchdog;
-
-/**
- * TimeoutHandler - interface to define reaction on timeout.
- * @see TimeoutWatchdoc
- */
-public interface TimeoutHandler {
-
-        /**
-         * Invoked when watchdog detects timeout. Subclasses must implement this method to define how timeout should be handled.
-         */
-        void handleTimeout();
-
-}
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/test/timeoutwatchdog/TimeoutWatchdog.java	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +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 nsk.share.test.timeoutwatchdog;
-
-import nsk.share.test.ExecutionController;
-
-/**
- * This class watches for ExecutionControler and notifies TimeoutHander in case of timeout.
- */
-public class TimeoutWatchdog implements Runnable {
-
-        private ExecutionController executionController;
-
-        private TimeoutHandler handler;
-
-        private static long CHECK_PERIOD = 1000; // In milliseconds
-
-        private TimeoutWatchdog(ExecutionController executionController, TimeoutHandler handler) {
-                this.executionController = executionController;
-                this.handler = handler;
-        }
-
-        /**
-         * Start watching for timeout.
-         * This method runs a new daemon thread that checks periodically if the observable test is still running.
-         * If timeout is detected <code>handler.handleTimeout()</code> will be called. If the test finishes normally the daemon
-         * thread will silently die.
-         * @param executionController - executionController used to monitor time left
-         * @param handler - handler on which handleTimeout() will be called
-         */
-        public static void watch(ExecutionController executionController, TimeoutHandler handler) {
-                Thread thread = new Thread(new TimeoutWatchdog(executionController, handler));
-                thread.setName("TimeoutWatchdog_thread");
-                thread.setDaemon(true);
-                thread.start();
-        }
-
-        @Override
-        public void run() {
-                try {
-                        while (true) {
-                                Thread.sleep(CHECK_PERIOD);
-                                if (!executionController.continueExecution()) {
-                                        System.out.println("Time expired. TimeoutWatchdog is calling TimeoutHandler.handleTimeout.");
-                                        handler.handleTimeout();
-                                }
-                        }
-                } catch (InterruptedException e) {
-                        throw new RuntimeException("Somebody dared to interrupt TimeoutWatchdog thread.");
-                }
-        }
-
-}
--- a/test/hotspot/jtreg/vmTestbase/vm/share/gc/TriggerUnloadingByFillingHeap.java	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +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 vm.share.gc;
-
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-import nsk.share.TestFailure;
-import nsk.share.test.ExecutionController;
-
-public class TriggerUnloadingByFillingHeap implements TriggerUnloadingHelper {
-
-    public void triggerUnloading(ExecutionController stresser) {
-        List<String> jvmArgs = ManagementFactory.getRuntimeMXBean().getInputArguments();
-        if (jvmArgs.contains("-XX:+ExplicitGCInvokesConcurrent")) {
-                throw new TestFailure("Test bug! Found -XX:+ExplicitGCInvokesConcurrent in jvm args. TriggerUnloadingByFillingHeap.triggerUnloading will not work!.");
-        }
-
-        System.out.println("collections invoked: " + provokeGC(stresser));
-        System.out.println("collections invoked: " + provokeGC(stresser));
-        System.out.println("collections invoked: " + provokeGC(stresser));
-    }
-
-    private static long getGCCounter() {
-        return ManagementFactory.getGarbageCollectorMXBeans().get(1).getCollectionCount();
-    }
-
-    private static Random random = new Random();
-
-    public static byte[] garbage; //make it reference public to avoid compiler optimizations
-
-    private static long provokeGC(ExecutionController stresser) {
-        long initCounter = getGCCounter();
-        ArrayList<byte[]> list = new ArrayList<byte[]>();
-        while (getGCCounter() == initCounter && stresser.continueExecution()) {
-            list.add(new byte[1024]);
-
-            garbage = new byte[1024];
-            if (random.nextInt(10) % 10 < 3 && !list.isEmpty()) {
-                list.remove(0);
-            }
-            System.gc();
-        }
-        return getGCCounter() - initCounter;
-    }
-
-}
--- a/test/hotspot/jtreg/vmTestbase/vm/share/gc/TriggerUnloadingByFillingMetaspace.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/vm/share/gc/TriggerUnloadingByFillingMetaspace.java	Thu Sep 13 10:54:11 2018 -0700
@@ -22,76 +22,38 @@
  */
 package vm.share.gc;
 
-import java.util.ArrayList;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
+import nsk.share.test.ExecutionController;
 import metaspace.stressHierarchy.common.exceptions.GotWrongOOMEException;
 import nsk.share.gc.gp.classload.GeneratedClassProducer;
-import nsk.share.test.ExecutionController;
 
 public class TriggerUnloadingByFillingMetaspace implements
         TriggerUnloadingHelper {
 
-    private static final int NUMBER_OF_THREADS = 30;
-
-    private static class FillMetaspace {
-        private volatile boolean gotOOME = false;
-        private ExecutionController stresser;
-        private final ThreadLocal<GeneratedClassProducer> generatedClassProducer =
-            new ThreadLocal<GeneratedClassProducer>() {
-              @Override
-              protected GeneratedClassProducer initialValue() {
-                return new GeneratedClassProducer("metaspace.stressHierarchy.common.HumongousClass");
-              }
-            };
-
-        public FillMetaspace(ExecutionController stresser) { this.stresser = stresser; }
+    private volatile boolean gotOOME = false;
+    private ExecutionController stresser;
+    private final ThreadLocal<GeneratedClassProducer> generatedClassProducer =
+        new ThreadLocal<GeneratedClassProducer>() {
+          @Override
+          protected GeneratedClassProducer initialValue() {
+            return new GeneratedClassProducer("metaspace.stressHierarchy.common.HumongousClass");
+          }
+        };
 
-        private class FillMetaspaceTask implements Callable<Object> {
-            @Override
-            public Object call() throws Exception {
-                while (stresser.continueExecution() && ! gotOOME) {
-                    try {
-                        generatedClassProducer.get().create(-100500); //argument is not used.
-                    } catch (OutOfMemoryError oome) {
-                        if (!isInMetaspace(oome)) {
-                            throw new GotWrongOOMEException("Got OOME in heap while gaining OOME in metaspace. Test result can't be valid.");
-                        }
-                        gotOOME = true;
-                    }
-                }
-                return null;
-            }
-        }
-    }
-
-    private static boolean isInMetaspace(OutOfMemoryError error) {
-        return error.getMessage().trim().toLowerCase().contains("metadata");
+    private static boolean isInMetaspace(Throwable error) {
+        return (error.getMessage().trim().toLowerCase().contains("metaspace"));
     }
 
     @Override
     public void triggerUnloading(ExecutionController stresser) {
-        try {
-            FillMetaspace fillMetaspace = new FillMetaspace(stresser);
-            ArrayList<Callable<Object>> tasks = new ArrayList<Callable<Object>>(NUMBER_OF_THREADS);
-            for (int i = 0; i < NUMBER_OF_THREADS; i++) {
-                tasks.add(fillMetaspace.new FillMetaspaceTask());
-            }
-            ExecutorService executorService = Executors.newCachedThreadPool();
+        while (stresser.continueExecution() && !gotOOME) {
             try {
-                executorService.invokeAll(tasks);
-            } catch (InterruptedException e) {
-                System.out.println("Process of gaining OOME in metaspace was interrupted.");
-                e.printStackTrace();
+                generatedClassProducer.get().create(-100500); //argument is not used.
+            } catch (Throwable oome) {
+                if (!isInMetaspace(oome)) {
+                    throw new GotWrongOOMEException("Got OOME in heap while triggering OOME in metaspace. Test result can't be valid.");
+                }
+                gotOOME = true;
             }
-        } catch (OutOfMemoryError e) {
-            if (!isInMetaspace(e)) {
-                throw new GotWrongOOMEException("Got OOME in heap while gaining OOME in metaspace. Test result can't be valid.");
-            }
-            return;
         }
     }
-
 }
--- a/test/hotspot/jtreg/vmTestbase/vm/share/vmstresser/CompileAndDeoptimize.java	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * 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
- * 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 vm.share.vmstresser;
-
-public class CompileAndDeoptimize implements Runnable {
-
-    public static int v = 0;
-
-    private abstract static class A {
-        public abstract void incv();
-    }
-
-    private static class B extends A {
-        public void incv() {
-            v++;
-        }
-    }
-
-    public static class C extends A {
-        public void incv() {
-            v += (new int[1][1][1][1][1][1][1][1]).length;
-        }
-    }
-
-    private volatile boolean done = false;
-    public volatile A a = new B();
-
-    private void incv() {
-        a.incv();
-    }
-
-    private void inc() {
-        while ( ! done ) {
-            incv();
-        }
-        //while ( ! done ) {
-        //      incv();
-        //}
-        //while ( ! done ) {
-        //      incv();
-        //}
-    }
-
-    public void run() {
-        try {
-            Thread t = new Thread(new Runnable() { @Override public void run() { inc(); } });
-            t.start();
-            Thread.sleep(100);
-            a = (A) CompileAndDeoptimize.class.getClassLoader().loadClass(B.class.getName().replaceAll("B$", "C")).getConstructors()[0].newInstance(new Object[0]);
-            //Thread.sleep(1000);
-            //done = true;
-            //t.join();
-
-        } catch ( Throwable t ) {
-            t.printStackTrace();
-        }
-    }
-
-}
--- a/test/hotspot/jtreg/vmTestbase/vm/share/vmstresser/MetaspaceStresser.java	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,260 +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 vm.share.vmstresser;
-
-import java.util.*;
-import java.util.concurrent.locks.*;
-
-import nsk.share.*;
-import nsk.share.classload.*;
-import nsk.share.test.*;
-
-/**
- * Stresser that load classes until OOME, then unload some of them and continue loading.
- */
-public class MetaspaceStresser extends Thread {
-
-    /**
-     * Capacity of class containers.
-     * This amount of classes will be unloaded on reset call.
-     */
-    public static final int DEFAULT_BUCKET_SIZE = 4000;
-
-    public static final int DEFAULT_PAUSE_TIME = 0;
-
-    /*
-     * Loaded classes stored in ClassContainer instances.
-     * Such instances organized in array-based stack as it is
-     * one of the simplest way to minimize possibility
-     * to get OOME and guarntee that after replacing
-     * reference to class container by null there will be
-     * no cached refereces and container will be reclaimed by
-     * GC and classes will become unloadable.
-     */
-    // Maximum available amount of arrays with class containers.
-    private static final int CONTAINERS_ARRAY_LENGTH = 1000;
-    // Maximum length array with class containers.
-    private static final int CONTAINER_ARRAYS_COUNT = 100;
-
-    private ClassContainersStack containersStack = new ClassContainersStack(CONTAINER_ARRAYS_COUNT * CONTAINERS_ARRAY_LENGTH,
-            CONTAINERS_ARRAY_LENGTH);
-    private ClassContainer newContainer = null;
-
-    private ExecutionController controller = null;
-    private int bucketSize = DEFAULT_BUCKET_SIZE;
-    private int pauseTime = DEFAULT_PAUSE_TIME;
-
-    private ReentrantLock lock = new ReentrantLock();
-
-    /**
-     * Construct MetaspaceStrresser with default bucket size
-     * and pause time.
-     * @param c controller to control execution time.
-     */
-    public MetaspaceStresser(ExecutionController c) {
-        controller = c;
-    }
-
-    /**
-     * Construct MetaspaceStrresser with custom bucket size
-     * and pause time.
-     * @param c controller to control execution time.
-     * @param bucketSize classes to be unloaded on reset.
-     * @param pauseTime pause after reset.
-     */
-    public MetaspaceStresser(ExecutionController c, int bucketSize, int pauseTime) {
-        this(c);
-        this.bucketSize = bucketSize;
-        this.pauseTime = pauseTime;
-    }
-
-    /**
-     *  Fill Metaspace with classes.
-     *  Classes will be loaded until OOME, then some of them will be unloaded.
-     */
-    public synchronized void prepare() {
-        while (controller.continueExecution()) {
-            try {
-                fillContainerStack();
-            } catch (OutOfMemoryError oome) {
-                unloadLastClassBucket();
-                return;
-            } catch (ClassNotFoundException cnfe) {
-                throw new TestBug("Unexpected exception in stresser.", cnfe);
-            }
-        }
-    }
-
-    /**
-     * Load new class to container, fill containerStack.
-     * Classes will be loaded until OOME
-     * @throws ClassNotFoundException
-     */
-    private void fillContainerStack() throws ClassNotFoundException {
-        newContainer = new ClassContainer();
-        while (newContainer.size() < bucketSize && controller.continueExecution()) {
-            newContainer.loadClass();
-        }
-        containersStack.push(newContainer);
-        newContainer = null;
-    }
-
-    /**
-     * Run stresser.
-     * Stresser will load classes until OOME, then bucketSize classes
-     * will be unloaded and stresser will wait pauseTime millisiconds
-     * before continuing class loading.
-     */
-    public void run() {
-        try {
-            while (controller.continueExecution()) {
-                try {
-                    fillContainerStack();
-                } catch (OutOfMemoryError oome) {
-                    unloadLastClassBucket();
-                    try {
-                        Thread.sleep(pauseTime);
-                    } catch (InterruptedException ie) {
-                    }
-                }
-            }
-        } catch (Throwable e) {
-            throw new TestBug("Unexpected exception in stresser.", e);
-        } finally {
-            containersStack.free();
-        }
-    }
-
-    /**
-     * Unload most recently loaded bucket of classes.
-     */
-    public void unloadLastClassBucket() {
-        while (controller.continueExecution()) {
-            try {
-                containersStack.pop();
-                System.gc();
-                break;
-            } catch (OutOfMemoryError oome) {
-                oome.printStackTrace();
-                continue;
-            }
-        }
-    }
-
-    /**
-     * Array-based stack for ClassContainer's.
-     */
-    private class ClassContainersStack {
-
-        private int arrayLength = 0;
-        private int arraysCount = 0;
-        private int arrayIndex = 0;
-        private int elemIndex = 0;
-
-        private ClassContainer data[][];
-
-        /**
-         * Create ClassContainersStack that will be able
-         * to store size classes in arrays of segmentSize length.
-         */
-        public ClassContainersStack(int size, int segementSize) {
-            arrayLength = segementSize;
-            arraysCount = size / arrayLength;
-            data = new ClassContainer[arraysCount][];
-            data[0] = new ClassContainer[arrayLength];
-        }
-
-        /**
-         * Push ClassContainer c into stack.
-         */
-        public synchronized void push(ClassContainer c) {
-            data[arrayIndex][elemIndex] = c;
-            elemIndex++;
-            if (elemIndex == arrayLength) {
-                if (arrayIndex == arraysCount) {
-                    throw new TestBug("ClassContainersStack ran out of available slots");
-                }
-                data[arrayIndex + 1] = new ClassContainer[arrayLength];
-                arrayIndex++;
-                elemIndex = 0;
-            }
-        }
-
-        /**
-         * Remove reference to top ClassContainer.
-         */
-        public synchronized void pop() {
-            data[arrayIndex][elemIndex] = null;
-            if (elemIndex > 0) {
-                elemIndex--;
-            } else if (arrayIndex > 0) {
-                data[arrayIndex] = null;
-                arrayIndex--;
-                elemIndex = arrayLength - 1;
-            }
-        }
-
-        /**
-         * Remove all stored ClassContainers.
-         */
-        public synchronized void free() {
-            data = null;
-            System.gc();
-            data = new ClassContainer[arraysCount][];
-            data[0] = new ClassContainer[arrayLength];
-            arrayIndex = 0;
-            elemIndex = 0;
-        }
-
-    }
-
-    /// Variable used to create uniqe name for generated classes.
-    private static long lastClass = 0;
-
-    /**
-     * Class container consists of classes and their ClassLoader, so
-     * if there will be no references to container and classes inside it then
-     * it could be easely collected by GC.
-     */
-    private class ClassContainer {
-
-        private List<Class> classes = new LinkedList<Class>();
-        private GeneratingClassLoader loader = new GeneratingClassLoader();
-        private String prefix = loader.getPrefix();
-        private int length = loader.getNameLength();
-
-        public void loadClass() throws ClassNotFoundException {
-            String newName = prefix + "c" + lastClass;
-            lastClass++;
-            while (newName.length() < length) {
-                newName = newName + "c";
-            }
-            classes.add(loader.loadClass(newName));
-        }
-
-        public int size() {
-            return classes.size();
-        }
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/ProblemList-Xcomp.txt	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,31 @@
+#
+# 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.
+#
+
+#############################################################################
+#
+# List of quarantined tests for testing in Xcomp mode.
+#
+#############################################################################
+
+java/lang/invoke/MethodHandles/CatchExceptionTest.java 8146623 generic-all
+java/lang/Class/forName/modules/TestDriver.java 8208212 solaris-all
--- a/test/jdk/build/releaseFile/CheckSource.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/build/releaseFile/CheckSource.java	Thu Sep 13 10:54:11 2018 -0700
@@ -34,9 +34,13 @@
 import java.io.FileReader;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 public class CheckSource {
 
+    public static final String SRC_HASH_REGEXP = ":((hg)|(git)):[a-z0-9]*\\+?";
+
     CheckSource(String dataFile, boolean isOpenJDK) {
         // Read data files
         readFile(dataFile, isOpenJDK);
@@ -44,6 +48,7 @@
 
     private void readFile(String fileName, boolean isOpenJDK) {
         String fishForSOURCE = null;
+        String implementor = null;
 
         File file = new File(fileName);
 
@@ -65,7 +70,13 @@
                 // grab SOURCE line
                 if (readIn.startsWith("SOURCE=")) {
                     fishForSOURCE = readIn;
-                    break;
+                    continue;
+                }
+
+                // grab IMPLEMENTOR line
+                if (readIn.startsWith("IMPLEMENTOR=")) {
+                    implementor = readIn;
+                    continue;
                 }
             }
         } catch (FileNotFoundException fileExcept) {
@@ -79,27 +90,46 @@
         // was SOURCE even found?
         if (fishForSOURCE == null) {
             throw new RuntimeException("SOURCE line was not found!");
-        } else {
-            // OK it was found, did it have correct sources?
-            System.out.println("The source string found: " + fishForSOURCE);
+        }
+        System.out.println("The source string found: " + fishForSOURCE);
 
-            // First it MUST have .: regardless of closed or openJDK
-            if (!fishForSOURCE.contains(".:")) {
-                throw new RuntimeException("The test failed, .: not found!");
-            }
-            // take out the .: source path
-            fishForSOURCE = fishForSOURCE.replace(".:", "");
+        // Extract the value of SOURCE=
+        Pattern valuePattern = Pattern.compile("SOURCE=\"(.*)\"");
+        Matcher valueMatcher = valuePattern.matcher(fishForSOURCE);
+        if (!valueMatcher.matches()) {
+            throw new RuntimeException("SOURCE string has bad format, should be SOURCE=\"<value>\"");
+        }
+        String valueString = valueMatcher.group(1);
+
+        // Check if implementor is Oracle
+        boolean isOracle = (implementor != null) && implementor.contains("Oracle Corporation");
+
+        String[] values = valueString.split(" ");
 
-            // if its closedJDK it MUST have open:
-            if (!isOpenJDK && !fishForSOURCE.contains("open:")) {
-                throw new RuntimeException("The test failed, open: not found!");
-            }
-            // take out the open: source path
-            fishForSOURCE = fishForSOURCE.replace("open:", "");
+        // First value MUST start with ".:" regardless of Oracle or OpenJDK
+        String rootRegexp = "\\." + SRC_HASH_REGEXP;
+        if (!values[0].matches(rootRegexp)) {
+            throw new RuntimeException("The test failed, first element did not match regexp: " + rootRegexp);
+        }
 
-            // if any other source exists, that's an error
-            if (fishForSOURCE.contains(":")) {
-                throw new RuntimeException("The test failed, additional sources found!");
+        // If it's an Oracle build, it can be either OpenJDK or OracleJDK. Other
+        // builds may have any number of additional elements in any format.
+        if (isOracle) {
+            if (isOpenJDK) {
+                if (values.length != 1) {
+                    throw new RuntimeException("The test failed, wrong number of elements in SOURCE list." +
+                            " Should be 1 for Oracle built OpenJDK.");
+                }
+            } else {
+                if (values.length != 2) {
+                    throw new RuntimeException("The test failed, wrong number of elements in SOURCE list." +
+                            " Should be 2 for OracleJDK.");
+                }
+                // Second value MUST start with "open:" for OracleJDK
+                String openRegexp = "open" + SRC_HASH_REGEXP;
+                if (!values[1].matches(openRegexp)) {
+                    throw new RuntimeException("The test failed, second element did not match regexp: " + openRegexp);
+                }
             }
         }
 
@@ -114,7 +144,6 @@
         System.out.println("JDK Path : " + jdkPath);
         System.out.println("Runtime Name : " + runtime);
 
-        new CheckSource(jdkPath + "/release",
-                              runtime.contains("OpenJDK"));
+        new CheckSource(jdkPath + "/release", runtime.contains("OpenJDK"));
     }
 }
--- a/test/jdk/com/sun/jdi/BadAgentPath.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/BadAgentPath.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/BadHandshakeTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/BreakpointWithFullGC.java	Thu Sep 13 10:54:11 2018 -0700
@@ -67,7 +67,7 @@
     }
 
     private BreakpointWithFullGC() {
-        super(new Jdb.LaunchOptions(DEBUGGEE_CLASS)
+        super(new LaunchOptions(DEBUGGEE_CLASS)
                      .addDebuggeeOptions(DEBUGGEE_OPTIONS));
     }
 
--- a/test/jdk/com/sun/jdi/DeoptimizeWalk.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/DeoptimizeWalk.java	Thu Sep 13 10:54:11 2018 -0700
@@ -33,7 +33,6 @@
  */
 
 import jdk.test.lib.process.OutputAnalyzer;
-import lib.jdb.Jdb;
 import lib.jdb.JdbCommand;
 import lib.jdb.JdbTest;
 
@@ -83,7 +82,7 @@
     }
 
     private DeoptimizeWalk() {
-        super(new Jdb.LaunchOptions(DEBUGGEE_CLASS)
+        super(new LaunchOptions(DEBUGGEE_CLASS)
                 .addDebuggeeOptions(DEBUGGEE_OPTIONS));
     }
 
--- a/test/jdk/com/sun/jdi/DoubleAgentTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/DoubleAgentTest.java	Thu Sep 13 10:54:11 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
--- a/test/jdk/com/sun/jdi/ExclusiveBind.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/ExclusiveBind.java	Thu Sep 13 10:54:11 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/JdbArgTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ /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"
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/JdbLockTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ /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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/JdbMissStep.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ /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	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ /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	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ /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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/NoLaunchOptionTest.java	Thu Sep 13 10:54:11 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	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ /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	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ /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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/ProcessAttachTest.java	Thu Sep 13 10:54:11 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/Redefine-g.sh	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +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 4777868
-#  @summary Compile with java -g, do a RedefineClasses, and you don't get local vars
-#  @author Jim Holmlund
-#
-#  @run shell Redefine-g.sh
-#pkg=untitled7
-
-# Compile the first version without -g and the 2nd version with -g.
-compileOptions=
-compileOptions2=-g
-#java=java_g
-
-# Uncomment this to see the JDI trace
-# jdbOptions=-dbgtrace
-
-createJavaFile()
-{
-    cat <<EOF > $1.java.1
-
-public class $1 {
-  public $1() {
-  }
-  public static void main(String[] args) {
-    int gus = 22;
-    $1 kk = new $1();
-    kk.m1("ab");
-  }
-
-  void m1(String p1) {
-    int m1l1 = 1;
-    System.out.println("m1(String) called");
-    m1(p1, "2nd");
-    // @1 uncomment System.out.println("Hello Milpitas!");
-  }
-
-  void m1(String p1, String p2) {
-    int m1l2 = 2;
-    System.out.println("m2" + p1 + p2);  // @1 breakpoint
-  }
-
-}
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-    setBkpts @1
-    runToBkpt @1
-    cmd where
-    cmd locals
-
-    redefineClass @1
-    cmd where
-    cmd locals
-
-    cmd pop
-    cmd where
-    cmd locals
-
-    cmd pop
-    cmd where
-    cmd locals
-
-    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
-
-jdbFailIfNotPresent 'p1 = "ab"'
-jdbFailIfNotPresent 'p2 = "2nd"'
-jdbFailIfNotPresent 'm1l2 = 2'
-jdbFailIfPresent    'm1l1'
-
-jdbFailIfNotPresent 'args = instance of java.lang.String'
-jdbFailIfNotPresent 'gus = 22'
-jdbFailIfNotPresent 'kk = instance of shtest'
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/RedefineAbstractClass.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6805864
+ * @summary Redefine an abstract class that is called via a concrete
+ * class and via two interface objects and verify that the right
+ * methods are called.
+ * @comment converted from test/jdk/com/sun/jdi/RedefineAbstractClass.sh
+ *
+ * @library /test/lib
+ * @compile -g RedefineAbstractClass.java
+ * @run main/othervm RedefineAbstractClass
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.ClassTransformer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+class RedefineAbstractClassTarg {
+    public static void main(String[] args) {
+        System.out.println("This is RedefineAbstractClass");
+
+        MyConcreteClass foo = new MyConcreteClass();
+        // do the work once before redefine
+        foo.doWork();
+
+        System.out.println("stop here for redefine");  // @1 breakpoint
+
+        // do the work again after redefine
+        foo.doWork();
+
+        System.out.println("stop here to check results");  // @2 breakpoint
+    }
+}
+
+interface MyInterface1 {
+    public boolean checkFunc();
+    public boolean isMyInterface1();
+}
+
+interface MyInterface2 {
+    public boolean checkFunc();
+    public boolean isMyInterface2();
+}
+
+abstract class MyAbstractClass implements MyInterface1, MyInterface2 {
+    static int counter = 0;
+    public boolean checkFunc() {
+        counter++;
+        System.out.println("MyAbstractClass.checkFunc() called.");
+        // @1 uncomment System.out.println("This is call " + counter + " to checkFunc");
+        return true;
+    }
+    public boolean isMyInterface1() {
+        System.out.println("MyAbstractClass.isMyInterface1() called.");
+        return true;
+    }
+    public boolean isMyInterface2() {
+        System.out.println("MyAbstractClass.isMyInterface2() called.");
+        return true;
+    }
+}
+
+class MyConcreteClass extends MyAbstractClass {
+    public void doWork() {
+        // checkFunc() is called via invokevirtual here; MyConcreteClass
+        // inherits via MyAbstractClass
+        System.out.println("In doWork() calling checkFunc(): " + checkFunc());
+
+        MyInterface1 if1 = (MyInterface1) this;
+        // checkFunc() is called via invokeinterface here; this call will
+        // use the first itable entry
+        System.out.println("In doWork() calling if1.checkFunc(): " + if1.checkFunc());
+
+        MyInterface2 if2 = (MyInterface2) this;
+        // checkFunc() is called via invokeinterface here; this call will
+        // use the second itable entry
+        System.out.println("In doWork() calling if2.checkFunc(): " + if2.checkFunc());
+    }
+}
+
+
+public class RedefineAbstractClass extends JdbTest {
+    public static void main(String argv[]) {
+        new RedefineAbstractClass().run();
+    }
+
+    private RedefineAbstractClass() {
+        super(DEBUGGEE_CLASS, SOURCE_FILE);
+    }
+
+    private static final String DEBUGGEE_CLASS = RedefineAbstractClassTarg.class.getName();
+    private static final String SOURCE_FILE = "RedefineAbstractClass.java";
+    private static final String ABSTRACT_CLASS = "MyAbstractClass";
+
+    @Override
+    protected void runCases() {
+        setBreakpoints(1);
+        setBreakpoints(2);
+        jdb.command(JdbCommand.run());
+
+        // modified version of redefineClass function
+        String transformedClassFile = ClassTransformer.fromTestSource(SOURCE_FILE)
+                .transform(1, ABSTRACT_CLASS, "-g");
+        jdb.command(JdbCommand.redefine(ABSTRACT_CLASS, transformedClassFile));
+        // end modified version of redefineClass function
+
+        // this will continue to the second breakpoint
+        jdb.command(JdbCommand.cont());
+
+        new OutputAnalyzer(getDebuggeeOutput())
+                .shouldContain("This is call 4 to checkFunc")
+                .shouldContain("This is call 5 to checkFunc")
+                .shouldContain("This is call 6 to checkFunc");
+    }
+}
--- a/test/jdk/com/sun/jdi/RedefineAbstractClass.sh	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2009, 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 6805864
-# @summary Redefine an abstract class that is called via a concrete
-#   class and via two interface objects and verify that the right
-#   methods are called.
-# @author Daniel D. Daugherty
-#
-# @key intermittent
-# @run shell RedefineAbstractClass.sh
-
-compileOptions=-g
-
-# Uncomment this to see the JDI trace
-#jdbOptions=-dbgtrace
-
-createJavaFile()
-{
-    cat <<EOF > $1.java.1
-
-public class $1 {
-  public static void main(String[] args) {
-    System.out.println("This is RedefineAbstractClass");
-
-    MyConcreteClass foo = new MyConcreteClass();
-    // do the work once before redefine
-    foo.doWork();
-
-    System.out.println("stop here for redefine");  // @1 breakpoint
-
-    // do the work again after redefine
-    foo.doWork();
-
-    System.out.println("stop here to check results");  // @2 breakpoint
-  }
-}
-
-interface MyInterface1 {
-  public boolean checkFunc();
-  public boolean isMyInterface1();
-}
-
-interface MyInterface2 {
-  public boolean checkFunc();
-  public boolean isMyInterface2();
-}
-
-abstract class MyAbstractClass implements MyInterface1, MyInterface2 {
-  static int counter = 0;
-  public boolean checkFunc() {
-    counter++;
-    System.out.println("MyAbstractClass.checkFunc() called.");
-    // @1 uncomment System.out.println("This is call " + counter + " to checkFunc");
-    return true;
-  }
-  public boolean isMyInterface1() {
-    System.out.println("MyAbstractClass.isMyInterface1() called.");
-    return true;
-  }
-  public boolean isMyInterface2() {
-    System.out.println("MyAbstractClass.isMyInterface2() called.");
-    return true;
-  }
-}
-
-class MyConcreteClass extends MyAbstractClass {
-  public void doWork() {
-    // checkFunc() is called via invokevirtual here; MyConcreteClass
-    // inherits via MyAbstractClass
-    System.out.println("In doWork() calling checkFunc(): " + checkFunc());
-
-    MyInterface1 if1 = (MyInterface1) this;
-    // checkFunc() is called via invokeinterface here; this call will
-    // use the first itable entry
-    System.out.println("In doWork() calling if1.checkFunc(): " + if1.checkFunc());
-
-    MyInterface2 if2 = (MyInterface2) this;
-    // checkFunc() is called via invokeinterface here; this call will
-    // use the second itable entry
-    System.out.println("In doWork() calling if2.checkFunc(): " + if2.checkFunc());
-  }
-}
-
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-    setBkpts @1
-    setBkpts @2
-    runToBkpt @1
-    # modified version of redefineClass function
-    vers=2
-    abs_class=MyAbstractClass
-    cmd redefine $pkgDot$abs_class $tmpFileDir/vers$vers/$abs_class.class
-    cp $tmpFileDir/$classname.java.$vers \
-        $tmpFileDir/$classname.java
-    # end modified version of redefineClass function
-
-    # this will continue to the second breakpoint
-    cmd 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
-
-debuggeeFailIfNotPresent 'This is call 4 to checkFunc'
-debuggeeFailIfNotPresent 'This is call 5 to checkFunc'
-debuggeeFailIfNotPresent 'This is call 6 to checkFunc'
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/RedefineAddPrivateMethod.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,78 @@
+/*
+ * 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 8149743
+ * @summary crash when adding a breakpoint after redefining to add a private static method
+ * @comment converted from test/jdk/com/sun/jdi/RedefineAddPrivateMethod.sh
+ *
+ * @library /test/lib
+ * @compile -g RedefineAddPrivateMethod.java
+ * @run main/othervm RedefineAddPrivateMethod
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+class RedefineAddPrivateMethodTarg {
+    static public void main(String[] args) {
+        System.out.println("@1 breakpoint");
+        System.out.println("@2 breakpoint");
+    }
+
+    // @1 uncomment private static void test() {}
+}
+
+public class RedefineAddPrivateMethod extends JdbTest {
+    public static void main(String argv[]) {
+        new RedefineAddPrivateMethod().run();
+    }
+
+    private RedefineAddPrivateMethod() {
+        super(DEBUGGEE_CLASS, SOURCE_FILE);
+    }
+
+    private static final String DEBUGGEE_CLASS = RedefineAddPrivateMethodTarg.class.getName();
+    private static final String SOURCE_FILE = "RedefineAddPrivateMethod.java";
+
+    @Override
+    protected void runCases() {
+        setBreakpoints(1);
+        jdb.command(JdbCommand.run());
+
+        redefineClass(1, "-g");
+        // ensure "test()" method has been added successfully
+        execCommand(JdbCommand.eval(DEBUGGEE_CLASS + ".test()"))
+                .shouldNotContain("ParseException");
+
+        setBreakpoints(2);
+        jdb.command(JdbCommand.run());
+
+        jdb.quit();
+
+        new OutputAnalyzer(getDebuggeeOutput())
+                .shouldNotContain("Internal exception:");
+    }
+}
--- a/test/jdk/com/sun/jdi/RedefineAddPrivateMethod.sh	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 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.
-#
-
-#  @test
-#  @bug 8149743
-#  @summary crash when adding a breakpoint after redefining to add a private static method
-#  @run shell RedefineAddPrivateMethod.sh
-
-compileOptions=-g
-
-createJavaFile()
-{
-    cat <<EOF > $1.java.1
-public class $1 {
-    static public void main(String[] args) {
-        System.out.println("@1 breakpoint");
-        System.out.println("@2 breakpoint");
-    }
-
-    // @1 uncomment private static void test() {}
-}
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-    setBkpts @1
-    runToBkpt @1
-    redefineClass @1
-    setBkpts @2
-    runToBkpt @2
-    cmd exitJdb
-}
-
-
-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
-debuggeeFailIfPresent "Internal exception:"
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/RedefineAnnotation.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,231 @@
+/*
+ * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 5002251 6407335 6412391
+ * @summary Redefine a class that has an annotation and verify that the
+ * new annotation is returned.
+ * @comment converted from test/jdk/com/sun/jdi/RedefineAnnotation.sh
+ *
+ * @library /test/lib
+ * @compile -g RedefineAnnotation.java
+ * @run main/othervm RedefineAnnotation
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+import java.lang.annotation.*;
+import java.lang.reflect.*;
+
+@Foo(Constants.class_annotation)  // @1 commentout
+// @1 uncomment @Foo(Constants.new_class_annotation)
+class RedefineAnnotationTarg {
+    @Foo(Constants.field_annotation)  // @1 commentout
+    // @1 uncomment @Foo(Constants.new_field_annotation)
+    public int dummy_field;
+
+    public static void main(String[] args) {
+        MySubClass sub = new MySubClass();
+        MySubSubClass subsub = new MySubSubClass();
+        new RedefineAnnotationTarg().hi(false);
+        new RedefineAnnotationTarg().hi(true);  // @1 breakpoint
+        sub.hi(true);
+        subsub.hi(true);
+    }
+
+    @Foo(Constants.method_annotation)  // @1 commentout
+    // @1 uncomment @Foo(Constants.new_method_annotation)
+    public void hi(
+    @Foo(Constants.method_parameter_annotation)  // @1 commentout
+    // @1 uncomment @Foo(Constants.new_method_parameter_annotation)
+                   boolean isNewVersion) {
+
+        if (isNewVersion) {
+            System.out.println("Checking for NEW versions of annotations in "
+                + getClass());
+        }
+
+        // class annotations check:
+        Foo foo = getClass().getAnnotation(Foo.class);
+        if (foo == null) {
+          throw new Error("FAIL: cannot get class_annotation from "
+                        + getClass());
+        }
+
+        String class_annotation = foo.value();
+        System.out.println("class annotation is: " + class_annotation);
+        if (isNewVersion) {
+            if (class_annotation.equals(Constants.new_class_annotation)) {
+                System.out.println("PASS: class_annotation was changed.");
+            } else {
+                System.out.println("FAIL: class_annotation was NOT changed.");
+            }
+        }
+
+        // field annotations check:
+        try {
+            Field my_field = getClass().getField("dummy_field");
+            foo = my_field.getAnnotation(Foo.class);
+            if (foo == null) {
+              throw new Error("FAIL: cannot get field_annotation from "
+                            + getClass() + ".dummy_field");
+            }
+            String field_annotation = foo.value();
+            System.out.println("field annotation is: " + field_annotation);
+            if (isNewVersion) {
+                if (field_annotation.equals(Constants.new_field_annotation)) {
+                    System.out.println("PASS: field_annotation was changed.");
+                } else {
+                    System.out.println(
+                        "FAIL: field_annotation was NOT changed.");
+                }
+        }
+        } catch (NoSuchFieldException nsfe) {
+            throw new Error("FAIL: cannot find field 'dummy_field' in "
+                          + getClass());
+        }
+
+        // method annotations check:
+        try {
+            Class params[] = new Class[1];
+            params[0] = Boolean.TYPE;
+            Method my_method = getClass().getMethod("hi", params);
+            foo = my_method.getAnnotation(Foo.class);
+            if (foo == null) {
+              throw new Error("FAIL: cannot get field_annotation from "
+                            + getClass() + ".hi()");
+            }
+            String method_annotation = foo.value();
+            System.out.println("method annotation is: " + method_annotation);
+            if (isNewVersion) {
+                if (method_annotation.equals(Constants.new_method_annotation)) {
+                    System.out.println("PASS: method_annotation was changed.");
+                } else {
+                    System.out.println(
+                        "FAIL: method_annotation was NOT changed.");
+                }
+            }
+        } catch (NoSuchMethodException nsme) {
+            throw new Error("FAIL: cannot find method 'hi' in " + getClass());
+        }
+
+        // method parameter annotations check:
+        try {
+            Class params[] = new Class[1];
+            params[0] = Boolean.TYPE;
+            Method my_method = getClass().getMethod("hi", params);
+            Annotation my_annotations[][] = my_method.getParameterAnnotations();
+            if (my_annotations.length != 1) {
+                throw new Error("FAIL: unexpected my_annotations.length ("
+                              + my_annotations.length);
+            }
+            Annotation my_annotation[] = my_annotations[0];
+            if (my_annotation.length != 1) {
+                throw new Error("FAIL: unexpected my_annotation.length ("
+                              + my_annotation.length);
+            }
+            foo = (Foo)my_annotation[0];
+            String method_parameter_annotation = foo.value();
+            System.out.println("method parameter annotation is: "
+                + method_parameter_annotation);
+            if (isNewVersion) {
+                if (method_parameter_annotation.equals(
+                    Constants.new_method_parameter_annotation)) {
+                    System.out.println(
+                        "PASS: method_parameter_annotation was changed.");
+                } else {
+                    System.out.println(
+                        "FAIL: method_parameter_annotation was NOT changed.");
+                }
+            }
+        } catch (NoSuchMethodException nsme) {
+            throw new Error("FAIL: cannot find method 'hi' in " + getClass());
+        }
+    }
+}
+
+// this subclass exists just to make the RedefineClasses() code do a
+// subclass walk to update the counter
+class MySubClass extends RedefineAnnotationTarg {
+    int my_int_field_makes_me_different;
+}
+
+// this subclass exists just to make the RedefineClasses() code do a
+// sub-subclass walk to update the counter
+class MySubSubClass extends MySubClass {
+    float my_float_field_makes_me_different;
+}
+
+class Constants {
+    static final String class_annotation     = "Patrick's class comment";
+    static final String new_class_annotation = "*NEW* Patrick's class comment";
+
+    static final String field_annotation     = "dummy_field comment";
+    static final String new_field_annotation = "*NEW* dummy_field comment";
+
+    static final String method_annotation     = "method hi() comment";
+    static final String new_method_annotation = "*NEW* method hi() comment";
+
+    static final String method_parameter_annotation     =
+        "param isNewVersion comment";
+    static final String new_method_parameter_annotation =
+        "*NEW* param isNewVersion comment";
+}
+
+
+/**
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@interface Foo {
+    String value();
+}
+
+public class RedefineAnnotation extends JdbTest {
+
+    public static void main(String argv[]) {
+        new RedefineAnnotation().run();
+    }
+
+    private RedefineAnnotation() {
+        super(DEBUGGEE_CLASS, SOURCE_FILE);
+    }
+
+    private static final String DEBUGGEE_CLASS = RedefineAnnotationTarg.class.getName();
+    private static final String SOURCE_FILE = "RedefineAnnotation.java";
+
+    @Override
+    protected void runCases() {
+        setBreakpoints(1);
+        jdb.command(JdbCommand.run());
+
+        redefineClass(1, "-g");
+        jdb.contToExit(1);
+
+        new OutputAnalyzer(getDebuggeeOutput())
+                .shouldNotContain("FAIL:");
+    }
+}
--- a/test/jdk/com/sun/jdi/RedefineAnnotation.sh	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,246 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2006, 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 5002251 6407335 6412391
-#  @summary Redefine a class that has an annotation and verify that the
-#    new annotation is returned.
-#
-#  @key intermittent
-#  @run shell RedefineAnnotation.sh
-
-compileOptions=-g
-
-# Uncomment this to see the JDI trace
-#jdbOptions=-dbgtrace
-
-createJavaFile()
-{
-    cat <<EOF > $1.java.1
-
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-
-/**
- */
-@Foo(Constants.class_annotation)  // @1 commentout
-// @1 uncomment @Foo(Constants.new_class_annotation)
-public class $1 {
-@Foo(Constants.field_annotation)  // @1 commentout
-// @1 uncomment @Foo(Constants.new_field_annotation)
-    public int dummy_field;
-
-    public static void main(String[] args) {
-        MySubClass sub = new MySubClass();
-        MySubSubClass subsub = new MySubSubClass();
-        new $1().hi(false);
-        new $1().hi(true);  // @1 breakpoint
-        sub.hi(true);
-        subsub.hi(true);
-    }
-
-@Foo(Constants.method_annotation)  // @1 commentout
-// @1 uncomment @Foo(Constants.new_method_annotation)
-    public void hi(
-@Foo(Constants.method_parameter_annotation)  // @1 commentout
-// @1 uncomment @Foo(Constants.new_method_parameter_annotation)
-                   boolean isNewVersion) {
-
-        if (isNewVersion) {
-            System.out.println("Checking for NEW versions of annotations in "
-                + getClass());
-        }
-
-        // class annotations check:
-        Foo foo = getClass().getAnnotation(Foo.class);
-        if (foo == null) {
-          throw new Error("FAIL: cannot get class_annotation from "
-                        + getClass());
-        }
-
-        String class_annotation = foo.value();
-        System.out.println("class annotation is: " + class_annotation);
-        if (isNewVersion) {
-            if (class_annotation.equals(Constants.new_class_annotation)) {
-                System.out.println("PASS: class_annotation was changed.");
-            } else {
-                System.out.println("FAIL: class_annotation was NOT changed.");
-            }
-        }
-    
-        // field annotations check:
-        try {
-            Field my_field = getClass().getField("dummy_field");
-            foo = my_field.getAnnotation(Foo.class);
-            if (foo == null) {
-              throw new Error("FAIL: cannot get field_annotation from "
-                            + getClass() + ".dummy_field");
-            }
-            String field_annotation = foo.value();
-            System.out.println("field annotation is: " + field_annotation);
-            if (isNewVersion) {
-                if (field_annotation.equals(Constants.new_field_annotation)) {
-                    System.out.println("PASS: field_annotation was changed.");
-                } else {
-                    System.out.println(
-                        "FAIL: field_annotation was NOT changed.");
-                }
-        }
-        } catch (NoSuchFieldException nsfe) {
-            throw new Error("FAIL: cannot find field 'dummy_field' in "
-                          + getClass());
-        }
-    
-        // method annotations check:
-        try {
-            Class params[] = new Class[1];
-            params[0] = Boolean.TYPE;
-            Method my_method = getClass().getMethod("hi", params);
-            foo = my_method.getAnnotation(Foo.class);
-            if (foo == null) {
-              throw new Error("FAIL: cannot get field_annotation from "
-                            + getClass() + ".hi()");
-            }
-            String method_annotation = foo.value();
-            System.out.println("method annotation is: " + method_annotation);
-            if (isNewVersion) {
-                if (method_annotation.equals(Constants.new_method_annotation)) {
-                    System.out.println("PASS: method_annotation was changed.");
-                } else {
-                    System.out.println(
-                        "FAIL: method_annotation was NOT changed.");
-                }
-            }
-        } catch (NoSuchMethodException nsme) {
-            throw new Error("FAIL: cannot find method 'hi' in " + getClass());
-        }
-    
-        // method parameter annotations check:
-        try {
-            Class params[] = new Class[1];
-            params[0] = Boolean.TYPE;
-            Method my_method = getClass().getMethod("hi", params);
-            Annotation my_annotations[][] = my_method.getParameterAnnotations();
-            if (my_annotations.length != 1) {
-                throw new Error("FAIL: unexpected my_annotations.length ("
-                              + my_annotations.length);
-            }
-            Annotation my_annotation[] = my_annotations[0];
-            if (my_annotation.length != 1) {
-                throw new Error("FAIL: unexpected my_annotation.length ("
-                              + my_annotation.length);
-            }
-            foo = (Foo)my_annotation[0];
-            String method_parameter_annotation = foo.value();
-            System.out.println("method parameter annotation is: "
-                + method_parameter_annotation);
-            if (isNewVersion) {
-                if (method_parameter_annotation.equals(
-                    Constants.new_method_parameter_annotation)) {
-                    System.out.println(
-                        "PASS: method_parameter_annotation was changed.");
-                } else {
-                    System.out.println(
-                        "FAIL: method_parameter_annotation was NOT changed.");
-                }
-            }
-        } catch (NoSuchMethodException nsme) {
-            throw new Error("FAIL: cannot find method 'hi' in " + getClass());
-        }
-    }
-}
-
-// this subclass exists just to make the RedefineClasses() code do a
-// subclass walk to update the counter
-class MySubClass extends $1 {
-  int my_int_field_makes_me_different;
-}
-
-// this subclass exists just to make the RedefineClasses() code do a
-// sub-subclass walk to update the counter
-class MySubSubClass extends MySubClass {
-  float my_float_field_makes_me_different;
-}
-
-class Constants {
-    static final String class_annotation     = "Patrick's class comment";
-    static final String new_class_annotation = "*NEW* Patrick's class comment";
-
-    static final String field_annotation     = "dummy_field comment";
-    static final String new_field_annotation = "*NEW* dummy_field comment";
-
-    static final String method_annotation     = "method hi() comment";
-    static final String new_method_annotation = "*NEW* method hi() comment";
-
-    static final String method_parameter_annotation     =
-        "param isNewVersion comment";
-    static final String new_method_parameter_annotation =
-        "*NEW* param isNewVersion comment";
-}
-
-
-/**
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-@interface Foo {
-    String value();
-}
-
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-    setBkpts @1
-    runToBkpt @1
-    redefineClass @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
-
-debuggeeFailIfPresent 'FAIL:'
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/RedefineChangeClassOrder.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6270982
+ * @summary Redefine a class so that the order of external classes in
+ *          the constant pool are changed.
+ * @comment converted from test/jdk/com/sun/jdi/RedefineChangeClassOrder.sh
+ *
+ * @library /test/lib
+ * @compile -g RedefineChangeClassOrder.java
+ * @run main/othervm RedefineChangeClassOrder
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+class RedefineChangeClassOrderTarg {
+    public static void main(String[] args) {
+        new RedefineChangeClassOrderTarg().hi(false);
+        new RedefineChangeClassOrderTarg().hi(true);  // @1 breakpoint
+    }
+
+    public void hi(boolean expected) {
+        boolean isNewVersion = false; // @1 commentout
+        // @1 uncomment boolean isNewVersion = true;
+
+        if (expected == isNewVersion) {
+            System.out.println("PASS: expected and isNewVersion match.");
+        } else {
+            System.out.println("FAIL: expected and isNewVersion do not match.");
+            System.out.println("expected=" + expected
+              + "  isNewVersion=" + isNewVersion);
+        }
+
+        Foo1 foo1 = new Foo1();  // @1 commentout
+        foo1.hi();  // @1 commentout
+
+        // This Hack code block exists to force some verification_type_info
+        // objects of subtype Object_variable_info into the StackMapTable.
+        //
+        // In the redefined code, the above Foo1 code is effectively
+        // moved after the Foo2 code below which causes things to be
+        // layed out in a different order in the constant pool. The
+        // cpool_index in the Object_variable_info has to be updated
+        // in the redefined code's StackMapTable to refer to right
+        /// constant pool index in the merged constant pool.
+        Hack hack = getClass().getAnnotation(Hack.class);
+        if (hack != null) {
+            String class_annotation = hack.value();
+            System.out.println("class annotation is: " + class_annotation);
+            if (isNewVersion) {
+                if (class_annotation.equals("JUNK")) {
+                    System.out.println("class_annotation is JUNK.");
+                } else {
+                    System.out.println("class_annotation is NOT JUNK.");
+                }
+            }
+        }
+
+        Foo2 foo2 = new Foo2();
+        foo2.hi();
+
+        // @1 uncomment Foo1 foo1 = new Foo1();
+        // @1 uncomment foo1.hi();
+    }
+}
+
+class Foo1 {
+    public void hi() {
+        System.out.println("Hello from " + getClass());
+    }
+}
+
+class Foo2 {
+    public void hi() {
+        System.out.println("Hello from " + getClass());
+    }
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Hack {
+    String value();
+}
+
+
+public class RedefineChangeClassOrder extends JdbTest {
+
+    public static void main(String argv[]) {
+        new RedefineChangeClassOrder().run();
+    }
+
+    private RedefineChangeClassOrder() {
+        super(DEBUGGEE_CLASS, SOURCE_FILE);
+    }
+
+    private static final String DEBUGGEE_CLASS = RedefineChangeClassOrderTarg.class.getName();
+    private static final String SOURCE_FILE = "RedefineChangeClassOrder.java";
+
+    @Override
+    protected void runCases() {
+        setBreakpoints(1);
+        jdb.command(JdbCommand.run());
+        redefineClass(1, "-g");
+        jdb.contToExit(1);
+
+        new OutputAnalyzer(getDebuggeeOutput())
+                .shouldNotContain("FAIL:");
+    }
+}
--- a/test/jdk/com/sun/jdi/RedefineChangeClassOrder.sh	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2006, 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 6270982
-#  @summary Redefine a class so that the order of external classes in
-#  the constant pool are changed.
-#  @author dcubed
-#
-#  @run shell RedefineChangeClassOrder.sh
-
-compileOptions=-g
-
-# Would like to run this test with this option:
-# -XX:-FailOverToOldVerifier
-
-# Uncomment this to see the JDI trace
-#jdbOptions=-dbgtrace
-
-createJavaFile()
-{
-    cat <<EOF > $1.java.1
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-public class $1 {
-    public static void main(String[] args) {
-        new $1().hi(false);
-        new $1().hi(true);  // @1 breakpoint
-    }
-
-    public void hi(boolean expected) {
-        boolean isNewVersion = false; // @1 commentout
-        // @1 uncomment boolean isNewVersion = true;
-
-        if (expected == isNewVersion) {
-            System.out.println("PASS: expected and isNewVersion match.");
-        } else {
-            System.out.println("FAIL: expected and isNewVersion do not match.");
-            System.out.println("expected=" + expected
-              + "  isNewVersion=" + isNewVersion);
-        }
-
-        Foo1 foo1 = new Foo1();  // @1 commentout
-        foo1.hi();  // @1 commentout
-
-        // This Hack code block exists to force some verification_type_info
-        // objects of subtype Object_variable_info into the StackMapTable.
-        //
-        // In the redefined code, the above Foo1 code is effectively
-        // moved after the Foo2 code below which causes things to be
-        // layed out in a different order in the constant pool. The
-        // cpool_index in the Object_variable_info has to be updated
-        // in the redefined code's StackMapTable to refer to right
-        /// constant pool index in the merged constant pool.
-        Hack hack = getClass().getAnnotation(Hack.class);
-        if (hack != null) {
-            String class_annotation = hack.value();
-            System.out.println("class annotation is: " + class_annotation);
-            if (isNewVersion) {
-                if (class_annotation.equals("JUNK")) {
-                    System.out.println("class_annotation is JUNK.");
-                } else {
-                    System.out.println("class_annotation is NOT JUNK.");
-                }
-            }
-        }
-
-        Foo2 foo2 = new Foo2();
-        foo2.hi();
-
-        // @1 uncomment Foo1 foo1 = new Foo1();
-        // @1 uncomment foo1.hi();
-    }
-}
-
-class Foo1 {
-    public void hi() {
-        System.out.println("Hello from " + getClass());
-    }
-}
-
-class Foo2 {
-    public void hi() {
-        System.out.println("Hello from " + getClass());
-    }
-}
-
-@Retention(RetentionPolicy.RUNTIME)
-@interface Hack {
-    String value();
-}
-
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-    setBkpts @1
-    runToBkpt @1
-    redefineClass @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
-
-debuggeeFailIfPresent 'FAIL:'
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/RedefineClasses.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,146 @@
+/*
+ * 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 4628760
+ * @summary RedefineClasses gets assertion: "Should be a method entry in cpcache!"
+ * @comment converted from test/jdk/com/sun/jdi/RedefineClasses.sh
+ *
+ * @library /test/lib
+ * @run main/othervm RedefineClasses
+ */
+
+/* On windows, with b90, this gets this:
+ * assert(u2_at_bcp >= 0 && u2_at_bcp < old_cache->length(), "Bad cpcache index!")
+ *
+ * Error happened during: VM_RedefineClasses
+ *
+ * Error ID: D:/jdk1.4/hotspot\src\share\vm\prims\jvmdi_hotswap.cpp, 331
+
+ * On solaris, and on windows with 4559100 fixed, this test fails with:
+ *
+ * HotSpot Virtual Machine Error, assertion failure
+ * Please report this error at
+ * http://java.sun.com/cgi-bin/bugreport.cgi
+ *
+ * Java VM: Java HotSpot(TM) Client VM (1.4-internal-debug mixed mode)
+ *
+ * assert(old_cache->entry_at(u2_at_bcp)->is_method_entry(), "Should be a method entry in cpcache!")
+ *
+ * Error happened during: VM_RedefineClasses
+ *
+ * Error ID: M:\ws\m\b2\service_hs_baseline\src\share\vm\prims\jvmdi_hotswap.cpp, 335
+ */
+
+/*
+ * With -Xcomp on solaris this passes, but takes 2 minutes.
+ */
+
+import lib.jdb.ClassTransformer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+import java.lang.Thread;
+import java.util.HashMap;
+import javax.swing.*;
+import java.util.*;
+
+class RedefineClassesTarg {
+    int xxx = 20;
+    //ThreadGroup k = new ThreadGroup("group");
+    int i;
+
+    public RedefineClassesTarg() {
+    }
+
+    public void a1() {
+    a2();
+    }
+
+    public void a2() {
+    a3();
+    }
+
+    public void a3() {
+        System.out.println("out from a3");   // @1 breakpoint
+        //System.out.println("hello world"); // @ 1 delete this isn't even necesary
+    }
+    public void a4() {
+        System.out.println("in a4");
+        int i = 2;
+        int j = 3333;
+        System.out.println("i + j = " + (i + j));
+        System.out.println("out from a4");
+        System.out.println("def");
+        a1();
+    }
+
+    public void aa() {
+        a4();
+        System.out.println("out from aa");
+    }
+
+
+    public static void main(String[] args) {
+        byte xyz[] = new byte[] { 'a', 'b', 'c' };
+
+        int x1 = 100;
+        x1 = 101;
+        x1 = 102;
+        x1 = 103;
+        String m1 = "def";
+        String m2 = "abc";
+        String m3 = "def";
+
+        int[] m = new int[] { 100, 200, 300 };
+
+        RedefineClassesTarg untitled31 = new RedefineClassesTarg();
+        untitled31.aa();
+    }
+}
+
+public class RedefineClasses extends JdbTest {
+
+    public static void main(String argv[]) {
+        new RedefineClasses().run();
+    }
+
+    private RedefineClasses() {
+        super(DEBUGGEE_CLASS, SOURCE_FILE);
+    }
+
+    private static final String DEBUGGEE_CLASS = RedefineClassesTarg.class.getName();
+    private static final String SOURCE_FILE = "RedefineClasses.java";
+
+    @Override
+    protected void runCases() {
+        setBreakpoints(1);
+        jdb.command(JdbCommand.run());
+        String transformedClassFile = ClassTransformer.fromTestSource(SOURCE_FILE)
+                .transform(1, DEBUGGEE_CLASS);
+        jdb.command(JdbCommand.redefine(DEBUGGEE_CLASS, transformedClassFile));
+        jdb.command(JdbCommand.redefine(DEBUGGEE_CLASS, transformedClassFile));
+        jdb.command(JdbCommand.redefine(DEBUGGEE_CLASS, transformedClassFile));
+    }
+}
--- a/test/jdk/com/sun/jdi/RedefineClasses.sh	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +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 4628760
-#  @summary RedefineClasses gets assertion: "Should be a method entry in cpcache!"
-#  @author jjh
-#
-#  @run shell/timeout=180 RedefineClasses.sh
-
-# On windows, with b90, this gets this:
-# assert(u2_at_bcp >= 0 && u2_at_bcp < old_cache->length(), "Bad cpcache index!")
-#
-# Error happened during: VM_RedefineClasses
-#
-# Error ID: D:/jdk1.4/hotspot\src\share\vm\prims\jvmdi_hotswap.cpp, 331
-
-# On solaris, and on windows with 4559100 fixed, this test fails with:
-#
-# HotSpot Virtual Machine Error, assertion failure
-# Please report this error at
-# http://java.sun.com/cgi-bin/bugreport.cgi
-#
-# Java VM: Java HotSpot(TM) Client VM (1.4-internal-debug mixed mode)
-#
-# assert(old_cache->entry_at(u2_at_bcp)->is_method_entry(), "Should be a method entry in cpcache!")
-#
-# Error happened during: VM_RedefineClasses
-#
-# Error ID: M:\ws\m\b2\service_hs_baseline\src\share\vm\prims\jvmdi_hotswap.cpp, 335
-
-
-# With -Xcomp on solaris this passes, but takes 2 minutes, thus the /timeout above.
-
-# These are variables that can be set to control execution
-
-java=java
-
-createJavaFile()
-{
-    cat <<EOF > $1.java.1
-
-
-import java.lang.Thread;
-import java.util.HashMap;
-import javax.swing.*;
-import java.util.*;
-
-
-public class $1 {
-  int xxx = 20;
-  //ThreadGroup k = new ThreadGroup("group");
-  int i;
-
-  public $1() {
-  }
-
-  public void a1() {
-      a2();
-  }
-
-  public void a2() {
-    a3();
-  }
-
-  public void a3() {
-     System.out.println("out from a3");   // @1 breakpoint
-     //System.out.println("hello world"); // @ 1 delete this isn't even necesary
-  }
-  public void a4() {
-    System.out.println("in a4");
-    int i = 2;
-    int j = 3333;
-    System.out.println("i + j = " + (i + j));
-    System.out.println("out from a4");
-    System.out.println("def");
-    a1();
-  }
-
-  public void aa() {
-    a4();
-    System.out.println("out from aa");
-  }
-
-
-  public static void main(String[] args) {
-    byte xyz[] = new byte[] { 'a', 'b', 'c' };
-
-    int x1 = 100;
-    x1 = 101;
-    x1 = 102;
-    x1 = 103;
-    String m1 = "def";
-    String m2 = "abc";
-    String m3 = "def";
-
-    int[] m = new int[] { 100, 200, 300 };
-
-    $1 untitled31 = new $1();
-    untitled31.aa();
-  }
-}
-
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-    setBkpts @1
-    runToBkpt
-    cmd redefine $classname $tmpFileDir/$classname.class
-    cmd redefine $classname $tmpFileDir/$classname.class
-    cmd redefine $classname $tmpFileDir/$classname.class
-}
-
-
-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/RedefineClearBreakpoint.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,99 @@
+/*
+ * 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 4705330
+ * @summary Netbeans Fix and Continue crashes JVM
+ * @comment converted from test/jdk/com/sun/jdi/RedefineClearBreakpoint.sh
+ *
+ * @library /test/lib
+ * @compile -g RedefineClearBreakpoint.java
+ * @run main/othervm RedefineClearBreakpoint
+ */
+
+/*
+ * The failure occurs after a breakpoint is set and then cleared
+ * after a class redefinition, in a method that was EMCP.
+ * This sequence creates a state in which subsequent operations
+ * such as accessing local vars via JVMDI, can cause a hotspot crash.
+ */
+
+import jdk.test.lib.Asserts;
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+import java.util.List;
+
+class RedefineClearBreakpointTarg {
+
+    public RedefineClearBreakpointTarg() {
+        int a=23;
+        a=m(a);
+    }
+    public int m(int b){
+        int bb=89;
+        System.out.println("RedefineClearBreakpointTarg -  constructor" + b); //@1 breakpoint
+        return b*b;
+    }
+
+    public static void main(java.lang.String[] args) {
+        new RedefineClearBreakpointTarg();
+        int jj = 0;   //@1 delete
+    }
+
+}
+
+
+public class RedefineClearBreakpoint extends JdbTest {
+
+    public static void main(String argv[]) {
+        new RedefineClearBreakpoint().run();
+    }
+
+    private RedefineClearBreakpoint() {
+        super(DEBUGGEE_CLASS, SOURCE_FILE);
+    }
+
+    private static final String DEBUGGEE_CLASS = RedefineClearBreakpointTarg.class.getName();
+    private static final String SOURCE_FILE = "RedefineClearBreakpoint.java";
+
+    @Override
+    protected void runCases() {
+        List<Integer> bps = parseBreakpoints(getTestSourcePath(SOURCE_FILE), 1);
+        Asserts.assertEquals(bps.size(), 1, "unexpected breakpoint count");
+        jdb.command(JdbCommand.stopAt(DEBUGGEE_CLASS, bps.get(0)));
+        jdb.command(JdbCommand.run());
+        redefineClass(1, "-g");
+
+        jdb.command(JdbCommand.stopAt(DEBUGGEE_CLASS, bps.get(0)));
+        jdb.command(JdbCommand.next());     // This is needed to make the crash happen at the 'locals' cmd
+
+        jdb.command(JdbCommand.clear(DEBUGGEE_CLASS, bps.get(0)));
+        jdb.command(JdbCommand.locals());   // The crash happens here
+
+        new OutputAnalyzer(getDebuggeeOutput())
+                .shouldNotContain("Internal exception:");
+    }
+}
--- a/test/jdk/com/sun/jdi/RedefineClearBreakpoint.sh	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +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 4705330
-#  @summary Netbeans Fix and Continue crashes JVM
-#  @author Jim Holmlund/Swamy Venkataramanappa
-#  @key intermittent
-#  @run shell RedefineClearBreakpoint.sh
-
-#  The failure occurs after a bkpt is set and then cleared
-#  after a class redefinition, in a method that was EMCP.
-#  This sequence creates a state in which subsequent operations
-#  such as accessing local vars via JVMDI, can cause a hotspot crash.
-
-# These are variables that can be set to control execution
-
-compileOptions=-g
-createJavaFile()
-{
-    cat <<EOF > $1.java.1
-
-public class $1 {
-        
-        public $1() {
-            int a=23;
-            a=m(a);
-            
-        }
-        public int m(int b){
-            int bb=89;
-            System.out.println("$1 -  constructor" + b); //@1 breakpoint
-            return b*b;
-        }
-        
-        public static void main(java.lang.String[] args) {
-            new $1();        
-            int jj = 0;   //@1 delete
-        }
-            
-}
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-    setBkpts @1
-    runToBkpt @1
-    redefineClass @1
-    #cmd clear    NOTE this shows that jdb thinks the bpt is still set :-(
-    setBkpts @1
-    cmd next     # This is needed to make the crash happen at the 'locals' cmd
-    cmd clear shtest:11
-    cmd locals   # The crash happens here.
-    #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
-debuggeeFailIfPresent "Internal exception:"
-pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/RedefineG.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,106 @@
+/*
+ * 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 4777868
+ * @summary Compile with java -g, do a RedefineClasses, and you don't get local vars
+ * @comment converted from test/jdk/com/sun/jdi/Redefine-g.sh
+ *
+ * @library /test/lib
+ * @compile RedefineG.java
+ * @run main/othervm RedefineG
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+
+// Compile the first version without -g and the 2nd version with -g.
+class RedefineGTarg {
+    public RedefineGTarg() {
+    }
+    public static void main(String[] args){
+        int gus=22;
+        RedefineGTarg kk=new RedefineGTarg();
+        kk.m1("ab");
+      }
+
+    void m1(String p1) {
+        int m1l1 = 1;
+        System.out.println("m1(String) called");
+        m1(p1, "2nd");
+        // @1 uncomment System.out.println("Hello Milpitas!");
+    }
+
+    void m1(String p1, String p2) {
+        int m1l2 = 2;
+        System.out.println("m2" + p1 + p2);  // @1 breakpoint
+    }
+
+}
+
+public class RedefineG extends JdbTest {
+    public static void main(String argv[]) {
+        new RedefineG().run();
+    }
+
+    private RedefineG() {
+        super(DEBUGGEE_CLASS,
+                "RedefineG.java");
+    }
+
+    private static final String DEBUGGEE_CLASS = RedefineGTarg.class.getName();
+
+    @Override
+    protected void runCases() {
+        setBreakpoints(1);
+        jdb.command(JdbCommand.run());
+        jdb.command(JdbCommand.where(""));
+        jdb.command(JdbCommand.locals());
+
+        redefineClass(1, "-g");
+        jdb.command(JdbCommand.where(""));
+        jdb.command(JdbCommand.locals());
+
+        jdb.command(JdbCommand.pop());
+        jdb.command(JdbCommand.where(""));
+        jdb.command(JdbCommand.locals());
+
+        jdb.command(JdbCommand.pop());
+        jdb.command(JdbCommand.where(""));
+        jdb.command(JdbCommand.locals());
+
+        jdb.contToExit(1);
+
+        new OutputAnalyzer(getJdbOutput())
+                .shouldContain("p1 = \"ab\"")
+                .shouldContain("p2 = \"2nd\"")
+                .shouldContain("m1l2 = 2")
+                .shouldNotContain("m1l1")
+                .shouldContain("args = instance of java.lang.String")
+                .shouldContain("gus = 22")
+                .shouldContain("kk = instance of " + DEBUGGEE_CLASS);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/RedefineImplementor.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6173560
+ * @summary Redefine a class that implements an interface
+ *          and verify that a subclass calls the right method.
+ * @comment converted from test/jdk/com/sun/jdi/RedefineImplementor.sh
+ *
+ * @library /test/lib
+ * @compile -g RedefineImplementor.java
+ * @run main/othervm RedefineImplementor
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import lib.jdb.JdbCommand;
+import lib.jdb.JdbTest;
+
+class RedefineImplementorTarg implements Runnable {
+    public void run() {
+        System.out.println("RedefineImplementorTarg's run");
+        // @1 uncomment System.out.println("This is the new version of RedefineImplementorTarg");
+    }
+
+    public static void main(String[] args) {
+        Runnable r = new B();
+        B.func(r);
+        B.func(r);  // @1 breakpoint
+    }
+
+}
+
+class B extends RedefineImplementorTarg {
+    static void func(Runnable r) {
+        r.run();
+    }
+}
+
+public class RedefineImplementor extends JdbTest {
+    public static void main(String argv[]) {
+        new RedefineImplementor().run();
+    }
+
+    private RedefineImplementor() {
+        super(RedefineImplementorTarg.class.getName(),
+                "RedefineImplementor.java");
+    }
+
+    @Override
+    protected void runCases() {
+        setBreakpoints(1);
+        jdb.command(JdbCommand.run());
+
+        redefineClass(1, "-g");
+
+        jdb.contToExit(1);
+
+        new OutputAnalyzer(getDebuggeeOutput())
+                .shouldContain("This is the new version of ");
+    }
+}
--- a/test/jdk/com/sun/jdi/RedefineImplementor.sh	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2006, 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 6173560
-#  @summary Redefine a class that implements an interface
-#    and verify that a subclass calls the right method.
-#
-#
-#  @run shell RedefineImplementor.sh
-
-compileOptions=-g
-
-# Uncomment this to see the JDI trace
-#jdbOptions=-dbgtrace
-
-createJavaFile()
-{
-    cat <<EOF > $1.java.1
-
-public class $1 implements Runnable {
-    public void run() {
-        System.out.println("$1's run");
-        // @1 uncomment System.out.println("This is the new version of $1");
-    }
-
-    public static void main(String[] args) {
-        Runnable r = new B();
-        B.func(r);
-        B.func(r);  // @1 breakpoint
-    }
-
-}
-
-class B extends $1 {
-    static void func(Runnable r) {
-        r.run();
-    }
-}
-
-EOF
-}
-
-# This is called to feed cmds to jdb.
-dojdbCmds()
-{
-    setBkpts @1
-    runToBkpt @1
-    redefineClass @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
-
-debuggeeFailIfNotPresent 'This is the new version of '
-pass
--- a/test/jdk/com/sun/jdi/RunToExit.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/RunToExit.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/SuspendNoFlagTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/cds/CDSBreakpointTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/cds/CDSDeleteAllBkptsTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/cds/CDSFieldWatchpoints.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/cds/CDSJDITest.java	Thu Sep 13 10:54:11 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;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/com/sun/jdi/lib/jdb/ClassTransformer.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,163 @@
+/*
+ * 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 lib.jdb;
+
+import jdk.test.lib.compiler.CompilerUtils;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.text.MessageFormat;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+// ClassTransformer provides functionality to transform java source and compile it.
+// We cannot use InMemoryJavaCompiler as test files usually contain 2 classes (the test itself and debuggee)
+// and InMemoryJavaCompiler cannot compile them.
+public class ClassTransformer {
+
+    private final List<String> lines;
+    private String fileName;
+    private String workDir = "ver{0}";
+    private static final String LINE_SEPARATOR = System.getProperty("line.separator");
+
+    private ClassTransformer(List<String> lines) {
+        this.lines = lines;
+    }
+
+    public ClassTransformer setFileName(String fileName) {
+        this.fileName = fileName;
+        return this;
+    }
+
+    // workDir is a MessageFormat pattern, id (int) is an {0} arg of the pattern.
+    // can be relative (relatively "scratch" dir) or absolute.
+    public ClassTransformer setWorkDir(String dir) {
+        workDir = dir;
+        return this;
+    }
+
+    public static ClassTransformer fromString(String content) {
+        return new ClassTransformer(Arrays.asList(content.split("\\R")));
+    }
+
+    public static ClassTransformer fromFile(Path filePath) {
+        try {
+            return new ClassTransformer(Files.readAllLines(filePath))
+                    .setFileName(filePath.getFileName().toString());
+        } catch (IOException e) {
+            throw new RuntimeException("failed to read " + filePath, e);
+        }
+    }
+    public static ClassTransformer fromFile(String filePath) {
+        return fromFile(Paths.get(filePath));
+    }
+
+    public static ClassTransformer fromTestSource(String fileName) {
+        return fromFile(Paths.get(System.getProperty("test.src")).resolve(fileName));
+    }
+
+    // returns path to the .class file of the transformed class
+    public String transform(int id, String className, String... compilerOptions) {
+        Path subdir = Paths.get(".").resolve(MessageFormat.format(workDir, id));
+        Path transformedSrc = subdir.resolve(fileName);
+        try {
+            Files.createDirectories(subdir);
+            Files.write(transformedSrc, transform(id).getBytes());
+        } catch (IOException e) {
+            throw new RuntimeException("failed to write transformed " + transformedSrc, e);
+        }
+        try {
+            // need to add extra classpath args
+            List<String> args = new LinkedList<>(Arrays.asList(compilerOptions));
+            args.add("-cp");
+            args.add(System.getProperty("java.class.path"));
+            CompilerUtils.compile(subdir, subdir, false, args.toArray(new String[args.size()]));
+        } catch (IOException e) {
+            throw new RuntimeException("failed to compile " + transformedSrc, e);
+        }
+        return subdir.resolve(className + ".class").toString();
+    }
+
+    /*
+    * To do RedefineClasses operations, embed @1 tags in the .java
+    * file to tell this script how to modify it to produce the 2nd
+    * version of the .class file to be used in the redefine operation.
+    * Here are examples of each editing tag and what change
+    * it causes in the new file.  Note that blanks are not preserved
+    * in these editing operations.
+    *
+    * @1 uncomment
+    *  orig:   // @1 uncomment   gus = 89;
+    *  new:         gus = 89;
+    *
+    * @1 commentout
+    *  orig:   gus = 89      // @1 commentout
+    *  new: // gus = 89      // @1 commentout
+    *
+    * @1 delete
+    *  orig:  gus = 89      // @1 delete
+    *  new:   entire line deleted
+    *
+    * @1 newline
+    *  orig:  gus = 89;     // @1 newline gus++;
+    *  new:   gus = 89;     //
+    *         gus++;
+    *
+    * @1 replace
+    *  orig:  gus = 89;     // @1 replace gus = 90;
+    *  new:   gus = 90;
+    */
+    public String transform(int id) {
+        Pattern delete = Pattern.compile("@" + id + " *delete");
+        Pattern uncomment = Pattern.compile("// *@" + id + " *uncomment (.*)");
+        Pattern commentout = Pattern.compile(".* @" + id + " *commentout");
+        Pattern newline = Pattern.compile("(.*) @" + id + " *newline (.*)");
+        Pattern replace = Pattern.compile("@" + id + " *replace (.*)");
+        return lines.stream()
+                .filter(s -> !delete.matcher(s).find())     // @1 delete
+                .map(s -> {
+                    Matcher m = uncomment.matcher(s);       // @1 uncomment
+                    return m.find() ? m.group(1) : s;
+                })
+                .map(s-> {
+                    Matcher m = commentout.matcher(s);      // @1 commentout
+                    return m.find() ? "//" + s : s;
+                })
+                .map(s -> {
+                    Matcher m = newline.matcher(s);         // @1 newline
+                    return m.find() ? m.group(1) + LINE_SEPARATOR + m.group(2) : s;
+                })
+                .map(s -> {
+                    Matcher m = replace.matcher(s);         // @1 replace
+                    return m.find() ? m.group(1) : s;
+                })
+                .collect(Collectors.joining(LINE_SEPARATOR));
+    }
+
+}
--- a/test/jdk/com/sun/jdi/lib/jdb/Jdb.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/lib/jdb/Jdb.java	Thu Sep 13 10:54:11 2018 -0700
@@ -33,88 +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.Utils;
-import jdk.test.lib.process.ProcessTools;
 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());
 
@@ -126,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)
@@ -146,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
@@ -156,6 +85,11 @@
     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 {
@@ -178,18 +112,6 @@
                 }
             }
         }
-        // shutdown debuggee
-        if (debuggee.isAlive()) {
-            try {
-                debuggee.waitFor(Utils.adjustTimeout(10), TimeUnit.SECONDS);
-            } catch (InterruptedException e) {
-                // ignore
-            } finally {
-                if (debuggee.isAlive()) {
-                    debuggee.destroy();
-                }
-            }
-        }
     }
 
 
@@ -231,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 {
@@ -333,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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/lib/jdb/JdbCommand.java	Thu Sep 13 10:54:11 2018 -0700
@@ -149,6 +149,11 @@
         return new JdbCommand("stop in " + targetClass + "." + methodName);
     }
 
+    // clear <class id>:<line>   -- clear a breakpoint at a line
+    public static JdbCommand clear(String targetClass, int lineNum) {
+        return new JdbCommand("clear " + targetClass + ":" + lineNum);
+    }
+
     // exception type used by catch/ignore
     public enum ExType{
         uncaught,
@@ -197,6 +202,14 @@
         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
@@ -226,4 +239,17 @@
     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);
+    }
+
+    public static JdbCommand pop() {
+        return new JdbCommand("pop");
+    }
+
+    public static JdbCommand redefine(String classId, String classFileName) {
+        return new JdbCommand("redefine " + classId + " " + classFileName);
+    }
 }
--- a/test/jdk/com/sun/jdi/lib/jdb/JdbTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/jdi/lib/jdb/JdbTest.java	Thu Sep 13 10:54:11 2018 -0700
@@ -23,28 +23,62 @@
 
 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 String sourceFilename;
+
+        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 LaunchOptions setSourceFilename(String name) {
+            sourceFilename = name;
+            return this;
+        }
+    }
+
+    public JdbTest(LaunchOptions launchOptions) {
+        this.launchOptions = launchOptions;
     }
     public JdbTest(String debuggeeClass) {
-        this(new Jdb.LaunchOptions(debuggeeClass));
+        this(new LaunchOptions(debuggeeClass));
     }
 
-    private final Jdb.LaunchOptions jdbOptions;
+    // sourceFilename is used by setBreakpoints and redefineClass
+    public JdbTest(String debuggeeClass, String sourceFilename) {
+        this(new LaunchOptions(debuggeeClass).setSourceFilename(sourceFilename));
+    }
+
     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;
 
     // returns the whole jdb output as a string
     public String getJdbOutput() {
@@ -53,7 +87,7 @@
 
     // returns the whole debuggee output as a string
     public String getDebuggeeOutput() {
-        return jdb == null ? "" : jdb.getDebuggeeOutput();
+        return debuggeeOutput.stream().collect(Collectors.joining(lineSeparator));
     }
 
     public void run() {
@@ -66,10 +100,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();
@@ -78,6 +152,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");
@@ -123,13 +209,46 @@
     // 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);
+        return setBreakpoints(jdb, launchOptions.debuggeeClass,
+                              getTestSourcePath(debuggeeFileName), id);
+    }
+
+    // sets breakpoints in the class {@code launchOptions.debuggeeClass}
+    // to the lines parsed by {@code parseBreakpoints}
+    // from the file from test source directory specified by {@code launchOptions.sourceFilename}.
+    // returns number of the breakpoints set.
+    protected int setBreakpoints(int id) {
+        verifySourceFilename();
+        return setBreakpointsFromTestSource(launchOptions.sourceFilename, id);
+    }
+
+    // transforms class with the specified id (see {@code ClassTransformer})
+    // and executes "redefine" jdb command for {@code launchOptions.debuggeeClass}.
+    // returns reply for the command.
+    protected List<String> redefineClass(int id, String... compilerOptions) {
+        verifySourceFilename();
+        String transformedClassFile = ClassTransformer.fromTestSource(launchOptions.sourceFilename)
+                .transform(id, launchOptions.debuggeeClass, compilerOptions);
+        return jdb.command(JdbCommand.redefine(launchOptions.debuggeeClass, transformedClassFile));
+    }
+
+    // gets full test source path for the given test filename
+    protected static String getTestSourcePath(String fileName) {
+        return Paths.get(System.getProperty("test.src")).resolve(fileName).toString();
+    }
+
+    // verifies that sourceFilename is specified in ctor
+    private void verifySourceFilename() {
+        if (launchOptions.sourceFilename == null) {
+            throw new RuntimeException("launchOptions.sourceFilename must be specified.");
+        }
     }
 
     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) {
--- a/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/management/OperatingSystemMXBean/TestTotalSwap.java	Thu Sep 13 10:54:11 2018 -0700
@@ -28,10 +28,8 @@
  * @author  Steve Bohne
  * @author  Jaroslav Bachorik
  *
- * @library /lib/testlibrary
  * @library /test/lib
  *
- * @build TestTotalSwap jdk.testlibrary.*
  * @run main TestTotalSwap
  */
 
@@ -57,8 +55,8 @@
 import java.lang.management.*;
 
 import jdk.test.lib.Platform;
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
 
 public class TestTotalSwap {
 
--- a/test/jdk/com/sun/tools/attach/BasicTests.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/tools/attach/BasicTests.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/tools/attach/PermissionTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/tools/attach/ProviderTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/tools/attach/RunnerUtil.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/tools/attach/StartManagementAgent.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/com/sun/tools/attach/TempDirTest.java	Thu Sep 13 10:54:11 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/io/BufferedInputStream/LargeCopyWithMark.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/io/BufferedInputStream/LargeCopyWithMark.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/Class/forName/modules/TestDriver.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/Class/getResource/ResourcesTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/ClassLoader/EndorsedDirs.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/ClassLoader/ExtDirs.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/ClassLoader/GetDotResource.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/ClassLoader/GetSystemPackage.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/ClassLoader/getResource/GetResource.java	Thu Sep 13 10:54:11 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,8 +24,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
@@ -44,8 +44,8 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import jdk.testlibrary.JDKToolFinder;
-import static jdk.testlibrary.ProcessTools.*;
+import jdk.test.lib.JDKToolFinder;
+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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/ClassLoader/getResource/automaticmodules/Driver.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/ClassLoader/getResource/modules/ResourcesTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/ModuleTests/access/AccessTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/Runtime/shutdown/ShutdownInterruptedMain.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/StackWalker/CallerFromMain.java	Thu Sep 13 10:54:11 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 {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/String/AlignIndent.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,201 @@
+/*
+ * 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 Unit tests for String#align and String#indent
+ * @run main AlignIndent
+ */
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class AlignIndent {
+    static final List<String> ENDS = List.of("", "\n", "   \n", "\n\n", "\n\n\n");
+    static final List<String> MIDDLES = List.of(
+            "",
+            "xyz",
+            "   xyz",
+            "      xyz",
+            "xyz   ",
+            "   xyz   ",
+            "      xyz   ",
+            "xyz\u2022",
+            "   xyz\u2022",
+            "xyz\u2022   ",
+            "   xyz\u2022   ",
+            "   // comment"
+    );
+
+    public static void main(String[] args) {
+        test1();
+        test2();
+        test3();
+    }
+
+    /*
+     * Test String#align() functionality.
+     */
+    static void test1() {
+        for (String prefix : ENDS) {
+            for (String suffix : ENDS) {
+                for (String middle : MIDDLES) {
+                    {
+                        String input = prefix + "   abc   \n" + middle + "\n   def   \n" + suffix;
+                        String output = input.align();
+
+                        String[] inLines = input.split("\\R");
+                        String[] outLines = output.split("\\R");
+
+                        String[] inLinesBody = getBody(inLines);
+
+                        if (inLinesBody.length < outLines.length) {
+                            report("String::align()", "Result has more lines than expected", input, output);
+                        } else if (inLinesBody.length > outLines.length) {
+                            report("String::align()", "Result has fewer lines than expected", input, output);
+                        }
+
+                        int indent = -1;
+                        for (int i = 0; i < inLinesBody.length; i++) {
+                            String in = inLinesBody[i];
+                            String out = outLines[i];
+                            if (!out.isBlank()) {
+                                int offset = in.indexOf(out);
+                                if (offset == -1) {
+                                    report("String::align()", "Portions of line are missing", input, output);
+                                }
+                                if (indent == -1) {
+                                    indent = offset;
+                                } else if (offset != indent) {
+                                    report("String::align()",
+                                            "Inconsistent indentation in result", input, output);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /*
+     * Test String#align(int n) functionality.
+     */
+    static void test2() {
+        for (int adjust : new int[] {-8, -7, -4, -3, -2, -1, 0, 1, 2, 3, 4, 7, 8}) {
+            for (String prefix : ENDS) {
+                for (String suffix : ENDS) {
+                    for (String middle : MIDDLES) {
+                        {
+                            String input = prefix + "   abc   \n" + middle + "\n   def   \n" + suffix;
+                            String output = input.align(adjust);
+                            String expected = input.align().indent(adjust);
+
+                            if (!output.equals(expected)) {
+                                report("String::align(int n)",
+                                        "Result inconsistent with align().indent(n)", expected, output);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /*
+     * Test String#indent(int n) functionality.
+     */
+    static void test3() {
+        for (int adjust : new int[] {-8, -7, -4, -3, -2, -1, 0, 1, 2, 3, 4, 7, 8}) {
+            for (String prefix : ENDS) {
+                for (String suffix : ENDS) {
+                    for (String middle : MIDDLES) {
+                        String input = prefix + "   abc   \n" + middle + "\n   def   \n" + suffix;
+                        String output = input.indent(adjust);
+
+                        Stream<String> stream = input.lines();
+                        if (adjust > 0) {
+                            final String spaces = " ".repeat(adjust);
+                            stream = stream.map(s -> s.isBlank() ? s : spaces + s);
+                        } else if (adjust < 0) {
+                            stream = stream.map(s -> s.substring(Math.min(-adjust, indexOfNonWhitespace(s))));
+                        }
+                        String expected = stream.collect(Collectors.joining("\n", "", "\n"));
+
+                        if (!output.equals(expected)) {
+                            report("String::indent(int n)",
+                                    "Result indentation not as expected", expected, output);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public static int indexOfNonWhitespace(String s) {
+        int left = 0;
+        while (left < s.length()) {
+            char ch = s.charAt(left);
+            if (ch != ' ' && ch != '\t' && !Character.isWhitespace(ch)) {
+                break;
+            }
+            left++;
+        }
+        return left;
+    }
+
+
+    private static String[] getBody(String[] inLines) {
+        int from = -1, to = -1;
+        for (int i = 0; i < inLines.length; i++) {
+            String line = inLines[i];
+            if (!line.isBlank()) {
+                if (from == -1) {
+                    from = i;
+                }
+                to = i + 1;
+            }
+        }
+        return Arrays.copyOfRange(inLines, from, to);
+    }
+
+    /*
+     * Report difference in result.
+     */
+    static void report(String test, String message, String input, String output) {
+        System.err.println("Testing " + test + ": " + message);
+        System.err.println();
+        System.err.println("Input: length = " + input.length());
+        System.err.println("_".repeat(40));
+        System.err.print(input.replaceAll(" ", "."));
+        System.err.println("_".repeat(40));
+        System.err.println();
+        System.err.println("Output: length = " + output.length());
+        System.err.println("_".repeat(40));
+        System.err.print(output.replaceAll(" ", "."));
+        System.err.println("_".repeat(40));
+        throw new RuntimeException();
+    }
+}
--- a/test/jdk/java/lang/System/LoggerFinder/modules/Base.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/Base.java	Thu Sep 13 10:54:11 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
@@ -32,10 +32,10 @@
 import java.util.List;
 import java.util.stream.Stream;
 
-import jdk.testlibrary.JDKToolFinder;
+import jdk.test.lib.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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForImageTest.java	Thu Sep 13 10:54:11 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
@@ -45,8 +32,8 @@
  *               patched system module, or Xbootclasspath
  *          This test does not require existence of java.logging module,
  *          but require jdk.compiler module
- * @library /lib/testlibrary /test/lib
- * @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @library /test/lib
+ * @build Base jdk.test.lib.compiler.CompilerUtils
  * @run main/othervm JDKLoggerForImageTest
  */
 
--- a/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForJDKTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForJDKTest.java	Thu Sep 13 10:54:11 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
@@ -45,8 +32,8 @@
  *            2. clients are in named/unnamed module,
  *               patched system module, or Xbootclasspath
  *          This test DOES require existence of java.logging module
- * @library /lib/testlibrary /test/lib
- * @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @library /test/lib
+ * @build Base jdk.test.lib.compiler.CompilerUtils
  * @run main/othervm JDKLoggerForJDKTest
  */
 
--- a/test/jdk/java/lang/System/LoggerFinder/modules/LoggerInImageTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/LoggerInImageTest.java	Thu Sep 13 10:54:11 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
@@ -45,8 +32,8 @@
  *               patched system module, or Xbootclasspath
  *          This test does not require existence of java.logging module,
  *          but require jdk.compiler module
- * @library /lib/testlibrary /test/lib
- * @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @library /test/lib
+ * @build Base jdk.test.lib.compiler.CompilerUtils
  * @run main/othervm LoggerInImageTest
  */
 
--- a/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForImageTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForImageTest.java	Thu Sep 13 10:54:11 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
@@ -45,8 +34,8 @@
  *               patched system module, or Xbootclasspath
  *          This test does not require existence of java.logging module,
  *          but require jdk.compiler module
- * @library /lib/testlibrary /test/lib
- * @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @library /test/lib
+ * @build Base jdk.test.lib.compiler.CompilerUtils
  * @run main/othervm NamedLoggerForImageTest
  */
 
--- a/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForJDKTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForJDKTest.java	Thu Sep 13 10:54:11 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
@@ -45,8 +34,8 @@
  *               patched system module, or Xbootclasspath
  *          This test does not require existence of java.logging module,
  *          but require jdk.compiler module
- * @library /lib/testlibrary /test/lib
- * @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @library /test/lib
+ * @build Base jdk.test.lib.compiler.CompilerUtils
  * @run main/othervm NamedLoggerForJDKTest
  */
 
--- a/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForImageTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForImageTest.java	Thu Sep 13 10:54:11 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
@@ -45,8 +34,8 @@
  *               patched system module, or Xbootclasspath
  *          This test does not require existence of java.logging module,
  *          but require jdk.compiler module
- * @library /lib/testlibrary /test/lib
- * @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @library /test/lib
+ * @build Base jdk.test.lib.compiler.CompilerUtils
  * @run main/othervm UnnamedLoggerForImageTest
  */
 
--- a/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForJDKTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForJDKTest.java	Thu Sep 13 10:54:11 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
@@ -45,8 +34,8 @@
  *               patched system module, or Xbootclasspath
  *          This test does not require existence of java.logging module,
  *          but require jdk.compiler module
- * @library /lib/testlibrary /test/lib
- * @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
+ * @library /test/lib
+ * @build Base jdk.test.lib.compiler.CompilerUtils
  * @run main/othervm UnnamedLoggerForJDKTest
  */
 
--- a/test/jdk/java/lang/System/OsVersionTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/System/OsVersionTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThread.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/instrument/PremainClass/NoPremainAgentTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/instrument/PremainClass/PremainClassTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/instrument/executableJAR/ExecJarWithAgent.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/instrument/modules/AppendToClassPathModuleTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest.java	Thu Sep 13 10:54:11 2018 -0700
@@ -45,8 +45,8 @@
 import java.util.concurrent.Phaser;
 import javax.management.*;
 import javax.management.openmbean.CompositeData;
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.JDKToolFinder;
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.process.ProcessTools;
 import jdk.testlibrary.Utils;
 
 import sun.hotspot.code.Compiler;
--- a/test/jdk/java/lang/management/MemoryMXBean/RunUtil.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/management/MemoryMXBean/RunUtil.java	Thu Sep 13 10:54:11 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,10 +28,10 @@
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.JDKToolFinder;
+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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/reflect/Proxy/ProxyClassAccessTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/reflect/Proxy/ProxyLayerTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/lang/reflect/Proxy/ProxyTest.java	Thu Sep 13 10:54:11 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/CookieHandler/CookieManagerTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/net/CookieHandler/CookieManagerTest.java	Thu Sep 13 10:54:11 2018 -0700
@@ -31,6 +31,9 @@
  */
 
 import com.sun.net.httpserver.*;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
 import java.io.IOException;
 import java.net.*;
 import static java.net.Proxy.NO_PROXY;
@@ -160,14 +163,40 @@
         exchange.close();
     }
 
+    private static String trim(String s) {
+        StringBuilder sb = new StringBuilder();
+        for (int i=0; i<s.length(); i++) {
+            char c = s.charAt(i);
+            if (!Character.isWhitespace(c))
+                sb.append(c);
+        }
+        return sb.toString();
+    }
+
+    private static boolean cookieEquals(String s1, String s2) {
+        s1 = trim(s1);
+        s2 = trim(s2);
+        String[] s1a = s1.split(";");
+        String[] s2a = s2.split(";");
+        List<String> l1 = new LinkedList(List.of(s1a));
+        List<String> l2 = new LinkedList(List.of(s2a));
+        Collections.sort(l1);
+        Collections.sort(l2);
+        int i = 0;
+        for (String s : l1) {
+            if (!s.equals(l2.get(i++))) {
+                return false;
+            }
+        }
+        return true;
+    }
+
     private void checkRequest(Headers hdrs) {
 
         assert testDone > 0;
         String cookieHeader = hdrs.getFirst("Cookie");
-        if (cookieHeader != null &&
-            cookieHeader
-                .equalsIgnoreCase(testCases[testcaseDone][testDone-1]
-                                  .cookieToRecv))
+        if (cookieHeader != null && cookieEquals(
+                cookieHeader, testCases[testcaseDone][testDone-1].cookieToRecv))
         {
             System.out.printf("%15s %s\n", "PASSED:", cookieHeader);
         } else {
--- a/test/jdk/java/net/Inet6Address/serialize/Inet6AddressSerializationTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/net/Inet6Address/serialize/Inet6AddressSerializationTest.java	Thu Sep 13 10:54:11 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/net/MulticastSocket/MultiDead.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/net/MulticastSocket/MultiDead.java	Thu Sep 13 10:54:11 2018 -0700
@@ -26,6 +26,7 @@
  * @bug 8072466
  * @summary Deadlock when initializing MulticastSocket and DatagramSocket
  * @library /lib/testlibrary
+ * @library /test/lib
  * @build jdk.testlibrary.*
  * @run main/othervm MultiDead
  */
@@ -36,7 +37,7 @@
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.CountDownLatch;
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import jdk.testlibrary.JDKToolLauncher;
+import jdk.test.lib.JDKToolLauncher;
 import jdk.testlibrary.Utils;
 
 public class MultiDead {
--- a/test/jdk/java/net/spi/URLStreamHandlerProvider/Basic.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/net/spi/URLStreamHandlerProvider/Basic.java	Thu Sep 13 10:54:11 2018 -0700
@@ -46,7 +46,7 @@
 import javax.tools.StandardLocation;
 import javax.tools.ToolProvider;
 import jdk.test.lib.util.FileUtils;
-import jdk.testlibrary.JDKToolFinder;
+import jdk.test.lib.JDKToolFinder;
 import static java.lang.String.format;
 import static java.util.Arrays.asList;
 
@@ -55,10 +55,10 @@
  * @bug 8064924
  * @modules jdk.compiler
  * @summary Basic test for URLStreamHandlerProvider
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @build jdk.test.lib.Platform
  *        jdk.test.lib.util.FileUtils
- *        jdk.testlibrary.JDKToolFinder
+ *        jdk.test.lib.JDKToolFinder
  * @compile Basic.java Child.java
  * @run main Basic
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/net/whitebox/CookieTestDriver.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,29 @@
+/*
+ * 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
+ * @modules java.base/java.net
+ * @run main/othervm java.base/java.net.CookieManagerTest
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/net/whitebox/TEST.properties	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,3 @@
+modules = \
+    java.base/java.net
+bootclasspath.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/net/whitebox/java.base/java/net/CookieManagerTest.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,133 @@
+/*
+ * 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 java.net;
+
+import java.net.CookieManager;
+import java.net.HttpCookie;
+import java.util.*;
+import java.util.stream.Collectors;
+
+// Whitebox Test of CookieManager.sortByPathAndAge
+
+public class CookieManagerTest
+{
+    Random r1; // random is reseeded so it is reproducible
+    long seed;
+
+    public static void main(String[] args) {
+        CookieManagerTest test = new CookieManagerTest();
+        test.run();
+    }
+
+    CookieManagerTest() {
+        r1 = new Random();
+        seed = r1.nextLong();
+        System.out.println("Random seed is: " + seed);
+        r1.setSeed(seed);
+    }
+
+    static class TestCookie {
+        String path;
+        long creationTime;
+
+        static TestCookie of(String path, long creationTime) {
+            TestCookie t = new TestCookie();
+            t.path = path;
+            t.creationTime = creationTime;
+            return t;
+        }
+    }
+
+    // The order shown below is what we expect the sort to produce
+    // longest paths first then for same length path by age (oldest first)
+    // This array is copied to a list and shuffled before being passed to
+    // the sort function several times.
+
+    TestCookie[] cookies = new TestCookie[] {
+        TestCookie.of("alpha/bravo/charlie/delta", 50),
+        TestCookie.of("alphA/Bravo/charlie/delta", 100),
+        TestCookie.of("bravo/charlie/delta", 1),
+        TestCookie.of("bravo/chArlie/delta", 2),
+        TestCookie.of("bravo/charlie/delta", 5),
+        TestCookie.of("bravo/charliE/dElta", 10),
+        TestCookie.of("charlie/delta", 1),
+        TestCookie.of("charlie/delta", 1),
+        TestCookie.of("charlie/delta", 1),
+        TestCookie.of("charlie/delta", 2),
+        TestCookie.of("charlie/delta", 2),
+        TestCookie.of("charlie/delta", 2),
+        TestCookie.of("ChaRlie/delta", 3),
+        TestCookie.of("charliE/deLta", 4),
+        TestCookie.of("cHarlie/delta", 7),
+        TestCookie.of("chaRRie/delta", 9),
+        TestCookie.of("delta", 999),
+        TestCookie.of("Delta", 1000),
+        TestCookie.of("Delta", 1000),
+        TestCookie.of("DeLta", 1001),
+        TestCookie.of("DeLta", 1002),
+        TestCookie.of("/", 2),
+        TestCookie.of("/", 3),
+        TestCookie.of("/", 300)
+    };
+
+    public void run()
+    {
+        for (int i=0; i<100; i++) {
+            List<TestCookie> l1 = new LinkedList(Arrays.asList(cookies));
+            Collections.shuffle(l1, r1);
+            List<HttpCookie> l2 = l1
+                    .stream()
+                    .map(this::createCookie)
+                    .collect(Collectors.toList());
+
+
+            // call PP method of CookieManager
+            List<String> result = CookieManager.sortByPathAndAge(l2);
+            int index = 0;
+            for (String r : result) {
+                if (!r.contains("name=\"value\""))
+                    continue;
+                // extract Path value
+                r = r.substring(r.indexOf("Path=")+6);
+                // remove trailing "
+
+                // should go from name="value";$Path="bravo/charlie/delta" ->
+                //                                    bravo/charlie/delta
+                r = r.substring(0, r.indexOf('"'));
+                if (!r.equals(cookies[index].path)) {
+                    System.err.printf("ERROR: got %s index: %d", r, index);
+                    System.err.printf(" expected: %s\n", cookies[index].path);
+                    throw new RuntimeException("Test failed");
+                }
+                index++;
+            }
+        }
+    }
+
+    private HttpCookie createCookie(TestCookie tc) {
+        HttpCookie ck = new HttpCookie("name", "value", null, tc.creationTime);
+        ck.setPath(tc.path);
+        return ck;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/nio/charset/CharsetDecoder/NaNinCtor.java	Thu Sep 13 10:54:11 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	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/nio/file/spi/SetDefaultProvider.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/rmi/module/ModuleTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/security/AccessController/DoPrivAccompliceTest.java	Thu Sep 13 10:54:11 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/EntryProtectionTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/security/KeyStore/PKCS12/EntryProtectionTest.java	Thu Sep 13 10:54:11 2018 -0700
@@ -40,7 +40,7 @@
  * @summary Test for feature 'support stronger entry protection'. An entry is
  * stored to keystore with different PasswordProtection objects which are
  * specified by different PBE algorithms (use -Dseed=X to set PRNG seed)
- * @library /test/lib /lib/testlibrary ../
+ * @library /test/lib ../
  * @key randomness
  * @build jdk.test.lib.RandomFactory
  * @run main EntryProtectionTest
--- a/test/jdk/java/security/KeyStore/PKCS12/KeytoolReaderP12Test.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/security/KeyStore/PKCS12/KeytoolReaderP12Test.java	Thu Sep 13 10:54:11 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;
@@ -36,7 +36,8 @@
  * @bug 8048830
  * @summary Test for PKCS12 keystore list , export commands. Refer README for
  * keystore files information
- * @library /lib/testlibrary ../
+ * @library ../
+ * @library /test/lib
  * @run main KeytoolReaderP12Test
  */
 public class KeytoolReaderP12Test {
--- a/test/jdk/java/security/KeyStore/PKCS12/KeytoolWriteP12Test.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/security/KeyStore/PKCS12/KeytoolWriteP12Test.java	Thu Sep 13 10:54:11 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,14 +24,15 @@
  */
 
 import java.io.File;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.process.OutputAnalyzer;
 import static java.lang.System.out;
 
 /**
  * @test
  * @bug 8048830
  * @summary Tests for creating pkcs12 keystore with various algorithms
- * @library /lib/testlibrary ../
+ * @library ../
+ * @library /test/lib
  * @run main KeytoolWriteP12Test
  */
 public class KeytoolWriteP12Test {
--- a/test/jdk/java/security/KeyStore/PKCS12/MetadataEmptyTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/security/KeyStore/PKCS12/MetadataEmptyTest.java	Thu Sep 13 10:54:11 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
@@ -39,7 +39,8 @@
  * @test
  * @bug 8048830
  * @summary Entry's attribute set should be empty
- * @library /lib/testlibrary ../
+ * @library ../
+ * @library /test/lib
  * @run main MetadataEmptyTest
  */
 public class MetadataEmptyTest {
--- a/test/jdk/java/security/KeyStore/PKCS12/MetadataStoreLoadTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/security/KeyStore/PKCS12/MetadataStoreLoadTest.java	Thu Sep 13 10:54:11 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,7 +43,8 @@
  * @test
  * @bug 8048830
  * @summary Test store metadata attributes to PKCS12 keystore.
- * @library /lib/testlibrary ../
+ * @library ../
+ * @library /test/lib
  * @run main MetadataStoreLoadTest
  */
 public class MetadataStoreLoadTest {
--- a/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertAPITest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertAPITest.java	Thu Sep 13 10:54:11 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
@@ -42,7 +42,8 @@
  * @summary Test imports certificate from file to PKCS12 keystore store it as
  * trusted certificate Check import errors (must be not errors) & check keystore
  * content after import
- * @library /lib/testlibrary ../
+ * @library ../
+ * @library /test/lib
  * @run main StoreTrustedCertAPITest
  */
 public class StoreTrustedCertAPITest {
--- a/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertKeytool.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertKeytool.java	Thu Sep 13 10:54:11 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;
 
 /**
@@ -38,7 +38,8 @@
  * @bug 8048830
  * @summary Tests keytool command imports certificate , list keystore, print
  * certificate and import password help.
- * @library /lib/testlibrary ../
+ * @library ../
+ * @library /test/lib
  * @run main StoreTrustedCertKeytool
  */
 public class StoreTrustedCertKeytool {
--- a/test/jdk/java/security/KeyStore/PKCS12/Utils.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/security/KeyStore/PKCS12/Utils.java	Thu Sep 13 10:54:11 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,9 +32,9 @@
 import java.security.cert.CertificateException;
 import java.util.Arrays;
 import java.util.List;
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JDKToolFinder;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.JDKToolFinder;
 import static java.lang.System.out;
 import java.util.ArrayList;
 
--- a/test/jdk/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/security/Policy/SignedJar/SignedJarTest.java	Thu Sep 13 10:54:11 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/util/Arrays/TimSortStackSize2.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/util/Arrays/TimSortStackSize2.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/util/Calendar/CalendarTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/util/ResourceBundle/modules/cache/CacheTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/util/ResourceBundle/modules/casesensitive/CaseInsensitiveNameClash.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/util/ResourceBundle/modules/security/TestPermission.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/util/logging/TestLoggerWeakRefLeak.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/util/logging/modules/GetResourceBundleTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/util/zip/EntryCount64k.java	Thu Sep 13 10:54:11 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/java/util/zip/ZipFile/DeleteTempJar.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/java/util/zip/ZipFile/DeleteTempJar.java	Thu Sep 13 10:54:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, 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
@@ -21,16 +21,6 @@
  * questions.
  */
 
-/* @test
-   @bug 4166799
-   @summary Make sure URL-downloaded jar files (jar_cache files)
-            will be deleted when VM exits.
-
-   @modules jdk.httpserver
-   @build DeleteTempJar
-   @run shell deletetempjar.sh
- */
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -106,6 +96,5 @@
         else return fail(x + " not equal to " + y);}
     public static void main(String[] args) throws Throwable {
         try {realMain(args);} catch (Throwable t) {unexpected(t);}
-        System.out.println("\nPassed = " + passed + " failed = " + failed);
         if (failed > 0) throw new AssertionError("Some tests failed");}
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/util/zip/ZipFile/DeleteTempJarTest.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,51 @@
+/*
+ * 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 4166799
+ * @summary Make sure URL-downloaded jar files (jar_cache files)
+ *          will be deleted when VM exits.
+ * @modules jdk.httpserver
+ * @library /test/lib
+ * @build jdk.test.lib.process.*
+ *        DeleteTempJar
+ * @run main DeleteTempJarTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.Asserts;
+
+public class DeleteTempJarTest {
+
+    public static void main(String[] args) throws Exception {
+        String tmpFile = ProcessTools.executeTestJvm(DeleteTempJar.class.getName())
+                                     .shouldHaveExitValue(0)
+                                     .getStdout();
+
+        Asserts.assertFalse(Files.exists(Paths.get(tmpFile.trim())));
+    }
+}
--- a/test/jdk/java/util/zip/ZipFile/deletetempjar.sh	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-#! /bin/sh
-
-#
-# Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#
-
-#
-
-if [ "x$TESTJAVA" = x ]; then
-  TESTJAVA=$1; shift
-  TESTCLASSES=.
-fi
-
-tmpfile=`$TESTJAVA/bin/java ${TESTVMOPTS} -classpath $TESTCLASSES DeleteTempJar`
-rc=$?
-if [ $rc != 0 ]; then
-    echo Unexpected failure with exit status $rc
-    exit $rc
-elif [ -f "$tmpfile" ]; then
-  echo "temp file not deleted"; exit 1
-fi
--- a/test/jdk/javax/management/mxbean/MXBeanWeirdParamTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/javax/management/mxbean/MXBeanWeirdParamTest.java	Thu Sep 13 10:54:11 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,8 +59,8 @@
 import javax.management.openmbean.TabularDataSupport;
 import javax.management.openmbean.TabularType;
 
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.JDKToolFinder;
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.process.ProcessTools;
 
 public class MXBeanWeirdParamTest {
 
--- a/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/javax/management/security/AuthorizationTest.java	Thu Sep 13 10:54:11 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,8 +65,8 @@
 import javax.management.Attribute ;
 import javax.management.ObjectName ;
 
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.JDKToolFinder;
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.process.ProcessTools;
 
 public class AuthorizationTest {
 
--- a/test/jdk/javax/management/security/SecurityTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/javax/management/security/SecurityTest.java	Thu Sep 13 10:54:11 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,8 +81,8 @@
 
 import java.security.Security;
 
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.JDKToolFinder;
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.process.ProcessTools;
 
 public class SecurityTest {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/naming/module/RunBasic.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.Utils;
+import jdk.test.lib.compiler.CompilerUtils;
+import jdk.test.lib.process.ProcessTools;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static jdk.test.lib.Utils.TEST_SRC;
+
+/*
+ * @test
+ * @summary Test of JNDI factories using classes exported by third-party modules.
+ * @library /test/lib
+ * @modules jdk.compiler
+ * @run main RunBasic
+ */
+
+/*
+ * Demonstrates Java object storage/retrieval, LDAP control and URL context
+ * usage using an LDAP directory. The objects and their associated object
+ * factories, state factories, control factories and URL context factories
+ * are exported from third-party modules.
+ *
+ * Seven types of object are used:
+ *   - an AWT object (Serializable) from the 'java.desktop' JDK module
+ *   - a Person object (DirContext) from the 'person' third-party module
+ *   - a Fruit object (Referenceable) from the 'fruit' third-party module
+ *   - an RMI object (Remote) from the 'hello' third-party module
+ *   - an LDAP request control (Control) from the 'foo' third-party module
+ *   - an LDAP response control (Control) from the 'authz' third-party module
+ *   - an ldapv4 URL (DirContext) from the 'ldapv4' third-party module
+ */
+
+public class RunBasic {
+
+    private static final List<String> JAVA_CMDS;
+
+    static {
+        String javaPath = JDKToolFinder.getJDKTool("java");
+
+        JAVA_CMDS = Stream
+                .concat(Stream.of(javaPath), Stream.of(Utils.getTestJavaOpts()))
+                .collect(Collectors.collectingAndThen(Collectors.toList(),
+                        Collections::unmodifiableList));
+    }
+
+    public static void main(String[] args) throws Throwable {
+        // prepare all test modules
+        prepareModule("person");
+        prepareModule("fruit");
+        prepareModule("hello");
+        prepareModule("foo");
+        prepareModule("authz");
+        prepareModule("ldapv4");
+        prepareModule("test", "--module-source-path",
+                Path.of(TEST_SRC, "src").toString());
+
+        // run tests
+        runTest("java.desktop", "test.StoreObject");
+        runTest("person", "test.StorePerson");
+        runTest("fruit", "test.StoreFruit");
+        runTest("hello", "test.StoreRemote");
+        runTest("foo", "test.ConnectWithFoo");
+        runTest("authz", "test.ConnectWithAuthzId");
+        runTest("ldapv4", "test.ReadByUrl");
+    }
+
+    private static void prepareModule(String mod, String... opts)
+            throws IOException {
+        System.out.println("Preparing the '" + mod + "' module...");
+        makeDir("mods", mod);
+        CompilerUtils.compile(Path.of(TEST_SRC, "src", mod),
+                Path.of("mods", (mod.equals("test") ? "" : mod)), opts);
+    }
+
+    private static void makeDir(String first, String... more)
+            throws IOException {
+        Files.createDirectories(Path.of(first, more));
+    }
+
+    private static void runTest(String desc, String clsName) throws Throwable {
+        System.out.println("Running with the '" + desc + "' module...");
+        runJava("-Dtest.src=" + TEST_SRC, "-p", "mods", "-m", "test/" + clsName,
+                "ldap://localhost/dc=ie,dc=oracle,dc=com");
+    }
+
+    private static void runJava(String... opts) throws Throwable {
+        ProcessTools.executeCommand(
+                Stream.of(JAVA_CMDS, List.of(opts)).flatMap(Collection::stream)
+                        .toArray(String[]::new)).shouldHaveExitValue(0);
+    }
+}
--- a/test/jdk/javax/naming/module/basic.sh	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-#
-# Copyright (c) 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
-# @summary Test of JNDI factories using classes exported by third-party modules.
-
-# Demonstrates Java object storage/retrieval, LDAP control and URL context
-# usage using an LDAP directory. The objects and their associated object
-# factories, state factories, control factories and URL context factories
-# are exported from third-party modules.
-#
-# Seven types of object are used:
-#   - an AWT object (Serializable) from the 'java.desktop' JDK module
-#   - a Person object (DirContext) from the 'person' third-party module
-#   - a Fruit object (Referenceable) from the 'fruit' third-party module
-#   - an RMI object (Remote) from the 'hello' third-party module
-#   - an LDAP request control (Control) from the 'foo' third-party module
-#   - an LDAP response control (Control) from the 'authz' third-party module
-#   - an ldapv4 URL (DirContext) from the 'ldapv4' third-party module
-#
-
-set -e
-
-if [ -z "$TESTJAVA" ]; then
-  if [ $# -lt 1 ]; then exit 1; fi
-  TESTJAVA="$1"; shift
-  COMPILEJAVA="${TESTJAVA}"
-  TESTSRC="`pwd`"
-  TESTCLASSES="`pwd`"
-fi
-
-JAVAC="$COMPILEJAVA/bin/javac"
-JAVA="$TESTJAVA/bin/java"
-
-echo "\nPreparing the 'person' module..."
-mkdir -p mods/person
-$JAVAC -d mods/person `find $TESTSRC/src/person -name "*.java"`
-
-echo "\nPreparing the 'fruit' module..."
-mkdir -p mods/fruit
-$JAVAC -d mods/fruit `find $TESTSRC/src/fruit -name "*.java"`
-
-echo "\nPreparing the 'hello' module..."
-mkdir -p mods/hello
-$JAVAC -d mods/hello `find $TESTSRC/src/hello -name "*.java"`
-
-echo "\nPreparing the 'foo' module..."
-mkdir -p mods/foo
-$JAVAC -d mods/foo `find $TESTSRC/src/foo -name "*.java"`
-
-echo "\nPreparing the 'authz' module..."
-mkdir -p mods/authz
-$JAVAC -d mods/authz `find $TESTSRC/src/authz -name "*.java"`
-
-echo "\nPreparing the 'ldapv4' module..."
-mkdir -p mods/ldapv4
-$JAVAC -d mods/ldapv4 `find $TESTSRC/src/ldapv4 -name "*.java"`
-
-echo "\nPreparing the 'test' module..."
-mkdir -p mods/test
-$JAVAC -d mods --module-source-path $TESTSRC/src `find $TESTSRC/src/test -name "*.java"`
-
-
-echo "\nRunning with the 'java.desktop' module..."
-$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.StoreObject ldap://localhost/dc=ie,dc=oracle,dc=com
-
-echo "\nRunning with the 'person' module..."
-$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.StorePerson ldap://localhost/dc=ie,dc=oracle,dc=com
-
-echo "\nRunning with the 'fruit' module..."
-$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.StoreFruit ldap://localhost/dc=ie,dc=oracle,dc=com
-
-echo "\nRunning with the 'hello' module..."
-$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.StoreRemote ldap://localhost/dc=ie,dc=oracle,dc=com
-
-echo "\nRunning with the 'foo' module..."
-$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.ConnectWithFoo ldap://localhost/dc=ie,dc=oracle,dc=com
-
-echo "\nRunning with the 'authz' module..."
-$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.ConnectWithAuthzId ldap://localhost/dc=ie,dc=oracle,dc=com
-
-echo "\nRunning with the 'ldapv4' module..."
-$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.ReadByUrl ldap://localhost/dc=ie,dc=oracle,dc=com
-
--- a/test/jdk/javax/security/auth/Subject/doAs/NestedActions.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/javax/security/auth/Subject/doAs/NestedActions.java	Thu Sep 13 10:54:11 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/xml/crypto/dsig/GenerationTests.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/javax/xml/crypto/dsig/GenerationTests.java	Thu Sep 13 10:54:11 2018 -0700
@@ -24,7 +24,7 @@
 /**
  * @test
  * @bug 4635230 6283345 6303830 6824440 6867348 7094155 8038184 8038349 8046949
- *      8046724 8079693 8177334
+ *      8046724 8079693 8177334 8205507
  * @summary Basic unit tests for generating XML Signatures with JSR 105
  * @modules java.base/sun.security.util
  *          java.base/sun.security.x509
@@ -258,6 +258,26 @@
         KeyValue, x509data, KeyName
     }
 
+    // cached keys (for performance) used by test_create_detached_signature().
+    private static HashMap<String,Key[]> cachedKeys = new HashMap<>();
+
+    // Load cachedKeys persisted in a file to reproduce a failure.
+    // The keys are always saved to "cached-keys" but you can rename
+    // it to a different file name and load it here. Note: The keys will
+    // always be persisted so renaming is a good idea although the
+    // content might not change.
+    static {
+        String cacheFile = System.getProperty("use.cached.keys");
+        if (cacheFile != null) {
+            try (FileInputStream fis = new FileInputStream(cacheFile);
+                 ObjectInputStream ois = new ObjectInputStream(fis)) {
+                cachedKeys = (HashMap<String,Key[]>) ois.readObject();
+            } catch (Exception e) {
+                throw new AssertionError("Cannot read " + cacheFile, e);
+            }
+        }
+    }
+
     private static boolean result = true;
 
     public static void main(String args[]) throws Exception {
@@ -422,6 +442,12 @@
                     XMLSignatureException.class);
         }
 
+        // persist cached keys to a file.
+        try (FileOutputStream fos = new FileOutputStream("cached-keys", true);
+             ObjectOutputStream oos = new ObjectOutputStream(fos)) {
+            oos.writeObject(cachedKeys);
+        }
+
         if (!result) {
             throw new RuntimeException("At least one test case failed");
         }
@@ -1650,37 +1676,9 @@
 
         SignatureMethod sm = fac.newSignatureMethod(signatureMethod, null);
 
-        Key signingKey;
-        Key validationKey;
-        if (signatureMethod.contains("#hmac-")) {
-            // http://...#hmac-sha1 -> hmac-sha1 -> hmacsha1
-            String algName = signatureMethod
-                    .substring(signatureMethod.indexOf('#') + 1)
-                    .replace("-", "");
-            KeyGenerator kg = KeyGenerator.getInstance(algName);
-            signingKey = kg.generateKey();
-            validationKey = signingKey;
-        } else {
-            KeyPairGenerator kpg;
-            SecureRandom random = new SecureRandom();
-            if (signatureMethod.contains("#rsa-")
-                    || signatureMethod.contains("-rsa-MGF1")) {
-                kpg = KeyPairGenerator.getInstance("RSA");
-                kpg.initialize(signatureMethod.contains("#sha512-rsa-MGF1")
-                        ? 2048 : 1024, random);
-            } else if (signatureMethod.contains("#dsa-")) {
-                kpg = KeyPairGenerator.getInstance("DSA");
-                kpg.initialize(1024, random);
-            } else if (signatureMethod.contains("#ecdsa-")) {
-                kpg = KeyPairGenerator.getInstance("EC");
-                kpg.initialize(256, random);
-            } else {
-                throw new RuntimeException("Unsupported signature algorithm");
-            }
-            KeyPair kp = kpg.generateKeyPair();
-            validationKey = kp.getPublic();
-            signingKey = kp.getPrivate();
-        }
+        Key[] pair = getCachedKeys(signatureMethod);
+        Key signingKey = pair[0];
+        Key validationKey = pair[1];
 
         SignedInfo si = fac.newSignedInfo(cm, sm, refs, null);
 
@@ -1759,6 +1757,44 @@
         return true;
     }
 
+    private static Key[] getCachedKeys(String signatureMethod) {
+        return cachedKeys.computeIfAbsent(signatureMethod, sm -> {
+            try {
+                System.out.print("<create keys for " + sm + ">");
+                System.out.flush();
+                if (sm.contains("#hmac-")) {
+                    // http://...#hmac-sha1 -> hmac-sha1 -> hmacsha1
+                    String algName = sm
+                            .substring(sm.indexOf('#') + 1)
+                            .replace("-", "");
+                    KeyGenerator kg = KeyGenerator.getInstance(algName);
+                    Key signingKey = kg.generateKey();
+                    return new Key[] { signingKey, signingKey};
+                } else {
+                    KeyPairGenerator kpg;
+                    if (sm.contains("#rsa-")
+                            || sm.contains("-rsa-MGF1")) {
+                        kpg = KeyPairGenerator.getInstance("RSA");
+                        kpg.initialize(
+                                sm.contains("#sha512-rsa-MGF1") ? 2048 : 1024);
+                    } else if (sm.contains("#dsa-")) {
+                        kpg = KeyPairGenerator.getInstance("DSA");
+                        kpg.initialize(1024);
+                    } else if (sm.contains("#ecdsa-")) {
+                        kpg = KeyPairGenerator.getInstance("EC");
+                        kpg.initialize(256);
+                    } else {
+                        throw new RuntimeException("Unsupported signature algorithm");
+                    }
+                    KeyPair kp = kpg.generateKeyPair();
+                    return new Key[] { kp.getPrivate(), kp.getPublic()};
+                }
+            } catch (NoSuchAlgorithmException e) {
+                throw new AssertionError("Should not happen", e);
+            }
+        });
+    }
+
     private static final String DSA_Y =
         "070662842167565771936588335128634396171789331656318483584455493822" +
         "400811200853331373030669235424928346190274044631949560438023934623" +
--- a/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java	Thu Sep 13 10:54:11 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/modules/etc/DefaultModules.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/jdk/modules/etc/DefaultModules.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/jdk/modules/incubator/DefaultImage.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/jdk/modules/incubator/ImageModules.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/jdk/modules/scenarios/container/ContainerTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java	Thu Sep 13 10:54:11 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/lib/security/cacerts/VerifyCACerts.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/lib/security/cacerts/VerifyCACerts.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/lib/testlibrary/OutputAnalyzerReportingTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/lib/testlibrary/OutputAnalyzerTest.java	Thu Sep 13 10:54:11 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/JDKToolFinder.java	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +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.FileNotFoundException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-/**
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/jdk/test/lib}
- */
-@Deprecated
-public final class JDKToolFinder {
-
-    private JDKToolFinder() {
-    }
-
-    /**
-     * Returns the full path to an executable in jdk/bin based on System
-     * property {@code test.jdk} or {@code compile.jdk} (both are set by the jtreg test suite)
-     *
-     * @return Full path to an executable in jdk/bin
-     */
-    public static String getJDKTool(String tool) {
-
-        // First try to find the executable in test.jdk
-        try {
-            return getTool(tool, "test.jdk");
-        } catch (FileNotFoundException e) {
-
-        }
-
-        // Now see if it's available in compile.jdk
-        try {
-            return getTool(tool, "compile.jdk");
-        } catch (FileNotFoundException e) {
-            throw new RuntimeException("Failed to find " + tool +
-                    ", looked in test.jdk (" + System.getProperty("test.jdk") +
-                    ") and compile.jdk (" + System.getProperty("compile.jdk") + ")");
-        }
-    }
-
-    /**
-     * Returns the full path to an executable in jdk/bin based on System
-     * property {@code compile.jdk}
-     *
-     * @return Full path to an executable in jdk/bin
-     */
-    public static String getCompileJDKTool(String tool) {
-        try {
-            return getTool(tool, "compile.jdk");
-        } catch (FileNotFoundException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Returns the full path to an executable in jdk/bin based on System
-     * property {@code test.jdk}
-     *
-     * @return Full path to an executable in jdk/bin
-     */
-    public static String getTestJDKTool(String tool) {
-        try {
-            return getTool(tool, "test.jdk");
-        } catch (FileNotFoundException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    private static String getTool(String tool, String property) throws FileNotFoundException {
-        String jdkPath = System.getProperty(property);
-
-        if (jdkPath == null) {
-            throw new RuntimeException(
-                    "System property '" + property + "' not set. This property is normally set by jtreg. "
-                    + "When running test separately, set this property using '-D" + property + "=/path/to/jdk'.");
-        }
-
-        Path toolName = Paths.get("bin", tool + (isWindows() ? ".exe" : ""));
-
-        Path jdkTool = Paths.get(jdkPath, toolName.toString());
-        if (!jdkTool.toFile().exists()) {
-            throw new FileNotFoundException("Could not find file " + jdkTool.toAbsolutePath());
-        }
-
-        return jdkTool.toAbsolutePath().toString();
-    }
-
-    private static boolean isWindows() {
-        return System.getProperty("os.name").toLowerCase().startsWith("win");
-    }
-}
--- a/test/jdk/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java	Wed Sep 12 11:51:39 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +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.util.ArrayList;
-import java.util.List;
-
-/**
- * A utility for constructing command lines for starting JDK tool processes.
- *
- * The JDKToolLauncher can in particular be combined with a
- * java.lang.ProcessBuilder to easily run a JDK tool. For example, the following
- * code run {@code jmap -heap} against a process with GC logging turned on for
- * the {@code jmap} process:
- *
- * <pre>
- * {@code
- * JDKToolLauncher jmap = JDKToolLauncher.create("jmap")
- *                                       .addVMArg("-Xlog:gc*=debug")
- *                                       .addToolArg("-heap")
- *                                       .addToolArg(pid);
- * ProcessBuilder pb = new ProcessBuilder(jmap.getCommand());
- * Process p = pb.start();
- * }
- * </pre>
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/jdk/test/lib}
- */
-@Deprecated
-public class JDKToolLauncher {
-    private final String executable;
-    private final List<String> vmArgs = new ArrayList<String>();
-    private final List<String> toolArgs = new ArrayList<String>();
-
-    private JDKToolLauncher(String tool, boolean useCompilerJDK) {
-        if (useCompilerJDK) {
-            executable = JDKToolFinder.getJDKTool(tool);
-        } else {
-            executable = JDKToolFinder.getTestJDKTool(tool);
-        }
-    }
-
-    /**
-     * Creates a new JDKToolLauncher for the specified tool. Using tools path
-     * from the compiler JDK.
-     *
-     * @param tool
-     *            The name of the tool
-     * @return A new JDKToolLauncher
-     */
-    public static JDKToolLauncher create(String tool) {
-        return new JDKToolLauncher(tool, true);
-    }
-
-    /**
-     * Creates a new JDKToolLauncher for the specified tool in the Tested JDK.
-     *
-     * @param tool
-     *            The name of the tool
-     *
-     * @return A new JDKToolLauncher
-     */
-    public static JDKToolLauncher createUsingTestJDK(String tool) {
-        return new JDKToolLauncher(tool, false);
-    }
-
-    /**
-     * Adds an argument to the JVM running the tool.
-     *
-     * The JVM arguments are passed to the underlying JVM running the tool.
-     * Arguments will automatically be prepended with "-J".
-     *
-     * Any platform specific arguments required for running the tool are
-     * automatically added.
-     *
-     *
-     * @param arg
-     *            The argument to VM running the tool
-     * @return The JDKToolLauncher instance
-     */
-    public JDKToolLauncher addVMArg(String arg) {
-        vmArgs.add(arg);
-        return this;
-    }
-
-    /**
-     * Adds an argument to the tool.
-     *
-     * @param arg
-     *            The argument to the tool
-     * @return The JDKToolLauncher instance
-     */
-    public JDKToolLauncher addToolArg(String arg) {
-        toolArgs.add(arg);
-        return this;
-    }
-
-    /**
-     * Returns the command that can be used for running the tool.
-     *
-     * @return An array whose elements are the arguments of the command.
-     */
-    public String[] getCommand() {
-        List<String> command = new ArrayList<String>();
-        command.add(executable);
-        // Add -J in front of all vmArgs
-        for (String arg : vmArgs) {
-            command.add("-J" + arg);
-        }
-        command.addAll(toolArgs);
-        return command.toArray(new String[command.size()]);
-    }
-}
--- a/test/jdk/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java	Wed Sep 12 11:51:39 2018 +0530
+++ /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 Sep 12 11:51:39 2018 +0530
+++ /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 Sep 12 11:51:39 2018 +0530
+++ /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 Sep 12 11:51:39 2018 +0530
+++ /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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/native_sanity/simplenativelauncher/ProgramTest.java	Thu Sep 13 10:54:11 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/security/infra/java/security/cert/CertPathValidator/certification/TeliaSoneraCA.java	Thu Sep 13 10:54:11 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/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/management/jdp/DynamicLauncher.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/management/jdp/JdpDefaultsTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/management/jdp/JdpJmxRemoteDynamicPortTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/management/jdp/JdpOffTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/management/jdp/JdpSpecificAddressTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/management/jdp/PortAlreadyInUseTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/management/jmxremote/bootstrap/CustomLauncherTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/management/jmxremote/startstop/JMXStartStopTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/management/jmxremote/startstop/JMXStatusPerfCountersTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/management/jmxremote/startstop/JMXStatusTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/management/jmxremote/startstop/ManagementAgentJcmd.java	Thu Sep 13 10:54:11 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
@@ -33,8 +33,8 @@
 import jdk.internal.agent.Agent;
 import jdk.internal.agent.AgentConfigurationError;
 
-import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.JDKToolLauncher;
+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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/krb5/auto/tools/KinitConfPlusProps.java	Thu Sep 13 10:54:11 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/SSLEngineImpl/SSLEngineKeyLimit.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java	Thu Sep 13 10:54:11 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/SSLSocketKeyLimit.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/tools/jarsigner/TsacertOptionTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/tools/jarsigner/Warning.java	Thu Sep 13 10:54:11 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
@@ -21,10 +21,10 @@
  * questions.
  */
 
-import jdk.testlibrary.JDKToolLauncher;
+import jdk.test.lib.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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/AliasNotInStoreTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/BadExtendedKeyUsageTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/BadNetscapeCertTypeTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/ChainNotValidatedTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/HasExpiredCertTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/HasExpiringCertTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/HasUnsignedEntryTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/MultipleWarningsTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/NoTimestampTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/NotSignedByAliasTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/NotYetValidCertTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/security/tools/jarsigner/warnings/Test.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jcmd/JcmdBase.java	Thu Sep 13 10:54:11 2018 -0700
@@ -23,9 +23,9 @@
 
 import java.util.Arrays;
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.JDKToolLauncher;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.JDKToolLauncher;
 
 /**
  * Helper class for starting jcmd process.
--- a/test/jdk/sun/tools/jcmd/TestJcmdDefaults.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jcmd/TestJcmdDefaults.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jcmd/TestJcmdSanity.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java	Thu Sep 13 10:54:11 2018 -0700
@@ -40,12 +40,12 @@
 import java.util.List;
 import java.util.Arrays;
 import java.util.Optional;
-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;
 import jdk.test.lib.apps.LingeredApp;
 import jdk.test.lib.Platform;
+import jdk.test.lib.JDKToolLauncher;
+import jdk.testlibrary.Utils;
 
 public class BasicLauncherTest {
 
--- a/test/jdk/sun/tools/jhsdb/HeapDumpTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jhsdb/HeapDumpTest.java	Thu Sep 13 10:54:11 2018 -0700
@@ -38,11 +38,12 @@
 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.Platform;
+import jdk.test.lib.JDKToolLauncher;
+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;
 
 public class HeapDumpTest {
--- a/test/jdk/sun/tools/jhsdb/heapconfig/TmtoolTestScenario.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jhsdb/heapconfig/TmtoolTestScenario.java	Thu Sep 13 10:54:11 2018 -0700
@@ -33,7 +33,7 @@
 import java.util.logging.Logger;
 
 import jdk.test.lib.apps.LingeredApp;
-import jdk.testlibrary.JDKToolLauncher;
+import jdk.test.lib.JDKToolLauncher;
 import jdk.testlibrary.Utils;
 
 public class TmtoolTestScenario {
--- a/test/jdk/sun/tools/jinfo/BasicJInfoTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jinfo/BasicJInfoTest.java	Thu Sep 13 10:54:11 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,15 +23,14 @@
 
 import java.util.Arrays;
 
-import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.JDKToolLauncher;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 /*
  * @test
  * @summary Unit test for jinfo utility
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main BasicJInfoTest
  */
 public class BasicJInfoTest {
--- a/test/jdk/sun/tools/jmap/BasicJMapTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jmap/BasicJMapTest.java	Thu Sep 13 10:54:11 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
@@ -27,10 +27,10 @@
 import java.io.File;
 import java.util.Arrays;
 
+import jdk.test.lib.JDKToolLauncher;
 import jdk.test.lib.hprof.HprofParser;
-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/sun/tools/jps/JpsHelper.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jps/JpsHelper.java	Thu Sep 13 10:54:11 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.JDKToolLauncher;
+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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jps/TestJpsSanity.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jstack/BasicJStackTest.java	Thu Sep 13 10:54:11 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,15 +23,14 @@
 
 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.JDKToolLauncher;
 
 /*
  * @test
  * @summary Unit test for jstack utility
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main BasicJStackTest
  */
 public class BasicJStackTest {
--- a/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java	Thu Sep 13 10:54:11 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;
+import jdk.test.lib.JDKToolLauncher;
 
 /**
  * @test
--- a/test/jdk/sun/tools/jstat/JStatInterval.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jstat/JStatInterval.java	Thu Sep 13 10:54:11 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,17 +24,17 @@
 /**
  * @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.
  * @modules java.management
- * @build jdk.testlibrary.* JStatInterval
+ * @build JStatInterval
  * @run main JStatInterval
  */
 
-import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.JDKToolLauncher;
+import jdk.test.lib.JDKToolLauncher;
+import jdk.test.lib.process.ProcessTools;
 
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
--- a/test/jdk/sun/tools/jstat/jstatClassloadOutput1.sh	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jstat/jstatClassloadOutput1.sh	Thu Sep 13 10:54:11 2018 -0700
@@ -22,7 +22,7 @@
 #
 
 # @test
-# @bug 6959965 
+# @bug 6959965
 # @run shell jstatClassloadOutput1.sh
 # @summary Test that output of 'jstat -classload 0' has expected line counts
 
--- a/test/jdk/sun/tools/jstatd/JstatdTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jstatd/JstatdTest.java	Thu Sep 13 10:54:11 2018 -0700
@@ -30,10 +30,10 @@
 
 import jdk.test.lib.thread.ProcessThread;
 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.JDKToolLauncher;
+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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/sun/tools/jstatd/TestJstatdUsage.java	Thu Sep 13 10:54:11 2018 -0700
@@ -21,17 +21,15 @@
  * questions.
  */
 
-import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.JDKToolLauncher;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 /*
  * @test
  * @bug 4990825
- * @library /lib/testlibrary
  * @library /test/lib
  * @modules java.management
- * @build jdk.testlibrary.*
  * @run main TestJstatdUsage
  */
 public class TestJstatdUsage {
--- a/test/jdk/tools/jar/compat/CLICompatibility.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/jar/compat/CLICompatibility.java	Thu Sep 13 10:54:11 2018 -0700
@@ -36,7 +36,7 @@
 import java.util.stream.Stream;
 
 import jdk.test.lib.util.FileUtils;
-import jdk.testlibrary.JDKToolFinder;
+import jdk.test.lib.JDKToolFinder;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
@@ -52,7 +52,7 @@
  * @library /lib/testlibrary /test/lib
  * @build jdk.test.lib.Platform
  *        jdk.test.lib.util.FileUtils
- *        jdk.testlibrary.JDKToolFinder
+ *        jdk.test.lib.JDKToolFinder
  * @run testng CLICompatibility
  * @summary Basic test for compatibility of CLI options
  */
--- a/test/jdk/tools/jar/modularJar/Basic.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/jar/modularJar/Basic.java	Thu Sep 13 10:54:11 2018 -0700
@@ -36,7 +36,7 @@
 import java.util.stream.Stream;
 
 import jdk.test.lib.util.FileUtils;
-import jdk.testlibrary.JDKToolFinder;
+import jdk.test.lib.JDKToolFinder;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
@@ -47,12 +47,12 @@
 /*
  * @test
  * @bug 8167328 8171830 8165640 8174248 8176772 8196748 8191533
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
  *          jdk.jartool
  * @build jdk.test.lib.Platform
  *        jdk.test.lib.util.FileUtils
- *        jdk.testlibrary.JDKToolFinder
+ *        jdk.test.lib.JDKToolFinder
  * @compile Basic.java
  * @run testng Basic
  * @summary Tests for plain Modular jars & Multi-Release Modular jars
--- a/test/jdk/tools/jimage/JImageToolTest.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/jimage/JImageToolTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/jlink/basic/AllModulePath.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/jlink/basic/BasicTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/jlink/bindservices/BindServices.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/InfoStreams.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/addexports/AddExportsTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/addexports/AddExportsTestWarningError.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/addexports/manifest/AddExportsAndOpensInManifest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/addmods/AddModsTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/addreads/AddReadsTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/addreads/AddReadsTestWarningError.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/basic/BasicTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/basic/InitErrors.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/classpath/JavaClassPathTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/describe/DescribeModuleTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/dryrun/DryRunTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/illegalaccess/IllegalAccessTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/limitmods/LimitModsTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/listmods/ListModsTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/patch/basic/PatchTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/patch/basic/PatchTestWarningError.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java	Thu Sep 13 10:54:11 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 8157068 8177844
  * @summary Patch java.base and user module with ModuleHashes attribute
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
  * @build jdk.test.lib.compiler.CompilerUtils
  *        jdk.test.lib.util.FileUtils
@@ -43,11 +43,11 @@
 
 import jdk.test.lib.compiler.CompilerUtils;
 import jdk.test.lib.util.FileUtils;
-import jdk.testlibrary.JDKToolFinder;
+import jdk.test.lib.JDKToolFinder;
 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/jdk/tools/launcher/modules/validate/ValidateModulesTest.java	Thu Sep 13 10:54:11 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/AvoidNPEAtClassReader/AvoidNPEAtClassReaderTest.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,42 @@
+/*
+ * 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 8207160
+ * @summary ClassReader::adjustMethodParams can potentially return null if the args list is empty
+ * @compile pkg/Outer.jasm pkg/Outer$Inner.jasm AvoidNPEAtClassReaderTest.java
+ */
+
+import pkg.*;
+
+/** this test is checking that javac doesn't fail with NPE when reading inner classes with constructors
+ *  that doesn't have as a parameter a reference to the outer class. Such constructors were generated by
+ *  versions of javac previous to JDK7.
+ */
+
+public class AvoidNPEAtClassReaderTest {
+    public void bar(Outer outer) {
+        Object stuff = outer.foo();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/AvoidNPEAtClassReader/pkg/Outer$Inner.jasm	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,42 @@
+/*
+ * 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  pkg;
+
+super public final class Outer$Inner
+	version 56:0
+{
+
+final synthetic Field this$0:"Lpkg/Outer;";
+
+public Method "<init>":"()V"
+	stack 1 locals 1
+{
+		aload_0;
+		invokespecial	Method java/lang/Object."<init>":"()V";
+		return;
+}
+
+public final InnerClass Inner=class Outer$Inner of class Outer;
+
+} // end Class Outer$Inner
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/AvoidNPEAtClassReader/pkg/Outer.jasm	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * 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  pkg;
+
+super public class Outer
+	version 56:0
+{
+
+
+public Method "<init>":"()V"
+	stack 1 locals 1
+{
+		aload_0;
+		invokespecial	Method java/lang/Object."<init>":"()V";
+		return;
+}
+
+public Method foo:"()Lpkg/Outer$Inner;"
+	stack 1 locals 1
+{
+		aconst_null;
+		areturn;
+}
+
+public final InnerClass Inner=class Outer$Inner of class Outer;
+
+} // end Class Outer
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/RawStringLiteralLang.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,101 @@
+/*
+ * 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 Unit tests for Raw String Literal language changes
+ * @compile --enable-preview -source 12 -encoding utf8 RawStringLiteralLang.java
+ * @run main/othervm --enable-preview RawStringLiteralLang
+ */
+
+public class RawStringLiteralLang {
+    public static void main(String... args) {
+        test1();
+        test2();
+    }
+
+    /*
+     * Test raw string functionality.
+     */
+    static void test1() {
+        EQ(`abc`, "abc");
+        EQ(`can't`, "can\'t");
+        EQ(``can`t``, "can`t");
+        EQ(`can\\'t`, "can\\\\'t");
+        EQ(``can\\`t``, "can\\\\`t");
+        EQ(`\t`, "\\t");
+        EQ(`•`, "\u2022");
+
+        LENGTH("abc``def", 8);
+        EQ("abc`\u0020`def", "abc` `def");
+    }
+
+    /*
+     * Test multi-line string functionality.
+     */
+    static void test2() {
+        EQ(`abc
+def
+ghi`, "abc\ndef\nghi");
+        EQ(`abc
+def
+ghi
+`, "abc\ndef\nghi\n");
+        EQ(`
+abc
+def
+ghi`, "\nabc\ndef\nghi");
+        EQ(`
+abc
+def
+ghi
+`, "\nabc\ndef\nghi\n");
+    }
+
+    /*
+     * Raise an exception if the string is not the expected length.
+     */
+    static void LENGTH(String rawString, int length) {
+        if (rawString == null || rawString.length() != length) {
+            System.err.println("Failed LENGTH");
+            System.err.println(rawString + " " + length);
+            throw new RuntimeException("Failed LENGTH");
+        }
+    }
+
+    /*
+     * Raise an exception if the two input strings are not equal.
+     */
+    static void EQ(String input, String expected) {
+        if (input == null || expected == null || !expected.equals(input)) {
+            System.err.println("Failed EQ");
+            System.err.println();
+            System.err.println("Input:");
+            System.err.println(input.replaceAll(" ", "."));
+            System.err.println();
+            System.err.println("Expected:");
+            System.err.println(expected.replaceAll(" ", "."));
+            throw new RuntimeException();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/RawStringLiteralLangAPI.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,169 @@
+/*
+ * 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 Unit tests for Raw String Literal language changes
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.JavacTask
+ * @run main RawStringLiteralLangAPI
+ */
+
+import toolbox.JavacTask;
+import toolbox.JavaTask;
+import toolbox.Task;
+import toolbox.ToolBox;
+
+public class RawStringLiteralLangAPI {
+    private static ToolBox TOOLBOX = new ToolBox();
+
+    public static void main(String... args) {
+        test1();
+        test2();
+        test3();
+        test4();
+    }
+
+    /*
+     * Check that correct/incorrect syntax is properly detected
+     */
+    static void test1() {
+        int[] n = new int[] { 1, 2, 3, 4, 5, 10, 16, 32, 1000, 10000 };
+        String[] s = new String[] { "a", "ab", "abc", "\u2022", "*".repeat(1000), "*".repeat(10000) };
+        for (int i : n) {
+        for (int j : n) {
+        for (int k : n) {
+        for (String a : s)  {
+        for (String b : s) {
+            String code =
+                    "public class RawStringLiteralTest {\n" +
+                            "    public static void main(String... args) {\n" +
+                            "        String xxx = " +
+                            "`".repeat(i) + a + "`".repeat(j) + b + "`".repeat(k) + ";\n" +
+                            "    }\n" +
+                            "}\n";
+            if (i == k && j != i) {
+                compPass(code);
+            } else {
+                compFail(code);
+            }
+        }}}}}
+    }
+
+    /*
+     * Check that misuse of \u0060 is properly detected
+     */
+    static void test2() {
+        compFail("public class BadDelimiter {\n" +
+                "    public static void main(String... args) {\n" +
+                "        String xxx = \\u0060`abc`;\n" +
+                "    }\n" +
+                "}\n");
+    }
+
+    /*
+     * Check edge cases of raw string literal as last token
+     */
+    static void test3() {
+        compFail("public class RawStringLiteralTest {\n" +
+                "    public static void main(String... args) {\n" +
+                "        String xxx = `abc`");
+        compFail("public class RawStringLiteralTest {\n" +
+                "    public static void main(String... args) {\n" +
+                "        String xxx = `abc");
+        compFail("public class RawStringLiteralTest {\n" +
+                "    public static void main(String... args) {\n" +
+                "        String xxx = `abc\u0000");
+    }
+
+
+    /*
+     * Check line terminator translation
+     */
+    static void test4() {
+        String[] terminators = new String[] { "\n", "\r\n", "\r" };
+        for (String terminator : terminators) {
+            String code = "public class LineTerminatorTest {" + terminator +
+                          "    public static void main(String... args) {" + terminator +
+                          "        String s =" + terminator +
+                          "`" + terminator +
+                          "abc" + terminator +
+                          "`;" + terminator +
+                          "        System.out.println(s.equals(\"\\nabc\\n\"));" + terminator +
+                          "    }" + terminator +
+                          "}" + terminator;
+            new JavacTask(TOOLBOX)
+                    .sources(code)
+                    .classpath(".")
+                    .options("--enable-preview", "-source", "12")
+                    .run();
+            String output = new JavaTask(TOOLBOX)
+                    .vmOptions("--enable-preview")
+                    .classpath(".")
+                    .classArgs("LineTerminatorTest")
+                    .run()
+                    .writeAll()
+                    .getOutput(Task.OutputKind.STDOUT);
+
+            if (!output.contains("true")) {
+                throw new RuntimeException("Error detected");
+            }
+        }
+    }
+
+    /*
+     * Test source for successful compile.
+     */
+    static void compPass(String source) {
+        String output = new JavacTask(TOOLBOX)
+                .sources(source)
+                .classpath(".")
+                .options("--enable-preview", "-source", "12", "-encoding", "utf8")
+                .run()
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (output.contains("compiler.err")) {
+            throw new RuntimeException("Error detected");
+        }
+    }
+
+    /*
+     * Test source for unsuccessful compile and specific error.
+     */
+    static void compFail(String source)  {
+        String errors = new JavacTask(TOOLBOX)
+                .sources(source)
+                .classpath(".")
+                .options("-XDrawDiagnostics", "--enable-preview", "-source", "12", "-encoding", "utf8")
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        if (!errors.contains("compiler.err")) {
+            throw new RuntimeException("No error detected");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/T8210435/NoLocalsMustBeReservedForDCEedVarsTest.java	Thu Sep 13 10:54:11 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/IllegalChar.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/langtools/tools/javac/diags/examples/IllegalChar.java	Thu Sep 13 10:54:11 2018 -0700
@@ -24,5 +24,5 @@
 // key: compiler.err.illegal.char
 
 class IllegalChar {
-    int i = `;
+    int i = #;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/RawStringLiteral.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.unicode.backtick
+// key: compiler.misc.feature.raw.string.literals
+// key: compiler.warn.preview.feature.use.plural
+// options: --enable-preview -source 12 -Xlint:preview
+
+class RawStringLiteral {
+    String m() {
+        return `abc` + \u0060`def`;
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/lambda/8210495/T8210495.java	Thu Sep 13 10:54:11 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/lambda/methodReference/MethodRefStuck.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2018, Google LLC. All rights reserved.
+ * 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 8210483
+ * @summary AssertionError in DeferredAttr at setOverloadKind caused by JDK-8203679
+ * @compile/fail/ref=MethodRefStuck.out -XDrawDiagnostics MethodRefStuck.java
+ */
+
+import java.util.Optional;
+import java.util.stream.Stream;
+
+public abstract class MethodRefStuck {
+  public static void main(Stream<String> xs, Optional<String> x) {
+    xs.map(
+        c -> {
+          return new I(x.map(c::equals));
+        });
+  }
+
+  static class I {
+    I(boolean i) {}
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/lambda/methodReference/MethodRefStuck.out	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,2 @@
+MethodRefStuck.java:38:18: compiler.err.cant.apply.symbol: kindname.constructor, I, boolean, java.util.Optional<java.lang.Boolean>, kindname.class, MethodRefStuck.I, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.instance.exists: U, java.util.Optional<U>, boolean))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/launcher/GetResourceTest.java	Thu Sep 13 10:54:11 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	Thu Sep 13 10:54:11 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/jdeps/MultiReleaseJar.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/langtools/tools/jdeps/MultiReleaseJar.java	Thu Sep 13 10:54:11 2018 -0700
@@ -27,7 +27,7 @@
  * @summary Tests for jdeps tool with multi-release jar files
  * @modules jdk.jdeps/com.sun.tools.jdeps
  * @library mrjar mrjar/base mrjar/9 mrjar/10 mrjar/v9 mrjar/v10
- * @build test.* p.* q.*
+ * @build test.* p.* q.* foo/*
  * @run testng MultiReleaseJar
  */
 
@@ -37,11 +37,9 @@
 import org.testng.annotations.Test;
 
 import java.io.File;
-import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.concurrent.TimeUnit;
 import java.util.stream.Stream;
 
 public class MultiReleaseJar {
@@ -54,10 +52,10 @@
     public void initialize() throws Exception {
         String testClassPath = System.getProperty("test.class.path", "");
         mrjar = Stream.of(testClassPath.split(File.pathSeparator))
-                .map(Paths::get)
-                .filter(e -> e.endsWith("mrjar"))
-                .findAny()
-                .orElseThrow(() -> new InternalError("mrjar not found"));
+                      .map(Paths::get)
+                      .filter(e -> e.endsWith("mrjar"))
+                      .findAny()
+                      .orElseThrow(() -> new InternalError("mrjar not found"));
         testJdk = System.getProperty("test.jdk");
         fileSep = System.getProperty("file.separator");
         cmdPath = Paths.get(testJdk, "bin");
@@ -65,10 +63,16 @@
 
     @Test
     public void basic() throws Exception {
-        // build the jar file
+        // build Version.jar, Version_9.jar and main.jar
         Result r = run("jar -cf Version.jar -C base test --release 9 -C 9 test --release 10 -C 10 test");
         checkResult(r);
 
+        r = run("jar -cf Version_9.jar -C base test --release 9 -C 9 test");
+        checkResult(r);
+
+        r = run("jar -cf Main.jar test/Main.class");
+        checkResult(r);
+
         // try out a bunch of things
         r = run("jdeps --multi-release 9  -v missing.jar");
         checkResult(r, false, "Warning: Path does not exist: missing.jar");
@@ -78,31 +82,31 @@
 
         r = run("jdeps --multi-release base  -v Version.jar");
         checkResult(r, true,
-                "Version.jar ->",
-                "test.Version",
-                "test.Version"
+            "Version.jar ->",
+            "test.Version",
+            "test.Version"
         );
 
         r = run("jdeps --multi-release 9  -v Version.jar");
         checkResult(r, true,
-                "Version.jar ->",
-                "9/test.NonPublic",
-                "9/test.NonPublic",
-                "9/test.Version",
-                "9/test.Version",
-                "9/test.Version",
-                "9/test.Version"
+            "Version.jar ->",
+            "9/test.NonPublic",
+            "9/test.NonPublic",
+            "9/test.Version",
+            "9/test.Version",
+            "9/test.Version",
+            "9/test.Version"
         );
 
         r = run("jdeps --multi-release 10  -v Version.jar");
         checkResult(r, true,
-                "Version.jar ->",
-                "10/test.Version",
-                "10/test.Version",
-                "10/test.Version",
-                "10/test.Version",
-                "9/test.NonPublic",
-                "9/test.NonPublic"
+            "Version.jar ->",
+            "10/test.Version",
+            "10/test.Version",
+            "10/test.Version",
+            "10/test.Version",
+            "9/test.NonPublic",
+            "9/test.NonPublic"
         );
 
         r = run("jdeps --multi-release 8  -v Version.jar");
@@ -111,82 +115,90 @@
         r = run("jdeps --multi-release 9.1  -v Version.jar");
         checkResult(r, false, "Error: invalid argument for option: 9.1");
 
-        r = run("jdeps -v -R -cp Version.jar test/Main.class");
+        runJdeps("test/Main.class");
+        runJdeps("Main.jar");
+    }
+
+
+    private void runJdeps(String path) throws Exception {
+        Result r = run("jdeps -v -R -cp Version.jar " + path);
         checkResult(r, false, "--multi-release option is not set");
 
-        r = run("jdeps -v -R -cp Version.jar -multi-release 9 test/Main.class");
+        r = run("jdeps -v -R -cp Version.jar -multi-release 9 " + path);
         checkResult(r, false,
-                "Error: unknown option: -multi-release",
-                "Usage: jdeps <options> <path",
-                "use --help"
+            "Error: unknown option: -multi-release",
+            "Usage: jdeps <options> <path",
+            "use --help"
         );
 
-        r = run("jdeps -v -R -cp Version.jar --multi-release 9 test/Main.class");
+        r = run("jdeps -v -R -cp Version.jar --multi-release 9 " + path);
+
+        String name = path;
+        int index = path.lastIndexOf('/');
+        if (index >= 0) {
+            name = path.substring(index + 1, path.length());
+        }
         checkResult(r, true,
-                "Main.class ->",
-                "Main.class ->",
-                "test.Main",
-                "test.Main",
-                "test.Main",
-                "Version.jar ->",
-                "9/test.NonPublic",
-                "9/test.NonPublic",
-                "9/test.Version",
-                "9/test.Version",
-                "9/test.Version",
-                "9/test.Version"
+            name + " ->",
+            name + " ->",
+            "test.Main",
+            "test.Main",
+            "test.Main",
+            "Version.jar ->",
+            "9/test.NonPublic",
+            "9/test.NonPublic",
+            "9/test.Version",
+            "9/test.Version",
+            "9/test.Version",
+            "9/test.Version"
         );
 
-        r = run("jdeps -v -R -cp Version.jar --multi-release 10 test/Main.class");
+        r = run("jdeps -v -R -cp Version.jar --multi-release 10 " + path);
         checkResult(r, true,
-                "Main.class ->",
-                "Main.class ->",
-                "test.Main",
-                "test.Main",
-                "test.Main",
-                "Version.jar ->",
-                "10/test.Version",
-                "10/test.Version",
-                "10/test.Version",
-                "10/test.Version",
-                "9/test.NonPublic",
-                "9/test.NonPublic"
+            name + " ->",
+            name + " ->",
+            "test.Main",
+            "test.Main",
+            "test.Main",
+            "Version.jar ->",
+            "10/test.Version",
+            "10/test.Version",
+            "10/test.Version",
+            "10/test.Version",
+            "9/test.NonPublic",
+            "9/test.NonPublic"
         );
 
-        r = run("jdeps -v -R -cp Version.jar --multi-release base test/Main.class");
+        r = run("jdeps -v -R -cp Version.jar --multi-release base " + path);
         checkResult(r, true,
-                "Main.class ->",
-                "Main.class ->",
-                "test.Main",
-                "test.Main",
-                "test.Main",
-                "Version.jar ->",
-                "test.Version",
-                "test.Version"
+            name + " ->",
+            name + " ->",
+            "test.Main",
+            "test.Main",
+            "test.Main",
+            "Version.jar ->",
+            "test.Version",
+            "test.Version"
         );
 
-        r = run("jdeps -v -R -cp Version.jar --multi-release 9.1 test/Main.class");
+        r = run("jdeps -v -R -cp Version.jar --multi-release 9.1 " + path);
         checkResult(r, false, "Error: invalid argument for option: 9.1");
 
-        // Rebuild jar without version 10
-        r = run("jar -cf Version.jar -C base test --release 9 -C 9 test");
-        checkResult(r);
-
-        // but ask for version 10
-        r = run("jdeps -v -R -cp Version.jar --multi-release 10 test/Main.class");
+        // Version_9.jar does not have any version 10 entry
+        r = run("jdeps -v -R -cp Version_9.jar --multi-release 10 " + path);
         checkResult(r, true,
-                "Main.class ->",
-                "Main.class ->",
-                "test.Main",
-                "test.Main",
-                "test.Main",
-                "Version.jar ->",
-                "9/test.NonPublic",
-                "9/test.NonPublic",
-                "9/test.Version",
-                "9/test.Version",
-                "9/test.Version",
-                "9/test.Version"
+            name + " ->",
+            name + " ->",
+            "test.Main",
+            "test.Main",
+            "test.Main",
+            "Version_9.jar ->",
+            "9/test.NonPublic",
+            "9/test.NonPublic",
+            "9/test.Version",
+            "9/test.Version",
+            "9/test.Version",
+            "9/test.Version"
         );
     }
 
@@ -198,27 +210,72 @@
 
         r = run("jdeps -v -R -cp PQ.jar --multi-release base PQ.jar");
         checkResult(r, true,
-                "PQ.jar -> java.base",
-                "p.Foo"
+            "PQ.jar -> java.base",
+            "p.Foo"
         );
 
         r = run("jdeps -v -R -cp PQ.jar --multi-release 9 PQ.jar");
         checkResult(r, true,
-                "PQ.jar -> java.base",
-                "9/p.Foo",
-                "9/p.Foo",
-                "9/q.Bar"
+            "PQ.jar -> java.base",
+            "9/p.Foo",
+            "9/p.Foo",
+            "9/q.Bar"
         );
 
 
         r = run("jdeps -v -R -cp PQ.jar --multi-release 10 PQ.jar");
         checkResult(r, true,
-                "PQ.jar -> java.base",
-                "10/q.Bar",
-                "10/q.Bar",
-                "10/q.Gee",
-                "9/p.Foo",
-                "9/p.Foo"
+            "PQ.jar -> java.base",
+            "10/q.Bar",
+            "10/q.Bar",
+            "10/q.Gee",
+            "9/p.Foo",
+            "9/p.Foo"
+        );
+    }
+
+    @Test
+    public void modularJar() throws Exception {
+        Result r = run("jar -cf foo.jar -C base p");
+        checkResult(r);
+
+        Path foo = Paths.get(System.getProperty("test.classes")).resolve("modules").resolve("foo");
+        r = run("jar -uf foo.jar --release 9 -C " + foo.toString() + " module-info.class --release 10 -C v10 q");
+        checkResult(r);
+
+        r = run("jdeps -v --multi-release 10 --module-path foo.jar -m foo");
+        checkResult(r, true,
+            "foo",                   // module name
+            "foo.jar",                      // the path to foo.jar
+            "requires mandated java.base",  // module dependences
+            "foo -> java.base",
+            "10/q.Bar",
+            "10/q.Bar",
+            "10/q.Gee",
+            "p.Foo"
+        );
+
+        r = run("jdeps --multi-release 9 --module-path foo.jar Main.jar");
+        checkResult(r, true,
+            "Main.jar ->",
+            "test",
+            "foo",                          // module name
+            "foo.jar",                      // the path to foo.jar
+            "requires mandated java.base",  // module dependences
+            "foo -> java.base",
+            "p"
+        );
+
+        r = run("jdeps --multi-release 10 --module-path foo.jar Main.jar");
+        checkResult(r, true,
+            "Main.jar ->",
+            "test",
+            "foo",                          // module name
+            "foo.jar",                      // the path to foo.jar
+            "requires mandated java.base",  // module dependences
+            "foo -> java.base",
+            "p",
+            "q"
         );
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/jdeps/foo/module-info.java	Thu Sep 13 10:54:11 2018 -0700
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+module foo {
+}
--- a/test/lib/jdk/test/lib/Platform.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/lib/jdk/test/lib/Platform.java	Thu Sep 13 10:54:11 2018 -0700
@@ -329,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 Sep 12 11:51:39 2018 +0530
+++ b/test/lib/jdk/test/lib/apps/LingeredApp.java	Thu Sep 13 10:54:11 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/cds/CDSTestUtils.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/lib/jdk/test/lib/cds/CDSTestUtils.java	Thu Sep 13 10:54:11 2018 -0700
@@ -40,6 +40,8 @@
         "UseSharedSpaces: Unable to allocate region, range is not within java heap.";
     public static final String MSG_RANGE_ALREADT_IN_USE =
         "Unable to allocate region, java heap range is already in use.";
+    public static final String MSG_COMPRESSION_MUST_BE_USED =
+        "Unable to use shared archive: UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.";
 
     public interface Checker {
         public void check(OutputAnalyzer output) throws Exception;
--- a/test/lib/jdk/test/lib/dcmd/CommandExecutor.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/lib/jdk/test/lib/dcmd/CommandExecutor.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/lib/jdk/test/lib/process/OutputAnalyzer.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/lib/jdk/test/lib/process/OutputBuffer.java	Thu Sep 13 10:54:11 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 Sep 12 11:51:39 2018 +0530
+++ b/test/lib/jdk/test/lib/process/ProcessTools.java	Thu Sep 13 10:54:11 2018 -0700
@@ -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;
@@ -65,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(privilegedStart(processBuilder));
-    }
-
-    /**
-     * 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
@@ -392,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 = privilegedStart(pb);
+            if (input != null) {
+               try (PrintStream ps = new PrintStream(p.getOutputStream())) {
+                   ps.print(input);
+               }
+            }
+
             output = new OutputAnalyzer(p);
             p.waitFor();
 
--- a/test/lib/jdk/test/lib/process/StreamPumper.java	Wed Sep 12 11:51:39 2018 +0530
+++ b/test/lib/jdk/test/lib/process/StreamPumper.java	Thu Sep 13 10:54:11 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;
     }
 }