Merge with ihse-runtestprebuilt-branch JDK-8152988-branch
authorerikj
Mon, 15 Oct 2018 11:39:10 -0700
branchJDK-8152988-branch
changeset 56969 25f960592a92
parent 56967 23adfcd11311 (current diff)
parent 56968 de6373676c08 (diff)
child 56970 f6dc7d933bab
Merge with ihse-runtestprebuilt-branch
make/RunTestsPrebuiltSpec.gmk
make/conf/jib-profiles.js
test/jdk/lib/testlibrary/ModuleTargetHelper.java
test/jdk/lib/testlibrary/ModuleUtils.java
test/jdk/lib/testlibrary/jdk/testlibrary/SimpleSSLContext.java
test/jdk/lib/testlibrary/jdk/testlibrary/testkeys
--- a/make/RunTestsPrebuiltSpec.gmk	Sat Oct 13 19:28:10 2018 +0200
+++ b/make/RunTestsPrebuiltSpec.gmk	Mon Oct 15 11:39:10 2018 -0700
@@ -124,7 +124,7 @@
 JMOD := $(FIXPATH) $(JMOD_CMD)
 JARSIGNER := $(FIXPATH) $(JARSIGNER_CMD)
 
-BUILD_JAVA := $(JAVA)
+BUILD_JAVA := $(JDK_IMAGE_DIR)/bin/JAVA
 ################################################################################
 # Some common tools. Assume most common name and no path.
 AWK := awk
--- a/make/conf/jib-profiles.js	Sat Oct 13 19:28:10 2018 +0200
+++ b/make/conf/jib-profiles.js	Mon Oct 15 11:39:10 2018 -0700
@@ -801,7 +801,7 @@
         windowsRunTestPrebuiltExtra = {
             dependencies: [ testedProfile + ".jdk_symbols" ],
             environment: {
-                "PRODUCT_SYMBOLS_HOME": input.get(testedProfile + ".jdk_symbols", "home_path"),
+                "SYMBOLS_IMAGE_DIR": input.get(testedProfile + ".jdk_symbols", "home_path"),
             }
         };
         profiles["run-test-prebuilt"] = concatObjects(profiles["run-test-prebuilt"],
--- a/make/lib/Lib-jdk.hotspot.agent.gmk	Sat Oct 13 19:28:10 2018 +0200
+++ b/make/lib/Lib-jdk.hotspot.agent.gmk	Mon Oct 15 11:39:10 2018 -0700
@@ -44,7 +44,12 @@
   ifeq ($(OPENJDK_TARGET_CPU), x86_64)
     SA_CXXFLAGS := -DWIN64
   else
-    SA_CXXFLAGS := -RTC1
+    # Only add /RTC1 flag for debug builds as it's
+    # incompatible with release type builds. See
+    # https://msdn.microsoft.com/en-us/library/8wtf2dfz.aspx
+    ifeq ($(DEBUG_LEVEL),slowdebug)
+      SA_CXXFLAGS := -RTC1
+    endif
   endif
 endif
 
--- a/src/hotspot/cpu/sparc/nativeInst_sparc.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/cpu/sparc/nativeInst_sparc.cpp	Mon Oct 15 11:39:10 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
@@ -205,9 +205,9 @@
   uint idx;
   int offsets[] = {
     0x0,
-    0xfffffff0,
-    0x7ffffff0,
-    0x80000000,
+    (int)0xfffffff0,
+    (int)0x7ffffff0,
+    (int)0x80000000,
     0x20,
     0x4000,
   };
@@ -361,9 +361,9 @@
   uint idx;
   int offsets[] = {
     0x0,
-    0x7fffffff,
-    0x80000000,
-    0xffffffff,
+    (int)0x7fffffff,
+    (int)0x80000000,
+    (int)0xffffffff,
     0x20,
     4096,
     4097,
@@ -534,9 +534,9 @@
   uint idx;
   int offsets[] = {
     0x0,
-    0x7fffffff,
-    0x80000000,
-    0xffffffff,
+    (int)0x7fffffff,
+    (int)0x80000000,
+    (int)0xffffffff,
     0x20,
     4096,
     4097,
@@ -630,9 +630,9 @@
   uint idx1;
   int offsets[] = {
     0x0,
-    0xffffffff,
-    0x7fffffff,
-    0x80000000,
+    (int)0xffffffff,
+    (int)0x7fffffff,
+    (int)0x80000000,
     4096,
     4097,
     0x20,
@@ -751,9 +751,9 @@
   uint idx;
   int offsets[] = {
     0x0,
-    0xffffffff,
-    0x7fffffff,
-    0x80000000,
+    (int)0xffffffff,
+    (int)0x7fffffff,
+    (int)0x80000000,
     4096,
     4097,
     0x20,
--- a/src/hotspot/cpu/x86/jniFastGetField_x86_64.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/cpu/x86/jniFastGetField_x86_64.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -35,9 +35,6 @@
 
 #define BUFFER_SIZE 30*wordSize
 
-// Instead of issuing lfence for LoadLoad barrier, we create data dependency
-// between loads, which is more efficient than lfence.
-
 // Common register usage:
 // rax/xmm0: result
 // c_rarg0:    jni env
@@ -77,12 +74,6 @@
   __ mov   (robj, c_rarg1);
   __ testb (rcounter, 1);
   __ jcc (Assembler::notZero, slow);
-
-  __ xorptr(robj, rcounter);
-  __ xorptr(robj, rcounter);  // obj, since
-                              // robj ^ rcounter ^ rcounter == robj
-                              // robj is data dependent on rcounter.
-
   __ mov   (roffset, c_rarg2);
   __ shrptr(roffset, 2);                         // offset
 
@@ -103,12 +94,7 @@
     default:        ShouldNotReachHere();
   }
 
-  // create data dependency on rax
-  __ lea(rcounter_addr, counter);
-  __ xorptr(rcounter_addr, rax);
-  __ xorptr(rcounter_addr, rax);
-  __ cmpl (rcounter, Address(rcounter_addr, 0));
-
+  __ cmp32 (rcounter, counter);
   __ jcc (Assembler::notEqual, slow);
 
   __ ret (0);
@@ -178,11 +164,6 @@
   __ testb (rcounter, 1);
   __ jcc (Assembler::notZero, slow);
 
-  __ xorptr(robj, rcounter);
-  __ xorptr(robj, rcounter);  // obj, since
-                              // robj ^ rcounter ^ rcounter == robj
-                              // robj is data dependent on rcounter.
-
   // Both robj and rtmp are clobbered by try_resolve_jobject_in_native.
   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
   bs->try_resolve_jobject_in_native(masm, /* jni_env */ c_rarg0, robj, rtmp, slow);
@@ -198,13 +179,7 @@
     case T_DOUBLE: __ movdbl (xmm0, Address(robj, roffset, Address::times_1)); break;
     default:        ShouldNotReachHere();
   }
-
-  __ lea(rcounter_addr, counter);
-  __ movdq (rax, xmm0);
-  // counter address is data dependent on xmm0.
-  __ xorptr(rcounter_addr, rax);
-  __ xorptr(rcounter_addr, rax);
-  __ cmpl (rcounter, Address(rcounter_addr, 0));
+  __ cmp32 (rcounter, counter);
   __ jcc (Assembler::notEqual, slow);
 
   __ ret (0);
--- a/src/hotspot/os/aix/os_aix.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/os/aix/os_aix.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -4259,7 +4259,7 @@
 // or -1 on failure (e.g. can't fork a new process).
 // Unlike system(), this function can be called from signal handler. It
 // doesn't block SIGINT et al.
-int os::fork_and_exec(char* cmd) {
+int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
   char * argv[4] = {"sh", "-c", cmd, NULL};
 
   pid_t pid = fork();
--- a/src/hotspot/os/bsd/os_bsd.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/os/bsd/os_bsd.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -3785,7 +3785,7 @@
 // or -1 on failure (e.g. can't fork a new process).
 // Unlike system(), this function can be called from signal handler. It
 // doesn't block SIGINT et al.
-int os::fork_and_exec(char* cmd) {
+int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
   const char * argv[4] = {"sh", "-c", cmd, NULL};
 
   // fork() in BsdThreads/NPTL is not async-safe. It needs to run
--- a/src/hotspot/os/linux/os_linux.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/os/linux/os_linux.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -5676,10 +5676,16 @@
 // or -1 on failure (e.g. can't fork a new process).
 // Unlike system(), this function can be called from signal handler. It
 // doesn't block SIGINT et al.
-int os::fork_and_exec(char* cmd) {
+int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
   const char * argv[4] = {"sh", "-c", cmd, NULL};
 
-  pid_t pid = fork();
+  pid_t pid ;
+
+  if (use_vfork_if_available) {
+    pid = vfork();
+  } else {
+    pid = fork();
+  }
 
   if (pid < 0) {
     // fork failed
--- a/src/hotspot/os/solaris/os_solaris.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/os/solaris/os_solaris.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -1567,11 +1567,11 @@
   }
 
   typedef struct {
-    Elf32_Half  code;         // Actual value as defined in elf.h
-    Elf32_Half  compat_class; // Compatibility of archs at VM's sense
-    char        elf_class;    // 32 or 64 bit
-    char        endianess;    // MSB or LSB
-    char*       name;         // String representation
+    Elf32_Half    code;         // Actual value as defined in elf.h
+    Elf32_Half    compat_class; // Compatibility of archs at VM's sense
+    unsigned char elf_class;    // 32 or 64 bit
+    unsigned char endianess;    // MSB or LSB
+    char*         name;         // String representation
   } arch_t;
 
   static const arch_t arch_array[]={
@@ -5252,7 +5252,7 @@
 // or -1 on failure (e.g. can't fork a new process).
 // Unlike system(), this function can be called from signal handler. It
 // doesn't block SIGINT et al.
-int os::fork_and_exec(char* cmd) {
+int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
   char * argv[4];
   argv[0] = (char *)"sh";
   argv[1] = (char *)"-c";
--- a/src/hotspot/os/windows/os_windows.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/os/windows/os_windows.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -5254,7 +5254,7 @@
 
 // Run the specified command in a separate process. Return its exit value,
 // or -1 on failure (e.g. can't create a new process).
-int os::fork_and_exec(char* cmd) {
+int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
   STARTUPINFO si;
   PROCESS_INFORMATION pi;
   DWORD exit_code;
--- a/src/hotspot/share/gc/parallel/pcTasks.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/gc/parallel/pcTasks.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -35,6 +35,7 @@
 #include "gc/shared/gcTimer.hpp"
 #include "gc/shared/gcTraceTime.inline.hpp"
 #include "logging/log.hpp"
+#include "memory/iterator.inline.hpp"
 #include "memory/resourceArea.hpp"
 #include "memory/universe.hpp"
 #include "oops/objArrayKlass.inline.hpp"
@@ -58,7 +59,7 @@
   ParCompactionManager* cm =
     ParCompactionManager::gc_thread_compaction_manager(which);
 
-  ParCompactionManager::MarkAndPushClosure mark_and_push_closure(cm);
+  PCMarkAndPushClosure mark_and_push_closure(cm);
   MarkingCodeBlobClosure mark_and_push_in_blobs(&mark_and_push_closure, !CodeBlobToOopClosure::FixRelocations);
 
   _thread->oops_do(&mark_and_push_closure, &mark_and_push_in_blobs);
@@ -73,7 +74,7 @@
 
   ParCompactionManager* cm =
     ParCompactionManager::gc_thread_compaction_manager(which);
-  ParCompactionManager::MarkAndPushClosure mark_and_push_closure(cm);
+  PCMarkAndPushClosure mark_and_push_closure(cm);
 
   switch (_root_type) {
     case universe:
@@ -139,7 +140,7 @@
 
   ParCompactionManager* cm =
     ParCompactionManager::gc_thread_compaction_manager(which);
-  ParCompactionManager::MarkAndPushClosure mark_and_push_closure(cm);
+  PCMarkAndPushClosure mark_and_push_closure(cm);
   ParCompactionManager::FollowStackClosure follow_stack_closure(cm);
   _rp_task.work(_work_id, *PSParallelCompact::is_alive_closure(),
                 mark_and_push_closure, follow_stack_closure);
@@ -182,13 +183,12 @@
 
   ParCompactionManager* cm =
     ParCompactionManager::gc_thread_compaction_manager(which);
-  ParCompactionManager::MarkAndPushClosure mark_and_push_closure(cm);
 
   oop obj = NULL;
   ObjArrayTask task;
   do {
     while (ParCompactionManager::steal_objarray(which,  task)) {
-      cm->follow_contents((objArrayOop)task.obj(), task.index());
+      cm->follow_array((objArrayOop)task.obj(), task.index());
       cm->follow_marking_stacks();
     }
     while (ParCompactionManager::steal(which, obj)) {
--- a/src/hotspot/share/gc/parallel/psCardTable.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psCardTable.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -28,7 +28,7 @@
 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
 #include "gc/parallel/psCardTable.hpp"
 #include "gc/parallel/psPromotionManager.inline.hpp"
-#include "gc/parallel/psScavenge.hpp"
+#include "gc/parallel/psScavenge.inline.hpp"
 #include "gc/parallel/psTasks.hpp"
 #include "gc/parallel/psYoungGen.hpp"
 #include "memory/iterator.inline.hpp"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/parallel/psClosure.inline.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_GC_PARALLEL_PSCLOSURE_INLINE_HPP
+#define SHARE_VM_GC_PARALLEL_PSCLOSURE_INLINE_HPP
+
+#include "gc/parallel/psPromotionManager.inline.hpp"
+#include "gc/parallel/psScavenge.inline.hpp"
+#include "memory/iterator.hpp"
+#include "oops/access.inline.hpp"
+#include "oops/oop.inline.hpp"
+#include "utilities/globalDefinitions.hpp"
+
+template <bool promote_immediately>
+class PSRootsClosure: public OopClosure {
+private:
+  PSPromotionManager* _promotion_manager;
+
+  template <class T> void do_oop_work(T *p) {
+    if (PSScavenge::should_scavenge(p)) {
+      // We never card mark roots, maybe call a func without test?
+      _promotion_manager->copy_and_push_safe_barrier<T, promote_immediately>(p);
+    }
+  }
+public:
+  PSRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { }
+  void do_oop(oop* p)       { PSRootsClosure::do_oop_work(p); }
+  void do_oop(narrowOop* p) { PSRootsClosure::do_oop_work(p); }
+};
+
+typedef PSRootsClosure</*promote_immediately=*/false> PSScavengeRootsClosure;
+typedef PSRootsClosure</*promote_immediately=*/true> PSPromoteRootsClosure;
+
+// Scavenges a single oop in a ClassLoaderData.
+class PSScavengeFromCLDClosure: public OopClosure {
+private:
+  PSPromotionManager* _pm;
+  // Used to redirty a scanned cld if it has oops
+  // pointing to the young generation after being scanned.
+  ClassLoaderData*    _scanned_cld;
+public:
+  PSScavengeFromCLDClosure(PSPromotionManager* pm) : _pm(pm), _scanned_cld(NULL) { }
+  void do_oop(narrowOop* p) { ShouldNotReachHere(); }
+  void do_oop(oop* p)       {
+    ParallelScavengeHeap* psh = ParallelScavengeHeap::heap();
+    assert(!psh->is_in_reserved(p), "GC barrier needed");
+    if (PSScavenge::should_scavenge(p)) {
+      assert(PSScavenge::should_scavenge(p, true), "revisiting object?");
+
+      oop o = *p;
+      oop new_obj;
+      if (o->is_forwarded()) {
+        new_obj = o->forwardee();
+      } else {
+        new_obj = _pm->copy_to_survivor_space</*promote_immediately=*/false>(o);
+      }
+      RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
+
+      if (PSScavenge::is_obj_in_young(new_obj)) {
+        do_cld_barrier();
+      }
+    }
+  }
+
+  void set_scanned_cld(ClassLoaderData* cld) {
+    assert(_scanned_cld == NULL || cld == NULL, "Should always only handling one cld at a time");
+    _scanned_cld = cld;
+  }
+
+private:
+  void do_cld_barrier() {
+    assert(_scanned_cld != NULL, "Should not be called without having a scanned cld");
+    _scanned_cld->record_modified_oops();
+  }
+};
+
+// Scavenges the oop in a ClassLoaderData.
+class PSScavengeCLDClosure: public CLDClosure {
+private:
+  PSScavengeFromCLDClosure _oop_closure;
+public:
+  PSScavengeCLDClosure(PSPromotionManager* pm) : _oop_closure(pm) { }
+  void do_cld(ClassLoaderData* cld) {
+    // If the cld has not been dirtied we know that there's
+    // no references into  the young gen and we can skip it.
+
+    if (cld->has_modified_oops()) {
+      // Setup the promotion manager to redirty this cld
+      // if references are left in the young gen.
+      _oop_closure.set_scanned_cld(cld);
+
+      // Clean the cld since we're going to scavenge all the metadata.
+      cld->oops_do(&_oop_closure, false, /*clear_modified_oops*/true);
+
+      _oop_closure.set_scanned_cld(NULL);
+    }
+  }
+};
+
+#endif
--- a/src/hotspot/share/gc/parallel/psCompactionManager.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psCompactionManager.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -132,113 +132,6 @@
   return _manager_array[index];
 }
 
-void InstanceKlass::oop_pc_follow_contents(oop obj, ParCompactionManager* cm) {
-  assert(obj != NULL, "can't follow the content of NULL object");
-
-  cm->follow_klass(this);
-  // Only mark the header and let the scan of the meta-data mark
-  // everything else.
-
-  ParCompactionManager::MarkAndPushClosure cl(cm);
-  if (UseCompressedOops) {
-    InstanceKlass::oop_oop_iterate_oop_maps<narrowOop>(obj, &cl);
-  } else {
-    InstanceKlass::oop_oop_iterate_oop_maps<oop>(obj, &cl);
-  }
-}
-
-void InstanceMirrorKlass::oop_pc_follow_contents(oop obj, ParCompactionManager* cm) {
-  InstanceKlass::oop_pc_follow_contents(obj, cm);
-
-  // Follow the klass field in the mirror.
-  Klass* klass = java_lang_Class::as_Klass(obj);
-  if (klass != NULL) {
-    // An unsafe anonymous class doesn't have its own class loader,
-    // so the call to follow_klass will mark and push its java mirror instead of the
-    // class loader. When handling the java mirror for an unsafe anonymous
-    // class we need to make sure its class loader data is claimed, this is done
-    // by calling follow_class_loader explicitly. For non-anonymous classes the
-    // call to follow_class_loader is made when the class loader itself is handled.
-    if (klass->is_instance_klass() &&
-        InstanceKlass::cast(klass)->is_unsafe_anonymous()) {
-      cm->follow_class_loader(klass->class_loader_data());
-    } else {
-      cm->follow_klass(klass);
-    }
-  } else {
-    // If klass is NULL then this a mirror for a primitive type.
-    // We don't have to follow them, since they are handled as strong
-    // roots in Universe::oops_do.
-    assert(java_lang_Class::is_primitive(obj), "Sanity check");
-  }
-
-  ParCompactionManager::MarkAndPushClosure cl(cm);
-  if (UseCompressedOops) {
-    oop_oop_iterate_statics<narrowOop>(obj, &cl);
-  } else {
-    oop_oop_iterate_statics<oop>(obj, &cl);
-  }
-}
-
-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_acquire(obj);
-  if (loader_data != NULL) {
-    cm->follow_class_loader(loader_data);
-  }
-}
-
-template <class T>
-static void oop_pc_follow_contents_specialized(InstanceRefKlass* klass, oop obj, ParCompactionManager* cm) {
-  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr_raw(obj);
-  T heap_oop = RawAccess<>::oop_load(referent_addr);
-  log_develop_trace(gc, ref)("InstanceRefKlass::oop_pc_follow_contents " PTR_FORMAT, p2i(obj));
-  if (!CompressedOops::is_null(heap_oop)) {
-    oop referent = CompressedOops::decode_not_null(heap_oop);
-    if (PSParallelCompact::mark_bitmap()->is_unmarked(referent) &&
-        PSParallelCompact::ref_processor()->discover_reference(obj, klass->reference_type())) {
-      // reference already enqueued, referent will be traversed later
-      klass->InstanceKlass::oop_pc_follow_contents(obj, cm);
-      log_develop_trace(gc, ref)("       Non NULL enqueued " PTR_FORMAT, p2i(obj));
-      return;
-    } else {
-      // treat referent as normal oop
-      log_develop_trace(gc, ref)("       Non NULL normal " PTR_FORMAT, p2i(obj));
-      cm->mark_and_push(referent_addr);
-    }
-  }
-  // Treat discovered as normal oop.
-  T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr_raw(obj);
-  cm->mark_and_push(discovered_addr);
-  klass->InstanceKlass::oop_pc_follow_contents(obj, cm);
-}
-
-
-void InstanceRefKlass::oop_pc_follow_contents(oop obj, ParCompactionManager* cm) {
-  if (UseCompressedOops) {
-    oop_pc_follow_contents_specialized<narrowOop>(this, obj, cm);
-  } else {
-    oop_pc_follow_contents_specialized<oop>(this, obj, cm);
-  }
-}
-
-void ObjArrayKlass::oop_pc_follow_contents(oop obj, ParCompactionManager* cm) {
-  cm->follow_klass(this);
-
-  if (UseCompressedOops) {
-    oop_pc_follow_contents_specialized<narrowOop>(objArrayOop(obj), 0, cm);
-  } else {
-    oop_pc_follow_contents_specialized<oop>(objArrayOop(obj), 0, cm);
-  }
-}
-
-void TypeArrayKlass::oop_pc_follow_contents(oop obj, ParCompactionManager* cm) {
-  assert(obj->is_typeArray(),"must be a type array");
-  // Performance tweak: We skip iterating over the klass pointer since we
-  // know that Universe::TypeArrayKlass never moves.
-}
-
 void ParCompactionManager::follow_marking_stacks() {
   do {
     // Drain the overflow stack first, to allow stealing from the marking stack.
@@ -253,7 +146,7 @@
     // Process ObjArrays one at a time to avoid marking stack bloat.
     ObjArrayTask task;
     if (_objarray_stack.pop_overflow(task) || _objarray_stack.pop_local(task)) {
-      follow_contents((objArrayOop)task.obj(), task.index());
+      follow_array((objArrayOop)task.obj(), task.index());
     }
   } while (!marking_stacks_empty());
 
--- a/src/hotspot/share/gc/parallel/psCompactionManager.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psCompactionManager.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2017, 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
@@ -171,24 +171,10 @@
   void drain_region_stacks();
 
   void follow_contents(oop obj);
-  void follow_contents(objArrayOop array, int index);
+  void follow_array(objArrayOop array, int index);
 
   void update_contents(oop obj);
 
-  class MarkAndPushClosure: public BasicOopIterateClosure {
-   private:
-    ParCompactionManager* _compaction_manager;
-   public:
-    MarkAndPushClosure(ParCompactionManager* cm) : _compaction_manager(cm) { }
-
-    template <typename T> void do_oop_work(T* p);
-    virtual void do_oop(oop* p);
-    virtual void do_oop(narrowOop* p);
-
-    // This closure provides its own oop verification code.
-    debug_only(virtual bool should_verify_oops() { return false; })
-  };
-
   class FollowStackClosure: public VoidClosure {
    private:
     ParCompactionManager* _compaction_manager;
--- a/src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -25,6 +25,7 @@
 #ifndef SHARE_VM_GC_PARALLEL_PSCOMPACTIONMANAGER_INLINE_HPP
 #define SHARE_VM_GC_PARALLEL_PSCOMPACTIONMANAGER_INLINE_HPP
 
+#include "classfile/javaClasses.inline.hpp"
 #include "gc/parallel/parMarkBitMap.hpp"
 #include "gc/parallel/psCompactionManager.hpp"
 #include "gc/parallel/psParallelCompact.inline.hpp"
@@ -37,6 +38,37 @@
 #include "utilities/debug.hpp"
 #include "utilities/globalDefinitions.hpp"
 
+class PCMarkAndPushClosure: public OopClosure {
+private:
+  ParCompactionManager* _compaction_manager;
+public:
+  PCMarkAndPushClosure(ParCompactionManager* cm) : _compaction_manager(cm) { }
+
+  template <typename T> void do_oop_nv(T* p)      { _compaction_manager->mark_and_push(p); }
+  virtual void do_oop(oop* p)                     { do_oop_nv(p); }
+  virtual void do_oop(narrowOop* p)               { do_oop_nv(p); }
+
+  // This closure provides its own oop verification code.
+  debug_only(virtual bool should_verify_oops()    { return false; })
+};
+
+class PCIterateMarkAndPushClosure: public MetadataVisitingOopIterateClosure {
+private:
+  ParCompactionManager* _compaction_manager;
+public:
+  PCIterateMarkAndPushClosure(ParCompactionManager* cm, ReferenceProcessor* rp) : MetadataVisitingOopIterateClosure(rp), _compaction_manager(cm) { }
+
+  template <typename T> void do_oop_nv(T* p)      { _compaction_manager->mark_and_push(p); }
+  virtual void do_oop(oop* p)                     { do_oop_nv(p); }
+  virtual void do_oop(narrowOop* p)               { do_oop_nv(p); }
+
+  void do_klass_nv(Klass* k)                      { _compaction_manager->follow_klass(k); }
+  void do_cld_nv(ClassLoaderData* cld)            { _compaction_manager->follow_class_loader(cld); }
+
+  // This closure provides its own oop verification code.
+  debug_only(virtual bool should_verify_oops()    { return false; })
+};
+
 inline bool ParCompactionManager::steal(int queue_num, oop& t) {
   return stack_array()->steal(queue_num, t);
 }
@@ -84,14 +116,6 @@
   }
 }
 
-template <typename T>
-inline void ParCompactionManager::MarkAndPushClosure::do_oop_work(T* p) {
-  _compaction_manager->mark_and_push(p);
-}
-
-inline void ParCompactionManager::MarkAndPushClosure::do_oop(oop* p)       { do_oop_work(p); }
-inline void ParCompactionManager::MarkAndPushClosure::do_oop(narrowOop* p) { do_oop_work(p); }
-
 inline void ParCompactionManager::follow_klass(Klass* klass) {
   oop holder = klass->klass_holder();
   mark_and_push(&holder);
@@ -101,19 +125,8 @@
   _compaction_manager->follow_marking_stacks();
 }
 
-inline void ParCompactionManager::follow_class_loader(ClassLoaderData* cld) {
-  MarkAndPushClosure mark_and_push_closure(this);
-
-  cld->oops_do(&mark_and_push_closure, true);
-}
-
-inline void ParCompactionManager::follow_contents(oop obj) {
-  assert(PSParallelCompact::mark_bitmap()->is_marked(obj), "should be marked");
-  obj->pc_follow_contents(this);
-}
-
-template <class T>
-inline void oop_pc_follow_contents_specialized(objArrayOop obj, int index, ParCompactionManager* cm) {
+template <typename T>
+inline void follow_array_specialized(objArrayOop obj, int index, ParCompactionManager* cm) {
   const size_t len = size_t(obj->length());
   const size_t beg_index = size_t(index);
   assert(beg_index < len || len == 0, "index too large");
@@ -134,16 +147,34 @@
   }
 }
 
-inline void ParCompactionManager::follow_contents(objArrayOop obj, int index) {
+inline void ParCompactionManager::follow_array(objArrayOop obj, int index) {
   if (UseCompressedOops) {
-    oop_pc_follow_contents_specialized<narrowOop>(obj, index, this);
+    follow_array_specialized<narrowOop>(obj, index, this);
   } else {
-    oop_pc_follow_contents_specialized<oop>(obj, index, this);
+    follow_array_specialized<oop>(obj, index, this);
   }
 }
 
 inline void ParCompactionManager::update_contents(oop obj) {
-  obj->pc_update_contents(this);
+  if (!obj->klass()->is_typeArray_klass()) {
+    PCAdjustPointerClosure apc(this);
+    obj->oop_iterate(&apc);
+  }
+}
+
+inline void ParCompactionManager::follow_class_loader(ClassLoaderData* cld) {
+  PCMarkAndPushClosure mark_and_push_closure(this);
+  cld->oops_do(&mark_and_push_closure, true);
+}
+
+inline void ParCompactionManager::follow_contents(oop obj) {
+  assert(PSParallelCompact::mark_bitmap()->is_marked(obj), "should be marked");
+  if (obj->is_objArray()) {
+    follow_array(objArrayOop(obj), 0);
+  } else {
+    PCIterateMarkAndPushClosure cl(this, PSParallelCompact::ref_processor());
+    obj->oop_iterate(&cl);
+  }
 }
 
 #endif // SHARE_VM_GC_PARALLEL_PSCOMPACTIONMANAGER_INLINE_HPP
--- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -846,18 +846,43 @@
 
 bool PSParallelCompact::IsAliveClosure::do_object_b(oop p) { return mark_bitmap()->is_marked(p); }
 
+class PCReferenceProcessor: public ReferenceProcessor {
+public:
+  PCReferenceProcessor(
+    BoolObjectClosure* is_subject_to_discovery,
+    BoolObjectClosure* is_alive_non_header) :
+      ReferenceProcessor(is_subject_to_discovery,
+      ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing
+      ParallelGCThreads,   // mt processing degree
+      true,                // mt discovery
+      ParallelGCThreads,   // mt discovery degree
+      true,                // atomic_discovery
+      is_alive_non_header) {
+  }
+
+  template<typename T> bool discover(oop obj, ReferenceType type) {
+    T* referent_addr = (T*) java_lang_ref_Reference::referent_addr_raw(obj);
+    T heap_oop = RawAccess<>::oop_load(referent_addr);
+    oop referent = CompressedOops::decode_not_null(heap_oop);
+    return PSParallelCompact::mark_bitmap()->is_unmarked(referent)
+        && ReferenceProcessor::discover_reference(obj, type);
+  }
+  virtual bool discover_reference(oop obj, ReferenceType type) {
+    if (UseCompressedOops) {
+      return discover<narrowOop>(obj, type);
+    } else {
+      return discover<oop>(obj, type);
+    }
+  }
+};
+
 void PSParallelCompact::post_initialize() {
   ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
   _span_based_discoverer.set_span(heap->reserved_region());
   _ref_processor =
-    new ReferenceProcessor(&_span_based_discoverer,
-                           ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing
-                           ParallelGCThreads,   // mt processing degree
-                           true,                // mt discovery
-                           ParallelGCThreads,   // mt discovery degree
-                           true,                // atomic_discovery
-                           &_is_alive_closure,  // non-header is alive closure
-                           false);              // disable adjusting number of processing threads
+    new PCReferenceProcessor(&_span_based_discoverer,
+                             &_is_alive_closure); // non-header is alive closure
+
   _counters = new CollectorCounters("PSParallelCompact", 1);
 
   // Initialize static fields in ParCompactionManager.
@@ -2077,7 +2102,7 @@
   TaskQueueSetSuper* qset = ParCompactionManager::stack_array();
   ParallelTaskTerminator terminator(active_gc_threads, qset);
 
-  ParCompactionManager::MarkAndPushClosure mark_and_push_closure(cm);
+  PCMarkAndPushClosure mark_and_push_closure(cm);
   ParCompactionManager::FollowStackClosure follow_stack_closure(cm);
 
   // Need new claim bits before marking starts.
@@ -2178,7 +2203,7 @@
   // Need new claim bits when tracing through and adjusting pointers.
   ClassLoaderDataGraph::clear_claimed_marks();
 
-  PSParallelCompact::AdjustPointerClosure oop_closure(cm);
+  PCAdjustPointerClosure oop_closure(cm);
 
   // General strong roots.
   Universe::oops_do(&oop_closure);
@@ -3071,76 +3096,6 @@
   update_state(words);
 }
 
-void InstanceKlass::oop_pc_update_pointers(oop obj, ParCompactionManager* cm) {
-  PSParallelCompact::AdjustPointerClosure closure(cm);
-  if (UseCompressedOops) {
-    oop_oop_iterate_oop_maps<narrowOop>(obj, &closure);
-  } else {
-    oop_oop_iterate_oop_maps<oop>(obj, &closure);
-  }
-}
-
-void InstanceMirrorKlass::oop_pc_update_pointers(oop obj, ParCompactionManager* cm) {
-  InstanceKlass::oop_pc_update_pointers(obj, cm);
-
-  PSParallelCompact::AdjustPointerClosure closure(cm);
-  if (UseCompressedOops) {
-    oop_oop_iterate_statics<narrowOop>(obj, &closure);
-  } else {
-    oop_oop_iterate_statics<oop>(obj, &closure);
-  }
-}
-
-void InstanceClassLoaderKlass::oop_pc_update_pointers(oop obj, ParCompactionManager* cm) {
-  InstanceKlass::oop_pc_update_pointers(obj, cm);
-}
-
-#ifdef ASSERT
-template <class T> static void trace_reference_gc(const char *s, oop obj,
-                                                  T* referent_addr,
-                                                  T* discovered_addr) {
-  log_develop_trace(gc, ref)("%s obj " PTR_FORMAT, s, p2i(obj));
-  log_develop_trace(gc, ref)("     referent_addr/* " PTR_FORMAT " / " PTR_FORMAT,
-                             p2i(referent_addr), referent_addr ? p2i((oop)RawAccess<>::oop_load(referent_addr)) : NULL);
-  log_develop_trace(gc, ref)("     discovered_addr/* " PTR_FORMAT " / " PTR_FORMAT,
-                             p2i(discovered_addr), discovered_addr ? p2i((oop)RawAccess<>::oop_load(discovered_addr)) : NULL);
-}
-#endif
-
-template <class T>
-static void oop_pc_update_pointers_specialized(oop obj, ParCompactionManager* cm) {
-  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr_raw(obj);
-  PSParallelCompact::adjust_pointer(referent_addr, cm);
-  T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr_raw(obj);
-  PSParallelCompact::adjust_pointer(discovered_addr, cm);
-  debug_only(trace_reference_gc("InstanceRefKlass::oop_update_ptrs", obj,
-                                referent_addr, discovered_addr);)
-}
-
-void InstanceRefKlass::oop_pc_update_pointers(oop obj, ParCompactionManager* cm) {
-  InstanceKlass::oop_pc_update_pointers(obj, cm);
-
-  if (UseCompressedOops) {
-    oop_pc_update_pointers_specialized<narrowOop>(obj, cm);
-  } else {
-    oop_pc_update_pointers_specialized<oop>(obj, cm);
-  }
-}
-
-void ObjArrayKlass::oop_pc_update_pointers(oop obj, ParCompactionManager* cm) {
-  assert(obj->is_objArray(), "obj must be obj array");
-  PSParallelCompact::AdjustPointerClosure closure(cm);
-  if (UseCompressedOops) {
-    oop_oop_iterate_elements<narrowOop>(objArrayOop(obj), &closure);
-  } else {
-    oop_oop_iterate_elements<oop>(objArrayOop(obj), &closure);
-  }
-}
-
-void TypeArrayKlass::oop_pc_update_pointers(oop obj, ParCompactionManager* cm) {
-  assert(obj->is_typeArray(),"must be a type array");
-}
-
 ParMarkBitMapClosure::IterationStatus
 MoveAndUpdateClosure::do_addr(HeapWord* addr, size_t words) {
   assert(destination() != NULL, "sanity");
--- a/src/hotspot/share/gc/parallel/psParallelCompact.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -934,23 +934,6 @@
     virtual bool do_object_b(oop p);
   };
 
-  class AdjustPointerClosure: public BasicOopIterateClosure {
-   public:
-    AdjustPointerClosure(ParCompactionManager* cm) {
-      assert(cm != NULL, "associate ParCompactionManage should not be NULL");
-      _cm = cm;
-    }
-    template <typename T> void do_oop_work(T* p);
-    virtual void do_oop(oop* p);
-    virtual void do_oop(narrowOop* p);
-
-    // This closure provides its own oop verification code.
-    debug_only(virtual bool should_verify_oops() { return false; })
-   private:
-    ParCompactionManager* _cm;
-  };
-
-  friend class AdjustPointerClosure;
   friend class RefProcTaskProxy;
   friend class PSParallelCompactTest;
 
--- a/src/hotspot/share/gc/parallel/psParallelCompact.inline.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.inline.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -124,12 +124,21 @@
   }
 }
 
-template <typename T>
-void PSParallelCompact::AdjustPointerClosure::do_oop_work(T* p) {
-  adjust_pointer(p, _cm);
-}
+class PCAdjustPointerClosure: public BasicOopIterateClosure {
+public:
+  PCAdjustPointerClosure(ParCompactionManager* cm) {
+    assert(cm != NULL, "associate ParCompactionManage should not be NULL");
+    _cm = cm;
+  }
+  template <typename T> void do_oop_nv(T* p) { PSParallelCompact::adjust_pointer(p, _cm); }
+  virtual void do_oop(oop* p)                { do_oop_nv(p); }
+  virtual void do_oop(narrowOop* p)          { do_oop_nv(p); }
 
-inline void PSParallelCompact::AdjustPointerClosure::do_oop(oop* p)       { do_oop_work(p); }
-inline void PSParallelCompact::AdjustPointerClosure::do_oop(narrowOop* p) { do_oop_work(p); }
+  // This closure provides its own oop verification code.
+  debug_only(virtual bool should_verify_oops() { return false; })
+  virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
+private:
+  ParCompactionManager* _cm;
+};
 
 #endif // SHARE_VM_GC_PARALLEL_PSPARALLELCOMPACT_INLINE_HPP
--- a/src/hotspot/share/gc/parallel/psPromotionManager.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psPromotionManager.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -41,14 +41,7 @@
 #include "memory/padded.inline.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/access.inline.hpp"
-#include "oops/arrayOop.inline.hpp"
 #include "oops/compressedOops.inline.hpp"
-#include "oops/instanceClassLoaderKlass.inline.hpp"
-#include "oops/instanceKlass.inline.hpp"
-#include "oops/instanceMirrorKlass.inline.hpp"
-#include "oops/objArrayKlass.inline.hpp"
-#include "oops/objArrayOop.inline.hpp"
-#include "oops/oop.inline.hpp"
 
 PaddedEnd<PSPromotionManager>* PSPromotionManager::_manager_array = NULL;
 OopStarTaskQueueSet*           PSPromotionManager::_stack_array_depth = NULL;
@@ -397,101 +390,6 @@
   }
 }
 
-class PushContentsClosure : public BasicOopIterateClosure {
-  PSPromotionManager* _pm;
- public:
-  PushContentsClosure(PSPromotionManager* pm) : _pm(pm) {}
-
-  template <typename T> void do_oop_work(T* p) {
-    if (PSScavenge::should_scavenge(p)) {
-      _pm->claim_or_forward_depth(p);
-    }
-  }
-
-  virtual void do_oop(oop* p)       { do_oop_work(p); }
-  virtual void do_oop(narrowOop* p) { do_oop_work(p); }
-
-  // Don't use the oop verification code in the oop_oop_iterate framework.
-  debug_only(virtual bool should_verify_oops() { return false; })
-};
-
-void InstanceKlass::oop_ps_push_contents(oop obj, PSPromotionManager* pm) {
-  PushContentsClosure cl(pm);
-  if (UseCompressedOops) {
-    oop_oop_iterate_oop_maps_reverse<narrowOop>(obj, &cl);
-  } else {
-    oop_oop_iterate_oop_maps_reverse<oop>(obj, &cl);
-  }
-}
-
-void InstanceMirrorKlass::oop_ps_push_contents(oop obj, PSPromotionManager* pm) {
-    // Note that we don't have to follow the mirror -> klass pointer, since all
-    // klasses that are dirty will be scavenged when we iterate over the
-    // ClassLoaderData objects.
-
-  InstanceKlass::oop_ps_push_contents(obj, pm);
-
-  PushContentsClosure cl(pm);
-  if (UseCompressedOops) {
-    oop_oop_iterate_statics<narrowOop>(obj, &cl);
-  } else {
-    oop_oop_iterate_statics<oop>(obj, &cl);
-  }
-}
-
-void InstanceClassLoaderKlass::oop_ps_push_contents(oop obj, PSPromotionManager* pm) {
-  InstanceKlass::oop_ps_push_contents(obj, pm);
-
-  // This is called by the young collector. It will already have taken care of
-  // all class loader data. So, we don't have to follow the class loader ->
-  // class loader data link.
-}
-
-template <class T>
-static void oop_ps_push_contents_specialized(oop obj, InstanceRefKlass *klass, PSPromotionManager* pm) {
-  T* referent_addr = (T*)java_lang_ref_Reference::referent_addr_raw(obj);
-  if (PSScavenge::should_scavenge(referent_addr)) {
-    ReferenceProcessor* rp = PSScavenge::reference_processor();
-    if (rp->discover_reference(obj, klass->reference_type())) {
-      // reference discovered, referent will be traversed later.
-      klass->InstanceKlass::oop_ps_push_contents(obj, pm);
-      return;
-    } else {
-      // treat referent as normal oop
-      pm->claim_or_forward_depth(referent_addr);
-    }
-  }
-  // Treat discovered as normal oop
-  T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr_raw(obj);
-  if (PSScavenge::should_scavenge(discovered_addr)) {
-    pm->claim_or_forward_depth(discovered_addr);
-  }
-  klass->InstanceKlass::oop_ps_push_contents(obj, pm);
-}
-
-void InstanceRefKlass::oop_ps_push_contents(oop obj, PSPromotionManager* pm) {
-  if (UseCompressedOops) {
-    oop_ps_push_contents_specialized<narrowOop>(obj, this, pm);
-  } else {
-    oop_ps_push_contents_specialized<oop>(obj, this, pm);
-  }
-}
-
-void ObjArrayKlass::oop_ps_push_contents(oop obj, PSPromotionManager* pm) {
-  assert(obj->is_objArray(), "obj must be obj array");
-  PushContentsClosure cl(pm);
-  if (UseCompressedOops) {
-    oop_oop_iterate_elements<narrowOop>(objArrayOop(obj), &cl);
-  } else {
-    oop_oop_iterate_elements<oop>(objArrayOop(obj), &cl);
-  }
-}
-
-void TypeArrayKlass::oop_ps_push_contents(oop obj, PSPromotionManager* pm) {
-  assert(obj->is_typeArray(),"must be a type array");
-  ShouldNotReachHere();
-}
-
 oop PSPromotionManager::oop_promotion_failed(oop obj, markOop obj_mark) {
   assert(_old_gen_is_full || PromotionFailureALot, "Sanity");
 
--- a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -30,9 +30,10 @@
 #include "gc/parallel/psOldGen.hpp"
 #include "gc/parallel/psPromotionLAB.inline.hpp"
 #include "gc/parallel/psPromotionManager.hpp"
-#include "gc/parallel/psScavenge.hpp"
+#include "gc/parallel/psScavenge.inline.hpp"
 #include "gc/shared/taskqueue.inline.hpp"
 #include "logging/log.hpp"
+#include "memory/iterator.inline.hpp"
 #include "oops/access.inline.hpp"
 #include "oops/oop.inline.hpp"
 
@@ -99,8 +100,48 @@
   }
 }
 
+class PSPushContentsClosure: public BasicOopIterateClosure {
+  PSPromotionManager* _pm;
+ public:
+  PSPushContentsClosure(PSPromotionManager* pm) : BasicOopIterateClosure(PSScavenge::reference_processor()), _pm(pm) {}
+
+  template <typename T> void do_oop_nv(T* p) {
+    if (PSScavenge::should_scavenge(p)) {
+      _pm->claim_or_forward_depth(p);
+    }
+  }
+
+  virtual void do_oop(oop* p)       { do_oop_nv(p); }
+  virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
+
+  // Don't use the oop verification code in the oop_oop_iterate framework.
+  debug_only(virtual bool should_verify_oops() { return false; })
+};
+
+//
+// This closure specialization will override the one that is defined in
+// instanceRefKlass.inline.cpp. It swaps the order of oop_oop_iterate and
+// oop_oop_iterate_ref_processing. Unfortunately G1 and Parallel behaves
+// significantly better (especially in the Derby benchmark) using opposite
+// order of these function calls.
+//
+template <>
+inline void InstanceRefKlass::oop_oop_iterate_reverse<oop, PSPushContentsClosure>(oop obj, PSPushContentsClosure* closure) {
+  oop_oop_iterate_ref_processing<oop>(obj, closure);
+  InstanceKlass::oop_oop_iterate_reverse<oop>(obj, closure);
+}
+
+template <>
+inline void InstanceRefKlass::oop_oop_iterate_reverse<narrowOop, PSPushContentsClosure>(oop obj, PSPushContentsClosure* closure) {
+  oop_oop_iterate_ref_processing<narrowOop>(obj, closure);
+  InstanceKlass::oop_oop_iterate_reverse<narrowOop>(obj, closure);
+}
+
 inline void PSPromotionManager::push_contents(oop obj) {
-  obj->ps_push_contents(this);
+  if (!obj->klass()->is_typeArray_klass()) {
+    PSPushContentsClosure pcc(this);
+    obj->oop_iterate_backwards(&pcc);
+  }
 }
 //
 // This method is pretty bulky. It would be nice to split it up
--- a/src/hotspot/share/gc/parallel/psScavenge.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psScavenge.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -28,8 +28,10 @@
 #include "gc/parallel/gcTaskManager.hpp"
 #include "gc/parallel/parallelScavengeHeap.hpp"
 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
+#include "gc/parallel/psClosure.inline.hpp"
 #include "gc/parallel/psMarkSweepProxy.hpp"
 #include "gc/parallel/psParallelCompact.inline.hpp"
+#include "gc/parallel/psPromotionManager.inline.hpp"
 #include "gc/parallel/psScavenge.inline.hpp"
 #include "gc/parallel/psTasks.hpp"
 #include "gc/shared/collectorPolicy.hpp"
--- a/src/hotspot/share/gc/parallel/psScavenge.inline.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psScavenge.inline.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -26,7 +26,6 @@
 #define SHARE_VM_GC_PARALLEL_PSSCAVENGE_INLINE_HPP
 
 #include "gc/parallel/parallelScavengeHeap.hpp"
-#include "gc/parallel/psPromotionManager.inline.hpp"
 #include "gc/parallel/psScavenge.hpp"
 #include "logging/log.hpp"
 #include "memory/iterator.hpp"
@@ -65,93 +64,4 @@
   return should_scavenge(p);
 }
 
-template<bool promote_immediately>
-class PSRootsClosure: public OopClosure {
- private:
-  PSPromotionManager* _promotion_manager;
-
- protected:
-  template <class T> void do_oop_work(T *p) {
-    if (PSScavenge::should_scavenge(p)) {
-      // We never card mark roots, maybe call a func without test?
-      _promotion_manager->copy_and_push_safe_barrier<T, promote_immediately>(p);
-    }
-  }
- public:
-  PSRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { }
-  void do_oop(oop* p)       { PSRootsClosure::do_oop_work(p); }
-  void do_oop(narrowOop* p) { PSRootsClosure::do_oop_work(p); }
-};
-
-typedef PSRootsClosure</*promote_immediately=*/false> PSScavengeRootsClosure;
-typedef PSRootsClosure</*promote_immediately=*/true> PSPromoteRootsClosure;
-
-// Scavenges a single oop in a ClassLoaderData.
-class PSScavengeFromCLDClosure: public OopClosure {
- private:
-  PSPromotionManager* _pm;
-  // Used to redirty a scanned cld if it has oops
-  // pointing to the young generation after being scanned.
-  ClassLoaderData*    _scanned_cld;
- public:
-  PSScavengeFromCLDClosure(PSPromotionManager* pm) : _pm(pm), _scanned_cld(NULL) { }
-  void do_oop(narrowOop* p) { ShouldNotReachHere(); }
-  void do_oop(oop* p)       {
-    ParallelScavengeHeap* psh = ParallelScavengeHeap::heap();
-    assert(!psh->is_in_reserved(p), "GC barrier needed");
-    if (PSScavenge::should_scavenge(p)) {
-      assert(PSScavenge::should_scavenge(p, true), "revisiting object?");
-
-      oop o = *p;
-      oop new_obj;
-      if (o->is_forwarded()) {
-        new_obj = o->forwardee();
-      } else {
-        new_obj = _pm->copy_to_survivor_space</*promote_immediately=*/false>(o);
-      }
-      RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
-
-      if (PSScavenge::is_obj_in_young(new_obj)) {
-        do_cld_barrier();
-      }
-    }
-  }
-
-  void set_scanned_cld(ClassLoaderData* cld) {
-    assert(_scanned_cld == NULL || cld == NULL, "Should always only handling one cld at a time");
-    _scanned_cld = cld;
-  }
-
- private:
-  void do_cld_barrier() {
-    assert(_scanned_cld != NULL, "Should not be called without having a scanned cld");
-    _scanned_cld->record_modified_oops();
-  }
-};
-
-// Scavenges the oop in a ClassLoaderData.
-class PSScavengeCLDClosure: public CLDClosure {
- private:
-  PSScavengeFromCLDClosure _oop_closure;
- protected:
- public:
-  PSScavengeCLDClosure(PSPromotionManager* pm) : _oop_closure(pm) { }
-  void do_cld(ClassLoaderData* cld) {
-    // If the cld has not been dirtied we know that there's
-    // no references into  the young gen and we can skip it.
-
-    if (cld->has_modified_oops()) {
-      // Setup the promotion manager to redirty this cld
-      // if references are left in the young gen.
-      _oop_closure.set_scanned_cld(cld);
-
-      // Clean the cld since we're going to scavenge all the metadata.
-      cld->oops_do(&_oop_closure, false, /*clear_modified_oops*/true);
-
-      _oop_closure.set_scanned_cld(NULL);
-    }
-  }
-};
-
-
 #endif // SHARE_VM_GC_PARALLEL_PSSCAVENGE_INLINE_HPP
--- a/src/hotspot/share/gc/parallel/psTasks.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/gc/parallel/psTasks.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -29,6 +29,7 @@
 #include "code/codeCache.hpp"
 #include "gc/parallel/gcTaskManager.hpp"
 #include "gc/parallel/psCardTable.hpp"
+#include "gc/parallel/psClosure.inline.hpp"
 #include "gc/parallel/psPromotionManager.hpp"
 #include "gc/parallel/psPromotionManager.inline.hpp"
 #include "gc/parallel/psScavenge.inline.hpp"
--- a/src/hotspot/share/gc/shared/taskqueue.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/gc/shared/taskqueue.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -370,6 +370,8 @@
 public:
   // Returns "true" if some TaskQueue in the set contains a task.
   virtual bool peek() = 0;
+  // Tasks in queue
+  virtual uint tasks() const = 0;
 };
 
 template <MEMFLAGS F> class TaskQueueSetSuperImpl: public CHeapObj<F>, public TaskQueueSetSuper {
@@ -399,6 +401,7 @@
   bool steal(uint queue_num, E& t);
 
   bool peek();
+  uint tasks() const;
 
   uint size() const { return _n; }
 };
@@ -424,6 +427,15 @@
   return false;
 }
 
+template<class T, MEMFLAGS F>
+uint GenericTaskQueueSet<T, F>::tasks() const {
+  uint n = 0;
+  for (uint j = 0; j < _n; j++) {
+    n += _queues[j]->size();
+  }
+  return n;
+}
+
 // When to terminate from the termination protocol.
 class TerminatorTerminator: public CHeapObj<mtInternal> {
 public:
--- a/src/hotspot/share/oops/accessBackend.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/oops/accessBackend.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -998,7 +998,7 @@
 
     template <DecoratorSet decorators>
     inline static typename EnableIf<
-      HasDecorator<decorators, INTERNAL_BT_TO_SPACE_INVARIANT>::value, bool>::type
+      HasDecorator<decorators, AS_RAW>::value || HasDecorator<decorators, INTERNAL_BT_TO_SPACE_INVARIANT>::value, bool>::type
     equals(oop o1, oop o2) {
       typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
       return Raw::equals(o1, o2);
@@ -1006,7 +1006,7 @@
 
     template <DecoratorSet decorators>
     inline static typename EnableIf<
-      !HasDecorator<decorators, INTERNAL_BT_TO_SPACE_INVARIANT>::value, bool>::type
+      !HasDecorator<decorators, AS_RAW>::value && !HasDecorator<decorators, INTERNAL_BT_TO_SPACE_INVARIANT>::value, bool>::type
     equals(oop o1, oop o2) {
       return RuntimeDispatch<decorators, oop, BARRIER_EQUALS>::equals(o1, o2);
     }
--- a/src/hotspot/share/oops/compressedOops.inline.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/oops/compressedOops.inline.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -66,7 +66,7 @@
     assert(OopEncodingHeapMax > pd, "change encoding max if new encoding");
     uint64_t result = pd >> shift;
     assert((result & CONST64(0xffffffff00000000)) == 0, "narrow oop overflow");
-    assert(decode(result) == v, "reversibility");
+    assert(oopDesc::equals_raw(decode(result), v), "reversibility");
     return (narrowOop)result;
   }
 
--- a/src/hotspot/share/oops/instanceClassLoaderKlass.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/oops/instanceClassLoaderKlass.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,7 @@
 // An InstanceClassLoaderKlass is a specialization of the InstanceKlass. It does
 // not add any field.  It is added to walk the dependencies for the class loader
 // key that this class loader points to.  This is how the loader_data graph is
-// walked and dependant class loaders are kept alive.  I thought we walked
+// walked and dependent class loaders are kept alive.  I thought we walked
 // the list later?
 
 class InstanceClassLoaderKlass: public InstanceKlass {
@@ -48,21 +48,10 @@
 public:
   InstanceClassLoaderKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
 
-  // GC specific object visitors
-  //
-#if INCLUDE_PARALLELGC
-  // Parallel Scavenge
-  void oop_ps_push_contents(  oop obj, PSPromotionManager* pm);
-  // Parallel Compact
-  void oop_pc_follow_contents(oop obj, ParCompactionManager* cm);
-  void oop_pc_update_pointers(oop obj, ParCompactionManager* cm);
-#endif
-
   // Oop fields (and metadata) iterators
   //
   // The InstanceClassLoaderKlass iterators also visit the CLD pointer (or mirror of anonymous klasses.)
 
- public:
   // Forward iteration
   // Iterate over the oop fields and metadata.
   template <typename T, class OopClosureType>
--- a/src/hotspot/share/oops/instanceKlass.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/oops/instanceKlass.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -1183,16 +1183,6 @@
   const char* signature_name() const;
   static Symbol* package_from_name(const Symbol* name, TRAPS);
 
-  // GC specific object visitors
-  //
-#if INCLUDE_PARALLELGC
-  // Parallel Scavenge
-  void oop_ps_push_contents(  oop obj, PSPromotionManager* pm);
-  // Parallel Compact
-  void oop_pc_follow_contents(oop obj, ParCompactionManager* cm);
-  void oop_pc_update_pointers(oop obj, ParCompactionManager* cm);
-#endif
-
   // Oop fields (and metadata) iterators
   //
   // The InstanceKlass iterators also visits the Object's klass.
--- a/src/hotspot/share/oops/instanceMirrorKlass.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/oops/instanceMirrorKlass.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -89,16 +89,6 @@
   // allocation
   instanceOop allocate_instance(Klass* k, TRAPS);
 
-  // GC specific object visitors
-  //
-#if INCLUDE_PARALLELGC
-  // Parallel Scavenge
-  void oop_ps_push_contents(  oop obj, PSPromotionManager* pm);
-  // Parallel Compact
-  void oop_pc_follow_contents(oop obj, ParCompactionManager* cm);
-  void oop_pc_update_pointers(oop obj, ParCompactionManager* cm);
-#endif
-
   static void serialize_offsets(class SerializeClosure* f) NOT_CDS_RETURN;
 
   // Oop fields (and metadata) iterators
--- a/src/hotspot/share/oops/instanceRefKlass.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/oops/instanceRefKlass.hpp	Mon Oct 15 11:39:10 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
@@ -58,16 +58,6 @@
  public:
   InstanceRefKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
 
-  // GC specific object visitors
-  //
-#if INCLUDE_PARALLELGC
-  // Parallel Scavenge
-  void oop_ps_push_contents(  oop obj, PSPromotionManager* pm);
-  // Parallel Compact
-  void oop_pc_follow_contents(oop obj, ParCompactionManager* cm);
-  void oop_pc_update_pointers(oop obj, ParCompactionManager* cm);
-#endif
-
   // Oop fields (and metadata) iterators
   //
   // The InstanceRefKlass iterators also support reference processing.
--- a/src/hotspot/share/oops/klass.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/oops/klass.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -673,16 +673,6 @@
     clean_weak_klass_links(/*unloading_occurred*/ true , /* clean_alive_klasses */ false);
   }
 
-  // GC specific object visitors
-  //
-#if INCLUDE_PARALLELGC
-  // Parallel Scavenge
-  virtual void oop_ps_push_contents(  oop obj, PSPromotionManager* pm)   = 0;
-  // Parallel Compact
-  virtual void oop_pc_follow_contents(oop obj, ParCompactionManager* cm) = 0;
-  virtual void oop_pc_update_pointers(oop obj, ParCompactionManager* cm) = 0;
-#endif
-
   virtual void array_klasses_do(void f(Klass* k)) {}
 
   // Return self, except for abstract classes with exactly 1
--- a/src/hotspot/share/oops/objArrayKlass.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/oops/objArrayKlass.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -120,16 +120,6 @@
   // Initialization (virtual from Klass)
   void initialize(TRAPS);
 
-  // GC specific object visitors
-  //
-#if INCLUDE_PARALLELGC
-  // Parallel Scavenge
-  void oop_ps_push_contents(  oop obj, PSPromotionManager* pm);
-  // Parallel Compact
-  void oop_pc_follow_contents(oop obj, ParCompactionManager* cm);
-  void oop_pc_update_pointers(oop obj, ParCompactionManager* cm);
-#endif
-
   // Oop fields (and metadata) iterators
   //
   // The ObjArrayKlass iterators also visits the Object's klass.
--- a/src/hotspot/share/oops/oop.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/oops/oop.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -285,16 +285,6 @@
   // mark-sweep support
   void follow_body(int begin, int end);
 
-  // Garbage Collection support
-
-#if INCLUDE_PARALLELGC
-  // Parallel Compact
-  inline void pc_follow_contents(ParCompactionManager* cm);
-  inline void pc_update_contents(ParCompactionManager* cm);
-  // Parallel Scavenge
-  inline void ps_push_contents(PSPromotionManager* pm);
-#endif
-
   template <typename OopClosureType>
   inline void oop_iterate(OopClosureType* cl);
 
--- a/src/hotspot/share/oops/oop.inline.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/oops/oop.inline.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -426,30 +426,6 @@
   }
 }
 
-#if INCLUDE_PARALLELGC
-void oopDesc::pc_follow_contents(ParCompactionManager* cm) {
-  klass()->oop_pc_follow_contents(this, cm);
-}
-
-void oopDesc::pc_update_contents(ParCompactionManager* cm) {
-  Klass* k = klass();
-  if (!k->is_typeArray_klass()) {
-    // It might contain oops beyond the header, so take the virtual call.
-    k->oop_pc_update_pointers(this, cm);
-  }
-  // Else skip it.  The TypeArrayKlass in the header never needs scavenging.
-}
-
-void oopDesc::ps_push_contents(PSPromotionManager* pm) {
-  Klass* k = klass();
-  if (!k->is_typeArray_klass()) {
-    // It might contain oops beyond the header, so take the virtual call.
-    k->oop_ps_push_contents(this, pm);
-  }
-  // Else skip it.  The TypeArrayKlass in the header never needs scavenging.
-}
-#endif // INCLUDE_PARALLELGC
-
 template <typename OopClosureType>
 void oopDesc::oop_iterate(OopClosureType* cl) {
   OopIteratorClosureDispatch::oop_oop_iterate(cl, this, klass());
--- a/src/hotspot/share/oops/typeArrayKlass.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/oops/typeArrayKlass.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -74,16 +74,6 @@
   // Copying
   void  copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
 
-  // GC specific object visitors
-  //
-#if INCLUDE_PARALLELGC
-  // Parallel Scavenge
-  void oop_ps_push_contents(  oop obj, PSPromotionManager* pm);
-  // Parallel Compact
-  void oop_pc_follow_contents(oop obj, ParCompactionManager* cm);
-  void oop_pc_update_pointers(oop obj, ParCompactionManager* cm);
-#endif
-
   // Oop iterators. Since there are no oops in TypeArrayKlasses,
   // these functions only return the size of the object.
 
--- a/src/hotspot/share/runtime/os.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/runtime/os.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -1153,7 +1153,11 @@
   }
 
   if (accessible) {
-    st->print_cr(INTPTR_FORMAT " points into unknown readable memory", p2i(addr));
+    st->print(INTPTR_FORMAT " points into unknown readable memory:", p2i(addr));
+    for (address p = addr; p < align_up(addr + 1, sizeof(intptr_t)); ++p) {
+      st->print(" %02x", *(u1*)p);
+    }
+    st->cr();
     return;
   }
 
--- a/src/hotspot/share/runtime/os.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/runtime/os.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -543,7 +543,7 @@
   static char* do_you_want_to_debug(const char* message);
 
   // run cmd in a separate process and return its exit code; or -1 on failures
-  static int fork_and_exec(char *cmd);
+  static int fork_and_exec(char *cmd, bool use_vfork_if_available = false);
 
   // Call ::exit() on all platforms but Windows
   static void exit(int num);
--- a/src/hotspot/share/runtime/threadHeapSampler.hpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/runtime/threadHeapSampler.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -39,10 +39,6 @@
   static int _enabled;
   static int _sampling_interval;
 
-  // Used for assertion mode to determine if there is a path to a TLAB slow path
-  // without a collector present.
-  size_t _collectors_present;
-
   static void init_log_table();
 
  public:
@@ -51,8 +47,6 @@
     if (_rnd == 0) {
       _rnd = 1;
     }
-
-    _collectors_present = 0;
   }
 
   size_t bytes_until_sample()                    { return _bytes_until_sample;   }
--- a/src/hotspot/share/runtime/vframe.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/runtime/vframe.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -134,7 +134,7 @@
     //
     // Skip the monitor that the thread is blocked to enter or waiting on
     //
-    if (!found_first_monitor && (obj == pending_obj || obj == waiting_obj)) {
+    if (!found_first_monitor && (oopDesc::equals(obj, pending_obj) || oopDesc::equals(obj, waiting_obj))) {
       continue;
     }
     found_first_monitor = true;
--- a/src/hotspot/share/runtime/vm_version.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/runtime/vm_version.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -218,10 +218,16 @@
         #define HOTSPOT_BUILD_COMPILER "MS VC++ 12.0 (VS2013)"
       #elif _MSC_VER == 1900
         #define HOTSPOT_BUILD_COMPILER "MS VC++ 14.0 (VS2015)"
+      #elif _MSC_VER == 1911
+        #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.3 (VS2017)"
       #elif _MSC_VER == 1912
         #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.5 (VS2017)"
       #elif _MSC_VER == 1913
         #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.6 (VS2017)"
+      #elif _MSC_VER == 1914
+        #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.7 (VS2017)"
+      #elif _MSC_VER == 1915
+        #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.8 (VS2017)"
       #else
         #define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER)
       #endif
--- a/src/hotspot/share/utilities/vmError.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/hotspot/share/utilities/vmError.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -756,6 +756,24 @@
        st->cr();
      }
 
+  STEP("inspecting top of stack")
+
+     // decode stack contents if possible
+     if (_verbose && _context && Universe::is_fully_initialized()) {
+       frame fr = os::fetch_frame_from_context(_context);
+       const int slots = 8;
+       const intptr_t *start = fr.sp();
+       const intptr_t *end = start + slots;
+       if (is_aligned(start, sizeof(intptr_t)) && os::is_readable_range(start, end)) {
+         st->print_cr("Stack slot to memory mapping:");
+         for (int i = 0; i < slots; ++i) {
+           st->print("stack at sp + %d slots: ", i);
+           os::print_location(st, *(start + i));
+         }
+       }
+       st->cr();
+     }
+
   STEP("printing code blob if possible")
 
      if (_verbose && _context) {
@@ -1565,7 +1583,7 @@
 #endif
     tty->print_cr("\"%s\"...", cmd);
 
-    if (os::fork_and_exec(cmd) < 0) {
+    if (os::fork_and_exec(cmd, true) < 0) {
       tty->print_cr("os::fork_and_exec failed: %s (%s=%d)",
                      os::strerror(errno), os::errno_name(errno), errno);
     }
--- a/src/java.base/share/classes/com/sun/crypto/provider/CipherCore.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/java.base/share/classes/com/sun/crypto/provider/CipherCore.java	Mon Oct 15 11:39:10 2018 -0700
@@ -253,11 +253,10 @@
         return result;
     }
 
-
     /**
      * Sets the padding mechanism of this cipher.
      *
-     * @param padding the padding mechanism
+     * @param paddingScheme the padding mechanism
      *
      * @exception NoSuchPaddingException if the requested padding mechanism
      * does not exist
@@ -660,10 +659,7 @@
      * (e.g., has not been initialized)
      */
     byte[] update(byte[] input, int inputOffset, int inputLen) {
-        if (requireReinit) {
-            throw new IllegalStateException
-                ("Must use either different key or iv for GCM encryption");
-        }
+        checkReinit();
 
         byte[] output = null;
         try {
@@ -711,10 +707,7 @@
      */
     int update(byte[] input, int inputOffset, int inputLen, byte[] output,
                int outputOffset) throws ShortBufferException {
-        if (requireReinit) {
-            throw new IllegalStateException
-                ("Must use either different key or iv for GCM encryption");
-        }
+        checkReinit();
 
         // figure out how much can be sent to crypto function
         int len = Math.addExact(buffered, inputLen);
@@ -849,12 +842,20 @@
      */
     byte[] doFinal(byte[] input, int inputOffset, int inputLen)
         throws IllegalBlockSizeException, BadPaddingException {
-        byte[] output = null;
         try {
-            output = new byte[getOutputSizeByOperation(inputLen, true)];
-            int len = doFinal(input, inputOffset, inputLen, output, 0);
-            if (len < output.length) {
-                byte[] copy = Arrays.copyOf(output, len);
+            checkReinit();
+            byte[] output = new byte[getOutputSizeByOperation(inputLen, true)];
+            byte[] finalBuf = prepareInputBuffer(input, inputOffset,
+                    inputLen, output, 0);
+            int finalOffset = (finalBuf == input) ? inputOffset : 0;
+            int finalBufLen = (finalBuf == input) ? inputLen : finalBuf.length;
+
+            int outLen = fillOutputBuffer(finalBuf, finalOffset, output, 0,
+                    finalBufLen, input);
+
+            endDoFinal();
+            if (outLen < output.length) {
+                byte[] copy = Arrays.copyOf(output, outLen);
                 if (decrypting) {
                     // Zero out internal (ouput) array
                     Arrays.fill(output, (byte) 0x00);
@@ -909,26 +910,81 @@
                 int outputOffset)
         throws IllegalBlockSizeException, ShortBufferException,
                BadPaddingException {
-        if (requireReinit) {
-            throw new IllegalStateException
-                ("Must use either different key or iv for GCM encryption");
-        }
+        checkReinit();
 
         int estOutSize = getOutputSizeByOperation(inputLen, true);
-        // check output buffer capacity.
-        // if we are decrypting with padding applied, we can perform this
-        // check only after we have determined how many padding bytes there
-        // are.
-        int outputCapacity = output.length - outputOffset;
-        int minOutSize = (decrypting? (estOutSize - blockSize):estOutSize);
-        if ((output == null) || (outputCapacity < minOutSize)) {
-            throw new ShortBufferException("Output buffer must be "
-                + "(at least) " + minOutSize + " bytes long");
+        int outputCapacity = checkOutputCapacity(output, outputOffset,
+                estOutSize);
+        int offset = decrypting ? 0 : outputOffset; // 0 for decrypting
+        byte[] finalBuf = prepareInputBuffer(input, inputOffset,
+                inputLen, output, outputOffset);
+        byte[] outWithPadding = null; // for decrypting only
+
+        int finalOffset = (finalBuf == input) ? inputOffset : 0;
+        int finalBufLen = (finalBuf == input) ? inputLen : finalBuf.length;
+
+        if (decrypting) {
+            // if the size of specified output buffer is less than
+            // the length of the cipher text, then the current
+            // content of cipher has to be preserved in order for
+            // users to retry the call with a larger buffer in the
+            // case of ShortBufferException.
+            if (outputCapacity < estOutSize) {
+                cipher.save();
+            }
+            // create temporary output buffer so that only "real"
+            // data bytes are passed to user's output buffer.
+            outWithPadding = new byte[estOutSize];
         }
+        byte[] outBuffer = decrypting ? outWithPadding : output;
 
+        int outLen = fillOutputBuffer(finalBuf, finalOffset, outBuffer,
+                offset, finalBufLen, input);
+
+        if (decrypting) {
+
+            if (outputCapacity < outLen) {
+                // restore so users can retry with a larger buffer
+                cipher.restore();
+                throw new ShortBufferException("Output buffer too short: "
+                                               + (outputCapacity)
+                                               + " bytes given, " + outLen
+                                               + " bytes needed");
+            }
+            // copy the result into user-supplied output buffer
+            System.arraycopy(outWithPadding, 0, output, outputOffset, outLen);
+            // decrypt mode. Zero out output data that's not required
+            Arrays.fill(outWithPadding, (byte) 0x00);
+        }
+        endDoFinal();
+        return outLen;
+    }
+
+    private void endDoFinal() {
+        buffered = 0;
+        diffBlocksize = blockSize;
+        if (cipherMode != ECB_MODE) {
+            cipher.reset();
+        }
+    }
+
+    private int unpad(int outLen, byte[] outWithPadding)
+            throws BadPaddingException {
+        int padStart = padding.unpad(outWithPadding, 0, outLen);
+        if (padStart < 0) {
+            throw new BadPaddingException("Given final block not " +
+            "properly padded. Such issues can arise if a bad key " +
+            "is used during decryption.");
+        }
+        outLen = padStart;
+        return outLen;
+    }
+
+    private byte[] prepareInputBuffer(byte[] input, int inputOffset,
+                      int inputLen, byte[] output, int outputOffset)
+                      throws IllegalBlockSizeException, ShortBufferException {
         // calculate total input length
         int len = Math.addExact(buffered, inputLen);
-
         // calculate padding length
         int totalLen = Math.addExact(len, cipher.getBufferedLength());
         int paddingLen = 0;
@@ -958,18 +1014,15 @@
          *  - there are internally buffered bytes
          *  - doing encryption and padding is needed
          */
-        byte[] finalBuf = input;
-        int finalOffset = inputOffset;
-        int finalBufLen = inputLen;
         if ((buffered != 0) || (!decrypting && padding != null) ||
             ((input == output)
               && (outputOffset - inputOffset < inputLen)
               && (inputOffset - outputOffset < buffer.length))) {
+            byte[] finalBuf;
             if (decrypting || padding == null) {
                 paddingLen = 0;
             }
             finalBuf = new byte[Math.addExact(len, paddingLen)];
-            finalOffset = 0;
             if (buffered != 0) {
                 System.arraycopy(buffer, 0, finalBuf, 0, buffered);
                 if (!decrypting) {
@@ -980,56 +1033,31 @@
             }
             if (inputLen != 0) {
                 System.arraycopy(input, inputOffset, finalBuf,
-                                 buffered, inputLen);
+                        buffered, inputLen);
             }
             if (paddingLen != 0) {
                 padding.padWithLen(finalBuf, Math.addExact(buffered, inputLen), paddingLen);
             }
-            finalBufLen = finalBuf.length;
+            return finalBuf;
         }
-        int outLen = 0;
-        if (decrypting) {
-            // if the size of specified output buffer is less than
-            // the length of the cipher text, then the current
-            // content of cipher has to be preserved in order for
-            // users to retry the call with a larger buffer in the
-            // case of ShortBufferException.
-            if (outputCapacity < estOutSize) {
-                cipher.save();
-            }
-            // create temporary output buffer so that only "real"
-            // data bytes are passed to user's output buffer.
-            byte[] outWithPadding = new byte[estOutSize];
-            outLen = finalNoPadding(finalBuf, finalOffset, outWithPadding,
-                                    0, finalBufLen);
+        return input;
+    }
 
-            if (padding != null) {
-                int padStart = padding.unpad(outWithPadding, 0, outLen);
-                if (padStart < 0) {
-                    throw new BadPaddingException("Given final block not " +
-                    "properly padded. Such issues can arise if a bad key " +
-                    "is used during decryption.");
-                }
-                outLen = padStart;
+    private int fillOutputBuffer(byte[] finalBuf, int finalOffset,
+                                 byte[] output, int outOfs, int finalBufLen,
+                                 byte[] input)
+            throws ShortBufferException, BadPaddingException,
+            IllegalBlockSizeException {
+        int len;
+        try {
+            len = finalNoPadding(finalBuf, finalOffset, output,
+                    outOfs, finalBufLen);
+            if (decrypting && padding != null) {
+                len = unpad(len, output);
             }
-
-            if (outputCapacity < outLen) {
-                // restore so users can retry with a larger buffer
-                cipher.restore();
-                throw new ShortBufferException("Output buffer too short: "
-                                               + (outputCapacity)
-                                               + " bytes given, " + outLen
-                                               + " bytes needed");
-            }
-            // copy the result into user-supplied output buffer
-            System.arraycopy(outWithPadding, 0, output, outputOffset, outLen);
-            // decrypt mode. Zero out output data that's not required
-            Arrays.fill(outWithPadding, (byte) 0x00);
-        } else { // encrypting
-            try {
-                outLen = finalNoPadding(finalBuf, finalOffset, output,
-                                        outputOffset, finalBufLen);
-            } finally {
+            return len;
+        } finally {
+            if (!decrypting) {
                 // reset after doFinal() for GCM encryption
                 requireReinit = (cipherMode == GCM_MODE);
                 if (finalBuf != input) {
@@ -1038,13 +1066,28 @@
                 }
             }
         }
+    }
 
-        buffered = 0;
-        diffBlocksize = blockSize;
-        if (cipherMode != ECB_MODE) {
-            cipher.reset();
+    private int checkOutputCapacity(byte[] output, int outputOffset,
+                            int estOutSize) throws ShortBufferException {
+        // check output buffer capacity.
+        // if we are decrypting with padding applied, we can perform this
+        // check only after we have determined how many padding bytes there
+        // are.
+        int outputCapacity = output.length - outputOffset;
+        int minOutSize = decrypting ? (estOutSize - blockSize) : estOutSize;
+        if ((output == null) || (outputCapacity < minOutSize)) {
+            throw new ShortBufferException("Output buffer must be "
+                + "(at least) " + minOutSize + " bytes long");
         }
-        return outLen;
+        return outputCapacity;
+    }
+
+    private void checkReinit() {
+        if (requireReinit) {
+            throw new IllegalStateException
+                ("Must use either different key or iv for GCM encryption");
+        }
     }
 
     private int finalNoPadding(byte[] in, int inOfs, byte[] out, int outOfs,
@@ -1177,10 +1220,7 @@
      * @since 1.8
      */
     void updateAAD(byte[] src, int offset, int len) {
-        if (requireReinit) {
-            throw new IllegalStateException
-                ("Must use either different key or iv for GCM encryption");
-        }
+        checkReinit();
         cipher.updateAAD(src, offset, len);
     }
 }
--- a/src/java.base/share/classes/java/lang/doc-files/ValueBased.html	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/java.base/share/classes/java/lang/doc-files/ValueBased.html	Mon Oct 15 11:39:10 2018 -0700
@@ -2,7 +2,7 @@
 <html lang="en">
 <head>
   <title>Value-based Classes</title>
-  <link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
+  <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
 </head>
 <body>
 <h2 id="ValueBased">Value-based Classes</h2>
--- a/src/java.base/share/classes/java/lang/doc-files/threadPrimitiveDeprecation.html	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/java.base/share/classes/java/lang/doc-files/threadPrimitiveDeprecation.html	Mon Oct 15 11:39:10 2018 -0700
@@ -26,7 +26,7 @@
 <html lang="en">
 <head>
   <title>Java Thread Primitive Deprecation</title>
-  <link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
+  <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
 </head>
 <body>
 <h2>Java Thread Primitive Deprecation</h2>
--- a/src/java.base/share/classes/java/net/SocketInputStream.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/java.base/share/classes/java/net/SocketInputStream.java	Mon Oct 15 11:39:10 2018 -0700
@@ -232,7 +232,11 @@
      * @return the number of immediately available bytes
      */
     public int available() throws IOException {
-        return impl.available();
+        if (eof) {
+            return 0;
+        } else {
+            return impl.available();
+        }
     }
 
     /**
--- a/src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java	Mon Oct 15 11:39:10 2018 -0700
@@ -133,9 +133,7 @@
         // A case insensitive TreeSet of strings.
         TreeSet<String> treeSet = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
         treeSet.addAll(Set.of("connection", "content-length",
-                "date", "expect", "from", "host", "origin",
-                "referer", "upgrade",
-                "via", "warning"));
+                "date", "expect", "from", "host", "upgrade", "via", "warning"));
         DISALLOWED_HEADERS_SET = Collections.unmodifiableSet(treeSet);
     }
 
--- a/test/hotspot/jtreg/runtime/jni/terminatedThread/TestTerminatedThread.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/runtime/jni/terminatedThread/TestTerminatedThread.java	Mon Oct 15 11:39:10 2018 -0700
@@ -85,10 +85,14 @@
             System.out.println("Calling getThreadCpuTime ...");
             long t1 = mbean.getThreadCpuTime(t.getId());
             if (t1 != -1) {
-                throw new RuntimeException("Invalid ThreadCpuTime returned = " +
-                                           t1 + " expected = -1");
+                // At least on PPC, we know threads can still be around a short
+                // instant. In some stress scenarios we seem to grab times of
+                // new threads started with the same thread id. In these cases
+                // we get here.
+                System.out.println("Unexpected: thread still reports CPU time: " + t1);
+            } else {
+                System.out.println("Okay: getThreadCpuTime() reported -1 as expected");
             }
-            System.out.println("Okay: getThreadCpuTime() reported -1 as expected");
         } else {
             System.out.println("Skipping Thread CPU time test as it's not supported");
         }
@@ -96,10 +100,14 @@
         System.out.println("Calling getThreadUserTime ...");
         long t1 = mbean.getThreadUserTime(t.getId());
         if (t1 != -1) {
-            throw new RuntimeException("Invalid ThreadUserTime returned = " +
-                                       t1 + " expected = -1");
+            // At least on PPC, we know threads can still be around a short
+            // instant. In some stress scenarios we seem to grab times of
+            // new threads started with the same thread id. In these cases
+            // we get here.
+            System.out.println("Unexpected: thread still reports User time: " + t1);
+        } else {
+            System.out.println("Okay: getThreadUserTime() reported -1 as expected");
         }
-        System.out.println("Okay: getThreadUserTime() reported -1 as expected");
 
         System.out.println("Calling getThreadInfo ...");
         ThreadInfo info = mbean.getThreadInfo(t.getId());
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor001/setenvstor001.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor001/setenvstor001.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -73,8 +73,7 @@
 static int setEnvStorage(jvmtiEnv* jvmti, StorageStructure* storage, const char where[]) {
 
     NSK_DISPLAY1("Set local storage for current JVMTI env: 0x%p\n", (void*)storage);
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(SetEnvironmentLocalStorage, jvmti, storage))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEnvironmentLocalStorage(storage))) {
         return NSK_FALSE;
     }
     NSK_DISPLAY0("  ... ok\n");
@@ -89,8 +88,7 @@
     StorageStructure* storage = NULL;
 
     NSK_DISPLAY0("Get local storage for current JVMTI env\n");
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(GetEnvironmentLocalStorage, jvmti, (void**)&storage))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->GetEnvironmentLocalStorage((void**)&storage))) {
         return NSK_FALSE;
     }
     NSK_DISPLAY1("  ... got storage: 0x%p\n", (void*)storage);
@@ -216,9 +214,7 @@
         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
         eventCallbacks.VMInit = callbackVMInit;
         eventCallbacks.VMDeath = callbackVMDeath;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetEventCallbacks, jvmti,
-                                    &eventCallbacks, sizeof(eventCallbacks)))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {
             return JNI_ERR;
         }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor002/setenvstor002.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor002/setenvstor002.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -73,8 +73,7 @@
 static int setEnvStorage(jvmtiEnv* jvmti, StorageStructure* storage, const char where[]) {
 
     NSK_DISPLAY1("Set local storage for current JVMTI env: 0x%p\n", (void*)storage);
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(SetEnvironmentLocalStorage, jvmti, storage))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEnvironmentLocalStorage(storage))) {
         return NSK_FALSE;
     }
     NSK_DISPLAY0("  ... ok\n");
@@ -89,8 +88,7 @@
     StorageStructure* storage = NULL;
 
     NSK_DISPLAY0("Get local storage for current JVMTI env\n");
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(GetEnvironmentLocalStorage, jvmti, (void**)&storage))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->GetEnvironmentLocalStorage((void**)&storage))) {
         return NSK_FALSE;
     }
     NSK_DISPLAY1("  ... got storage: 0x%p\n", (void*)storage);
@@ -221,9 +219,7 @@
         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
         eventCallbacks.VMInit = callbackVMInit;
         eventCallbacks.VMDeath = callbackVMDeath;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetEventCallbacks, jvmti,
-                                    &eventCallbacks, sizeof(eventCallbacks)))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {
             return JNI_ERR;
         }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor003/setenvstor003.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor003/setenvstor003.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -73,8 +73,7 @@
 static int setEnvStorage(jvmtiEnv* jvmti, StorageStructure* storage, const char where[]) {
 
     NSK_DISPLAY1("Set local storage for current JVMTI env: 0x%p\n", (void*)storage);
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(SetEnvironmentLocalStorage, jvmti, storage))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEnvironmentLocalStorage(storage))) {
         return NSK_FALSE;
     }
     NSK_DISPLAY0("  ... ok\n");
@@ -89,8 +88,7 @@
     StorageStructure* storage = NULL;
 
     NSK_DISPLAY0("Get local storage for current JVMTI env\n");
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(GetEnvironmentLocalStorage, jvmti, (void**)&storage))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->GetEnvironmentLocalStorage((void**)&storage))) {
         return NSK_FALSE;
     }
     NSK_DISPLAY1("  ... got storage: 0x%p\n", (void*)storage);
@@ -224,9 +222,7 @@
         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
         eventCallbacks.VMInit = callbackVMInit;
         eventCallbacks.VMDeath = callbackVMDeath;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetEventCallbacks, jvmti,
-                                    &eventCallbacks, sizeof(eventCallbacks)))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {
             return JNI_ERR;
         }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb001/setevntcallb001.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb001/setevntcallb001.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -143,9 +143,7 @@
         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
         eventCallbacks.ThreadStart = callbackThreadStart;
         eventCallbacks.ThreadEnd = callbackThreadEnd;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetEventCallbacks, jvmti,
-                                    &eventCallbacks, sizeof(eventCallbacks)))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {
             nsk_jvmti_setFailStatus();
         } else {
             nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT - 1, eventsList + 1, NULL);
@@ -190,9 +188,7 @@
 
         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
         eventCallbacks.VMInit = callbackVMInit;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetEventCallbacks, jvmti,
-                                    &eventCallbacks, sizeof(eventCallbacks)))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {
             nsk_jvmti_setFailStatus();
         } else {
             nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, eventsList, NULL);
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb002/setevntcallb002.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb002/setevntcallb002.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -145,8 +145,7 @@
 
     NSK_DISPLAY0(">>> Testcase #2: Set NULL for events callbacks\n");
     {
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetEventCallbacks, jvmti, NULL, 0))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(NULL, 0))) {
             nsk_jvmti_setFailStatus();
         }
 
@@ -193,9 +192,7 @@
         eventCallbacks.VMInit = callbackVMInit;
         eventCallbacks.ThreadStart = callbackThreadStart;
         eventCallbacks.ThreadEnd = callbackThreadEnd;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetEventCallbacks, jvmti,
-                                    &eventCallbacks, sizeof(eventCallbacks)))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {
             nsk_jvmti_setFailStatus();
         } else {
             nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, eventsList, NULL);
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb003/setevntcallb003.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb003/setevntcallb003.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -151,9 +151,7 @@
         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
         eventCallbacks.ThreadStart = callbackThreadStart;
         eventCallbacks.ThreadEnd = callbackThreadEnd;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetEventCallbacks, jvmti,
-                                    &eventCallbacks, size))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, size))) {
             nsk_jvmti_setFailStatus();
         }
 
@@ -198,9 +196,7 @@
 
         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
         eventCallbacks.VMInit = callbackVMInit;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetEventCallbacks, jvmti,
-                                    &eventCallbacks, sizeof(eventCallbacks)))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {
             nsk_jvmti_setFailStatus();
         } else {
             nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, eventsList, NULL);
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetExtensionEventCallback/setextevent001/setextevent001.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetExtensionEventCallback/setextevent001/setextevent001.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -48,8 +48,7 @@
     int i;
 
     NSK_DISPLAY0("Get extension events list\n");
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetExtensionEvents, jvmti, &extCount, &extList))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->GetExtensionEvents(&extCount, &extList))) {
         return NSK_FALSE;
     }
     NSK_DISPLAY1("  ... got count: %d\n", (int)extCount);
@@ -72,18 +71,14 @@
 
             NSK_DISPLAY1("    ... setting callback: 0x%p\n", (void*)callbackExtensionEvent);
             if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB3(SetExtensionEventCallback, jvmti,
-                                        extList[i].extension_event_index,
-                                        callbackExtensionEvent))) {
+                    jvmti->SetExtensionEventCallback(extList[i].extension_event_index, callbackExtensionEvent))) {
                 success = NSK_FALSE;
             }
             NSK_DISPLAY0("    ... done\n");
 
             NSK_DISPLAY1("    ... clearing callback: 0x%p\n", (void*)NULL);
             if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB3(SetExtensionEventCallback, jvmti,
-                                        extList[i].extension_event_index,
-                                        NULL))) {
+                    jvmti->SetExtensionEventCallback(extList[i].extension_event_index, NULL))) {
                 success = NSK_FALSE;
             }
             NSK_DISPLAY0("    ... done\n");
@@ -91,8 +86,7 @@
     }
 
     NSK_DISPLAY1("Deallocate extension events list: 0x%p\n", (void*)extList);
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)extList))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)extList))) {
         return NSK_FALSE;
     }
     NSK_DISPLAY0("  ... deallocated\n");
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix001/SetNativeMethodPrefix001.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix001/SetNativeMethodPrefix001.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -123,27 +123,11 @@
     char *str = NULL;
 
     if (prefix != NULL) {
-        if (!NSK_VERIFY(
-                (str = (char *) NSK_CPP_STUB3(
-                              GetStringUTFChars
-                              , jni
-                              , prefix
-                              , 0
-                         )
-                    ) != NULL
-                )
-           )
+        if (!NSK_VERIFY((str = (char *) jni->GetStringUTFChars(prefix, 0)) != NULL))
         { result = JNI_FALSE; goto finally; }
     }
 
-    if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(
-                    SetNativeMethodPrefix
-                    , jvmti
-                    , str
-                    )
-                )
-       )
+    if (!NSK_JVMTI_VERIFY(jvmti->SetNativeMethodPrefix(str)))
     { result = JNI_FALSE; goto finally; }
 
     if (str != NULL) {
@@ -175,27 +159,10 @@
     char *str = NULL;
 
     if (prefix != NULL) {
-        if (!NSK_VERIFY(
-                (str = (char *) NSK_CPP_STUB3(
-                              GetStringUTFChars
-                              , jni
-                              , prefix
-                              , 0
-                         )
-                    ) != NULL
-                )
-           )
+        if (!NSK_VERIFY((str = (char *) jni->GetStringUTFChars(prefix, 0)) != NULL))
         { result = JNI_FALSE; goto finally; }
 
-        if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB3(
-                        SetNativeMethodPrefixes
-                        , jvmti
-                        , 1
-                        , (char **) &str
-                        )
-                    )
-           )
+        if (!NSK_JVMTI_VERIFY(jvmti->SetNativeMethodPrefixes(1, (char **) &str)))
         { result = JNI_FALSE; goto finally; }
 
         NSK_DISPLAY1("MultiplePrefixes: New PREFIX is set: %s\n"
@@ -205,15 +172,7 @@
         char* prefixes[1];
         prefixes[0] = NULL;
 
-        if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB3(
-                        SetNativeMethodPrefixes
-                        , jvmti
-                        , 0
-                        , (char **)&prefixes
-                        )
-                    )
-           )
+        if (!NSK_JVMTI_VERIFY(jvmti->SetNativeMethodPrefixes(0, (char **)&prefixes)))
         { result = JNI_FALSE; goto finally; }
 
         NSK_DISPLAY0("Old PREFIX is reset\n");
@@ -250,33 +209,11 @@
         return JNI_FALSE;
     }
 
-    if (!NSK_VERIFY(
-            (method.name =
-                (char *) NSK_CPP_STUB3(
-                     GetStringUTFChars
-                     , jni
-                     , method_name_obj
-                     , 0
-                    )
-            ) != NULL
-            )
-       )
-    {
+    if (!NSK_VERIFY((method.name = (char *) jni->GetStringUTFChars(method_name_obj, 0)) != NULL)) {
         goto finally;
     }
 
-    if (!NSK_VERIFY(
-            (method.signature =
-                    (char *) NSK_CPP_STUB3(
-                         GetStringUTFChars
-                         , jni
-                         , method_sig_obj
-                         , 0
-                    )
-            ) != NULL
-            )
-       )
-    {
+    if (!NSK_VERIFY((method.signature = (char *) jni->GetStringUTFChars(method_sig_obj, 0)) != NULL)) {
         goto finally;
     }
 
@@ -341,25 +278,13 @@
        )
         return JNI_ERR;
 
-    if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(
-                    GetCapabilities
-                    , jvmti
-                    , &caps)
-                )
-       )
+    if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
         return JNI_ERR;
 
     // Register all necessary JVM capabilities
     caps.can_set_native_method_prefix = 1;
 
-    if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(
-                    AddCapabilities
-                    , jvmti
-                    , &caps)
-                )
-       )
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
         return JNI_ERR;
 
     return JNI_OK;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/SetNativeMethodPrefix002.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/SetNativeMethodPrefix002.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -60,13 +60,7 @@
 
 static jboolean setMethodPrefix (char *prefix)
 {
-    if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(
-                    SetNativeMethodPrefix
-                    , jvmti
-                    , prefix)
-                )
-       )
+    if (!NSK_JVMTI_VERIFY(jvmti->SetNativeMethodPrefix(prefix)))
         return JNI_FALSE;
 
     return JNI_TRUE;
@@ -114,25 +108,13 @@
        )
         return JNI_ERR;
 
-    if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(
-                    GetCapabilities
-                    , jvmti
-                    , &caps)
-                )
-       )
+    if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
         return JNI_ERR;
 
     // Register all necessary JVM capabilities
     caps.can_set_native_method_prefix = 1;
 
-    if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(
-                    AddCapabilities
-                    , jvmti
-                    , &caps)
-                )
-       )
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
         return JNI_ERR;
 
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetSystemProperty/setsysprop002/setsysprop002.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetSystemProperty/setsysprop002/setsysprop002.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -76,8 +76,7 @@
     char* value = NULL;
 
     NSK_DISPLAY1("  property: %s\n", name);
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetSystemProperty, jvmti, name, &value))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->GetSystemProperty(name, &value))) {
         return NSK_FALSE;
     }
     NSK_DISPLAY1("     value: \"%s\"\n", nsk_null_string(value));
@@ -93,8 +92,7 @@
         success = NSK_FALSE;
     }
 
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)value))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)value))) {
         success = NSK_FALSE;
     }
 
@@ -120,14 +118,12 @@
         NSK_DISPLAY1("     value: \"%s\"\n", propDescList[i].values[step]);
         if (step > 1) {
             if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_WRONG_PHASE,
-                   NSK_CPP_STUB3(SetSystemProperty, jvmti,
-                     propDescList[i].name, propDescList[i].values[step]))) {
+                   jvmti->SetSystemProperty(propDescList[i].name, propDescList[i].values[step]))) {
                 success = NSK_FALSE;
             }
         } else {
             if (!NSK_JVMTI_VERIFY(
-                   NSK_CPP_STUB3(SetSystemProperty, jvmti,
-                     propDescList[i].name, propDescList[i].values[step]))) {
+                   jvmti->SetSystemProperty(propDescList[i].name, propDescList[i].values[step]))) {
                 success = NSK_FALSE;
             }
         }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetSystemProperty/setsysprop003/setsysprop003.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetSystemProperty/setsysprop003/setsysprop003.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -56,8 +56,7 @@
         NSK_DISPLAY1("  property: %s\n", propDescList[i].name);
         NSK_DISPLAY1("     value: \"%s\"\n", propDescList[i].value);
         if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetSystemProperty, jvmti,
-                                propDescList[i].name, propDescList[i].value))) {
+                jvmti->SetSystemProperty(propDescList[i].name, propDescList[i].value))) {
             success = NSK_FALSE;
         }
     }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetTag/settag001/settag001.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetTag/settag001/settag001.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -61,7 +61,7 @@
 
             NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME);
             if (!NSK_JNI_VERIFY(jni, (debugeeClass =
-                    NSK_CPP_STUB2(FindClass, jni, DEBUGEE_CLASS_NAME)) != NULL)) {
+                    jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) {
                 nsk_jvmti_setFailStatus();
                 return;
             }
@@ -69,8 +69,7 @@
 
             NSK_DISPLAY1("Find static field: %s\n", OBJECT_FIELD_NAME);
             if (!NSK_JNI_VERIFY(jni, (objectField =
-                    NSK_CPP_STUB4(GetStaticFieldID, jni, debugeeClass,
-                                    OBJECT_FIELD_NAME, OBJECT_CLASS_SIG)) != NULL)) {
+                    jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, OBJECT_CLASS_SIG)) != NULL)) {
                 nsk_jvmti_setFailStatus();
                 return;
             }
@@ -78,16 +77,14 @@
 
             NSK_DISPLAY1("Get object from static field: %s\n", OBJECT_FIELD_NAME);
             if (!NSK_JNI_VERIFY(jni, (testedObject =
-                    NSK_CPP_STUB3(GetStaticObjectField, jni, debugeeClass,
-                                                            objectField)) != NULL)) {
+                    jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) {
                 nsk_jvmti_setFailStatus();
                 return;
             }
             NSK_DISPLAY1("  ... got object: 0x%p\n", (void*)testedObject);
 
             NSK_DISPLAY1("Create global reference for object: 0x%p\n", (void*)testedObject);
-            if (!NSK_JNI_VERIFY(jni, (testedObject =
-                    NSK_CPP_STUB2(NewGlobalRef, jni, testedObject)) != NULL)) {
+            if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != NULL)) {
                 nsk_jvmti_setFailStatus();
                 return;
             }
@@ -97,8 +94,7 @@
         NSK_DISPLAY0(">>> Testcase #1: set tag for the tested object\n");
         {
             NSK_DISPLAY1("Set tag for object: 0x%p\n", (void*)testedObject);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB3(SetTag, jvmti, testedObject, objectTag))) {
+            if (!NSK_JVMTI_VERIFY(jvmti->SetTag(testedObject, objectTag))) {
                 nsk_jvmti_setFailStatus();
                 return;
             }
@@ -110,8 +106,7 @@
             jlong tag = 222;
 
             NSK_DISPLAY1("Get tag for object: 0x%p\n", (void*)testedObject);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB3(GetTag, jvmti, testedObject, &tag))) {
+            if (!NSK_JVMTI_VERIFY(jvmti->GetTag(testedObject, &tag))) {
                 nsk_jvmti_setFailStatus();
                 return;
             }
@@ -140,8 +135,7 @@
                 return;
 
             NSK_DISPLAY1("Get tag for object: 0x%p\n", (void*)testedObject);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB3(GetTag, jvmti, testedObject, &tag))) {
+            if (!NSK_JVMTI_VERIFY(jvmti->GetTag(testedObject, &tag))) {
                 nsk_jvmti_setFailStatus();
                 return;
             }
@@ -162,7 +156,7 @@
         NSK_DISPLAY0(">>> Clean used data\n");
         {
             NSK_DISPLAY1("Delete object reference: 0x%p\n", (void*)testedObject);
-            NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, testedObject));
+            NSK_TRACE(jni->DeleteGlobalRef(testedObject));
         }
     }
 
@@ -205,8 +199,7 @@
 
         memset(&caps, 0, sizeof(caps));
         caps.can_tag_objects = 1;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
             return JNI_ERR;
         }
     }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor001/setthrdstor001.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor001/setthrdstor001.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -73,9 +73,7 @@
 
         NSK_DISPLAY1("SetThreadLocalStorage() for tested thread with pointer: %p\n",
                                                     (void*)initialStorage);
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetThreadLocalStorage, jvmti,
-                                        testedThread, (void*)initialStorage))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->SetThreadLocalStorage(testedThread, (void*)initialStorage))) {
             nsk_jvmti_setFailStatus();
             return;
         }
@@ -90,8 +88,7 @@
 
         NSK_DISPLAY0("GetThreadLocalStorage() for tested thread\n");
         if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadLocalStorage, jvmti,
-                                        testedThread, (void**)&obtainedStorage))) {
+                jvmti->GetThreadLocalStorage(testedThread, (void**)&obtainedStorage))) {
             nsk_jvmti_setFailStatus();
             return;
         }
@@ -128,7 +125,7 @@
         }
 
         NSK_DISPLAY0("Delete thread reference\n");
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, testedThread));
+        NSK_TRACE(jni->DeleteGlobalRef(testedThread));
     }
 
     NSK_DISPLAY0("Let debugee to finish\n");
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor002/setthrdstor002.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor002/setthrdstor002.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -66,9 +66,7 @@
 
         NSK_DISPLAY1("SetThreadLocalStorage() for current agent thread with pointer: %p\n",
                                                     (void*)initialStorage);
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetThreadLocalStorage, jvmti,
-                                        NULL, (void*)initialStorage))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->SetThreadLocalStorage(NULL, (void*)initialStorage))) {
             nsk_jvmti_setFailStatus();
             return;
         }
@@ -82,9 +80,7 @@
             return;
 
         NSK_DISPLAY0("GetThreadLocalStorage() for current agent thread\n");
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadLocalStorage, jvmti,
-                                        NULL, (void**)&obtainedStorage))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadLocalStorage(NULL, (void**)&obtainedStorage))) {
             nsk_jvmti_setFailStatus();
             return;
         }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor003/setthrdstor003.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor003/setthrdstor003.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -120,8 +120,7 @@
     if (thread != NULL) {
         jvmtiThreadInfo info;
 
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, thread, &info))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(thread, &info))) {
             nsk_jvmti_setFailStatus();
             return;
         }
@@ -133,9 +132,7 @@
 
             NSK_DISPLAY1("SetThreadLocalStorage() for current thread with pointer: %p\n",
                                                                 (void*)initialStorage);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB3(SetThreadLocalStorage, jvmti,
-                                        NULL, (void*)initialStorage))) {
+            if (!NSK_JVMTI_VERIFY(jvmti->SetThreadLocalStorage(NULL, (void*)initialStorage))) {
                 nsk_jvmti_setFailStatus();
                 return;
             }
@@ -151,8 +148,7 @@
     if (thread != NULL) {
         jvmtiThreadInfo info;
 
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, thread, &info))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(thread, &info))) {
             nsk_jvmti_setFailStatus();
             return;
         }
@@ -168,8 +164,7 @@
 
                 NSK_DISPLAY0("GetThreadLocalStorage() for current thread\n");
                 if (!NSK_JVMTI_VERIFY(
-                        NSK_CPP_STUB3(GetThreadLocalStorage, jvmti,
-                                            NULL, (void**)&obtainedStorage))) {
+                        jvmti->GetThreadLocalStorage(NULL, (void**)&obtainedStorage))) {
                     nsk_jvmti_setFailStatus();
                     return;
                 }
@@ -243,8 +238,7 @@
         memset(&callbacks, 0, sizeof(callbacks));
         callbacks.ThreadStart = callbackThreadStart;
         callbacks.ThreadEnd = callbackThreadEnd;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetEventCallbacks, jvmti, &callbacks, sizeof(callbacks))))
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
         return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA08/ma08t001/ma08t001.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA08/ma08t001/ma08t001.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -60,8 +60,7 @@
     NSK_DISPLAY0("Prepare: find tested thread\n");
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-           NSK_CPP_STUB3(GetAllThreads, jvmti, &threads_count, &threads)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(threads_count > 0 && threads != NULL))
@@ -73,8 +72,7 @@
             return NSK_FALSE;
 
         /* get thread information */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, threads[i], &info)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(threads[i], &info)))
             return NSK_FALSE;
 
         NSK_DISPLAY3("    thread #%d (%s): %p\n", i, info.name, threads[i]);
@@ -90,8 +88,7 @@
     }
 
     /* deallocate threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threads)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads)))
         return NSK_FALSE;
 
     if (threadForStop == NULL) {
@@ -106,17 +103,14 @@
 
     NSK_DISPLAY0("Prepare: create new instance of ThreadDeath exception\n");
 
-    if (!NSK_JNI_VERIFY(jni, (cls =
-            NSK_CPP_STUB2(FindClass, jni, THREAD_DEATH_CLASS_NAME)) != NULL))
+    if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL))
         return NSK_FALSE;
 
     if (!NSK_JNI_VERIFY(jni, (ctor =
-            NSK_CPP_STUB4(GetMethodID, jni, cls,
-                THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL))
+            jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL))
         return NSK_FALSE;
 
-    if (!NSK_JNI_VERIFY(jni, (threadDeath =
-            NSK_CPP_STUB3(NewObject, jni, cls, ctor)) != NULL))
+    if (!NSK_JNI_VERIFY(jni, (threadDeath = jni->NewObject(cls, ctor)) != NULL))
         return NSK_FALSE;
 
     return NSK_TRUE;
@@ -140,8 +134,7 @@
     if (!NSK_VERIFY(threadForStop != NULL)) {
         nsk_jvmti_setFailStatus();
     } else {
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(StopThread, jvmti, threadForStop, threadDeath)))
+        if (!NSK_JVMTI_VERIFY(jvmti->StopThread(threadForStop, threadDeath)))
             nsk_jvmti_setFailStatus();
     }
 
@@ -149,8 +142,7 @@
     if (!NSK_VERIFY(threadForInterrupt != NULL)) {
         nsk_jvmti_setFailStatus();
     } else {
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(InterruptThread, jvmti, threadForInterrupt)))
+        if (!NSK_JVMTI_VERIFY(jvmti->InterruptThread(threadForInterrupt)))
             nsk_jvmti_setFailStatus();
     }
 
@@ -199,7 +191,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_signal_thread = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA08/ma08t001/ma08t001a.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA08/ma08t001/ma08t001a.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -56,14 +56,12 @@
     jclass klass = NULL;
     char *signature = NULL;
 
-    if (!NSK_JNI_VERIFY(jni_env, (klass =
-            NSK_CPP_STUB2(GetObjectClass, jni_env, exception)) != NULL)) {
+    if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) {
         nsk_jvmti_setFailStatus();
         return;
     }
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, jvmti_env,
-            klass, &signature, NULL))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) {
         nsk_jvmti_setFailStatus();
         return;
     }
@@ -75,7 +73,7 @@
 
     NSK_DISPLAY1("Exception event: %s\n", signature);
 
-    if (NSK_CPP_STUB3(IsSameObject, jni_env, threadForInterrupt, thread)) {
+    if (jni_env->IsSameObject(threadForInterrupt, thread)) {
         if (strcmp(signature, INTERRUPTED_EXCEPTION_CLASS_SIG) == 0) {
             InterruptedExceptionFlag++;
         } else {
@@ -83,7 +81,7 @@
                 signature);
             nsk_jvmti_setFailStatus();
         }
-    } else if (NSK_CPP_STUB3(IsSameObject, jni_env, threadForStop, thread)) {
+    } else if (jni_env->IsSameObject(threadForStop, thread)) {
         if (strcmp(signature, THREAD_DEATH_CLASS_SIG) == 0) {
             ThreadDeathFlag++;
         } else {
@@ -93,7 +91,7 @@
         }
     }
 
-    NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
+    jvmti_env->Deallocate((unsigned char*)signature);
 }
 
 /* ========================================================================== */
@@ -109,8 +107,7 @@
     NSK_DISPLAY0("Prepare: find tested thread\n");
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-           NSK_CPP_STUB3(GetAllThreads, jvmti, &threads_count, &threads)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(threads_count > 0 && threads != NULL))
@@ -122,8 +119,7 @@
             return NSK_FALSE;
 
         /* get thread information */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, threads[i], &info)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(threads[i], &info)))
             return NSK_FALSE;
 
         NSK_DISPLAY3("    thread #%d (%s): %p\n", i, info.name, threads[i]);
@@ -139,8 +135,7 @@
     }
 
     /* deallocate threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threads)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads)))
         return NSK_FALSE;
 
     if (threadForStop == NULL) {
@@ -153,17 +148,14 @@
         return NSK_FALSE;
     }
 
-    if (!NSK_JNI_VERIFY(jni, (threadForStop =
-            NSK_CPP_STUB2(NewGlobalRef, jni, threadForStop)) != NULL))
+    if (!NSK_JNI_VERIFY(jni, (threadForStop = jni->NewGlobalRef(threadForStop)) != NULL))
         return NSK_FALSE;
 
-    if (!NSK_JNI_VERIFY(jni, (threadForInterrupt =
-            NSK_CPP_STUB2(NewGlobalRef, jni, threadForInterrupt)) != NULL))
+    if (!NSK_JNI_VERIFY(jni, (threadForInterrupt = jni->NewGlobalRef(threadForInterrupt)) != NULL))
         return NSK_FALSE;
 
     /* enable event */
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, NULL)))
         return NSK_FALSE;
 
     return NSK_TRUE;
@@ -199,12 +191,11 @@
         nsk_jvmti_setFailStatus();
 
     /* disable event */
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION, NULL)))
         nsk_jvmti_setFailStatus();
 
-    NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadForStop));
-    NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadForInterrupt));
+    NSK_TRACE(jni->DeleteGlobalRef(threadForStop));
+    NSK_TRACE(jni->DeleteGlobalRef(threadForInterrupt));
 
     if (!nsk_jvmti_resumeSync())
         return;
@@ -245,7 +236,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_exception_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t001/ma10t001.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t001/ma10t001.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -58,19 +58,17 @@
 
     ExceptionEventsCount++;
 
-    if (!NSK_JNI_VERIFY(jni_env, (klass =
-            NSK_CPP_STUB2(GetObjectClass, jni_env, exception)) != NULL)) {
+    if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) {
         nsk_jvmti_setFailStatus();
         return;
     }
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, jvmti_env,
-            klass, &signature, NULL))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) {
         nsk_jvmti_setFailStatus();
         return;
     }
     NSK_DISPLAY1("Exception event: %s\n", signature);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
+        jvmti_env->Deallocate((unsigned char*)signature);
 }
 
 void JNICALL
@@ -85,19 +83,17 @@
 
     ExceptionCatchEventsCount++;
 
-    if (!NSK_JNI_VERIFY(jni_env, (klass =
-            NSK_CPP_STUB2(GetObjectClass, jni_env, exception)) != NULL)) {
+    if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) {
         nsk_jvmti_setFailStatus();
         return;
     }
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, jvmti_env,
-            klass, &signature, NULL))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) {
         nsk_jvmti_setFailStatus();
         return;
     }
     NSK_DISPLAY1("ExceptionCatch event: %s\n", signature);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
+        jvmti_env->Deallocate((unsigned char*)signature);
 }
 
 /* ========================================================================== */
@@ -109,11 +105,9 @@
     if (!nsk_jvmti_waitForSync(timeout))
         return;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, NULL)))
         nsk_jvmti_setFailStatus();
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL)))
         nsk_jvmti_setFailStatus();
 
     /* resume debugee and wait for sync */
@@ -122,11 +116,9 @@
     if (!nsk_jvmti_waitForSync(timeout))
         return;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION, NULL)))
         nsk_jvmti_setFailStatus();
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL)))
         nsk_jvmti_setFailStatus();
 
     NSK_DISPLAY1("Exception events received: %d\n",
@@ -178,7 +170,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_exception_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t001/ma10t001a.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t001/ma10t001a.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -54,19 +54,17 @@
 
     ExceptionEventsCount++;
 
-    if (!NSK_JNI_VERIFY(jni_env, (klass =
-            NSK_CPP_STUB2(GetObjectClass, jni_env, exception)) != NULL)) {
+    if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) {
         nsk_jvmti_setFailStatus();
         return;
     }
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, jvmti_env,
-            klass, &signature, NULL))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) {
         nsk_jvmti_setFailStatus();
         return;
     }
     NSK_DISPLAY1("Exception event: %s\n", signature);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
+        jvmti_env->Deallocate((unsigned char*)signature);
 }
 
 void JNICALL
@@ -77,19 +75,17 @@
 
     ExceptionCatchEventsCount++;
 
-    if (!NSK_JNI_VERIFY(jni_env, (klass =
-            NSK_CPP_STUB2(GetObjectClass, jni_env, exception)) != NULL)) {
+    if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) {
         nsk_jvmti_setFailStatus();
         return;
     }
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, jvmti_env,
-            klass, &signature, NULL))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) {
         nsk_jvmti_setFailStatus();
         return;
     }
     NSK_DISPLAY1("ExceptionCatch event: %s\n", signature);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
+        jvmti_env->Deallocate((unsigned char*)signature);
 }
 
 /* ========================================================================== */
@@ -156,7 +152,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_exception_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t002/ma10t002.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t002/ma10t002.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -54,16 +54,15 @@
     char *signature = NULL;
 
     MethodEntryEventsCount++;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName,
-            jvmti_env, method, &name, &signature, NULL))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) {
         nsk_jvmti_setFailStatus();
         return;
     }
     NSK_DISPLAY2("MethodEntry event: %s%s\n", name, signature);
     if (name != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name);
+        jvmti_env->Deallocate((unsigned char*)name);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
+        jvmti_env->Deallocate((unsigned char*)signature);
 }
 
 /* ========================================================================== */
@@ -78,8 +77,7 @@
     NSK_DISPLAY0("Prepare: find tested thread\n");
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-           NSK_CPP_STUB3(GetAllThreads, jvmti, &threads_count, &threads)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(threads_count > 0 && threads != NULL))
@@ -91,8 +89,7 @@
             return NSK_FALSE;
 
         /* get thread information */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, threads[i], &info)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(threads[i], &info)))
             return NSK_FALSE;
 
         NSK_DISPLAY3("    thread #%d (%s): %p\n", i, info.name, threads[i]);
@@ -103,13 +100,11 @@
         }
     }
 
-    if (!NSK_JNI_VERIFY(jni, (thread =
-            NSK_CPP_STUB2(NewGlobalRef, jni, thread)) != NULL))
+    if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL))
         return NSK_FALSE;
 
     /* deallocate threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threads)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads)))
         return NSK_FALSE;
 
     return NSK_TRUE;
@@ -129,8 +124,7 @@
         return;
     }
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, thread)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, thread)))
         nsk_jvmti_setFailStatus();
 
     /* resume debugee and wait for sync */
@@ -144,7 +138,7 @@
     if (!NSK_VERIFY(MethodEntryEventsCount != 0))
         nsk_jvmti_setFailStatus();
 
-    NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, thread));
+    NSK_TRACE(jni->DeleteGlobalRef(thread));
 
     if (!nsk_jvmti_resumeSync())
         return;
@@ -185,7 +179,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_method_entry_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t002/ma10t002a.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t002/ma10t002a.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -51,16 +51,15 @@
     char *signature = NULL;
 
     MethodEntryEventsCount++;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName,
-            jvmti_env, method, &name, &signature, NULL))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) {
         nsk_jvmti_setFailStatus();
         return;
     }
     NSK_DISPLAY2("MethodEntry event: %s%s\n", name, signature);
     if (name != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name);
+        jvmti_env->Deallocate((unsigned char*)name);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
+        jvmti_env->Deallocate((unsigned char*)signature);
 }
 
 /* ========================================================================== */
@@ -122,7 +121,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_method_entry_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t003/ma10t003.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t003/ma10t003.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -55,16 +55,15 @@
     char *signature = NULL;
 
     MethodExitEventsCount++;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName,
-            jvmti_env, method, &name, &signature, NULL))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) {
         nsk_jvmti_setFailStatus();
         return;
     }
     NSK_DISPLAY2("MethodExit event: %s%s\n", name, signature);
     if (name != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name);
+        jvmti_env->Deallocate((unsigned char*)name);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
+        jvmti_env->Deallocate((unsigned char*)signature);
 }
 
 /* ========================================================================== */
@@ -79,8 +78,7 @@
     NSK_DISPLAY0("Prepare: find tested thread\n");
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-           NSK_CPP_STUB3(GetAllThreads, jvmti, &threads_count, &threads)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(threads_count > 0 && threads != NULL))
@@ -92,8 +90,7 @@
             return NSK_FALSE;
 
         /* get thread information */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, threads[i], &info)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(threads[i], &info)))
             return NSK_FALSE;
 
         NSK_DISPLAY3("    thread #%d (%s): %p\n", i, info.name, threads[i]);
@@ -104,13 +101,11 @@
         }
     }
 
-    if (!NSK_JNI_VERIFY(jni, (thread =
-            NSK_CPP_STUB2(NewGlobalRef, jni, thread)) != NULL))
+    if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL))
         return NSK_FALSE;
 
     /* deallocate threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threads)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads)))
         return NSK_FALSE;
 
     return NSK_TRUE;
@@ -130,8 +125,7 @@
         return;
     }
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, thread)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, thread)))
         nsk_jvmti_setFailStatus();
 
     /* resume debugee and wait for sync */
@@ -145,7 +139,7 @@
     if (!NSK_VERIFY(MethodExitEventsCount != 0))
         nsk_jvmti_setFailStatus();
 
-    NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, thread));
+    NSK_TRACE(jni->DeleteGlobalRef(thread));
 
     if (!nsk_jvmti_resumeSync())
         return;
@@ -186,7 +180,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_method_exit_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t003/ma10t003a.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t003/ma10t003a.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -52,16 +52,15 @@
     char *signature = NULL;
 
     MethodExitEventsCount++;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName,
-            jvmti_env, method, &name, &signature, NULL))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) {
         nsk_jvmti_setFailStatus();
         return;
     }
     NSK_DISPLAY2("MethodExit event: %s%s\n", name, signature);
     if (name != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name);
+        jvmti_env->Deallocate((unsigned char*)name);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
+        jvmti_env->Deallocate((unsigned char*)signature);
 }
 
 /* ========================================================================== */
@@ -123,7 +122,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_method_exit_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t004/ma10t004.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t004/ma10t004.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -56,20 +56,18 @@
 
     SingleStepEventsCount++;
 
-    NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-        jvmti_env, JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL));
+    NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL));
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName,
-            jvmti_env, method, &name, &signature, NULL))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) {
         nsk_jvmti_setFailStatus();
         return;
     }
     NSK_DISPLAY3("SingleStep event: %s%s, location=%s\n", name, signature,
         jlong_to_string(location, buffer));
     if (name != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name);
+        jvmti_env->Deallocate((unsigned char*)name);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
+        jvmti_env->Deallocate((unsigned char*)signature);
 }
 
 /* ========================================================================== */
@@ -84,8 +82,7 @@
     NSK_DISPLAY0("Prepare: find tested thread\n");
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-           NSK_CPP_STUB3(GetAllThreads, jvmti, &threads_count, &threads)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(threads_count > 0 && threads != NULL))
@@ -97,8 +94,7 @@
             return NSK_FALSE;
 
         /* get thread information */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, threads[i], &info)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(threads[i], &info)))
             return NSK_FALSE;
 
         NSK_DISPLAY3("    thread #%d (%s): %p\n", i, info.name, threads[i]);
@@ -109,13 +105,11 @@
         }
     }
 
-    if (!NSK_JNI_VERIFY(jni, (thread =
-            NSK_CPP_STUB2(NewGlobalRef, jni, thread)) != NULL))
+    if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL))
         return NSK_FALSE;
 
     /* deallocate threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threads)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads)))
         return NSK_FALSE;
 
     return NSK_TRUE;
@@ -135,8 +129,7 @@
         return;
     }
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, thread)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, thread)))
         nsk_jvmti_setFailStatus();
 
     /* resume debugee and wait for sync */
@@ -150,7 +143,7 @@
     if (!NSK_VERIFY(SingleStepEventsCount != 0))
         nsk_jvmti_setFailStatus();
 
-    NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, thread));
+    NSK_TRACE(jni->DeleteGlobalRef(thread));
 
     if (!nsk_jvmti_resumeSync())
         return;
@@ -191,7 +184,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_single_step_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t004/ma10t004a.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t004/ma10t004a.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -53,20 +53,18 @@
 
     SingleStepEventsCount++;
 
-    NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-        jvmti_env, JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL));
+    NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL));
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName,
-            jvmti_env, method, &name, &signature, NULL))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) {
         nsk_jvmti_setFailStatus();
         return;
     }
     NSK_DISPLAY3("SingleStep event: %s%s, location=%s\n", name, signature,
         jlong_to_string(location, buffer));
     if (name != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name);
+        jvmti_env->Deallocate((unsigned char*)name);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
+        jvmti_env->Deallocate((unsigned char*)signature);
 }
 
 /* ========================================================================== */
@@ -128,7 +126,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_single_step_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t005/ma10t005.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t005/ma10t005.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -52,14 +52,13 @@
 
     VMObjectAllocEventsCount++;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, jvmti_env,
-            object_klass, &signature, NULL))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(object_klass, &signature, NULL))) {
         nsk_jvmti_setFailStatus();
         return;
     }
     NSK_DISPLAY2("VMObjectAlloc: \"%s\", size=%d\n", signature, size);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
+        jvmti_env->Deallocate((unsigned char*)signature);
 }
 
 /* ========================================================================== */
@@ -115,7 +114,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_vm_object_alloc_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
@@ -124,8 +123,7 @@
     if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks)))
         return JNI_ERR;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, NULL)))
         return JNI_ERR;
 
     return JNI_OK;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t005/ma10t005a.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t005/ma10t005a.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -52,14 +52,13 @@
 
     VMObjectAllocEventsCount++;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, jvmti_env,
-            object_klass, &signature, NULL))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(object_klass, &signature, NULL))) {
         nsk_jvmti_setFailStatus();
         return;
     }
     NSK_DISPLAY2("VMObjectAlloc: \"%s\", size=%d\n", signature, size);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
+        jvmti_env->Deallocate((unsigned char*)signature);
 }
 
 /* ========================================================================== */
@@ -115,7 +114,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_vm_object_alloc_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t006/ma10t006.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t006/ma10t006.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -54,17 +54,16 @@
 
     CompiledMethodLoadEventsCount++;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName,
-            jvmti_env, method, &name, &signature, NULL))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) {
         nsk_jvmti_setFailStatus();
         return;
     }
     NSK_DISPLAY3("CompiledMethodLoad event: %s%s (0x%p)\n",
         name, signature, code_addr);
     if (name != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name);
+        jvmti_env->Deallocate((unsigned char*)name);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
+        jvmti_env->Deallocate((unsigned char*)signature);
 }
 
 static void JNICALL
@@ -81,8 +80,8 @@
     if (err == JVMTI_ERROR_NONE) {
         NSK_DISPLAY3("for: \tmethod: name=\"%s\" signature=\"%s\"\n\tnative address=0x%p\n",
           name, sig, code_addr);
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name);
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)sig);
+        jvmti_env->Deallocate((unsigned char*)name);
+        jvmti_env->Deallocate((unsigned char*)sig);
     }
 }
 
@@ -148,7 +147,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_compiled_method_load_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
@@ -158,11 +157,9 @@
     if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks)))
         return JNI_ERR;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL)))
         return JNI_ERR;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_UNLOAD, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_UNLOAD, NULL)))
         return JNI_ERR;
 
     return JNI_OK;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t006/ma10t006a.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t006/ma10t006a.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -54,17 +54,16 @@
 
     CompiledMethodLoadEventsCount++;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName,
-            jvmti_env, method, &name, &signature, NULL))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) {
         nsk_jvmti_setFailStatus();
         return;
     }
     NSK_DISPLAY3("CompiledMethodLoad event: %s%s (0x%p)\n",
         name, signature, code_addr);
     if (name != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name);
+        jvmti_env->Deallocate((unsigned char*)name);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
+        jvmti_env->Deallocate((unsigned char*)signature);
 }
 
 static void JNICALL
@@ -82,8 +81,8 @@
     if (err == JVMTI_ERROR_NONE) {
         NSK_DISPLAY3("for: \tmethod: name=\"%s\" signature=\"%s\"\n\tnative address=0x%p\n",
           name, sig, code_addr);
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name);
-        NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)sig);
+        jvmti_env->Deallocate((unsigned char*)name);
+        jvmti_env->Deallocate((unsigned char*)sig);
     }
 }
 
@@ -145,7 +144,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_compiled_method_load_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t007/ma10t007.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t007/ma10t007.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -115,7 +115,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_garbage_collection_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
@@ -125,11 +125,9 @@
     if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks)))
         return JNI_ERR;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, NULL)))
         return JNI_ERR;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, NULL)))
         return JNI_ERR;
 
     return JNI_OK;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t007/ma10t007a.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t007/ma10t007a.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -115,7 +115,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_garbage_collection_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t008/ma10t008.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t008/ma10t008.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -55,8 +55,7 @@
     MonitorContendedEnterEventsCount++;
 
     /* get thread information */
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetThreadInfo, jvmti_env,
-            thread, &info))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetThreadInfo(thread, &info))) {
         nsk_jvmti_setFailStatus();
         return;
     }
@@ -72,8 +71,7 @@
     MonitorContendedEnteredEventsCount++;
 
     /* get thread information */
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetThreadInfo, jvmti_env,
-            thread, &info))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetThreadInfo(thread, &info))) {
         nsk_jvmti_setFailStatus();
         return;
     }
@@ -89,8 +87,7 @@
     MonitorWaitEventsCount++;
 
     /* get thread information */
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetThreadInfo, jvmti_env,
-            thread, &info))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetThreadInfo(thread, &info))) {
         nsk_jvmti_setFailStatus();
         return;
     }
@@ -106,8 +103,7 @@
     MonitorWaitedEventsCount++;
 
     /* get thread information */
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetThreadInfo, jvmti_env,
-            thread, &info))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetThreadInfo(thread, &info))) {
         nsk_jvmti_setFailStatus();
         return;
     }
@@ -189,7 +185,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_monitor_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
@@ -202,17 +198,13 @@
         return JNI_ERR;
 
     /* enable events */
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL)))
         return JNI_ERR;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL)))
         return JNI_ERR;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, NULL)))
         return JNI_ERR;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
-            jvmti, JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, NULL)))
         return JNI_ERR;
 
     return JNI_OK;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t008/ma10t008a.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t008/ma10t008a.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -55,8 +55,7 @@
     MonitorContendedEnterEventsCount++;
 
     /* get thread information */
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetThreadInfo, jvmti_env,
-            thread, &info))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetThreadInfo(thread, &info))) {
         nsk_jvmti_setFailStatus();
         return;
     }
@@ -72,8 +71,7 @@
     MonitorContendedEnteredEventsCount++;
 
     /* get thread information */
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetThreadInfo, jvmti_env,
-            thread, &info))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetThreadInfo(thread, &info))) {
         nsk_jvmti_setFailStatus();
         return;
     }
@@ -89,8 +87,7 @@
     MonitorWaitEventsCount++;
 
     /* get thread information */
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetThreadInfo, jvmti_env,
-            thread, &info))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetThreadInfo(thread, &info))) {
         nsk_jvmti_setFailStatus();
         return;
     }
@@ -106,8 +103,7 @@
     MonitorWaitedEventsCount++;
 
     /* get thread information */
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetThreadInfo, jvmti_env,
-            thread, &info))) {
+    if (!NSK_JVMTI_VERIFY(jvmti_env->GetThreadInfo(thread, &info))) {
         nsk_jvmti_setFailStatus();
         return;
     }
@@ -189,7 +185,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_generate_monitor_events = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
         return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t001/sp01t001.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t001/sp01t001.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -121,37 +121,35 @@
     jsize i;
 
     /* find debugee class */
-    if (!NSK_JNI_VERIFY(jni, (debugeeClass =
-            NSK_CPP_STUB2(FindClass, jni, DEBUGEE_CLASS_NAME)) != NULL))
+    if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL))
         return NSK_FALSE;
 
     /* find static field with threads array */
     if (!NSK_JNI_VERIFY(jni, (threadsFieldID =
-            NSK_CPP_STUB4(GetStaticFieldID, jni, debugeeClass,
-                                    THREADS_FIELD_NAME, THREADS_FIELD_SIG)) != NULL))
+            jni->GetStaticFieldID(debugeeClass, THREADS_FIELD_NAME, THREADS_FIELD_SIG)) != NULL))
         return NSK_FALSE;
 
     /* get threads array from static field */
     if (!NSK_JNI_VERIFY(jni, (threadsArray = (jobjectArray)
-            NSK_CPP_STUB3(GetStaticObjectField, jni, debugeeClass, threadsFieldID)) != NULL))
+            jni->GetStaticObjectField(debugeeClass, threadsFieldID)) != NULL))
         return NSK_FALSE;
 
     /* check array length */
     if (!NSK_JNI_VERIFY(jni, (threadsArrayLength =
-            NSK_CPP_STUB2(GetArrayLength, jni, threadsArray)) == THREADS_COUNT))
+            jni->GetArrayLength(threadsArray)) == THREADS_COUNT))
         return NSK_FALSE;
 
     /* get each thread from array */
     for (i = 0; i < THREADS_COUNT; i++) {
         if (!NSK_JNI_VERIFY(jni, (threadsList[i] = (jthread)
-                NSK_CPP_STUB3(GetObjectArrayElement, jni, threadsArray, i)) != NULL))
+                jni->GetObjectArrayElement(threadsArray, i)) != NULL))
             return NSK_FALSE;
     }
 
     /* make global references to threads */
     for (i = 0; i < THREADS_COUNT; i++) {
         if (!NSK_JNI_VERIFY(jni, (threadsList[i] = (jthread)
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsList[i])) != NULL))
+                jni->NewGlobalRef(threadsList[i])) != NULL))
             return NSK_FALSE;
     }
 
@@ -174,8 +172,7 @@
         NSK_DISPLAY2("    thread #%d (%s):\n", i, threadsName[i]);
 
         /* get thread state */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadState, jvmti, threadsList[i], &state))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadState(threadsList[i], &state))) {
             nsk_jvmti_setFailStatus();
             return NSK_TRUE;
         }
@@ -233,7 +230,7 @@
 
     /* dispose global references to threads */
     for (i = 0; i < THREADS_COUNT; i++) {
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsList[i]));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsList[i]));
     }
 
     return NSK_TRUE;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t002/sp01t002.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t002/sp01t002.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -155,8 +155,7 @@
     }
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetAllThreads, jvmti, &allThreadsCount, &allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL))
@@ -170,8 +169,7 @@
             return NSK_FALSE;
 
         /* get thread name (info) */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, allThreadsList[i], &threadInfo)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(allThreadsList[i], &threadInfo)))
             return NSK_FALSE;
 
         /* find by name */
@@ -189,8 +187,7 @@
     }
 
     /* deallocate all threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)allThreadsList)))
         return NSK_FALSE;
 
     /* check if all tested threads found */
@@ -208,8 +205,7 @@
 
     /* make global refs */
     for (i = 0; i < THREADS_COUNT; i++) {
-        if (!NSK_JNI_VERIFY(jni, (threadsList[i] =
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsList[i])) != NULL))
+        if (!NSK_JNI_VERIFY(jni, (threadsList[i] = jni->NewGlobalRef(threadsList[i])) != NULL))
             return NSK_FALSE;
     }
 
@@ -225,13 +221,11 @@
     for (i = 0; i < THREADS_COUNT; i++) {
         if (suspend) {
             NSK_DISPLAY2("    suspend thread #%d (%s)\n", i, threadsName[i]);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(SuspendThread, jvmti, threadsList[i])))
+            if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(threadsList[i])))
                 nsk_jvmti_setFailStatus();
         } else {
             NSK_DISPLAY2("    resume thread #%d (%s)\n", i, threadsName[i]);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(ResumeThread, jvmti, threadsList[i])))
+            if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(threadsList[i])))
                 nsk_jvmti_setFailStatus();
         }
     }
@@ -260,8 +254,7 @@
         /* wait for WAITTIME for thread to reach expected state */
         do {
             /* get thread state */
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB3(GetThreadState, jvmti, threadsList[i], &state))) {
+            if (!NSK_JVMTI_VERIFY(jvmti->GetThreadState(threadsList[i], &state))) {
                 nsk_jvmti_setFailStatus();
                 return NSK_TRUE;
             }
@@ -371,7 +364,7 @@
 
     /* dispose global references to threads */
     for (i = 0; i < THREADS_COUNT; i++) {
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsList[i]));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsList[i]));
     }
 
     return NSK_TRUE;
@@ -449,8 +442,7 @@
         jvmtiCapabilities suspendCaps;
         memset(&suspendCaps, 0, sizeof(suspendCaps));
         suspendCaps.can_suspend = 1;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps)))
+        if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
             return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t003/sp01t003.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t003/sp01t003.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -155,8 +155,7 @@
     }
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetAllThreads, jvmti, &allThreadsCount, &allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL))
@@ -170,8 +169,7 @@
             return NSK_FALSE;
 
         /* get thread name (info) */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, allThreadsList[i], &threadInfo)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(allThreadsList[i], &threadInfo)))
             return NSK_FALSE;
 
         /* find by name */
@@ -189,8 +187,7 @@
     }
 
     /* deallocate all threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)allThreadsList)))
         return NSK_FALSE;
 
     /* check if all tested threads found */
@@ -208,8 +205,7 @@
 
     /* make global refs */
     for (i = 0; i < THREADS_COUNT; i++) {
-        if (!NSK_JNI_VERIFY(jni, (threadsList[i] =
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsList[i])) != NULL))
+        if (!NSK_JNI_VERIFY(jni, (threadsList[i] = jni->NewGlobalRef(threadsList[i])) != NULL))
             return NSK_FALSE;
     }
 
@@ -226,14 +222,10 @@
 
     /* suspend or resume threads list */
     if (suspend) {
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB4(SuspendThreadList, jvmti, THREADS_COUNT,
-                                                    threadsList, results)))
+        if (!NSK_JVMTI_VERIFY(jvmti->SuspendThreadList(THREADS_COUNT, threadsList, results)))
             nsk_jvmti_setFailStatus();
     } else {
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB4(ResumeThreadList, jvmti, THREADS_COUNT,
-                                                    threadsList, results)))
+        if (!NSK_JVMTI_VERIFY(jvmti->ResumeThreadList(THREADS_COUNT, threadsList, results)))
             nsk_jvmti_setFailStatus();
     }
 
@@ -273,8 +265,7 @@
         /* wait for WAITTIME for thread to reach expected state */
         do {
             /* get thread status */
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB3(GetThreadState, jvmti, threadsList[i], &state))) {
+            if (!NSK_JVMTI_VERIFY(jvmti->GetThreadState(threadsList[i], &state))) {
                 nsk_jvmti_setFailStatus();
                 return NSK_TRUE;
             }
@@ -384,7 +375,7 @@
 
     /* dispose global references to threads */
     for (i = 0; i < THREADS_COUNT; i++) {
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsList[i]));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsList[i]));
     }
 
     return NSK_TRUE;
@@ -462,8 +453,7 @@
         jvmtiCapabilities suspendCaps;
         memset(&suspendCaps, 0, sizeof(suspendCaps));
         suspendCaps.can_suspend = 1;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps)))
+        if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
             return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/sp02t001.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/sp02t001.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -136,8 +136,7 @@
     }
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetAllThreads, jvmti, &allThreadsCount, &allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL))
@@ -151,8 +150,7 @@
             return NSK_FALSE;
 
         /* get thread name (info) */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, allThreadsList[i], &threadInfo)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(allThreadsList[i], &threadInfo)))
             return NSK_FALSE;
 
         /* find by name */
@@ -170,8 +168,7 @@
     }
 
     /* deallocate all threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)allThreadsList)))
         return NSK_FALSE;
 
     /* check if all tested threads found */
@@ -190,7 +187,7 @@
     /* make global refs */
     for (i = 0; i < THREADS_COUNT; i++) {
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].thread = (jthread)
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsDesc[i].thread)) != NULL))
+                jni->NewGlobalRef(threadsDesc[i].thread)) != NULL))
             return NSK_FALSE;
     }
 
@@ -206,13 +203,11 @@
     for (i = 0; i < THREADS_COUNT; i++) {
         if (suspend) {
             NSK_DISPLAY2("    suspend thread #%d (%s)\n", i, threadsDesc[i].threadName);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(SuspendThread, jvmti, threadsDesc[i].thread)))
+            if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(threadsDesc[i].thread)))
                 nsk_jvmti_setFailStatus();
         } else {
             NSK_DISPLAY2("    resume thread #%d (%s)\n", i, threadsDesc[i].threadName);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(ResumeThread, jvmti, threadsDesc[i].thread)))
+            if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(threadsDesc[i].thread)))
                 nsk_jvmti_setFailStatus();
         }
     }
@@ -241,9 +236,7 @@
         NSK_DISPLAY2("  thread #%d (%s):\n", i, threadsDesc[i].threadName);
 
         /* get frame count */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetFrameCount, jvmti,
-                                    threadsDesc[i].thread, &frameCount))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->GetFrameCount(threadsDesc[i].thread, &frameCount))) {
             nsk_jvmti_setFailStatus();
             return NSK_TRUE;
         }
@@ -252,8 +245,7 @@
 
         /* get stack trace */
         if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB6(GetStackTrace, jvmti, threadsDesc[i].thread,
-                                    0, MAX_STACK_SIZE, frameStack, &frameStackSize))) {
+                jvmti->GetStackTrace(threadsDesc[i].thread, 0, MAX_STACK_SIZE, frameStack, &frameStackSize))) {
             nsk_jvmti_setFailStatus();
             return NSK_TRUE;
         }
@@ -294,7 +286,7 @@
 
     /* dispose global references to threads */
     for (i = 0; i < THREADS_COUNT; i++) {
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsDesc[i].thread));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsDesc[i].thread));
     }
 
     return NSK_TRUE;
@@ -372,8 +364,7 @@
         jvmtiCapabilities suspendCaps;
         memset(&suspendCaps, 0, sizeof(suspendCaps));
         suspendCaps.can_suspend = 1;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps)))
+        if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
             return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/sp02t002.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/sp02t002.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -158,8 +158,7 @@
     }
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetAllThreads, jvmti, &allThreadsCount, &allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL))
@@ -173,8 +172,7 @@
             return NSK_FALSE;
 
         /* get thread name (info) */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, allThreadsList[i], &threadInfo)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(allThreadsList[i], &threadInfo)))
             return NSK_FALSE;
 
         /* find by name */
@@ -192,8 +190,7 @@
     }
 
     /* deallocate all threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)allThreadsList)))
         return NSK_FALSE;
 
     /* check if all tested threads found */
@@ -214,12 +211,11 @@
     for (i = 0; i < THREADS_COUNT; i++) {
         /* get thread class */
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls =
-                NSK_CPP_STUB2(GetObjectClass, jni, threadsDesc[i].thread)) != NULL))
+                jni->GetObjectClass(threadsDesc[i].thread)) != NULL))
             return NSK_FALSE;
         /* get frame method */
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].method =
-                NSK_CPP_STUB4(GetMethodID, jni, threadsDesc[i].cls,
-                            threadsDesc[i].methodName, threadsDesc[i].methodSig)) != NULL))
+                jni->GetMethodID(threadsDesc[i].cls, threadsDesc[i].methodName, threadsDesc[i].methodSig)) != NULL))
             return NSK_FALSE;
 
         NSK_DISPLAY4("    thread #%d (%s): %p (%s)\n",
@@ -231,10 +227,10 @@
     /* make global refs */
     for (i = 0; i < THREADS_COUNT; i++) {
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].thread = (jthread)
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsDesc[i].thread)) != NULL))
+                jni->NewGlobalRef(threadsDesc[i].thread)) != NULL))
             return NSK_FALSE;
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls = (jclass)
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsDesc[i].cls)) != NULL))
+                jni->NewGlobalRef(threadsDesc[i].cls)) != NULL))
             return NSK_FALSE;
     }
 
@@ -250,13 +246,11 @@
     for (i = 0; i < THREADS_COUNT; i++) {
         if (suspend) {
             NSK_DISPLAY2("    suspend thread #%d (%s)\n", i, threadsDesc[i].threadName);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(SuspendThread, jvmti, threadsDesc[i].thread)))
+            if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(threadsDesc[i].thread)))
                 nsk_jvmti_setFailStatus();
         } else {
             NSK_DISPLAY2("    resume thread #%d (%s)\n", i, threadsDesc[i].threadName);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(ResumeThread, jvmti, threadsDesc[i].thread)))
+            if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(threadsDesc[i].thread)))
                 nsk_jvmti_setFailStatus();
         }
     }
@@ -285,9 +279,7 @@
         NSK_DISPLAY2("  thread #%d (%s):\n", i, threadsDesc[i].threadName);
 
         /* get frame count */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetFrameCount, jvmti,
-                                    threadsDesc[i].thread, &frameCount))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->GetFrameCount(threadsDesc[i].thread, &frameCount))) {
             nsk_jvmti_setFailStatus();
             return NSK_TRUE;
         }
@@ -296,8 +288,7 @@
 
         /* get stack trace */
         if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB6(GetStackTrace, jvmti, threadsDesc[i].thread,
-                                    0, MAX_STACK_SIZE, frameStack, &frameStackSize))) {
+                jvmti->GetStackTrace(threadsDesc[i].thread, 0, MAX_STACK_SIZE, frameStack, &frameStackSize))) {
             nsk_jvmti_setFailStatus();
             return NSK_TRUE;
         }
@@ -357,8 +348,8 @@
 
     /* dispose global references to threads */
     for (i = 0; i < THREADS_COUNT; i++) {
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsDesc[i].thread));
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsDesc[i].cls));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsDesc[i].thread));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsDesc[i].cls));
     }
 
     return NSK_TRUE;
@@ -436,8 +427,7 @@
         jvmtiCapabilities suspendCaps;
         memset(&suspendCaps, 0, sizeof(suspendCaps));
         suspendCaps.can_suspend = 1;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps)))
+        if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
             return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/sp02t003.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/sp02t003.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -159,8 +159,7 @@
     }
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetAllThreads, jvmti, &allThreadsCount, &allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL))
@@ -174,8 +173,7 @@
             return NSK_FALSE;
 
         /* get thread name (info) */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, allThreadsList[i], &threadInfo)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(allThreadsList[i], &threadInfo)))
             return NSK_FALSE;
 
         /* find by name */
@@ -193,8 +191,7 @@
     }
 
     /* deallocate all threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)allThreadsList)))
         return NSK_FALSE;
 
     /* check if all tested threads found */
@@ -215,12 +212,11 @@
     for (i = 0; i < THREADS_COUNT; i++) {
         /* get thread class */
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls =
-                NSK_CPP_STUB2(GetObjectClass, jni, threadsDesc[i].thread)) != NULL))
+                jni->GetObjectClass(threadsDesc[i].thread)) != NULL))
             return NSK_FALSE;
         /* get frame method */
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].method =
-                NSK_CPP_STUB4(GetMethodID, jni, threadsDesc[i].cls,
-                            threadsDesc[i].methodName, threadsDesc[i].methodSig)) != NULL))
+                jni->GetMethodID(threadsDesc[i].cls, threadsDesc[i].methodName, threadsDesc[i].methodSig)) != NULL))
             return NSK_FALSE;
 
         NSK_DISPLAY4("    thread #%d (%s): %p (%s)\n",
@@ -232,10 +228,10 @@
     /* make global refs */
     for (i = 0; i < THREADS_COUNT; i++) {
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].thread = (jthread)
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsDesc[i].thread)) != NULL))
+                jni->NewGlobalRef(threadsDesc[i].thread)) != NULL))
             return NSK_FALSE;
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls = (jclass)
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsDesc[i].cls)) != NULL))
+                jni->NewGlobalRef(threadsDesc[i].cls)) != NULL))
             return NSK_FALSE;
     }
 
@@ -251,13 +247,11 @@
     for (i = 0; i < THREADS_COUNT; i++) {
         if (suspend) {
             NSK_DISPLAY2("    suspend thread #%d (%s)\n", i, threadsDesc[i].threadName);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(SuspendThread, jvmti, threadsDesc[i].thread)))
+            if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(threadsDesc[i].thread)))
                 nsk_jvmti_setFailStatus();
         } else {
             NSK_DISPLAY2("    resume thread #%d (%s)\n", i, threadsDesc[i].threadName);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(ResumeThread, jvmti, threadsDesc[i].thread)))
+            if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(threadsDesc[i].thread)))
                 nsk_jvmti_setFailStatus();
         }
     }
@@ -288,9 +282,7 @@
         NSK_DISPLAY2("  thread #%d (%s):\n", i, threadsDesc[i].threadName);
 
         /* get frame count */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetFrameCount, jvmti,
-                                    threadsDesc[i].thread, &frameCount))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->GetFrameCount(threadsDesc[i].thread, &frameCount))) {
             nsk_jvmti_setFailStatus();
             return NSK_TRUE;
         }
@@ -298,8 +290,7 @@
 
         /* get stack trace */
         if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB6(GetStackTrace, jvmti, threadsDesc[i].thread,
-                                    0, MAX_STACK_SIZE, frameStack, &frameStackSize))) {
+                jvmti->GetStackTrace(threadsDesc[i].thread, 0, MAX_STACK_SIZE, frameStack, &frameStackSize))) {
             nsk_jvmti_setFailStatus();
             return NSK_TRUE;
         }
@@ -319,8 +310,7 @@
                                         (long)frameStack[j].location);
             /* query frame location */
             if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB5(GetFrameLocation, jvmti, threadsDesc[i].thread,
-                                                        j, &qMethod, &qLocation))) {
+                    jvmti->GetFrameLocation(threadsDesc[i].thread, j, &qMethod, &qLocation))) {
                 nsk_jvmti_setFailStatus();
                 continue;
             }
@@ -375,8 +365,8 @@
 
     /* dispose global references to threads */
     for (i = 0; i < THREADS_COUNT; i++) {
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsDesc[i].thread));
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsDesc[i].cls));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsDesc[i].thread));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsDesc[i].cls));
     }
 
     return NSK_TRUE;
@@ -453,8 +443,7 @@
         jvmtiCapabilities suspendCaps;
         memset(&suspendCaps, 0, sizeof(suspendCaps));
         suspendCaps.can_suspend = 1;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps)))
+        if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
             return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP03/sp03t001/sp03t001.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP03/sp03t001/sp03t001.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -158,9 +158,8 @@
         threadsCounts[i] = 0;
         threadsList[i] = NULL;
 
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(Allocate, jvmti, (threadsCount * sizeof(jthread)),
-                                                    (unsigned char**)&threadsList[i])))
+        if (!NSK_JVMTI_VERIFY(jvmti->Allocate(threadsCount * sizeof(jthread),
+                                              (unsigned char**)&threadsList[i])))
             return NSK_FALSE;
 
         for (j = 0; j < threadsCount; j++) {
@@ -169,8 +168,7 @@
     }
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetAllThreads, jvmti, &allThreadsCount, &allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL))
@@ -184,8 +182,7 @@
             return NSK_FALSE;
 
         /* get thread name (info) */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, allThreadsList[i], &threadInfo)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(allThreadsList[i], &threadInfo)))
             return NSK_FALSE;
 
         /* find by name */
@@ -202,8 +199,7 @@
     }
 
     /* deallocate all threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)allThreadsList)))
         return NSK_FALSE;
 
     /* check if all tested threads found */
@@ -226,7 +222,7 @@
     for (i = 0; i < THREADS_KINDS; i++) {
         for (j = 0; j < threadsCount; j++) {
             if (!NSK_JNI_VERIFY(jni, (threadsList[i][j] =
-                    NSK_CPP_STUB2(NewGlobalRef, jni, threadsList[i][j])) != NULL))
+                    jni->NewGlobalRef(threadsList[i][j])) != NULL))
                 return NSK_FALSE;
         }
     }
@@ -244,8 +240,7 @@
     int i, j;
 
     /* allocate results array */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(Allocate, jvmti, resultsSize, (unsigned char**)&results))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->Allocate(resultsSize, (unsigned char**)&results))) {
         nsk_jvmti_setFailStatus();
         return NSK_FALSE;
     }
@@ -253,14 +248,10 @@
     for (i = 0; i < THREADS_KINDS; i++) {
         /* suspend or resume threads list */
         if (suspend) {
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB4(SuspendThreadList, jvmti, threadsCount,
-                                                        threadsList[i], results)))
+            if (!NSK_JVMTI_VERIFY(jvmti->SuspendThreadList(threadsCount, threadsList[i], results)))
                 nsk_jvmti_setFailStatus();
         } else {
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB4(ResumeThreadList, jvmti, threadsCount,
-                                                        threadsList[i], results)))
+            if (!NSK_JVMTI_VERIFY(jvmti->ResumeThreadList(threadsCount, threadsList[i], results)))
                 nsk_jvmti_setFailStatus();
         }
 
@@ -277,8 +268,7 @@
     }
 
     /* deallocate results array */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)results))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)results))) {
         nsk_jvmti_setFailStatus();
     }
 
@@ -295,13 +285,11 @@
         for (j = 0; j < threadsCount; j++) {
             if (suspend) {
                 NSK_DISPLAY2("    suspend thread #%d (%s)\n", j, threadsName[i]);
-                if (!NSK_JVMTI_VERIFY(
-                        NSK_CPP_STUB2(SuspendThread, jvmti, threadsList[i][j])))
+                if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(threadsList[i][j])))
                     nsk_jvmti_setFailStatus();
             } else {
                 NSK_DISPLAY2("    resume thread #%d (%s)\n", j, threadsName[i]);
-                if (!NSK_JVMTI_VERIFY(
-                        NSK_CPP_STUB2(ResumeThread, jvmti, threadsList[i][j])))
+                if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(threadsList[i][j])))
                     nsk_jvmti_setFailStatus();
             }
         }
@@ -329,8 +317,7 @@
             NSK_DISPLAY2("    thread #%d (%s):\n", j, threadsName[i]);
 
             /* get thread state */
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB3(GetThreadState, jvmti, threadsList[i][j], &state))) {
+            if (!NSK_JVMTI_VERIFY(jvmti->GetThreadState(threadsList[i][j], &state))) {
                 nsk_jvmti_setFailStatus();
                 return NSK_FALSE;
             }
@@ -373,14 +360,13 @@
     /* dispose global references to threads */
     for (i = 0; i < THREADS_KINDS; i++) {
         for (j = 0; j < threadsCount; j++) {
-            NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsList[i][j]));
+            NSK_TRACE(jni->DeleteGlobalRef(threadsList[i][j]));
         }
     }
 
     /* deallocate memory */
     for (i = 0; i < THREADS_KINDS; i++) {
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threadsList[i])))
+        if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threadsList[i])))
             return NSK_FALSE;
         threadsList[i] = NULL;
     }
@@ -465,8 +451,7 @@
         jvmtiCapabilities suspendCaps;
         memset(&suspendCaps, 0, sizeof(suspendCaps));
         suspendCaps.can_suspend = 1;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps)))
+        if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
             return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP03/sp03t002/sp03t002.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP03/sp03t002/sp03t002.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -161,9 +161,8 @@
         threadsCounts[i] = 0;
         threadsList[i] = NULL;
 
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(Allocate, jvmti, (threadsCount * sizeof(jthread)),
-                                                    (unsigned char**)&threadsList[i])))
+        if (!NSK_JVMTI_VERIFY(jvmti->Allocate(threadsCount * sizeof(jthread),
+                                              (unsigned char**)&threadsList[i])))
             return NSK_FALSE;
 
         for (j = 0; j < threadsCount; j++) {
@@ -172,8 +171,7 @@
     }
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetAllThreads, jvmti, &allThreadsCount, &allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL))
@@ -187,8 +185,7 @@
             return NSK_FALSE;
 
         /* get thread name (info) */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, allThreadsList[i], &threadInfo)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(allThreadsList[i], &threadInfo)))
             return NSK_FALSE;
 
         /* find by name */
@@ -205,8 +202,7 @@
     }
 
     /* deallocate all threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)allThreadsList)))
         return NSK_FALSE;
 
     /* check if all tested threads found */
@@ -229,7 +225,7 @@
     for (i = 0; i < THREADS_KINDS; i++) {
         for (j = 0; j < threadsCount; j++) {
             if (!NSK_JNI_VERIFY(jni, (threadsList[i][j] =
-                    NSK_CPP_STUB2(NewGlobalRef, jni, threadsList[i][j])) != NULL))
+                    jni->NewGlobalRef(threadsList[i][j])) != NULL))
                 return NSK_FALSE;
         }
     }
@@ -247,8 +243,7 @@
     int i, j;
 
     /* allocate results array */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(Allocate, jvmti, resultsSize, (unsigned char**)&results))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->Allocate(resultsSize, (unsigned char**)&results))) {
         nsk_jvmti_setFailStatus();
         return NSK_FALSE;
     }
@@ -256,14 +251,10 @@
     for (i = 0; i < THREADS_KINDS; i++) {
         /* suspend or resume threads list */
         if (suspend) {
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB4(SuspendThreadList, jvmti, threadsCount,
-                                                        threadsList[i], results)))
+            if (!NSK_JVMTI_VERIFY(jvmti->SuspendThreadList(threadsCount, threadsList[i], results)))
                 nsk_jvmti_setFailStatus();
         } else {
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB4(ResumeThreadList, jvmti, threadsCount,
-                                                        threadsList[i], results)))
+            if (!NSK_JVMTI_VERIFY(jvmti->ResumeThreadList(threadsCount, threadsList[i], results)))
                 nsk_jvmti_setFailStatus();
         }
 
@@ -280,8 +271,7 @@
     }
 
     /* deallocate results array */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)results))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)results))) {
         nsk_jvmti_setFailStatus();
     }
 
@@ -298,13 +288,11 @@
         for (j = 0; j < threadsCount; j++) {
             if (suspend) {
                 NSK_DISPLAY2("    suspend thread #%d (%s)\n", j, threadsName[i]);
-                if (!NSK_JVMTI_VERIFY(
-                        NSK_CPP_STUB2(SuspendThread, jvmti, threadsList[i][j])))
+                if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(threadsList[i][j])))
                     nsk_jvmti_setFailStatus();
             } else {
                 NSK_DISPLAY2("    resume thread #%d (%s)\n", j, threadsName[i]);
-                if (!NSK_JVMTI_VERIFY(
-                        NSK_CPP_STUB2(ResumeThread, jvmti, threadsList[i][j])))
+                if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(threadsList[i][j])))
                     nsk_jvmti_setFailStatus();
             }
         }
@@ -332,8 +320,7 @@
             NSK_DISPLAY2("    thread #%d (%s):\n", j, threadsName[i]);
 
             /* get thread state */
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB3(GetThreadState, jvmti, threadsList[i][j], &state))) {
+            if (!NSK_JVMTI_VERIFY(jvmti->GetThreadState(threadsList[i][j], &state))) {
                 nsk_jvmti_setFailStatus();
                 return NSK_FALSE;
             }
@@ -376,14 +363,13 @@
     /* dispose global references to threads */
     for (i = 0; i < THREADS_KINDS; i++) {
         for (j = 0; j < threadsCount; j++) {
-            NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsList[i][j]));
+            NSK_TRACE(jni->DeleteGlobalRef(threadsList[i][j]));
         }
     }
 
     /* deallocate memory */
     for (i = 0; i < THREADS_KINDS; i++) {
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threadsList[i])))
+        if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threadsList[i])))
             return NSK_FALSE;
         threadsList[i] = NULL;
     }
@@ -468,8 +454,7 @@
         jvmtiCapabilities suspendCaps;
         memset(&suspendCaps, 0, sizeof(suspendCaps));
         suspendCaps.can_suspend = 1;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps)))
+        if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
             return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP04/sp04t001/sp04t001.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP04/sp04t001/sp04t001.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -158,9 +158,8 @@
         threadsCounts[i] = 0;
         threadsList[i] = NULL;
 
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(Allocate, jvmti, (threadsCount * sizeof(jthread)),
-                                                    (unsigned char**)&threadsList[i])))
+        if (!NSK_JVMTI_VERIFY(jvmti->Allocate(threadsCount * sizeof(jthread),
+                                              (unsigned char**)&threadsList[i])))
             return NSK_FALSE;
 
         for (j = 0; j < threadsCount; j++) {
@@ -169,8 +168,7 @@
     }
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetAllThreads, jvmti, &allThreadsCount, &allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL))
@@ -184,8 +182,7 @@
             return NSK_FALSE;
 
         /* get thread name (info) */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, allThreadsList[i], &threadInfo)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(allThreadsList[i], &threadInfo)))
             return NSK_FALSE;
 
         /* find by name */
@@ -202,8 +199,7 @@
     }
 
     /* deallocate all threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)allThreadsList)))
         return NSK_FALSE;
 
     /* check if all tested threads found */
@@ -226,7 +222,7 @@
     for (i = 0; i < THREADS_KINDS; i++) {
         for (j = 0; j < threadsCount; j++) {
             if (!NSK_JNI_VERIFY(jni, (threadsList[i][j] =
-                    NSK_CPP_STUB2(NewGlobalRef, jni, threadsList[i][j])) != NULL))
+                    jni->NewGlobalRef(threadsList[i][j])) != NULL))
                 return NSK_FALSE;
         }
     }
@@ -244,8 +240,7 @@
     int i, j;
 
     /* allocate results array */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(Allocate, jvmti, resultsSize, (unsigned char**)&results))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->Allocate(resultsSize, (unsigned char**)&results))) {
         nsk_jvmti_setFailStatus();
         return NSK_FALSE;
     }
@@ -253,14 +248,10 @@
     for (i = 0; i < THREADS_KINDS; i++) {
         /* suspend or resume threads list */
         if (suspend) {
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB4(SuspendThreadList, jvmti, threadsCount,
-                                                        threadsList[i], results)))
+            if (!NSK_JVMTI_VERIFY(jvmti->SuspendThreadList(threadsCount, threadsList[i], results)))
                 nsk_jvmti_setFailStatus();
         } else {
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB4(ResumeThreadList, jvmti, threadsCount,
-                                                        threadsList[i], results)))
+            if (!NSK_JVMTI_VERIFY(jvmti->ResumeThreadList(threadsCount, threadsList[i], results)))
                 nsk_jvmti_setFailStatus();
         }
 
@@ -277,8 +268,7 @@
     }
 
     /* deallocate results array */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)results))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)results))) {
         nsk_jvmti_setFailStatus();
     }
 
@@ -295,13 +285,11 @@
         for (j = 0; j < threadsCount; j++) {
             if (suspend) {
                 NSK_DISPLAY2("    suspend thread #%d (%s)\n", j, threadsName[i]);
-                if (!NSK_JVMTI_VERIFY(
-                        NSK_CPP_STUB2(SuspendThread, jvmti, threadsList[i][j])))
+                if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(threadsList[i][j])))
                     nsk_jvmti_setFailStatus();
             } else {
                 NSK_DISPLAY2("    resume thread #%d (%s)\n", j, threadsName[i]);
-                if (!NSK_JVMTI_VERIFY(
-                        NSK_CPP_STUB2(ResumeThread, jvmti, threadsList[i][j])))
+                if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(threadsList[i][j])))
                     nsk_jvmti_setFailStatus();
             }
         }
@@ -329,8 +317,7 @@
             NSK_DISPLAY2("    thread #%d (%s):\n", j, threadsName[i]);
 
             /* get thread state */
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB3(GetThreadState, jvmti, threadsList[i][j], &state))) {
+            if (!NSK_JVMTI_VERIFY(jvmti->GetThreadState(threadsList[i][j], &state))) {
                 nsk_jvmti_setFailStatus();
                 return NSK_FALSE;
             }
@@ -373,14 +360,13 @@
     /* dispose global references to threads */
     for (i = 0; i < THREADS_KINDS; i++) {
         for (j = 0; j < threadsCount; j++) {
-            NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsList[i][j]));
+            NSK_TRACE(jni->DeleteGlobalRef(threadsList[i][j]));
         }
     }
 
     /* deallocate memory */
     for (i = 0; i < THREADS_KINDS; i++) {
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threadsList[i])))
+        if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threadsList[i])))
             return NSK_FALSE;
         threadsList[i] = NULL;
     }
@@ -465,8 +451,7 @@
         jvmtiCapabilities suspendCaps;
         memset(&suspendCaps, 0, sizeof(suspendCaps));
         suspendCaps.can_suspend = 1;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps)))
+        if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
             return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP04/sp04t002/sp04t002.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP04/sp04t002/sp04t002.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -158,9 +158,8 @@
         threadsCounts[i] = 0;
         threadsList[i] = NULL;
 
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(Allocate, jvmti, (threadsCount * sizeof(jthread)),
-                                                    (unsigned char**)&threadsList[i])))
+        if (!NSK_JVMTI_VERIFY(jvmti->Allocate(threadsCount * sizeof(jthread),
+                                              (unsigned char**)&threadsList[i])))
             return NSK_FALSE;
 
         for (j = 0; j < threadsCount; j++) {
@@ -169,8 +168,7 @@
     }
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetAllThreads, jvmti, &allThreadsCount, &allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL))
@@ -184,8 +182,7 @@
             return NSK_FALSE;
 
         /* get thread name (info) */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, allThreadsList[i], &threadInfo)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(allThreadsList[i], &threadInfo)))
             return NSK_FALSE;
 
         /* find by name */
@@ -202,8 +199,7 @@
     }
 
     /* deallocate all threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)allThreadsList)))
         return NSK_FALSE;
 
     /* check if all tested threads found */
@@ -226,7 +222,7 @@
     for (i = 0; i < THREADS_KINDS; i++) {
         for (j = 0; j < threadsCount; j++) {
             if (!NSK_JNI_VERIFY(jni, (threadsList[i][j] =
-                    NSK_CPP_STUB2(NewGlobalRef, jni, threadsList[i][j])) != NULL))
+                    jni->NewGlobalRef(threadsList[i][j])) != NULL))
                 return NSK_FALSE;
         }
     }
@@ -244,8 +240,7 @@
     int i, j;
 
     /* allocate results array */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(Allocate, jvmti, resultsSize, (unsigned char**)&results))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->Allocate(resultsSize, (unsigned char**)&results))) {
         nsk_jvmti_setFailStatus();
         return NSK_FALSE;
     }
@@ -253,14 +248,10 @@
     for (i = 0; i < THREADS_KINDS; i++) {
         /* suspend or resume threads list */
         if (suspend) {
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB4(SuspendThreadList, jvmti, threadsCount,
-                                                        threadsList[i], results)))
+            if (!NSK_JVMTI_VERIFY(jvmti->SuspendThreadList(threadsCount, threadsList[i], results)))
                 nsk_jvmti_setFailStatus();
         } else {
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB4(ResumeThreadList, jvmti, threadsCount,
-                                                        threadsList[i], results)))
+            if (!NSK_JVMTI_VERIFY(jvmti->ResumeThreadList(threadsCount, threadsList[i], results)))
                 nsk_jvmti_setFailStatus();
         }
 
@@ -277,8 +268,7 @@
     }
 
     /* deallocate results array */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)results))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)results))) {
         nsk_jvmti_setFailStatus();
     }
 
@@ -295,13 +285,11 @@
         for (j = 0; j < threadsCount; j++) {
             if (suspend)  {
                 NSK_DISPLAY2("    suspend thread #%d (%s)\n", j, threadsName[i]);
-                if (!NSK_JVMTI_VERIFY(
-                        NSK_CPP_STUB2(SuspendThread, jvmti, threadsList[i][j])))
+                if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(threadsList[i][j])))
                     nsk_jvmti_setFailStatus();
             } else {
                 NSK_DISPLAY2("    resume thread #%d (%s)\n", j, threadsName[i]);
-                if (!NSK_JVMTI_VERIFY(
-                        NSK_CPP_STUB2(ResumeThread, jvmti, threadsList[i][j])))
+                if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(threadsList[i][j])))
                     nsk_jvmti_setFailStatus();
             }
         }
@@ -329,8 +317,7 @@
             NSK_DISPLAY2("    thread #%d (%s):\n", j, threadsName[i]);
 
             /* get thread state */
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB3(GetThreadState, jvmti, threadsList[i][j], &state))) {
+            if (!NSK_JVMTI_VERIFY(jvmti->GetThreadState(threadsList[i][j], &state))) {
                 nsk_jvmti_setFailStatus();
                 return NSK_FALSE;
             }
@@ -373,14 +360,13 @@
     /* dispose global references to threads */
     for (i = 0; i < THREADS_KINDS; i++) {
         for (j = 0; j < threadsCount; j++) {
-            NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsList[i][j]));
+            NSK_TRACE(jni->DeleteGlobalRef(threadsList[i][j]));
         }
     }
 
     /* deallocate memory */
     for (i = 0; i < THREADS_KINDS; i++) {
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threadsList[i])))
+        if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threadsList[i])))
             return NSK_FALSE;
         threadsList[i] = NULL;
     }
@@ -465,8 +451,7 @@
         jvmtiCapabilities suspendCaps;
         memset(&suspendCaps, 0, sizeof(suspendCaps));
         suspendCaps.can_suspend = 1;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps)))
+        if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
             return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t002/sp05t002.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t002/sp05t002.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -143,9 +143,7 @@
     int i;
 
     for (i = 0; i < EVENTS_COUNT; i++) {
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB4(SetEventNotificationMode, jvmti, enable,
-                                                eventsList[i], NULL))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, eventsList[i], NULL))) {
             nsk_jvmti_setFailStatus();
             return NSK_FALSE;
         }
@@ -168,37 +166,35 @@
     jsize i;
 
     /* find debugee class */
-    if (!NSK_JNI_VERIFY(jni, (debugeeClass =
-            NSK_CPP_STUB2(FindClass, jni, DEBUGEE_CLASS_NAME)) != NULL))
+    if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL))
         return NSK_FALSE;
 
     /* find static field with threads array */
     if (!NSK_JNI_VERIFY(jni, (threadsFieldID =
-            NSK_CPP_STUB4(GetStaticFieldID, jni, debugeeClass,
-                                    THREADS_FIELD_NAME, THREADS_FIELD_SIG)) != NULL))
+            jni->GetStaticFieldID(debugeeClass, THREADS_FIELD_NAME, THREADS_FIELD_SIG)) != NULL))
         return NSK_FALSE;
 
     /* get threads array from static field */
     if (!NSK_JNI_VERIFY(jni, (threadsArray = (jobjectArray)
-            NSK_CPP_STUB3(GetStaticObjectField, jni, debugeeClass, threadsFieldID)) != NULL))
+            jni->GetStaticObjectField(debugeeClass, threadsFieldID)) != NULL))
         return NSK_FALSE;
 
     /* check array length */
     if (!NSK_JNI_VERIFY(jni, (threadsArrayLength =
-            NSK_CPP_STUB2(GetArrayLength, jni, threadsArray)) == THREADS_COUNT))
+            jni->GetArrayLength(threadsArray)) == THREADS_COUNT))
         return NSK_FALSE;
 
     /* get each thread from array */
     for (i = 0; i < THREADS_COUNT; i++) {
         if (!NSK_JNI_VERIFY(jni, (threadsList[i] = (jthread)
-                NSK_CPP_STUB3(GetObjectArrayElement, jni, threadsArray, i)) != NULL))
+                jni->GetObjectArrayElement(threadsArray, i)) != NULL))
             return NSK_FALSE;
     }
 
     /* make global references to threads */
     for (i = 0; i < THREADS_COUNT; i++) {
         if (!NSK_JNI_VERIFY(jni, (threadsList[i] = (jthread)
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsList[i])) != NULL))
+                jni->NewGlobalRef(threadsList[i])) != NULL))
             return NSK_FALSE;
     }
 
@@ -218,8 +214,7 @@
     NSK_DISPLAY3("  thread #%d (%s): %p\n", i, threadsName[i], (void*)thread);
 
     /* get frames count */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetFrameCount, jvmti, thread, &framesCount))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->GetFrameCount(thread, &framesCount))) {
         nsk_jvmti_setFailStatus();
         return NSK_TRUE;
     }
@@ -227,8 +222,7 @@
 
     /* get stack frames */
     if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB6(GetStackTrace, jvmti, thread, 0, MAX_STACK_DEPTH,
-                                                    stackFrames, &stackDepth))) {
+            jvmti->GetStackTrace(thread, 0, MAX_STACK_DEPTH, stackFrames, &stackDepth))) {
         nsk_jvmti_setFailStatus();
         return NSK_TRUE;
     }
@@ -269,7 +263,7 @@
 
     /* dispose global references to threads */
     for (i = 0; i < THREADS_COUNT; i++) {
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsList[i]));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsList[i]));
     }
 
     return NSK_TRUE;
@@ -293,7 +287,7 @@
 
     /* check if event is for tested thread */
     for (i = 0; i < THREADS_COUNT; i++) {
-        if (NSK_CPP_STUB3(IsSameObject, jni, threadsList[i], thread)) {
+        if (jni->IsSameObject(threadsList[i], thread)) {
                 NSK_DISPLAY0("SUCCESS: expected THREAD_START event\n");
             eventsStart++;
 
@@ -320,7 +314,7 @@
 
     /* check if event is for tested thread */
     for (i = 0; i < THREADS_COUNT; i++) {
-        if (NSK_CPP_STUB3(IsSameObject, jni, threadsList[i], thread)) {
+        if (jni->IsSameObject(threadsList[i], thread)) {
                 NSK_DISPLAY0("SUCCESS: expected THREAD_START event\n");
             eventsEnd++;
 
@@ -403,9 +397,7 @@
         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
         eventCallbacks.ThreadStart = callbackThreadStart;
         eventCallbacks.ThreadEnd = callbackThreadEnd;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetEventCallbacks, jvmti,
-                                    &eventCallbacks, sizeof(eventCallbacks))))
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks))))
             return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t003/sp05t003.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t003/sp05t003.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -100,8 +100,7 @@
         {
             eventsStart = 0;
             if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB4(SetEventNotificationMode, jvmti, JVMTI_ENABLE,
-                                            JVMTI_EVENT_THREAD_START, NULL))) {
+                    jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL))) {
                 nsk_jvmti_setFailStatus();
                 return;
             }
@@ -122,8 +121,7 @@
             }
 
             if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB4(SetEventNotificationMode, jvmti, JVMTI_DISABLE,
-                                            JVMTI_EVENT_THREAD_START, NULL))) {
+                    jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_START, NULL))) {
                 nsk_jvmti_setFailStatus();
             }
 
@@ -152,8 +150,7 @@
         {
             eventsEnd = 0;
             if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB4(SetEventNotificationMode, jvmti, JVMTI_ENABLE,
-                                            JVMTI_EVENT_THREAD_END, NULL))) {
+                    jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_END, NULL))) {
                 nsk_jvmti_setFailStatus();
                 return;
             }
@@ -174,8 +171,7 @@
             }
 
             if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB4(SetEventNotificationMode, jvmti, JVMTI_DISABLE,
-                                            JVMTI_EVENT_THREAD_END, NULL))) {
+                    jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_END, NULL))) {
                 nsk_jvmti_setFailStatus();
             }
 
@@ -221,8 +217,7 @@
     int i;
 
     for (i = 0; i < THREADS_COUNT; i++) {
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(ResumeThread, jvmti, threadsList[i]))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(threadsList[i]))) {
             nsk_jvmti_setFailStatus();
         }
     }
@@ -243,37 +238,35 @@
     jsize i;
 
     /* find debugee class */
-    if (!NSK_JNI_VERIFY(jni, (debugeeClass =
-            NSK_CPP_STUB2(FindClass, jni, DEBUGEE_CLASS_NAME)) != NULL))
+    if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL))
         return NSK_FALSE;
 
     /* find static field with threads array */
     if (!NSK_JNI_VERIFY(jni, (threadsFieldID =
-            NSK_CPP_STUB4(GetStaticFieldID, jni, debugeeClass,
-                                    THREADS_FIELD_NAME, THREADS_FIELD_SIG)) != NULL))
+            jni->GetStaticFieldID(debugeeClass, THREADS_FIELD_NAME, THREADS_FIELD_SIG)) != NULL))
         return NSK_FALSE;
 
     /* get threads array from static field */
     if (!NSK_JNI_VERIFY(jni, (threadsArray = (jobjectArray)
-            NSK_CPP_STUB3(GetStaticObjectField, jni, debugeeClass, threadsFieldID)) != NULL))
+            jni->GetStaticObjectField(debugeeClass, threadsFieldID)) != NULL))
         return NSK_FALSE;
 
     /* check array length */
     if (!NSK_JNI_VERIFY(jni, (threadsArrayLength =
-            NSK_CPP_STUB2(GetArrayLength, jni, threadsArray)) == THREADS_COUNT))
+            jni->GetArrayLength(threadsArray)) == THREADS_COUNT))
         return NSK_FALSE;
 
     /* get each thread from array */
     for (i = 0; i < THREADS_COUNT; i++) {
         if (!NSK_JNI_VERIFY(jni, (threadsList[i] = (jthread)
-                NSK_CPP_STUB3(GetObjectArrayElement, jni, threadsArray, i)) != NULL))
+                jni->GetObjectArrayElement(threadsArray, i)) != NULL))
             return NSK_FALSE;
     }
 
     /* make global references to threads */
     for (i = 0; i < THREADS_COUNT; i++) {
         if (!NSK_JNI_VERIFY(jni, (threadsList[i] = (jthread)
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsList[i])) != NULL))
+                jni->NewGlobalRef(threadsList[i])) != NULL))
             return NSK_FALSE;
     }
 
@@ -293,8 +286,7 @@
     NSK_DISPLAY3("  thread #%d (%s): %p\n", i, threadsName[i], (void*)thread);
 
     /* get frames count */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetFrameCount, jvmti, thread, &framesCount))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->GetFrameCount(thread, &framesCount))) {
         nsk_jvmti_setFailStatus();
         return NSK_TRUE;
     }
@@ -302,8 +294,7 @@
 
     /* get stack frames */
     if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB6(GetStackTrace, jvmti, thread, 0, MAX_STACK_DEPTH,
-                                                    stackFrames, &stackDepth))) {
+            jvmti->GetStackTrace(thread, 0, MAX_STACK_DEPTH, stackFrames, &stackDepth))) {
         nsk_jvmti_setFailStatus();
         return NSK_TRUE;
     }
@@ -355,7 +346,7 @@
 
     /* dispose global references to threads */
     for (i = 0; i < THREADS_COUNT; i++) {
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsList[i]));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsList[i]));
     }
 
     return NSK_TRUE;
@@ -379,15 +370,14 @@
 
     /* check if event is for tested thread */
     for (i = 0; i < THREADS_COUNT; i++) {
-        if (NSK_CPP_STUB3(IsSameObject, jni, threadsList[i], thread)) {
+        if (jni->IsSameObject(threadsList[i], thread)) {
                 NSK_DISPLAY0("SUCCESS: expected THREAD_START event\n");
 
             /* suspend thread */
             NSK_DISPLAY3("  suspend starting thread #%d (%s): %p\n",
                                 i, threadsName[i], (void*)thread);
 
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(SuspendThread, jvmti, thread))) {
+            if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(thread))) {
                 nsk_jvmti_setFailStatus();
                 return;
             }
@@ -414,15 +404,14 @@
 
     /* check if event is for tested thread */
     for (i = 0; i < THREADS_COUNT; i++) {
-        if (NSK_CPP_STUB3(IsSameObject, jni, threadsList[i], thread)) {
+        if (jni->IsSameObject(threadsList[i], thread)) {
                 NSK_DISPLAY0("SUCCESS: expected THREAD_END event\n");
 
             /* suspend thread */
             NSK_DISPLAY3("  suspend finishing thread #%d (%s): %p\n",
                                 i, threadsName[i], (void*)thread);
 
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(SuspendThread, jvmti, thread))) {
+            if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(thread))) {
                 nsk_jvmti_setFailStatus();
                 return;
             }
@@ -504,8 +493,7 @@
         jvmtiCapabilities suspendCaps;
         memset(&suspendCaps, 0, sizeof(suspendCaps));
         suspendCaps.can_suspend = 1;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps)))
+        if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps)))
             return JNI_ERR;
     }
 
@@ -515,9 +503,7 @@
         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
         eventCallbacks.ThreadStart = callbackThreadStart;
         eventCallbacks.ThreadEnd = callbackThreadEnd;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetEventCallbacks, jvmti,
-                                    &eventCallbacks, sizeof(eventCallbacks))))
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks))))
             return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/sp06t001.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/sp06t001.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -135,8 +135,7 @@
  * Generate missed events (COMPILED_METHOD_LOAD only).
  */
 static int generateEvents() {
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(GenerateEvents, jvmti, JVMTI_EVENT_COMPILED_METHOD_LOAD))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->GenerateEvents(JVMTI_EVENT_COMPILED_METHOD_LOAD))) {
         nsk_jvmti_setFailStatus();
         return NSK_FALSE;
     }
@@ -168,8 +167,7 @@
     }
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetAllThreads, jvmti, &allThreadsCount, &allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL))
@@ -182,8 +180,7 @@
         if (!NSK_VERIFY(allThreadsList[i] != NULL))
             return NSK_FALSE;
 
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, allThreadsList[i], &threadInfo)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(allThreadsList[i], &threadInfo)))
             return NSK_FALSE;
 
         if (threadInfo.name != NULL) {
@@ -200,8 +197,7 @@
     }
 
     /* deallocate all threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)allThreadsList)))
         return NSK_FALSE;
 
     /* check if all tested threads found */
@@ -222,12 +218,11 @@
     for (i = 0; i < THREADS_COUNT; i++) {
 
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls =
-                NSK_CPP_STUB2(GetObjectClass, jni, threadsDesc[i].thread)) != NULL))
+                jni->GetObjectClass(threadsDesc[i].thread)) != NULL))
             return NSK_FALSE;
 
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].method =
-                NSK_CPP_STUB4(GetMethodID, jni, threadsDesc[i].cls,
-                            threadsDesc[i].methodName, threadsDesc[i].methodSig)) != NULL))
+                jni->GetMethodID(threadsDesc[i].cls, threadsDesc[i].methodName, threadsDesc[i].methodSig)) != NULL))
             return NSK_FALSE;
 
         NSK_DISPLAY4("    thread #%d (%s): 0x%p (%s)\n",
@@ -239,10 +234,10 @@
     /* make global refs */
     for (i = 0; i < THREADS_COUNT; i++) {
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].thread = (jthread)
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsDesc[i].thread)) != NULL))
+                jni->NewGlobalRef(threadsDesc[i].thread)) != NULL))
             return NSK_FALSE;
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls = (jclass)
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsDesc[i].cls)) != NULL))
+                jni->NewGlobalRef(threadsDesc[i].cls)) != NULL))
             return NSK_FALSE;
     }
 
@@ -262,13 +257,11 @@
     for (i = 0; i < THREADS_COUNT; i++) {
         if (suspend) {
             NSK_DISPLAY2("    suspend thread #%d (%s)\n", i, threadsDesc[i].threadName);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(SuspendThread, jvmti, threadsDesc[i].thread)))
+            if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(threadsDesc[i].thread)))
                 nsk_jvmti_setFailStatus();
         } else {
             NSK_DISPLAY2("    resume thread #%d (%s)\n", i, threadsDesc[i].threadName);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(ResumeThread, jvmti, threadsDesc[i].thread)))
+            if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(threadsDesc[i].thread)))
                 nsk_jvmti_setFailStatus();
         }
     }
@@ -300,9 +293,7 @@
         NSK_DISPLAY2("  thread #%d (%s):\n", i, threadsDesc[i].threadName);
 
         /* get frame count */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetFrameCount, jvmti,
-                                    threadsDesc[i].thread, &frameCount))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->GetFrameCount(threadsDesc[i].thread, &frameCount))) {
             nsk_jvmti_setFailStatus();
             return NSK_TRUE;
         }
@@ -311,8 +302,7 @@
 
         /* get stack trace */
         if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB6(GetStackTrace, jvmti, threadsDesc[i].thread,
-                                    0, MAX_STACK_SIZE, frameStack, &frameStackSize))) {
+                jvmti->GetStackTrace(threadsDesc[i].thread, 0, MAX_STACK_SIZE, frameStack, &frameStackSize))) {
             nsk_jvmti_setFailStatus();
             return NSK_TRUE;
         }
@@ -358,8 +348,8 @@
 
     NSK_DISPLAY0("Dispose global references to threads\n");
     for (i = 0; i < THREADS_COUNT; i++) {
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsDesc[i].thread));
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsDesc[i].cls));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsDesc[i].thread));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsDesc[i].cls));
     }
 
     return NSK_TRUE;
@@ -492,8 +482,7 @@
         memset(&caps, 0, sizeof(caps));
         caps.can_suspend = 1;
         caps.can_generate_compiled_method_load_events = 1;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)))
+        if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
             return JNI_ERR;
     }
 
@@ -502,9 +491,7 @@
         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
         eventCallbacks.CompiledMethodLoad = callbackCompiledMethodLoad;
         eventCallbacks.CompiledMethodUnload = callbackCompiledMethodUnload;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetEventCallbacks, jvmti,
-                                    &eventCallbacks, sizeof(eventCallbacks))))
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks))))
             return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/sp06t002.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/sp06t002.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -143,8 +143,7 @@
  * Generate missed events (COMPILED_METHOD_LOAD only).
  */
 static int generateEvents() {
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(GenerateEvents, jvmti, JVMTI_EVENT_COMPILED_METHOD_LOAD))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->GenerateEvents(JVMTI_EVENT_COMPILED_METHOD_LOAD))) {
         nsk_jvmti_setFailStatus();
         return NSK_FALSE;
     }
@@ -177,8 +176,7 @@
     }
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetAllThreads, jvmti, &allThreadsCount, &allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL))
@@ -191,8 +189,7 @@
         if (!NSK_VERIFY(allThreadsList[i] != NULL))
             return NSK_FALSE;
 
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, allThreadsList[i], &threadInfo)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(allThreadsList[i], &threadInfo)))
             return NSK_FALSE;
 
         if (threadInfo.name != NULL) {
@@ -209,8 +206,7 @@
     }
 
     /* deallocate all threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)allThreadsList)))
         return NSK_FALSE;
 
     /* check if all tested threads found */
@@ -231,12 +227,11 @@
     for (i = 0; i < THREADS_COUNT; i++) {
 
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls =
-                NSK_CPP_STUB2(GetObjectClass, jni, threadsDesc[i].thread)) != NULL))
+                jni->GetObjectClass(threadsDesc[i].thread)) != NULL))
             return NSK_FALSE;
 
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].method =
-                NSK_CPP_STUB4(GetMethodID, jni, threadsDesc[i].cls,
-                            threadsDesc[i].methodName, threadsDesc[i].methodSig)) != NULL))
+                jni->GetMethodID(threadsDesc[i].cls, threadsDesc[i].methodName, threadsDesc[i].methodSig)) != NULL))
             return NSK_FALSE;
 
         NSK_DISPLAY4("    thread #%d (%s): 0x%p (%s)\n",
@@ -248,10 +243,10 @@
     /* make global refs */
     for (i = 0; i < THREADS_COUNT; i++) {
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].thread = (jthread)
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsDesc[i].thread)) != NULL))
+                jni->NewGlobalRef(threadsDesc[i].thread)) != NULL))
             return NSK_FALSE;
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls = (jclass)
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsDesc[i].cls)) != NULL))
+                jni->NewGlobalRef(threadsDesc[i].cls)) != NULL))
             return NSK_FALSE;
     }
 
@@ -271,13 +266,11 @@
     for (i = 0; i < THREADS_COUNT; i++) {
         if (suspend) {
             NSK_DISPLAY2("    suspend thread #%d (%s)\n", i, threadsDesc[i].threadName);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(SuspendThread, jvmti, threadsDesc[i].thread)))
+            if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(threadsDesc[i].thread)))
                 nsk_jvmti_setFailStatus();
         } else {
             NSK_DISPLAY2("    resume thread #%d (%s)\n", i, threadsDesc[i].threadName);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(ResumeThread, jvmti, threadsDesc[i].thread)))
+            if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(threadsDesc[i].thread)))
                 nsk_jvmti_setFailStatus();
         }
     }
@@ -310,9 +303,7 @@
         NSK_DISPLAY2("  thread #%d (%s):\n", i, threadsDesc[i].threadName);
 
         /* get frame count */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetFrameCount, jvmti,
-                                    threadsDesc[i].thread, &frameCount))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->GetFrameCount(threadsDesc[i].thread, &frameCount))) {
             nsk_jvmti_setFailStatus();
             return NSK_TRUE;
         }
@@ -321,8 +312,7 @@
 
         /* get stack trace */
         if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB6(GetStackTrace, jvmti, threadsDesc[i].thread,
-                                    0, MAX_STACK_SIZE, frameStack, &frameStackSize))) {
+                jvmti->GetStackTrace(threadsDesc[i].thread, 0, MAX_STACK_SIZE, frameStack, &frameStackSize))) {
             nsk_jvmti_setFailStatus();
             return NSK_TRUE;
         }
@@ -387,8 +377,8 @@
 
     NSK_DISPLAY0("Dispose global references to threads\n");
     for (i = 0; i < THREADS_COUNT; i++) {
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsDesc[i].thread));
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsDesc[i].cls));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsDesc[i].thread));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsDesc[i].cls));
     }
 
     return NSK_TRUE;
@@ -521,8 +511,7 @@
         memset(&caps, 0, sizeof(caps));
         caps.can_suspend = 1;
         caps.can_generate_compiled_method_load_events = 1;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)))
+        if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
             return JNI_ERR;
     }
 
@@ -531,9 +520,7 @@
         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
         eventCallbacks.CompiledMethodLoad = callbackCompiledMethodLoad;
         eventCallbacks.CompiledMethodUnload = callbackCompiledMethodUnload;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetEventCallbacks, jvmti,
-                                    &eventCallbacks, sizeof(eventCallbacks))))
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks))))
             return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/sp06t003.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/sp06t003.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -143,8 +143,7 @@
  * Generate missed events (COMPILED_METHOD_LOAD only).
  */
 static int generateEvents() {
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(GenerateEvents, jvmti, JVMTI_EVENT_COMPILED_METHOD_LOAD))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->GenerateEvents(JVMTI_EVENT_COMPILED_METHOD_LOAD))) {
         nsk_jvmti_setFailStatus();
         return NSK_FALSE;
     }
@@ -177,8 +176,7 @@
     }
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(GetAllThreads, jvmti, &allThreadsCount, &allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL))
@@ -191,8 +189,7 @@
         if (!NSK_VERIFY(allThreadsList[i] != NULL))
             return NSK_FALSE;
 
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, allThreadsList[i], &threadInfo)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(allThreadsList[i], &threadInfo)))
             return NSK_FALSE;
 
         if (threadInfo.name != NULL) {
@@ -209,8 +206,7 @@
     }
 
     /* deallocate all threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)allThreadsList)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)allThreadsList)))
         return NSK_FALSE;
 
     /* check if all tested threads found */
@@ -231,12 +227,11 @@
     for (i = 0; i < THREADS_COUNT; i++) {
 
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls =
-                NSK_CPP_STUB2(GetObjectClass, jni, threadsDesc[i].thread)) != NULL))
+                jni->GetObjectClass(threadsDesc[i].thread)) != NULL))
             return NSK_FALSE;
 
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].method =
-                NSK_CPP_STUB4(GetMethodID, jni, threadsDesc[i].cls,
-                            threadsDesc[i].methodName, threadsDesc[i].methodSig)) != NULL))
+                jni->GetMethodID(threadsDesc[i].cls, threadsDesc[i].methodName, threadsDesc[i].methodSig)) != NULL))
             return NSK_FALSE;
 
         NSK_DISPLAY4("    thread #%d (%s): 0x%p (%s)\n",
@@ -248,10 +243,10 @@
     /* make global refs */
     for (i = 0; i < THREADS_COUNT; i++) {
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].thread = (jthread)
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsDesc[i].thread)) != NULL))
+                jni->NewGlobalRef(threadsDesc[i].thread)) != NULL))
             return NSK_FALSE;
         if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls = (jclass)
-                NSK_CPP_STUB2(NewGlobalRef, jni, threadsDesc[i].cls)) != NULL))
+                jni->NewGlobalRef(threadsDesc[i].cls)) != NULL))
             return NSK_FALSE;
     }
 
@@ -271,13 +266,11 @@
     for (i = 0; i < THREADS_COUNT; i++) {
         if (suspend) {
             NSK_DISPLAY2("    suspend thread #%d (%s)\n", i, threadsDesc[i].threadName);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(SuspendThread, jvmti, threadsDesc[i].thread)))
+            if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(threadsDesc[i].thread)))
                 nsk_jvmti_setFailStatus();
         } else {
             NSK_DISPLAY2("    resume thread #%d (%s)\n", i, threadsDesc[i].threadName);
-            if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB2(ResumeThread, jvmti, threadsDesc[i].thread)))
+            if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(threadsDesc[i].thread)))
                 nsk_jvmti_setFailStatus();
         }
     }
@@ -312,9 +305,7 @@
         NSK_DISPLAY2("  thread #%d (%s):\n", i, threadsDesc[i].threadName);
 
         /* get frame count */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetFrameCount, jvmti,
-                                    threadsDesc[i].thread, &frameCount))) {
+        if (!NSK_JVMTI_VERIFY(jvmti->GetFrameCount(threadsDesc[i].thread, &frameCount))) {
             nsk_jvmti_setFailStatus();
             return NSK_TRUE;
         }
@@ -322,8 +313,7 @@
 
         /* get stack trace */
         if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB6(GetStackTrace, jvmti, threadsDesc[i].thread,
-                                    0, MAX_STACK_SIZE, frameStack, &frameStackSize))) {
+                jvmti->GetStackTrace(threadsDesc[i].thread, 0, MAX_STACK_SIZE, frameStack, &frameStackSize))) {
             nsk_jvmti_setFailStatus();
             return NSK_TRUE;
         }
@@ -343,8 +333,7 @@
                                         (long)frameStack[j].location);
             /* query frame location */
             if (!NSK_JVMTI_VERIFY(
-                    NSK_CPP_STUB5(GetFrameLocation, jvmti, threadsDesc[i].thread,
-                                        j, &qMethod, &qLocation))) {
+                    jvmti->GetFrameLocation(threadsDesc[i].thread, j, &qMethod, &qLocation))) {
                 nsk_jvmti_setFailStatus();
                 continue;
             }
@@ -404,8 +393,8 @@
 
     NSK_DISPLAY0("Dispose global references to threads\n");
     for (i = 0; i < THREADS_COUNT; i++) {
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsDesc[i].thread));
-        NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, threadsDesc[i].cls));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsDesc[i].thread));
+        NSK_TRACE(jni->DeleteGlobalRef(threadsDesc[i].cls));
     }
 
     return NSK_TRUE;
@@ -538,8 +527,7 @@
         memset(&caps, 0, sizeof(caps));
         caps.can_suspend = 1;
         caps.can_generate_compiled_method_load_events = 1;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)))
+        if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
             return JNI_ERR;
     }
 
@@ -548,9 +536,7 @@
         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
         eventCallbacks.CompiledMethodLoad = callbackCompiledMethodLoad;
         eventCallbacks.CompiledMethodUnload = callbackCompiledMethodUnload;
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(SetEventCallbacks, jvmti,
-                                    &eventCallbacks, sizeof(eventCallbacks))))
+        if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks))))
             return JNI_ERR;
     }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t001/sp07t001.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t001/sp07t001.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -62,8 +62,7 @@
     NSK_DISPLAY0("Prepare: find tested thread\n");
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-           NSK_CPP_STUB3(GetAllThreads, jvmti, &threads_count, &threads)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(threads_count > 0 && threads != NULL))
@@ -75,8 +74,7 @@
             return NSK_FALSE;
 
         /* get thread information */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, threads[i], &info)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(threads[i], &info)))
             return NSK_FALSE;
 
         NSK_DISPLAY3("    thread #%d (%s): %p\n", i, info.name, threads[i]);
@@ -87,15 +85,13 @@
         }
 
         if (info.name != NULL) {
-            if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(
-                    Deallocate, jvmti, (unsigned char*)info.name)))
+            if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)info.name)))
                 return NSK_FALSE;
         }
     }
 
     /* deallocate threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threads)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads)))
         return NSK_FALSE;
 
     if (thread == NULL) {
@@ -103,8 +99,7 @@
         return NSK_FALSE;
     }
 
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(CreateRawMonitor, jvmti, "waitLock", &waitLock)))
+    if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("waitLock", &waitLock)))
         return NSK_FALSE;
 
     return NSK_TRUE;
@@ -114,14 +109,13 @@
 
 static int wait_for(jvmtiEnv* jvmti, jlong millis) {
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, waitLock)))
+    if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(waitLock)))
         return NSK_FALSE;
 
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(RawMonitorWait, jvmti, waitLock, millis)))
+    if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorWait(waitLock, millis)))
         nsk_jvmti_setFailStatus();
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, waitLock)))
+    if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(waitLock)))
         return NSK_FALSE;
 
     return NSK_TRUE;
@@ -132,27 +126,25 @@
     char *name = NULL;
     char *signature = NULL;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, jvmti,
-            frameBuffer[frameCount-1-i].method, &name, &signature, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(frameBuffer[frameCount-1-i].method, &name, &signature, NULL)))
         return NSK_FALSE;
 
     NSK_DISPLAY4("    got[%d] method: %s%s, location: %s\n", i, name,
         signature, jlong_to_string(frameBuffer[frameCount-1-i].location, buffer));
     if (name != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)name);
+        jvmti->Deallocate((unsigned char*)name);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)signature);
+        jvmti->Deallocate((unsigned char*)signature);
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, jvmti,
-            sampleStack[i].method, &name, &signature, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(sampleStack[i].method, &name, &signature, NULL)))
         return NSK_FALSE;
 
     NSK_DISPLAY4("    exp[%d] method: %s%s, location: %s\n", i, name,
         signature, jlong_to_string(sampleStack[i].location, buffer));
     if (name != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)name);
+        jvmti->Deallocate((unsigned char*)name);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)signature);
+        jvmti->Deallocate((unsigned char*)signature);
 
     return NSK_TRUE;
 }
@@ -162,27 +154,25 @@
     char *name = NULL;
     char *signature = NULL;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, jvmti,
-            frameBuffer[frameCount-1-i].method, &name, &signature, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(frameBuffer[frameCount-1-i].method, &name, &signature, NULL)))
         return NSK_FALSE;
 
     NSK_COMPLAIN3("    got: method=%s%s, location=%s\n", name, signature,
         jlong_to_string(frameBuffer[frameCount-1-i].location, buffer));
     if (name != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)name);
+        jvmti->Deallocate((unsigned char*)name);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)signature);
+        jvmti->Deallocate((unsigned char*)signature);
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, jvmti,
-            sampleStack[i].method, &name, &signature, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(sampleStack[i].method, &name, &signature, NULL)))
         return NSK_FALSE;
 
     NSK_COMPLAIN3("    expected: method=%s%s, location=%s\n", name, signature,
         jlong_to_string(sampleStack[i].location, buffer));
     if (name != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)name);
+        jvmti->Deallocate((unsigned char*)name);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)signature);
+        jvmti->Deallocate((unsigned char*)signature);
 
     return NSK_TRUE;
 }
@@ -193,13 +183,11 @@
     int displayFlag =
         (nsk_getVerboseMode() && (sampleCount % DISPLAYING_FREQUENCY) == 0);
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, frameLock)))
+    if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(frameLock)))
         return NSK_FALSE;
 
     /* get stack trace */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB6(GetStackTrace, jvmti, thread,
-                0, MAX_DEPTH, frameBuffer, &frameCount))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->GetStackTrace(thread, 0, MAX_DEPTH, frameBuffer, &frameCount))) {
         res = NSK_FALSE;
     } else {
         if (displayFlag) {
@@ -228,7 +216,7 @@
         }
     }
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, frameLock)))
+    if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(frameLock)))
         return NSK_FALSE;
 
     return res;
@@ -278,49 +266,45 @@
         return 0;
     }
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, frameLock)))
+    if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(frameLock)))
         return NSK_FALSE;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetFrameLocation, jvmti, NULL, 1,
-            &sampleStack[depth].method, &sampleStack[depth].location))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->GetFrameLocation(NULL, 1, &sampleStack[depth].method, &sampleStack[depth].location))) {
         nsk_jvmti_setFailStatus();
         return 0;
     }
 
     depth++;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetFrameLocation, jvmti, NULL, 0,
-            &sampleStack[depth].method, &sampleStack[depth].location))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->GetFrameLocation(NULL, 0, &sampleStack[depth].method, &sampleStack[depth].location))) {
         nsk_jvmti_setFailStatus();
         return 0;
     }
 
     depth++;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, frameLock)))
+    if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(frameLock)))
         return NSK_FALSE;
 
-    if (!NSK_JNI_VERIFY(jni, (klass = NSK_CPP_STUB2(GetObjectClass,
-            jni, obj)) != NULL)) {
+    if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(obj)) != NULL)) {
         nsk_jvmti_setFailStatus();
         return 0;
     }
 
-    if (!NSK_JNI_VERIFY(jni, (method = NSK_CPP_STUB4(GetMethodID,
-            jni, klass, "fibonacci", "(I)I")) != NULL)) {
+    if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "fibonacci", "(I)I")) != NULL)) {
         nsk_jvmti_setFailStatus();
         return 0;
     }
 
-    result = NSK_CPP_STUB4(CallIntMethod, jni, obj, method, i);
+    result = jni->CallIntMethod(obj, method, i);
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, frameLock)))
+    if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(frameLock)))
         return NSK_FALSE;
 
     depth--;
     depth--;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, frameLock)))
+    if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(frameLock)))
         return NSK_FALSE;
 
     return result;
@@ -355,8 +339,7 @@
             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
         return JNI_ERR;
 
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(CreateRawMonitor, jvmti, "frameLock", &frameLock)))
+    if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("frameLock", &frameLock)))
         return NSK_FALSE;
 
     /* register agent proc and arg */
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t002/sp07t002.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t002/sp07t002.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -66,8 +66,7 @@
     NSK_DISPLAY0("Prepare: find tested thread\n");
 
     /* get all live threads */
-    if (!NSK_JVMTI_VERIFY(
-           NSK_CPP_STUB3(GetAllThreads, jvmti, &threads_count, &threads)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads)))
         return NSK_FALSE;
 
     if (!NSK_VERIFY(threads_count > 0 && threads != NULL))
@@ -79,8 +78,7 @@
             return NSK_FALSE;
 
         /* get thread information */
-        if (!NSK_JVMTI_VERIFY(
-                NSK_CPP_STUB3(GetThreadInfo, jvmti, threads[i], &info)))
+        if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(threads[i], &info)))
             return NSK_FALSE;
 
         NSK_DISPLAY3("    thread #%d (%s): %p\n", i, info.name, threads[i]);
@@ -91,15 +89,13 @@
         }
 
         if (info.name != NULL) {
-            if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(
-                    Deallocate, jvmti, (unsigned char*)info.name)))
+            if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)info.name)))
                 return NSK_FALSE;
         }
     }
 
     /* deallocate threads list */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threads)))
+    if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads)))
         return NSK_FALSE;
 
     if (thread == NULL) {
@@ -108,41 +104,34 @@
     }
 
     /* get tested thread class */
-    if (!NSK_JNI_VERIFY(jni, (klass =
-            NSK_CPP_STUB2(GetObjectClass, jni, thread)) != NULL))
+    if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL))
         return NSK_FALSE;
 
     /* get tested thread field 'MAX_LADDER' */
-    if (!NSK_JNI_VERIFY(jni, (fid =
-            NSK_CPP_STUB4(GetStaticFieldID, jni, klass,
-                "MAX_LADDER", "I")) != NULL))
+    if (!NSK_JNI_VERIFY(jni, (fid = jni->GetStaticFieldID(klass, "MAX_LADDER", "I")) != NULL))
         return NSK_FALSE;
 
-    MAX_LADDER = NSK_CPP_STUB3(GetStaticIntField, jni, klass, fid);
+    MAX_LADDER = jni->GetStaticIntField(klass, fid);
     NSK_DISPLAY1("MAX_LADDER: %d\n", MAX_LADDER);
 
     /* get tested thread field 'depth' */
-    if (!NSK_JNI_VERIFY(jni, (field =
-            NSK_CPP_STUB4(GetFieldID, jni, klass, "depth", "I")) != NULL))
+    if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "depth", "I")) != NULL))
         return NSK_FALSE;
 
     /* get tested thread method 'run' */
-    if (!NSK_JNI_VERIFY(jni, (methodRun =
-            NSK_CPP_STUB4(GetMethodID, jni, klass, "run", "()V")) != NULL))
+    if (!NSK_JNI_VERIFY(jni, (methodRun = jni->GetMethodID(klass, "run", "()V")) != NULL))
         return NSK_FALSE;
 
     /* get tested thread method 'catcher' */
     if (!NSK_JNI_VERIFY(jni, (methodCatcher =
-            NSK_CPP_STUB4(GetMethodID, jni, klass, "catcher", "(II)V")) != NULL))
+            jni->GetMethodID(klass, "catcher", "(II)V")) != NULL))
         return NSK_FALSE;
 
     /* get tested thread method 'thrower' */
-    if (!NSK_JNI_VERIFY(jni, (methodThrower=
-            NSK_CPP_STUB4(GetMethodID, jni, klass, "thrower", "(I)V")) != NULL))
+    if (!NSK_JNI_VERIFY(jni, (methodThrower= jni->GetMethodID(klass, "thrower", "(I)V")) != NULL))
         return NSK_FALSE;
 
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(CreateRawMonitor, jvmti, "waitLock", &waitLock)))
+    if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("waitLock", &waitLock)))
         return NSK_FALSE;
 
     return NSK_TRUE;
@@ -152,14 +141,13 @@
 
 static int wait_for(jvmtiEnv* jvmti, jlong millis) {
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, waitLock)))
+    if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(waitLock)))
         return NSK_FALSE;
 
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB3(RawMonitorWait, jvmti, waitLock, millis)))
+    if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorWait(waitLock, millis)))
         nsk_jvmti_setFailStatus();
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, waitLock)))
+    if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(waitLock)))
         return NSK_FALSE;
 
     return NSK_TRUE;
@@ -170,16 +158,15 @@
     char *name = NULL;
     char *signature = NULL;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, jvmti,
-            frameBuffer[frameCount-1-i].method, &name, &signature, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(frameBuffer[frameCount-1-i].method, &name, &signature, NULL)))
         return NSK_FALSE;
 
     NSK_DISPLAY4("    [%d] method: %s%s, location: %s\n", i, name,
         signature, jlong_to_string(frameBuffer[frameCount-1-i].location, buffer));
     if (name != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)name);
+        jvmti->Deallocate((unsigned char*)name);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)signature);
+        jvmti->Deallocate((unsigned char*)signature);
 
     return NSK_TRUE;
 }
@@ -189,19 +176,17 @@
     char *name = NULL;
     char *signature = NULL;
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, jvmti,
-            frameBuffer[frameCount-1-i].method, &name, &signature, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(frameBuffer[frameCount-1-i].method, &name, &signature, NULL)))
         return NSK_FALSE;
 
     NSK_COMPLAIN3("    got method: %s%s, location: %s\n", name, signature,
         jlong_to_string(frameBuffer[frameCount-1-i].location, buffer));
     if (name != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)name);
+        jvmti->Deallocate((unsigned char*)name);
     if (signature != NULL)
-        NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)signature);
+        jvmti->Deallocate((unsigned char*)signature);
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, jvmti,
-            method, &name, &signature, NULL)))
+    if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(method, &name, &signature, NULL)))
         return NSK_FALSE;
 
     NSK_COMPLAIN2("    expected method: %s%s\n", name, signature);
@@ -217,19 +202,17 @@
     int displayFlag =
         (nsk_getVerboseMode() && (sampleCount % DISPLAYING_FREQUENCY) == 0);
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(SuspendThread, jvmti, thread)))
+    if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(thread)))
         return NSK_FALSE;
 
-    depth = NSK_CPP_STUB3(GetIntField, jni, thread, field);
+    depth = jni->GetIntField(thread, field);
 
     /* get stack trace */
-    if (!NSK_JVMTI_VERIFY(
-            NSK_CPP_STUB6(GetStackTrace, jvmti, thread,
-                0, MAX_DEPTH, frameBuffer, &frameCount))) {
+    if (!NSK_JVMTI_VERIFY(jvmti->GetStackTrace(thread, 0, MAX_DEPTH, frameBuffer, &frameCount))) {
         res = NSK_FALSE;
     }
 
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(ResumeThread, jvmti, thread)))
+    if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(thread)))
         res = NSK_FALSE;
 
     if (res) {
@@ -322,7 +305,7 @@
 
     memset(&caps, 0, sizeof(caps));
     caps.can_suspend = 1;
-    if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)))
+    if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
         return JNI_ERR;
 
     /* register agent proc and arg */
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -20,10 +20,12 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
 #include <jni.h>
 #include <stdio.h>
 #include <time.h>
 #include "jni_tools.h"
+#include "ExceptionCheckingJniEnv.hpp"
 
 extern "C" {
 
@@ -35,28 +37,18 @@
  * Signature: (JJ)V
  */
 JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIGlobalRefLocker_criticalNative
-  (JNIEnv *env, jobject o, jlong enterTime, jlong sleepTime) {
+  (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
+        ExceptionCheckingJniEnvPtr env(jni_env);
+
         jobject obj;
         jobject gref;
         time_t start_time, current_time;
 
         if (objFieldId == NULL) {
                 jclass klass = env->GetObjectClass(o);
-                if (klass == NULL) {
-                        printf("Error: GetObjectClass returned NULL\n");
-                        return;
-                }
                 objFieldId = env->GetFieldID(klass, "obj", "Ljava/lang/Object;");
-                if (objFieldId == NULL) {
-                        printf("Error: GetFieldID returned NULL\n");
-                        return;
-                }
         }
         obj = env->GetObjectField(o, objFieldId);
-        if (obj == NULL) {
-                printf("Error: GetObjectField returned NULL\n");
-                return;
-        }
         env->SetObjectField(o, objFieldId, NULL);
         start_time = time(NULL);
         enterTime /= 1000;
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/libJNIGlobalRefLocker.cpp	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/libJNIGlobalRefLocker.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -24,3 +24,4 @@
 #include "JNIGlobalRefLocker.cpp"
 #include "jni_tools.cpp"
 #include "nsk_tools.cpp"
+#include "ExceptionCheckingJniEnv.cpp"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.cpp	Mon Oct 15 11:39:10 2018 -0700
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, Google and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "ExceptionCheckingJniEnv.hpp"
+
+namespace {
+
+template<class T = void*>
+class JNIVerifier {
+ public:
+  JNIVerifier(ExceptionCheckingJniEnv *env, const char* base_msg)
+      : _env(env), _base_msg(base_msg), _return_error(NULL) {
+  }
+
+  ~JNIVerifier() {
+    JNIEnv* jni_env = _env->GetJNIEnv();
+    if (jni_env->ExceptionCheck()) {
+      _env->HandleError(_base_msg);
+      return;
+    }
+
+    if (_return_error != NULL) {
+      ProcessReturnError();
+    }
+  }
+
+  void ProcessReturnError() {
+    int len = snprintf(NULL, 0, "%s : %s", _base_msg, _return_error) + 1;
+
+    if (len <= 0) {
+      _env->HandleError(_return_error);
+      return;
+    }
+
+    char* full_message = (char*) malloc(len);
+    if (full_message == NULL) {
+      _env->HandleError(_return_error);
+      return;
+    }
+
+    snprintf(full_message, len, "%s : %s", _base_msg, _return_error);
+
+    _env->HandleError(full_message);
+    free(full_message);
+  }
+
+  T ResultNotNull(T ptr) {
+    if (ptr == NULL) {
+      _return_error = "Return is NULL";
+    }
+    return ptr;
+  }
+
+ private:
+  ExceptionCheckingJniEnv* _env;
+  const char* const _base_msg;
+  const char* _return_error;
+};
+
+}
+
+jclass ExceptionCheckingJniEnv::GetObjectClass(jobject obj) {
+  JNIVerifier<jclass> marker(this, "GetObjectClass");
+  return marker.ResultNotNull(_jni_env->GetObjectClass(obj));
+}
+
+jfieldID ExceptionCheckingJniEnv::GetFieldID(jclass klass, const char *name, const char* type) {
+  JNIVerifier<jfieldID> marker(this, "GetObjectClass");
+  return marker.ResultNotNull(_jni_env->GetFieldID(klass, name, type));
+}
+
+jobject ExceptionCheckingJniEnv::GetObjectField(jobject obj, jfieldID field) {
+  JNIVerifier<jobject> marker(this, "GetObjectField");
+  return marker.ResultNotNull(_jni_env->GetObjectField(obj, field));
+}
+
+void ExceptionCheckingJniEnv::SetObjectField(jobject obj, jfieldID field, jobject value) {
+  JNIVerifier<> marker(this, "SetObjectField");
+  _jni_env->SetObjectField(obj, field, value);
+}
+
+jobject ExceptionCheckingJniEnv::NewGlobalRef(jobject obj) {
+  JNIVerifier<jobject> marker(this, "GetObjectField");
+  return marker.ResultNotNull(_jni_env->NewGlobalRef(obj));
+}
+
+void ExceptionCheckingJniEnv::DeleteGlobalRef(jobject obj) {
+  JNIVerifier<> marker(this, "DeleteGlobalRef");
+  _jni_env->DeleteGlobalRef(obj);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.hpp	Mon Oct 15 11:39:10 2018 -0700
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, Google and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+#ifndef NSK_EXCEPTIONCHECKINGJNIENV_DEFINED
+#define NSK_EXCEPTIONCHECKINGJNIENV_DEFINED
+
+#include <jni.h>
+
+/**
+ * ExceptionCheckingJniEnv wraps around the JNIEnv data structure and
+ * methods to enable automatic exception checking. This allows test writers
+ * and readers to concentrate on what the test is to do and leave the
+ * error checking and throwing to this data structure and subsystem.
+ *
+ * For example:
+ *
+ * ... JNIEnv* env ...
+ *  jclass klass = env->GetObjectClass(o);
+ *  if (klass == NULL) {
+ *      printf("Error: GetObjectClass returned NULL\n");
+ *      return;
+ *  }
+ *  if (env->ExceptionCheck()) {
+ *    ...
+ *  }
+ *
+ *  Can be simplified to:
+ * ... ExceptionCheckingJniEnv* env ...
+ *  jclass klass = env->GetObjectClass(o);
+ *
+ *  Where now the JNI Exception checking and the NULL return checking are done
+ *  internally and will perform whatever action the ErrorHandler requires.
+ *
+ *  By default, the error handler describes the exception via the JNI
+ *  ExceptionDescribe method and calls FatalError.
+ *
+ *  Note: at a future date, this will also include the tracing mechanism done in
+ *  NSK_VERIFY, which will thus embed its logic into the ExceptionCheckingJniEnv
+ *  and clearing that up for the code readers and writers.
+ */
+class ExceptionCheckingJniEnv {
+ public:
+  // JNIEnv API redefinitions.
+  jfieldID GetFieldID(jclass klass, const char *name, const char* type);
+  jclass GetObjectClass(jobject obj);
+  jobject GetObjectField(jobject obj, jfieldID field);
+  void SetObjectField(jobject obj, jfieldID field, jobject value);
+
+  jobject NewGlobalRef(jobject obj);
+  void DeleteGlobalRef(jobject obj);
+
+  // ExceptionCheckingJniEnv methods.
+  JNIEnv* GetJNIEnv() {
+    return _jni_env;
+  }
+
+  void HandleError(const char* msg) {
+    if (_error_handler) {
+      _error_handler(_jni_env, msg);
+    }
+  }
+
+  typedef void (*ErrorHandler)(JNIEnv* env, const char* error_message);
+
+  static void FatalError(JNIEnv* env, const char* message) {
+    if (env->ExceptionCheck()) {
+      env->ExceptionDescribe();
+    }
+    env->FatalError(message);
+  }
+
+  ExceptionCheckingJniEnv(JNIEnv* jni_env, ErrorHandler error_handler) :
+    _jni_env(jni_env), _error_handler(error_handler) {}
+
+ private:
+  JNIEnv* _jni_env;
+  ErrorHandler _error_handler;
+};
+
+// We cannot use unique_ptr due to this being gnu98++, so use this instead:
+class ExceptionCheckingJniEnvPtr {
+ private:
+  ExceptionCheckingJniEnv _env;
+
+ public:
+  ExceptionCheckingJniEnv* operator->() {
+    return &_env;
+  }
+
+  ExceptionCheckingJniEnvPtr(
+      JNIEnv* jni_env,
+      ExceptionCheckingJniEnv::ErrorHandler error_handler = ExceptionCheckingJniEnv::FatalError) :
+          _env(jni_env, error_handler) {
+  }
+};
+
+#endif
--- a/test/jdk/ProblemList.txt	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/ProblemList.txt	Mon Oct 15 11:39:10 2018 -0700
@@ -835,8 +835,6 @@
 
 # jdk_jdi
 
-com/sun/jdi/BasicJDWPConnectionTest.java                        8195703 generic-all
-
 com/sun/jdi/RepStep.java                                        8043571 generic-all
 
 com/sun/jdi/sde/SourceDebugExtensionTest.java                   8158066 windows-all
--- a/test/jdk/com/sun/jdi/BasicJDWPConnectionTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/com/sun/jdi/BasicJDWPConnectionTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -29,17 +29,15 @@
  */
 
 import java.io.IOException;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
 
 import java.net.Socket;
 import java.net.SocketException;
 
 import jdk.test.lib.apps.LingeredApp;
-import jdk.test.lib.Utils;
 
 import java.util.ArrayList;
-import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 
 public class BasicJDWPConnectionTest {
@@ -64,25 +62,37 @@
         return res;
     }
 
-    public static ArrayList<String> prepareCmd(int port, String allowOpt) {
-         String address = "*:" + String.valueOf(port);
+    public static ArrayList<String> prepareCmd(String allowOpt) {
          ArrayList<String> cmd = new ArrayList<>();
 
          String jdwpArgs = "-agentlib:jdwp=transport=dt_socket,server=y," +
-                           "suspend=n,address=" + address + allowOpt;
+                           "suspend=n,address=*:0" + allowOpt;
          cmd.add(jdwpArgs);
          return cmd;
     }
 
+    private static Pattern listenRegexp = Pattern.compile("Listening for transport \\b(.+)\\b at address: \\b(\\d+)\\b");
+    private static int detectPort(String s) {
+        Matcher m = listenRegexp.matcher(s);
+        if (!m.find()) {
+            throw new RuntimeException("Could not detect port from '" + s + "'");
+        }
+        // m.group(1) is transport, m.group(2) is port
+        return Integer.parseInt(m.group(2));
+    }
+
     public static void positiveTest(String testName, String allowOpt)
         throws InterruptedException, IOException {
         System.err.println("\nStarting " + testName);
-        int port = Utils.getFreePort();
-        ArrayList<String> cmd = prepareCmd(port, allowOpt);
+        ArrayList<String> cmd = prepareCmd(allowOpt);
 
         LingeredApp a = LingeredApp.startApp(cmd);
-        int res = handshake(port);
-        a.stopApp();
+        int res;
+        try {
+            res = handshake(detectPort(a.getProcessStdout()));
+        } finally {
+            a.stopApp();
+        }
         if (res < 0) {
             throw new RuntimeException(testName + " FAILED");
         }
@@ -92,12 +102,15 @@
     public static void negativeTest(String testName, String allowOpt)
         throws InterruptedException, IOException {
         System.err.println("\nStarting " + testName);
-        int port = Utils.getFreePort();
-        ArrayList<String> cmd = prepareCmd(port, allowOpt);
+        ArrayList<String> cmd = prepareCmd(allowOpt);
 
         LingeredApp a = LingeredApp.startApp(cmd);
-        int res = handshake(port);
-        a.stopApp();
+        int res;
+        try {
+            res = handshake(detectPort(a.getProcessStdout()));
+        } finally {
+            a.stopApp();
+        }
         if (res > 0) {
             System.err.println(testName + ": res=" + res);
             throw new RuntimeException(testName + " FAILED");
@@ -109,16 +122,18 @@
     public static void badAllowOptionTest(String testName, String allowOpt)
         throws InterruptedException, IOException {
         System.err.println("\nStarting " + testName);
-        int port = Utils.getFreePort();
-        ArrayList<String> cmd = prepareCmd(port, allowOpt);
+        ArrayList<String> cmd = prepareCmd(allowOpt);
 
+        LingeredApp a;
         try {
-            LingeredApp a = LingeredApp.startApp(cmd);
+            a = LingeredApp.startApp(cmd);
         } catch (IOException ex) {
             System.err.println(testName + ": caught expected IOException");
             System.err.println(testName + " PASSED");
             return;
         }
+        // LingeredApp.startApp is expected to fail, but if not, terminate the app
+        a.stopApp();
         throw new RuntimeException(testName + " FAILED");
     }
 
@@ -174,26 +189,16 @@
         badAllowOptionTest("ExplicitMultiDefault2Test", allowOpt);
     }
 
-    public static void main(String[] args) {
-        try {
-            DefaultTest();
-            ExplicitDefaultTest();
-            AllowTest();
-            MultiAllowTest();
-            DenyTest();
-            MultiDenyTest();
-            EmptyAllowOptionTest();
-            ExplicitMultiDefault1Test();
-            ExplicitMultiDefault2Test();
-            System.err.println("\nTest PASSED");
-        } catch (InterruptedException ex) {
-            System.err.println("\nTest ERROR, getFreePort");
-            ex.printStackTrace();
-            System.exit(3);
-        } catch (IOException ex) {
-            System.err.println("\nTest ERROR");
-            ex.printStackTrace();
-            System.exit(3);
-        }
+    public static void main(String[] args) throws Exception {
+        DefaultTest();
+        ExplicitDefaultTest();
+        AllowTest();
+        MultiAllowTest();
+        DenyTest();
+        MultiDenyTest();
+        EmptyAllowOptionTest();
+        ExplicitMultiDefault1Test();
+        ExplicitMultiDefault2Test();
+        System.err.println("\nTest PASSED");
     }
 }
--- a/test/jdk/com/sun/jdi/DoubleAgentTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/com/sun/jdi/DoubleAgentTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -41,10 +41,8 @@
             "test.classes", ".");
 
     public static void main(String[] args) throws Throwable {
-        int port = Utils.getFreePort();
-
         String jdwpOption = "-agentlib:jdwp=transport=dt_socket"
-                         + ",server=y" + ",suspend=n" + ",address=*:" + String.valueOf(port);
+                         + ",server=y" + ",suspend=n" + ",address=*:0";
 
         OutputAnalyzer output = ProcessTools.executeTestJvm("-classpath",
                 TEST_CLASSES,
--- a/test/jdk/com/sun/net/httpserver/SelCacheTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/com/sun/net/httpserver/SelCacheTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 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
@@ -24,14 +24,14 @@
 /**
  * @test
  * @bug 6270015
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run main/othervm -Dsun.net.httpserver.selCacheTimeout=2 SelCacheTest
  * @summary  Light weight HTTP server
  */
 
 import com.sun.net.httpserver.*;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 import java.util.*;
 import java.util.concurrent.*;
--- a/test/jdk/com/sun/net/httpserver/Test1.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/com/sun/net/httpserver/Test1.java	Mon Oct 15 11:39:10 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -24,8 +24,8 @@
 /**
  * @test
  * @bug 6270015
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run main/othervm Test1
  * @run main/othervm -Dsun.net.httpserver.maxReqTime=10 Test1
  * @run main/othervm -Dsun.net.httpserver.nodelay=true Test1
@@ -38,7 +38,7 @@
 import java.io.*;
 import java.net.*;
 import javax.net.ssl.*;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 /* basic http/s connectivity test
  * Tests:
--- a/test/jdk/com/sun/net/httpserver/Test12.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/com/sun/net/httpserver/Test12.java	Mon Oct 15 11:39:10 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
@@ -24,10 +24,10 @@
 /**
  * @test
  * @bug 6270015
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run main/othervm Test12
- * @summary  Light weight HTTP server
+ * @summary Light weight HTTP server
  */
 
 import com.sun.net.httpserver.*;
@@ -36,7 +36,7 @@
 import java.io.*;
 import java.net.*;
 import javax.net.ssl.*;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 /* basic http/s connectivity test
  * Tests:
--- a/test/jdk/com/sun/net/httpserver/Test13.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/com/sun/net/httpserver/Test13.java	Mon Oct 15 11:39:10 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
@@ -24,10 +24,10 @@
 /**
  * @test
  * @bug 6270015
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run main/othervm Test13
- * @summary  Light weight HTTP server
+ * @summary Light weight HTTP server
  */
 
 import com.sun.net.httpserver.*;
@@ -37,7 +37,7 @@
 import java.io.*;
 import java.net.*;
 import javax.net.ssl.*;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 /* basic http/s connectivity test
  * Tests:
--- a/test/jdk/com/sun/net/httpserver/Test6a.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/com/sun/net/httpserver/Test6a.java	Mon Oct 15 11:39:10 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
@@ -24,10 +24,10 @@
 /**
  * @test
  * @bug 6270015
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run main/othervm Test6a
- * @summary  Light weight HTTP server
+ * @summary Light weight HTTP server
  */
 
 import com.sun.net.httpserver.*;
@@ -36,7 +36,7 @@
 import java.io.*;
 import java.net.*;
 import javax.net.ssl.*;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 /**
  * Test https POST large file via chunked encoding (unusually small chunks)
--- a/test/jdk/com/sun/net/httpserver/Test7a.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/com/sun/net/httpserver/Test7a.java	Mon Oct 15 11:39:10 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
@@ -24,10 +24,10 @@
 /**
  * @test
  * @bug 6270015
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run main/othervm Test7a
- * @summary  Light weight HTTP server
+ * @summary Light weight HTTP server
  */
 
 import com.sun.net.httpserver.*;
@@ -36,7 +36,7 @@
 import java.io.*;
 import java.net.*;
 import javax.net.ssl.*;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 /**
  * Test POST large file via chunked encoding (large chunks)
--- a/test/jdk/com/sun/net/httpserver/Test8a.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/com/sun/net/httpserver/Test8a.java	Mon Oct 15 11:39:10 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
@@ -24,10 +24,10 @@
 /**
  * @test
  * @bug 6270015
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run main/othervm Test8a
- * @summary  Light weight HTTP server
+ * @summary Light weight HTTP server
  */
 
 import com.sun.net.httpserver.*;
@@ -36,7 +36,7 @@
 import java.io.*;
 import java.net.*;
 import javax.net.ssl.*;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 /**
  * Test POST large file via fixed len encoding
--- a/test/jdk/com/sun/net/httpserver/Test9.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/com/sun/net/httpserver/Test9.java	Mon Oct 15 11:39:10 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
@@ -24,10 +24,10 @@
 /**
  * @test
  * @bug 6270015
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run main/othervm Test9
- * @summary  Light weight HTTP server
+ * @summary Light weight HTTP server
  */
 
 import com.sun.net.httpserver.*;
@@ -36,7 +36,7 @@
 import java.io.*;
 import java.net.*;
 import javax.net.ssl.*;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 /* Same as Test1 but requests run in parallel.
  */
--- a/test/jdk/com/sun/net/httpserver/Test9a.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/com/sun/net/httpserver/Test9a.java	Mon Oct 15 11:39:10 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, 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
@@ -24,10 +24,10 @@
 /**
  * @test
  * @bug 6270015
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run main/othervm Test9a
- * @summary  Light weight HTTP server
+ * @summary Light weight HTTP server
  */
 
 import com.sun.net.httpserver.*;
@@ -36,7 +36,7 @@
 import java.io.*;
 import java.net.*;
 import javax.net.ssl.*;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 /* Same as Test1 but requests run in parallel.
  */
--- a/test/jdk/java/lang/ModuleLayer/BasicLayerTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/lang/ModuleLayer/BasicLayerTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -23,9 +23,10 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.base/jdk.internal.misc
- * @build BasicLayerTest ModuleUtils
+ * @build BasicLayerTest
+ *        jdk.test.lib.util.ModuleUtils
  * @compile layertest/Test.java
  * @run testng BasicLayerTest
  * @summary Basic tests for java.lang.ModuleLayer
@@ -41,6 +42,8 @@
 import java.util.Set;
 import java.util.stream.Collectors;
 
+import jdk.test.lib.util.ModuleUtils;
+
 import jdk.internal.misc.SharedSecrets;
 
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/lang/ModuleLayer/LayerAndLoadersTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/lang/ModuleLayer/LayerAndLoadersTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -23,9 +23,11 @@
 
 /**
  * @test
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler
- * @build LayerAndLoadersTest jdk.test.lib.compiler.CompilerUtils ModuleUtils
+ * @build LayerAndLoadersTest
+ *        jdk.test.lib.compiler.CompilerUtils
+ *        jdk.test.lib.util.ModuleUtils
  * @run testng LayerAndLoadersTest
  * @summary Tests for java.lang.ModuleLayer@defineModulesWithXXX methods
  */
@@ -54,6 +56,7 @@
 import java.util.stream.Collectors;
 
 import jdk.test.lib.compiler.CompilerUtils;
+import jdk.test.lib.util.ModuleUtils;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/test/jdk/java/lang/ModuleLayer/LayerControllerTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/lang/ModuleLayer/LayerControllerTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -23,8 +23,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary
- * @build LayerControllerTest ModuleUtils
+ * @library /test/lib
+ * @build LayerControllerTest
+ *        jdk.test.lib.util.ModuleUtils
  * @run testng LayerControllerTest
  * @summary Basic tests for java.lang.ModuleLayer.Controller
  */
@@ -35,6 +36,8 @@
 import java.util.List;
 import java.util.Set;
 
+import jdk.test.lib.util.ModuleUtils;
+
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 
--- a/test/jdk/java/lang/module/AutomaticModulesTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/lang/module/AutomaticModulesTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -23,9 +23,10 @@
 
 /**
  * @test
- * @library /lib/testlibrary /test/lib
- * @build AutomaticModulesTest ModuleUtils
+ * @library /test/lib
+ * @build AutomaticModulesTest
  *        jdk.test.lib.util.JarUtils
+ *        jdk.test.lib.util.ModuleUtils
  * @run testng AutomaticModulesTest
  * @summary Basic tests for automatic modules
  */
@@ -50,6 +51,7 @@
 import java.util.stream.Stream;
 
 import jdk.test.lib.util.JarUtils;
+import jdk.test.lib.util.ModuleUtils;
 
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
--- a/test/jdk/java/lang/module/ConfigurationTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/lang/module/ConfigurationTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -23,10 +23,11 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.base/jdk.internal.misc
  *          java.base/jdk.internal.module
- * @build ConfigurationTest ModuleUtils
+ * @build ConfigurationTest
+ *        jdk.test.lib.util.ModuleUtils
  * @run testng ConfigurationTest
  * @summary Basic tests for java.lang.module.Configuration
  */
@@ -47,6 +48,8 @@
 import java.util.Optional;
 import java.util.Set;
 
+import jdk.test.lib.util.ModuleUtils;
+
 import jdk.internal.misc.SharedSecrets;
 import jdk.internal.module.ModuleInfoWriter;
 import jdk.internal.module.ModuleTarget;
--- a/test/jdk/java/net/HttpURLConnection/SetAuthenticator/HTTPSetAuthenticatorTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/HttpURLConnection/SetAuthenticator/HTTPSetAuthenticatorTest.java	Mon Oct 15 11:39:10 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,12 +35,12 @@
 /*
  * @test
  * @bug 8169415
- * @library /lib/testlibrary/
+ * @library /test/lib
  * @modules java.logging
  *          java.base/sun.net.www
  *          java.base/sun.net.www.protocol.http
  *          jdk.httpserver/sun.net.httpserver
- * @build jdk.testlibrary.SimpleSSLContext HTTPTest HTTPTestServer HTTPTestClient HTTPSetAuthenticatorTest
+ * @build jdk.test.lib.net.SimpleSSLContext HTTPTest HTTPTestServer HTTPTestClient HTTPSetAuthenticatorTest
  * @summary A simple HTTP test that starts an echo server supporting the given
  *          authentication scheme, then starts a regular HTTP client to invoke it.
  *          The client first does a GET request on "/", then follows on
--- a/test/jdk/java/net/HttpURLConnection/SetAuthenticator/HTTPTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/HttpURLConnection/SetAuthenticator/HTTPTest.java	Mon Oct 15 11:39:10 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
@@ -41,16 +41,16 @@
 import javax.net.ssl.HttpsURLConnection;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLSession;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 /*
  * @test
  * @bug 8169415
- * @library /lib/testlibrary/
+ * @library /test/lib
  * @modules java.logging
  *          java.base/sun.net.www
  *          jdk.httpserver/sun.net.httpserver
- * @build jdk.testlibrary.SimpleSSLContext HTTPTest HTTPTestServer HTTPTestClient
+ * @build jdk.test.lib.net.SimpleSSLContext HTTPTest HTTPTestServer HTTPTestClient
  * @summary A simple HTTP test that starts an echo server supporting Digest
  *          authentication, then starts a regular HTTP client to invoke it.
  *          The client first does a GET request on "/", then follows on
--- a/test/jdk/java/net/Socket/CloseAvailable.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/Socket/CloseAvailable.java	Mon Oct 15 11:39:10 2018 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4091859
+ * @bug 4091859 8189366
  * @summary Test Socket.available()
  * @run main CloseAvailable
  * @run main/othervm -Djava.net.preferIPv4Stack=true CloseAvailable
@@ -33,18 +33,32 @@
 import java.io.*;
 
 
-public class CloseAvailable implements Runnable {
-    static ServerSocket ss;
-    static InetAddress addr;
-    static int port;
+public class CloseAvailable {
 
     public static void main(String[] args) throws Exception {
+        testClose();
+
+        testEOF(true);
+        testEOF(false);
+    }
+
+    static void testClose() throws IOException {
         boolean error = true;
-        addr = InetAddress.getLocalHost();
-        ss = new ServerSocket(0);
-        port = ss.getLocalPort();
+        InetAddress addr = InetAddress.getLocalHost();
+        ServerSocket ss = new ServerSocket(0);
+        int port = ss.getLocalPort();
 
-        Thread t = new Thread(new CloseAvailable());
+        Thread t = new Thread(new Thread("Close-Available-1") {
+            public void run() {
+                try {
+                    Socket s = new Socket(addr, port);
+                    s.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+
         t.start();
 
         Socket  soc = ss.accept();
@@ -63,13 +77,42 @@
             throw new RuntimeException("Available() can be called after stream closed.");
     }
 
-    public void run() {
-        try {
-            Socket s = new Socket(addr, port);
-            s.close();
-        } catch (Exception e) {
-            e.printStackTrace();
+    // Verifies consistency of `available` behaviour when EOF reached, both
+    // explicitly and implicitly.
+    static void testEOF(boolean readUntilEOF) throws IOException {
+        System.out.println("testEOF, readUntilEOF: " + readUntilEOF);
+        InetAddress addr = InetAddress.getLoopbackAddress();
+        ServerSocket ss = new ServerSocket();
+        ss.bind(new InetSocketAddress(addr, 0), 0);
+        int port = ss.getLocalPort();
+
+        try (Socket s = new Socket(addr, port)) {
+            s.getOutputStream().write(0x42);
+            s.shutdownOutput();
+
+            try (Socket soc = ss.accept()) {
+                ss.close();
+
+                InputStream is = soc.getInputStream();
+                int b = is.read();
+                assert b == 0x42;
+                assert !s.isClosed();
+                if (readUntilEOF) {
+                    b = is.read();
+                    assert b == -1;
+                }
+
+                int a;
+                for (int i = 0; i < 100; i++) {
+                    a = is.available();
+                    System.out.print(a + ", ");
+                    if (a != 0)
+                        throw new RuntimeException("Unexpected non-zero available: " + a);
+                }
+                assert !s.isClosed();
+                assert is.read() == -1;
+            }
         }
+        System.out.println("\ncomplete");
     }
-
 }
--- a/test/jdk/java/net/URLPermission/URLTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/URLPermission/URLTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,8 @@
  * @test
  * @bug 8010464
  * @modules jdk.httpserver
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run main/othervm URLTest
  * @summary check URLPermission with Http(s)URLConnection
  */
@@ -38,7 +38,7 @@
 import java.util.concurrent.*;
 import com.sun.net.httpserver.*;
 import javax.net.ssl.*;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 public class URLTest {
 
--- a/test/jdk/java/net/httpclient/AbstractNoBody.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/AbstractNoBody.java	Mon Oct 15 11:39:10 2018 -0700
@@ -35,7 +35,7 @@
 import com.sun.net.httpserver.HttpsServer;
 import java.net.http.HttpClient;
 import javax.net.ssl.SSLContext;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/AbstractThrowingPublishers.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/AbstractThrowingPublishers.java	Mon Oct 15 11:39:10 2018 -0700
@@ -24,7 +24,7 @@
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
--- a/test/jdk/java/net/httpclient/AbstractThrowingPushPromises.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/AbstractThrowingPushPromises.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when push promise handlers and their
  *          response body handlers and subscribers throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
   *       ReferenceTracker AbstractThrowingPushPromises
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
@@ -35,7 +35,7 @@
  * @run testng/othervm -Djdk.internal.httpclient.debug=true AbstractThrowingPushPromises
  */
 
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeTest;
--- a/test/jdk/java/net/httpclient/AbstractThrowingSubscribers.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/AbstractThrowingSubscribers.java	Mon Oct 15 11:39:10 2018 -0700
@@ -24,7 +24,7 @@
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeTest;
--- a/test/jdk/java/net/httpclient/AsFileDownloadTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/AsFileDownloadTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -31,9 +31,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary /test/lib http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @build jdk.test.lib.Platform
  * @build jdk.test.lib.util.FileUtils
  * @run testng/othervm AsFileDownloadTest
@@ -67,7 +67,7 @@
 import java.util.Locale;
 import java.util.Map;
 import javax.net.ssl.SSLContext;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import jdk.test.lib.util.FileUtils;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
--- a/test/jdk/java/net/httpclient/AsFileDownloadTest.policy	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/AsFileDownloadTest.policy	Mon Oct 15 11:39:10 2018 -0700
@@ -21,10 +21,10 @@
 // questions.
 //
 
-// for JTwork/classes/0/lib/testlibrary/jdk/testlibrary/SimpleSSLContext.class
-grant codeBase "file:${test.classes}/../../../../lib/testlibrary/-" {
+// for JTwork/classes/0/test/lib/jdk/test/lib/net/SimpleSSLContext.class
+grant codeBase "file:${test.classes}/../../../../test/lib/-" {
     permission java.util.PropertyPermission "test.src.path", "read";
-    permission java.io.FilePermission "${test.src}/../../../lib/testlibrary/jdk/testlibrary/testkeys", "read";
+    permission java.io.FilePermission "${test.src}/../../../../lib/jdk/test/lib/net/testkeys", "read";
 };
 
 // for JTwork//classes/0/java/net/httpclient/http2/server/*
--- a/test/jdk/java/net/httpclient/BasicRedirectTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/BasicRedirectTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -30,9 +30,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary /test/lib http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm
  *       -Djdk.httpclient.HttpClient.log=trace,headers,requests
  *       BasicRedirectTest
@@ -53,7 +53,7 @@
 import java.net.http.HttpResponse;
 import java.net.http.HttpResponse.BodyHandlers;
 import javax.net.ssl.SSLContext;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/CancelledResponse.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/CancelledResponse.java	Mon Oct 15 11:39:10 2018 -0700
@@ -26,7 +26,7 @@
 import java.net.http.HttpHeaders;
 import java.net.http.HttpRequest;
 import java.net.http.HttpResponse;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 import javax.net.ServerSocketFactory;
 import javax.net.ssl.SSLContext;
@@ -55,9 +55,9 @@
 /**
  * @test
  * @bug 8087112
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.net.http/jdk.internal.net.http.common
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @build MockServer ReferenceTracker
  * @run main/othervm  CancelledResponse
  * @run main/othervm  CancelledResponse SSL
--- a/test/jdk/java/net/httpclient/ConcurrentResponses.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ConcurrentResponses.java	Mon Oct 15 11:39:10 2018 -0700
@@ -32,9 +32,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm
  *      -Djdk.httpclient.HttpClient.log=headers,errors,channel
  *      ConcurrentResponses
@@ -67,7 +67,7 @@
 import java.net.http.HttpResponse.BodyHandlers;
 import java.net.http.HttpResponse.BodySubscriber;
 import java.net.http.HttpResponse.BodySubscribers;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/CookieHeaderTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/CookieHeaderTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -31,9 +31,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary /test/lib http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm
  *       -Djdk.tls.acknowledgeCloseNotify=true
  *       -Djdk.httpclient.HttpClient.log=trace,headers,requests
@@ -43,7 +43,7 @@
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/CustomRequestPublisher.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/CustomRequestPublisher.java	Mon Oct 15 11:39:10 2018 -0700
@@ -30,9 +30,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm CustomRequestPublisher
  */
 
@@ -62,7 +62,7 @@
 import java.net.http.HttpClient;
 import java.net.http.HttpRequest;
 import java.net.http.HttpResponse;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/CustomResponseSubscriber.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/CustomResponseSubscriber.java	Mon Oct 15 11:39:10 2018 -0700
@@ -24,8 +24,8 @@
 /*
  * @test
  * @summary Tests response body subscribers's onComplete is not invoked before onSubscribe
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
@@ -57,7 +57,7 @@
 import java.net.http.HttpResponse.BodySubscriber;
 import java.net.http.HttpResponse.BodySubscribers;
 import javax.net.ssl.SSLContext;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/DependentActionsTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/DependentActionsTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -26,8 +26,8 @@
  * @summary Verify that dependent synchronous actions added before the CF
  *          completes are executed either asynchronously in an executor when the
  *          CF later completes, or in the user thread that joins.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters DependentActionsTest
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters DependentActionsTest
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
@@ -43,7 +43,7 @@
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeTest;
--- a/test/jdk/java/net/httpclient/DependentPromiseActionsTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/DependentPromiseActionsTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -26,8 +26,8 @@
  * @summary Verify that dependent synchronous actions added before the promise CF
  *          completes are executed either asynchronously in an executor when the
  *          CF later completes, or in the user thread that joins.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters DependentPromiseActionsTest
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters DependentPromiseActionsTest
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
@@ -40,7 +40,7 @@
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
 import java.lang.StackWalker.StackFrame;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeTest;
--- a/test/jdk/java/net/httpclient/DigestEchoClient.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/DigestEchoClient.java	Mon Oct 15 11:39:10 2018 -0700
@@ -51,7 +51,7 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import javax.net.ssl.SSLContext;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import sun.net.NetProperties;
 import sun.net.www.HeaderParser;
 import static java.lang.System.out;
@@ -62,8 +62,8 @@
  * @summary this test verifies that a client may provides authorization
  *          headers directly when connecting with a server.
  * @bug 8087112
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters DigestEchoServer
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters DigestEchoServer
  *        ReferenceTracker DigestEchoClient
  * @modules java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
--- a/test/jdk/java/net/httpclient/DigestEchoClientSSL.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/DigestEchoClientSSL.java	Mon Oct 15 11:39:10 2018 -0700
@@ -26,8 +26,8 @@
  * @bug 8087112
  * @summary this test verifies that a client may provides authorization
  *          headers directly when connecting with a server over SSL.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext DigestEchoServer
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext DigestEchoServer
  *        DigestEchoClient ReferenceTracker DigestEchoClientSSL
  * @modules java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
--- a/test/jdk/java/net/httpclient/EchoHandler.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/EchoHandler.java	Mon Oct 15 11:39:10 2018 -0700
@@ -32,7 +32,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Random;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import static java.net.http.HttpRequest.*;
 import static java.net.http.HttpResponse.*;
 import java.util.logging.ConsoleHandler;
--- a/test/jdk/java/net/httpclient/EncodedCharsInURI.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/EncodedCharsInURI.java	Mon Oct 15 11:39:10 2018 -0700
@@ -26,8 +26,8 @@
  * @bug 8199683
  * @summary Tests that escaped characters in URI are correctly
  *          handled (not re-escaped and not unescaped)
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters EncodedCharsInURI
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters EncodedCharsInURI
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
@@ -42,7 +42,7 @@
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
--- a/test/jdk/java/net/httpclient/EscapedOctetsInURI.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/EscapedOctetsInURI.java	Mon Oct 15 11:39:10 2018 -0700
@@ -31,9 +31,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm
  *       -Djdk.httpclient.HttpClient.log=reqeusts,headers
  *       EscapedOctetsInURI
@@ -58,7 +58,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/ExpectContinue.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ExpectContinue.java	Mon Oct 15 11:39:10 2018 -0700
@@ -26,8 +26,8 @@
  * @summary Basic test for Expect 100-Continue ( HTTP/1.1 only )
  * @modules java.net.http
  *          jdk.httpserver
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm ExpectContinue
  */
 
@@ -49,7 +49,7 @@
 import java.net.http.HttpResponse.BodyHandlers;
 import java.util.List;
 import javax.net.ssl.SSLContext;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/FlowAdapterPublisherTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/FlowAdapterPublisherTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -43,7 +43,7 @@
 import java.net.http.HttpClient;
 import java.net.http.HttpRequest;
 import java.net.http.HttpResponse;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
@@ -67,9 +67,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm FlowAdapterPublisherTest
  */
 
--- a/test/jdk/java/net/httpclient/FlowAdapterSubscriberTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/FlowAdapterSubscriberTest.java	Mon Oct 15 11:39:10 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
@@ -48,7 +48,7 @@
 import java.net.http.HttpResponse;
 import java.net.http.HttpResponse.BodyHandlers;
 import java.net.http.HttpResponse.BodySubscribers;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
@@ -68,9 +68,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm -Djdk.internal.httpclient.debug=true FlowAdapterSubscriberTest
  */
 
--- a/test/jdk/java/net/httpclient/HeadTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/HeadTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -31,9 +31,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary /test/lib http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm
  *       -Djdk.httpclient.HttpClient.log=trace,headers,requests
  *       HeadTest
@@ -42,7 +42,7 @@
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/HttpClientBuilderTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/HttpClientBuilderTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -48,7 +48,7 @@
 import java.net.http.HttpClient;
 import java.net.http.HttpClient.Redirect;
 import java.net.http.HttpClient.Version;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.Test;
 import static java.time.Duration.*;
 import static org.testng.Assert.*;
@@ -56,8 +56,8 @@
 /*
  * @test
  * @summary HttpClient[.Builder] API and behaviour checks
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng HttpClientBuilderTest
  */
 
--- a/test/jdk/java/net/httpclient/HttpEchoHandler.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/HttpEchoHandler.java	Mon Oct 15 11:39:10 2018 -0700
@@ -32,7 +32,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Random;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import static java.net.http.HttpRequest.*;
 import static java.net.http.HttpResponse.*;
 import java.util.logging.ConsoleHandler;
--- a/test/jdk/java/net/httpclient/HttpsTunnelTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/HttpsTunnelTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -23,7 +23,7 @@
 
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import javax.net.ssl.SSLContext;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
@@ -49,8 +49,8 @@
  *          be preemptively downgraded. That, is the stack should attempt
  *          a new h2 connection to the new host.
  * @bug 8196967
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters DigestEchoServer HttpsTunnelTest
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters DigestEchoServer HttpsTunnelTest
  * @modules java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
  *          java.net.http/jdk.internal.net.http.hpack
--- a/test/jdk/java/net/httpclient/ImmutableFlowItems.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ImmutableFlowItems.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests response body subscribers's onNext's Lists are unmodifiable,
  *          and that the buffers are read-only
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
@@ -57,7 +57,7 @@
 import java.net.http.HttpResponse.BodySubscriber;
 import java.net.http.HttpResponse.BodySubscribers;
 import javax.net.ssl.SSLContext;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/InvalidInputStreamSubscriptionRequest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/InvalidInputStreamSubscriptionRequest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -26,8 +26,8 @@
  * @summary Tests an asynchronous BodySubscriber that completes
  *          immediately with an InputStream which issues bad
  *          requests
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext ReferenceTracker
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext ReferenceTracker
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
@@ -38,7 +38,7 @@
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
--- a/test/jdk/java/net/httpclient/InvalidSSLContextTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/InvalidSSLContextTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Test to ensure the HTTP client throws an appropriate SSL exception
  *          when SSL context is not valid.
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm -Djdk.internal.httpclient.debug=true InvalidSSLContextTest
  */
 
@@ -47,7 +47,7 @@
 import java.net.http.HttpRequest;
 import java.net.http.HttpResponse;
 import java.net.http.HttpResponse.BodyHandlers;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.Assert;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
--- a/test/jdk/java/net/httpclient/InvalidSubscriptionRequest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/InvalidSubscriptionRequest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -27,8 +27,8 @@
  * @summary Tests an asynchronous BodySubscriber that completes
  *          immediately with a Publisher<List<ByteBuffer>> whose
  *          subscriber issues bad requests
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext ReferenceTracker
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext ReferenceTracker
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
@@ -39,7 +39,7 @@
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/LightWeightHttpServer.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/LightWeightHttpServer.java	Mon Oct 15 11:39:10 2018 -0700
@@ -22,8 +22,8 @@
  */
 
 /**
- * library /lib/testlibrary/ /
- * build jdk.testlibrary.SimpleSSLContext ProxyServer
+ * library /test/lib /
+ * build jdk.test.lib.net.SimpleSSLContext ProxyServer
  * compile ../../../com/sun/net/httpserver/LogFilter.java
  * compile ../../../com/sun/net/httpserver/EchoHandler.java
  * compile ../../../com/sun/net/httpserver/FileServerHandler.java
@@ -50,7 +50,7 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.net.ssl.SSLContext;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 public class LightWeightHttpServer {
 
--- a/test/jdk/java/net/httpclient/LineBodyHandlerTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/LineBodyHandlerTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -52,7 +52,7 @@
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
@@ -77,9 +77,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer LineBodyHandlerTest HttpServerAdapters
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm LineBodyHandlerTest
  */
 
--- a/test/jdk/java/net/httpclient/ManyRequests.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ManyRequests.java	Mon Oct 15 11:39:10 2018 -0700
@@ -27,8 +27,8 @@
  * @modules java.net.http
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary/ /
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @compile ../../../com/sun/net/httpserver/LogFilter.java
  * @compile ../../../com/sun/net/httpserver/EchoHandler.java
  * @compile ../../../com/sun/net/httpserver/FileServerHandler.java
@@ -63,7 +63,7 @@
 import java.util.logging.Level;
 import java.util.concurrent.CompletableFuture;
 import javax.net.ssl.SSLContext;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 public class ManyRequests {
 
--- a/test/jdk/java/net/httpclient/ManyRequests2.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ManyRequests2.java	Mon Oct 15 11:39:10 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,8 +27,8 @@
  * @modules java.net.http
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary/ /
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @compile ../../../com/sun/net/httpserver/LogFilter.java
  * @compile ../../../com/sun/net/httpserver/EchoHandler.java
  * @compile ../../../com/sun/net/httpserver/FileServerHandler.java
@@ -36,8 +36,11 @@
  * @run main/othervm/timeout=40 -Dtest.XFixed=true ManyRequests2
  * @run main/othervm/timeout=40 -Dtest.XFixed=true -Dtest.insertDelay=true ManyRequests2
  * @run main/othervm/timeout=40 -Dtest.XFixed=true -Dtest.chunkSize=64 ManyRequests2
- * @run main/othervm/timeout=40 -Djdk.internal.httpclient.debug=true -Dtest.XFixed=true -Dtest.insertDelay=true -Dtest.chunkSize=64 ManyRequests2
- * @summary Send a large number of requests asynchronously. The server echoes back using known content length.
+ * @run main/othervm/timeout=40 -Djdk.internal.httpclient.debug=true
+ *                              -Dtest.XFixed=true -Dtest.insertDelay=true
+ *                              -Dtest.chunkSize=64 ManyRequests2
+ * @summary Send a large number of requests asynchronously.
+ *          The server echoes back using known content length.
  */
  // * @run main/othervm/timeout=40 -Djdk.httpclient.HttpClient.log=ssl ManyRequests
 
--- a/test/jdk/java/net/httpclient/ManyRequestsLegacy.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ManyRequestsLegacy.java	Mon Oct 15 11:39:10 2018 -0700
@@ -26,16 +26,19 @@
  * @modules java.net.http
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary/ /
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @compile ../../../com/sun/net/httpserver/LogFilter.java
  * @compile ../../../com/sun/net/httpserver/EchoHandler.java
  * @compile ../../../com/sun/net/httpserver/FileServerHandler.java
  * @run main/othervm/timeout=40 ManyRequestsLegacy
  * @run main/othervm/timeout=40 -Dtest.insertDelay=true ManyRequestsLegacy
  * @run main/othervm/timeout=40 -Dtest.chunkSize=64 ManyRequestsLegacy
- * @run main/othervm/timeout=40 -Dtest.insertDelay=true -Dtest.chunkSize=64 ManyRequestsLegacy
- * @summary Send a large number of requests asynchronously using the legacy URL.openConnection(), to help sanitize results of the test ManyRequest.java.
+ * @run main/othervm/timeout=40 -Dtest.insertDelay=true
+ *                              -Dtest.chunkSize=64 ManyRequestsLegacy
+ * @summary Send a large number of requests asynchronously using the legacy
+ *          URL.openConnection(), to help sanitize results of the test
+ *          ManyRequest.java.
  */
 
 import javax.net.ssl.HttpsURLConnection;
@@ -70,7 +73,7 @@
 import java.util.Random;
 import java.util.logging.Logger;
 import java.util.logging.Level;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 public class ManyRequestsLegacy {
 
--- a/test/jdk/java/net/httpclient/MappingResponseSubscriber.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/MappingResponseSubscriber.java	Mon Oct 15 11:39:10 2018 -0700
@@ -24,8 +24,8 @@
 /*
  * @test
  * @summary Tests mapped response subscriber
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
@@ -62,7 +62,7 @@
 import  java.net.http.HttpResponse.BodySubscriber;
 import java.util.function.Function;
 import javax.net.ssl.SSLContext;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/MaxStreams.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/MaxStreams.java	Mon Oct 15 11:39:10 2018 -0700
@@ -32,9 +32,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm -ea -esa MaxStreams
  */
 
@@ -60,7 +60,7 @@
 import java.net.http.HttpResponse;
 import java.net.http.HttpResponse.BodyHandler;
 import java.net.http.HttpResponse.BodyHandlers;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/NoBodyPartOne.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/NoBodyPartOne.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @bug 8161157
  * @summary Test response body handlers/subscribers when there is no body
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
--- a/test/jdk/java/net/httpclient/NoBodyPartTwo.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/NoBodyPartTwo.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @bug 8161157
  * @summary Test response body handlers/subscribers when there is no body
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
--- a/test/jdk/java/net/httpclient/NonAsciiCharsInURI.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/NonAsciiCharsInURI.java	Mon Oct 15 11:39:10 2018 -0700
@@ -32,9 +32,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @compile -encoding utf-8 NonAsciiCharsInURI.java
  * @run testng/othervm
  *       -Djdk.httpclient.HttpClient.log=reqeusts,headers
@@ -58,7 +58,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/ProxyAuthDisabledSchemes.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ProxyAuthDisabledSchemes.java	Mon Oct 15 11:39:10 2018 -0700
@@ -28,8 +28,8 @@
  *          it verifies that the client honor the jdk.http.auth.*.disabledSchemes
  *          net properties.
  * @bug 8087112
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext DigestEchoServer DigestEchoClient
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext DigestEchoServer DigestEchoClient
  *        ReferenceTracker ProxyAuthDisabledSchemes
  * @modules java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
--- a/test/jdk/java/net/httpclient/ProxyAuthDisabledSchemesSSL.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ProxyAuthDisabledSchemesSSL.java	Mon Oct 15 11:39:10 2018 -0700
@@ -28,8 +28,8 @@
  *          headers directly when connecting with a server over SSL, and
  *          it verifies that the client honor the jdk.http.auth.*.disabledSchemes
  *          net properties.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext DigestEchoServer DigestEchoClient
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext DigestEchoServer DigestEchoClient
  *        ReferenceTracker ProxyAuthDisabledSchemesSSL
  * @modules java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
--- a/test/jdk/java/net/httpclient/ProxyTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ProxyTest.java	Mon Oct 15 11:39:10 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
@@ -56,7 +56,7 @@
 import java.net.http.HttpClient;
 import java.net.http.HttpRequest;
 import java.net.http.HttpResponse;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 /**
  * @test
@@ -67,8 +67,8 @@
  *          an SSL Tunnel connection when the client is HTTP/2 and the server
  *          and proxy are HTTP/1.1
  * @modules java.net.http
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.SimpleSSLContext ProxyTest
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext ProxyTest
  * @run main/othervm ProxyTest
  * @author danielfuchs
  */
--- a/test/jdk/java/net/httpclient/RedirectMethodChange.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/RedirectMethodChange.java	Mon Oct 15 11:39:10 2018 -0700
@@ -29,9 +29,9 @@
  *          java.net.http/jdk.internal.net.http.frame
  *          java.net.http/jdk.internal.net.http.hpack
  *          jdk.httpserver
- * @library /lib/testlibrary /test/lib http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm RedirectMethodChange
  */
 
@@ -50,7 +50,7 @@
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/RedirectWithCookie.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/RedirectWithCookie.java	Mon Oct 15 11:39:10 2018 -0700
@@ -30,9 +30,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary /test/lib http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm
  *       -Djdk.httpclient.HttpClient.log=trace,headers,requests
  *       RedirectWithCookie
@@ -55,7 +55,7 @@
 import java.net.http.HttpResponse.BodyHandlers;
 import java.util.List;
 import javax.net.ssl.SSLContext;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/RequestBodyTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/RequestBodyTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -27,11 +27,11 @@
  * @modules java.net.http
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary/ /test/lib
+ * @library /test/lib
  * @compile ../../../com/sun/net/httpserver/LogFilter.java
  * @compile ../../../com/sun/net/httpserver/EchoHandler.java
  * @compile ../../../com/sun/net/httpserver/FileServerHandler.java
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @build LightWeightHttpServer
  * @build jdk.test.lib.Platform
  * @build jdk.test.lib.util.FileUtils
--- a/test/jdk/java/net/httpclient/RequestBodyTest.policy	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/RequestBodyTest.policy	Mon Oct 15 11:39:10 2018 -0700
@@ -27,10 +27,10 @@
     permission java.io.FilePermission "RequestBodyTest.tmp", "read,delete";
 };
 
-// for JTwork/classes/0/lib/testlibrary/jdk/testlibrary/SimpleSSLContext.class
-grant codeBase "file:${test.classes}/../../../../lib/testlibrary/-" {
+// for JTwork/classes/0/test/lib/jdk/test/lib/net/SimpleSSLContext.class
+grant codeBase "file:${test.classes}/../../../../test/lib/-" {
     permission java.util.PropertyPermission "test.src.path", "read";
-    permission java.io.FilePermission "${test.src}/../../../lib/testlibrary/jdk/testlibrary/testkeys", "read";
+    permission java.io.FilePermission "${test.src}/../../../../lib/jdk/test/lib/net/testkeys", "read";
 };
 
 grant codeBase "file:${test.classes}/*" {
--- a/test/jdk/java/net/httpclient/RequestBuilderTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/RequestBuilderTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -337,15 +337,31 @@
         }
     }
 
+    // headers that are allowed now, but weren't before
+    private static final Set<String> FORMERLY_RESTRICTED = Set.of("referer", "origin",
+            "OriGin", "Referer");
+
+    @Test
+    public void testFormerlyRestricted()  throws URISyntaxException {
+        URI uri = new URI("http://localhost:80/test/");
+        URI otherURI = new URI("http://www.foo.com/test/");
+        for (String header : FORMERLY_RESTRICTED) {
+            HttpRequest req = HttpRequest.newBuilder(uri)
+                .header(header, otherURI.toString())
+                .GET()
+                .build();
+        }
+    }
+
     private static final Set<String> RESTRICTED = Set.of("connection", "content-length",
-            "date", "expect", "from", "host", "origin",
-            "referer", "upgrade", "via", "warning",
+            "date", "expect", "from", "host",
+            "upgrade", "via", "warning",
             "Connection", "Content-Length",
-            "DATE", "eXpect", "frOm", "hosT", "origIN",
-            "ReFerer", "upgradE", "vIa", "Warning",
+            "DATE", "eXpect", "frOm", "hosT",
+            "upgradE", "vIa", "Warning",
             "CONNection", "CONTENT-LENGTH",
-            "Date", "EXPECT", "From", "Host", "Origin",
-            "Referer", "Upgrade", "Via", "WARNING");
+            "Date", "EXPECT", "From", "Host",
+            "Upgrade", "Via", "WARNING");
 
     interface WithHeader {
         HttpRequest.Builder withHeader(HttpRequest.Builder builder, String name, String value);
--- a/test/jdk/java/net/httpclient/ResponseBodyBeforeError.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ResponseBodyBeforeError.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests that all response body is delivered to the BodySubscriber
  *          before an abortive error terminates the flow
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm ResponseBodyBeforeError
  */
 
@@ -52,7 +52,7 @@
 import java.util.concurrent.CompletionStage;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Flow;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/ResponsePublisher.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ResponsePublisher.java	Mon Oct 15 11:39:10 2018 -0700
@@ -26,8 +26,8 @@
  * @bug 8201186
  * @summary Tests an asynchronous BodySubscriber that completes
  *          immediately with a Publisher<List<ByteBuffer>>
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
@@ -40,7 +40,7 @@
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/RetryWithCookie.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/RetryWithCookie.java	Mon Oct 15 11:39:10 2018 -0700
@@ -31,9 +31,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary /test/lib http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext ReferenceTracker
+ * @build jdk.test.lib.net.SimpleSSLContext ReferenceTracker
  * @run testng/othervm
  *       -Djdk.httpclient.HttpClient.log=trace,headers,requests
  *       RetryWithCookie
@@ -42,7 +42,7 @@
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/ServerCloseTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ServerCloseTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests that our client deals correctly with servers that
  *          close the connection right after sending the last byte.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters EncodedCharsInURI
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters EncodedCharsInURI
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
@@ -35,7 +35,7 @@
  */
 //*        -Djdk.internal.httpclient.debug=true
 
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
--- a/test/jdk/java/net/httpclient/ShortResponseBody.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ShortResponseBody.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests Exception detail message when too few response bytes are
  *          received before a socket exception or eof.
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm
  *       -Djdk.httpclient.HttpClient.log=headers,errors,channel
  *       ShortResponseBody
@@ -55,7 +55,7 @@
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.stream.Stream;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/ShortResponseBodyWithRetry.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ShortResponseBodyWithRetry.java	Mon Oct 15 11:39:10 2018 -0700
@@ -24,8 +24,8 @@
 /*
  * @test
  * @summary Run of ShortResponseBody with -Djdk.httpclient.enableAllMethodRetry
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @build ShortResponseBody
  * @run testng/othervm
  *       -Djdk.httpclient.HttpClient.log=headers,errors,channel
--- a/test/jdk/java/net/httpclient/SmokeTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/SmokeTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -27,8 +27,8 @@
  * @modules java.net.http
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary/ /
- * @build jdk.testlibrary.SimpleSSLContext ProxyServer
+ * @library /test/lib /
+ * @build jdk.test.lib.net.SimpleSSLContext ProxyServer
  * @compile ../../../com/sun/net/httpserver/LogFilter.java
  * @compile ../../../com/sun/net/httpserver/EchoHandler.java
  * @compile ../../../com/sun/net/httpserver/FileServerHandler.java
@@ -88,7 +88,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Random;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
 import static java.nio.file.StandardOpenOption.WRITE;
 
--- a/test/jdk/java/net/httpclient/SpecialHeadersTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/SpecialHeadersTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -32,9 +32,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer HttpServerAdapters SpecialHeadersTest
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm
  *       -Djdk.httpclient.HttpClient.log=requests,headers,errors
  *       SpecialHeadersTest
@@ -43,7 +43,7 @@
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
@@ -57,21 +57,25 @@
 import java.net.InetSocketAddress;
 import java.net.URI;
 import java.net.http.HttpClient;
+import java.net.http.HttpHeaders;
 import java.net.http.HttpRequest;
 import java.net.http.HttpResponse;
 import java.net.http.HttpResponse.BodyHandlers;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Optional;
 
 import static java.lang.System.err;
 import static java.lang.System.out;
 import static java.net.http.HttpClient.Builder.NO_PROXY;
 import static java.nio.charset.StandardCharsets.US_ASCII;
+import org.testng.Assert;
 import static org.testng.Assert.assertEquals;
 
 public class SpecialHeadersTest implements HttpServerAdapters {
@@ -91,6 +95,13 @@
             {"User-Agent: camel-cased"},
             {"user-agent: all-lower-case"},
             {"user-Agent: mixed"},
+            // headers which were restricted before and are now allowable
+            {"referer: lower"},
+            {"Referer: normal"},
+            {"REFERER: upper"},
+            {"origin: lower"},
+            {"Origin: normal"},
+            {"ORIGIN: upper"},
     };
 
     @DataProvider(name = "variants")
@@ -169,6 +180,50 @@
     }
 
     @Test(dataProvider = "variants")
+    void testHomeMadeIllegalHeader(String uriString, String headerNameAndValue, boolean sameClient) throws Exception {
+        out.println("\n--- Starting ");
+        final URI uri = URI.create(uriString);
+
+        HttpClient client = HttpClient.newBuilder()
+                .proxy(NO_PROXY)
+                .sslContext(sslContext)
+                .build();
+
+        // Test a request which contains an illegal header created
+        HttpRequest req = new HttpRequest() {
+            @Override public Optional<BodyPublisher> bodyPublisher() {
+                return Optional.of(BodyPublishers.noBody());
+            }
+            @Override public String method() {
+                return "GET";
+            }
+            @Override public Optional<Duration> timeout() {
+                return Optional.empty();
+            }
+            @Override public boolean expectContinue() {
+                return false;
+            }
+            @Override public URI uri() {
+                return uri;
+            }
+            @Override public Optional<HttpClient.Version> version() {
+                return Optional.empty();
+            }
+            @Override public HttpHeaders headers() {
+                Map<String, List<String>> map = Map.of("via", List.of("http://foo.com"));
+                return HttpHeaders.of(map, (x, y) -> true);
+            }
+        };
+
+        try {
+            HttpResponse<String> response = client.send(req, BodyHandlers.ofString());
+            Assert.fail("Unexpected reply: " + response);
+        } catch (IllegalArgumentException ee) {
+            out.println("Got IAE as expected");
+        }
+    }
+
+    @Test(dataProvider = "variants")
     void testAsync(String uriString, String headerNameAndValue, boolean sameClient) {
         out.println("\n--- Starting ");
         int index = headerNameAndValue.indexOf(":");
@@ -259,7 +314,10 @@
         https2TestServer.stop();
     }
 
-    /** A handler that returns, as its body, the exact received request URI. */
+    /** A handler that returns, as its body, the exact received request URI.
+     *  The header whose name is in the URI query and is set in the request is
+     *  returned in the response with its name prefixed by X-
+     */
     static class HttpUriStringHandler implements HttpTestHandler {
         @Override
         public void handle(HttpTestExchange t) throws IOException {
--- a/test/jdk/java/net/httpclient/SplitResponse.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/SplitResponse.java	Mon Oct 15 11:39:10 2018 -0700
@@ -40,7 +40,7 @@
 import java.net.http.HttpResponse;
 import java.util.stream.Stream;
 
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import static java.lang.System.out;
 import static java.lang.String.format;
 import static java.nio.charset.StandardCharsets.ISO_8859_1;
@@ -49,8 +49,8 @@
 /**
  * @test
  * @bug 8087112
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @build MockServer
  * @run main/othervm
  *     -Djdk.internal.httpclient.debug=true
--- a/test/jdk/java/net/httpclient/SplitResponseAsync.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/SplitResponseAsync.java	Mon Oct 15 11:39:10 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,8 +24,8 @@
 /**
  * @test
  * @bug 8087112
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @build MockServer SplitResponse
  * @run main/othervm
  *      -Djdk.internal.httpclient.debug=true
--- a/test/jdk/java/net/httpclient/SplitResponseKeepAlive.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/SplitResponseKeepAlive.java	Mon Oct 15 11:39:10 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,8 +24,8 @@
 /**
  * @test
  * @bug 8087112
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @build MockServer SplitResponse
  * @run main/othervm
  *      -Djdk.internal.httpclient.debug=true
--- a/test/jdk/java/net/httpclient/SplitResponseKeepAliveAsync.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/SplitResponseKeepAliveAsync.java	Mon Oct 15 11:39:10 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,8 +24,8 @@
 /**
  * @test
  * @bug 8087112
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @build MockServer SplitResponse
  * @run main/othervm
  *      -Djdk.internal.httpclient.debug=true
--- a/test/jdk/java/net/httpclient/SplitResponseSSL.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/SplitResponseSSL.java	Mon Oct 15 11:39:10 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,8 +24,8 @@
 /**
  * @test
  * @bug 8087112
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @build MockServer SplitResponse
  * @run main/othervm
  *      -Djdk.internal.httpclient.debug=true
--- a/test/jdk/java/net/httpclient/SplitResponseSSLAsync.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/SplitResponseSSLAsync.java	Mon Oct 15 11:39:10 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,8 +24,8 @@
 /**
  * @test
  * @bug 8087112
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @build MockServer SplitResponse
  * @run main/othervm
  *      -Djdk.internal.httpclient.debug=true
--- a/test/jdk/java/net/httpclient/SplitResponseSSLKeepAlive.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/SplitResponseSSLKeepAlive.java	Mon Oct 15 11:39:10 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,8 +24,8 @@
 /**
  * @test
  * @bug 8087112
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @build MockServer SplitResponse
  * @run main/othervm
  *      -Djdk.internal.httpclient.debug=true
--- a/test/jdk/java/net/httpclient/SplitResponseSSLKeepAliveAsync.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/SplitResponseSSLKeepAliveAsync.java	Mon Oct 15 11:39:10 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,8 +24,8 @@
 /**
  * @test
  * @bug 8087112
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @build MockServer SplitResponse
  * @run main/othervm
  *      -Djdk.internal.httpclient.debug=true
--- a/test/jdk/java/net/httpclient/StreamingBody.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/StreamingBody.java	Mon Oct 15 11:39:10 2018 -0700
@@ -31,9 +31,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary /test/lib http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm
  *       -Djdk.httpclient.HttpClient.log=trace,headers,requests
  *       StreamingBody
@@ -53,7 +53,7 @@
 import java.net.http.HttpResponse;
 import java.net.http.HttpResponse.BodyHandlers;
 import javax.net.ssl.SSLContext;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/ThrowingPublishersCustomAfterCancel.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingPublishersCustomAfterCancel.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when request publishers
  *          throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
  *        ReferenceTracker AbstractThrowingPublishers ThrowingPublishersCustomAfterCancel
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingPublishersCustomBeforeCancel.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingPublishersCustomBeforeCancel.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when request publishers
  *          throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
  *        ReferenceTracker AbstractThrowingPublishers ThrowingPublishersCustomBeforeCancel
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingPublishersIOAfterCancel.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingPublishersIOAfterCancel.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when request publishers
  *          throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
  *        ReferenceTracker AbstractThrowingPublishers ThrowingPublishersIOAfterCancel
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingPublishersIOBeforeCancel.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingPublishersIOBeforeCancel.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when request publishers
  *          throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
  *        ReferenceTracker AbstractThrowingPublishers ThrowingPublishersIOBeforeCancel
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingPublishersInNextRequest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingPublishersInNextRequest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when request publishers
  *          throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
  *        ReferenceTracker AbstractThrowingPublishers ThrowingPublishersInNextRequest
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingPublishersInRequest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingPublishersInRequest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when request publishers
  *          throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
  *        ReferenceTracker AbstractThrowingPublishers ThrowingPublishersInRequest
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingPublishersInSubscribe.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingPublishersInSubscribe.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when request publishers
  *          throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
  *        ReferenceTracker AbstractThrowingPublishers ThrowingPublishersInSubscribe
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingPublishersSanity.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingPublishersSanity.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when request publishers
  *          throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
  *        ReferenceTracker AbstractThrowingPublishers ThrowingPublishersSanity
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingPushPromisesAsInputStreamCustom.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingPushPromisesAsInputStreamCustom.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when push promise handlers and their
  *          response body handlers and subscribers throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
   *       ReferenceTracker AbstractThrowingPushPromises ThrowingPushPromisesAsInputStreamCustom
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingPushPromisesAsInputStreamIO.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingPushPromisesAsInputStreamIO.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when push promise handlers and their
  *          response body handlers and subscribers throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
   *       ReferenceTracker AbstractThrowingPushPromises ThrowingPushPromisesAsInputStreamIO
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingPushPromisesAsLinesCustom.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingPushPromisesAsLinesCustom.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when push promise handlers and their
  *          response body handlers and subscribers throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
   *       ReferenceTracker AbstractThrowingPushPromises ThrowingPushPromisesAsLinesCustom
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingPushPromisesAsLinesIO.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingPushPromisesAsLinesIO.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when push promise handlers and their
  *          response body handlers and subscribers throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
   *       ReferenceTracker AbstractThrowingPushPromises ThrowingPushPromisesAsLinesIO
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingPushPromisesAsStringCustom.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingPushPromisesAsStringCustom.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when push promise handlers and their
  *          response body handlers and subscribers throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
   *       ReferenceTracker AbstractThrowingPushPromises ThrowingPushPromisesAsStringCustom
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingPushPromisesAsStringIO.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingPushPromisesAsStringIO.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when push promise handlers and their
  *          response body handlers and subscribers throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
   *       ReferenceTracker AbstractThrowingPushPromises ThrowingPushPromisesAsStringIO
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingPushPromisesSanity.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingPushPromisesSanity.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when push promise handlers and their
  *          response body handlers and subscribers throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
   *       ReferenceTracker AbstractThrowingPushPromises ThrowingPushPromisesSanity
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingSubscribersAsInputStream.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingSubscribersAsInputStream.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when response body handlers and subscribers
  *          throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
   *       ReferenceTracker ThrowingSubscribersAsInputStream AbstractThrowingSubscribers
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingSubscribersAsInputStreamAsync.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingSubscribersAsInputStreamAsync.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when response body handlers and subscribers
  *          throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
   *       ReferenceTracker ThrowingSubscribersAsInputStreamAsync AbstractThrowingSubscribers
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingSubscribersAsLines.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingSubscribersAsLines.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when response body handlers and subscribers
  *          throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
   *       ReferenceTracker ThrowingSubscribersAsLines AbstractThrowingSubscribers
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingSubscribersAsLinesAsync.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingSubscribersAsLinesAsync.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when response body handlers and subscribers
  *          throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
   *       ReferenceTracker ThrowingSubscribersAsLinesAsync AbstractThrowingSubscribers
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingSubscribersAsString.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingSubscribersAsString.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when response body handlers and subscribers
  *          throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
   *       ReferenceTracker ThrowingSubscribersAsString AbstractThrowingSubscribers
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingSubscribersAsStringAsync.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingSubscribersAsStringAsync.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when response body handlers and subscribers
  *          throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
   *       ReferenceTracker ThrowingSubscribersAsStringAsync AbstractThrowingSubscribers
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/ThrowingSubscribersSanity.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/ThrowingSubscribersSanity.java	Mon Oct 15 11:39:10 2018 -0700
@@ -25,8 +25,8 @@
  * @test
  * @summary Tests what happens when response body handlers and subscribers
  *          throw unexpected exceptions.
- * @library /lib/testlibrary http2/server
- * @build jdk.testlibrary.SimpleSSLContext HttpServerAdapters
+ * @library /test/lib http2/server
+ * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters
   *       ReferenceTracker ThrowingSubscribersSanity AbstractThrowingSubscribers
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
--- a/test/jdk/java/net/httpclient/TimeoutBasic.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/TimeoutBasic.java	Mon Oct 15 11:39:10 2018 -0700
@@ -31,7 +31,7 @@
 import java.net.http.HttpResponse;
 import java.net.http.HttpResponse.BodyHandlers;
 import java.net.http.HttpTimeoutException;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 import javax.net.ServerSocketFactory;
 import javax.net.ssl.SSLContext;
@@ -46,8 +46,8 @@
 
 /**
  * @test
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @summary Basic tests for response timeouts
  * @run main/othervm TimeoutBasic
  */
--- a/test/jdk/java/net/httpclient/UnauthorizedTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/UnauthorizedTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -35,9 +35,9 @@
  *          java.net.http/jdk.internal.net.http.hpack
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary /test/lib http2/server
+ * @library /test/lib http2/server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm
  *       -Djdk.httpclient.HttpClient.log=headers
  *       UnauthorizedTest
@@ -46,7 +46,7 @@
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/UnknownBodyLengthTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/UnknownBodyLengthTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -35,13 +35,13 @@
 import java.net.http.HttpClient;
 import java.net.http.HttpRequest;
 import java.net.http.HttpResponse;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 /**
  * @test
  * @bug 8207966
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run main/othervm -Djdk.tls.acknowledgeCloseNotify=true UnknownBodyLengthTest plain false
  * @run main/othervm -Djdk.tls.acknowledgeCloseNotify=true UnknownBodyLengthTest SSL false
  * @run main/othervm -Djdk.tls.acknowledgeCloseNotify=true UnknownBodyLengthTest plain true
--- a/test/jdk/java/net/httpclient/dependent.policy	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/dependent.policy	Mon Oct 15 11:39:10 2018 -0700
@@ -21,10 +21,10 @@
 // questions.
 //
 
-// for JTwork/classes/0/lib/testlibrary/jdk/testlibrary/SimpleSSLContext.class
-grant codeBase "file:${test.classes}/../../../../lib/testlibrary/-" {
+// for JTwork/classes/0/test/lib/jdk/test/lib/net/SimpleSSLContext.class
+grant codeBase "file:${test.classes}/../../../../test/lib/-" {
     permission java.util.PropertyPermission "test.src.path", "read";
-    permission java.io.FilePermission "${test.src}/../../../lib/testlibrary/jdk/testlibrary/testkeys", "read";
+    permission java.io.FilePermission "${test.src}/../../../../lib/jdk/test/lib/net/testkeys", "read";
 };
 
 // for JTwork//classes/0/java/net/httpclient/http2/server/*
--- a/test/jdk/java/net/httpclient/http2/BadHeadersTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/http2/BadHeadersTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -27,9 +27,9 @@
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
  *          java.net.http/jdk.internal.net.http.hpack
- * @library /lib/testlibrary server
+ * @library /test/lib server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm -Djdk.internal.httpclient.debug=true BadHeadersTest
  */
 
@@ -38,7 +38,7 @@
 import jdk.internal.net.http.frame.HeaderFrame;
 import jdk.internal.net.http.frame.HeadersFrame;
 import jdk.internal.net.http.frame.Http2Frame;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/http2/BasicTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/http2/BasicTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -24,8 +24,8 @@
 /*
  * @test
  * @bug 8087112
- * @library /lib/testlibrary server
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib server
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
@@ -47,7 +47,7 @@
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.Test;
 import static java.net.http.HttpClient.Version.HTTP_2;
 
--- a/test/jdk/java/net/httpclient/http2/ContinuationFrameTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/http2/ContinuationFrameTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -28,9 +28,9 @@
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
  *          java.net.http/jdk.internal.net.http.hpack
- * @library /lib/testlibrary server
+ * @library /test/lib server
  * @build Http2TestServer
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run testng/othervm ContinuationFrameTest
  */
 
@@ -55,7 +55,7 @@
 import jdk.internal.net.http.frame.HeaderFrame;
 import jdk.internal.net.http.frame.HeadersFrame;
 import jdk.internal.net.http.frame.Http2Frame;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/http2/ErrorTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/http2/ErrorTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -24,8 +24,8 @@
 /*
  * @test
  * @bug 8157105
- * @library /lib/testlibrary server
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib server
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
@@ -46,7 +46,7 @@
 import javax.net.ssl.SSLParameters;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ExecutorService;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import static java.net.http.HttpClient.Version.HTTP_2;
 
 import org.testng.annotations.Test;
--- a/test/jdk/java/net/httpclient/http2/FixedThreadPoolTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/http2/FixedThreadPoolTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -24,8 +24,8 @@
 /*
  * @test
  * @bug 8087112 8177935
- * @library /lib/testlibrary server
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib server
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
@@ -40,7 +40,7 @@
 import javax.net.ssl.*;
 import java.nio.file.*;
 import java.util.concurrent.*;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import static java.net.http.HttpClient.Version.HTTP_2;
 import org.testng.annotations.Test;
 
--- a/test/jdk/java/net/httpclient/http2/ImplicitPushCancel.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/http2/ImplicitPushCancel.java	Mon Oct 15 11:39:10 2018 -0700
@@ -23,8 +23,8 @@
 
 /*
  * @test
- * @library /lib/testlibrary server
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib server
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
--- a/test/jdk/java/net/httpclient/http2/ProxyTest2.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/http2/ProxyTest2.java	Mon Oct 15 11:39:10 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
@@ -52,7 +52,7 @@
 import java.net.http.HttpClient;
 import java.net.http.HttpRequest;
 import java.net.http.HttpResponse;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import java.util.concurrent.*;
 
 /**
@@ -61,12 +61,12 @@
  * @summary  Verifies that you can access an HTTP/2 server over HTTPS by
  *           tunnelling through an HTTP/1.1 proxy.
  * @modules java.net.http
- * @library /lib/testlibrary server
+ * @library /test/lib server
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
  *          java.net.http/jdk.internal.net.http.hpack
- * @build jdk.testlibrary.SimpleSSLContext ProxyTest2
+ * @build jdk.test.lib.net.SimpleSSLContext ProxyTest2
  * @run main/othervm ProxyTest2
  * @author danielfuchs
  */
--- a/test/jdk/java/net/httpclient/http2/RedirectTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/http2/RedirectTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -24,8 +24,8 @@
 /*
  * @test
  * @bug 8156514
- * @library /lib/testlibrary server
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib server
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
--- a/test/jdk/java/net/httpclient/http2/ServerPush.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/http2/ServerPush.java	Mon Oct 15 11:39:10 2018 -0700
@@ -24,8 +24,8 @@
 /*
  * @test
  * @bug 8087112 8159814
- * @library /lib/testlibrary server
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib server
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
--- a/test/jdk/java/net/httpclient/http2/ServerPushWithDiffTypes.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/http2/ServerPushWithDiffTypes.java	Mon Oct 15 11:39:10 2018 -0700
@@ -23,8 +23,8 @@
 
 /*
  * @test
- * @library /lib/testlibrary server
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib server
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @modules java.base/sun.net.www.http
  *          java.net.http/jdk.internal.net.http.common
  *          java.net.http/jdk.internal.net.http.frame
--- a/test/jdk/java/net/httpclient/security/Driver.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/security/Driver.java	Mon Oct 15 11:39:10 2018 -0700
@@ -24,12 +24,11 @@
 /*
  * @test
  * @bug 8087112
- * @library /lib/testlibrary/
  * @library /test/lib
  * @modules java.net.http
  *          java.logging
  *          jdk.httpserver
- * @build jdk.testlibrary.SimpleSSLContext jdk.test.lib.Utils
+ * @build jdk.test.lib.net.SimpleSSLContext jdk.test.lib.Utils
  * @compile ../../../../com/sun/net/httpserver/LogFilter.java
  * @compile ../../../../com/sun/net/httpserver/FileServerHandler.java
  * @compile ../ProxyServer.java
--- a/test/jdk/java/net/httpclient/security/Security.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/security/Security.java	Mon Oct 15 11:39:10 2018 -0700
@@ -27,8 +27,8 @@
  * @modules java.net.http
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @compile ../../../../com/sun/net/httpserver/LogFilter.java
  * @compile ../../../../com/sun/net/httpserver/FileServerHandler.java
  * @compile ../ProxyServer.java
--- a/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -24,8 +24,8 @@
 /*
  * @test
  * @summary Basic test for WebSocketHandshakeException
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SimpleSSLContext
+ * @library /test/lib
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @modules java.net.http
  *          jdk.httpserver
  * @run testng/othervm -Djdk.internal.httpclient.debug=true WSHandshakeExceptionTest
@@ -39,7 +39,7 @@
 import java.net.http.HttpClient;
 import java.net.http.WebSocket;
 import java.net.http.WebSocketHandshakeException;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AbstractSSLTubeTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AbstractSSLTubeTest.java	Mon Oct 15 11:39:10 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,22 +28,13 @@
 import jdk.internal.net.http.common.Utils;
 import org.testng.annotations.Test;
 
-import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLParameters;
-import javax.net.ssl.TrustManagerFactory;
-import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteBuffer;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
 import java.util.List;
 import java.util.StringTokenizer;
 import java.util.concurrent.CompletableFuture;
@@ -244,76 +235,4 @@
         engine.setUseClientMode(client);
         return engine;
     }
-
-    /**
-     * Creates a simple usable SSLContext for SSLSocketFactory or a HttpsServer
-     * using either a given keystore or a default one in the test tree.
-     *
-     * Using this class with a security manager requires the following
-     * permissions to be granted:
-     *
-     * permission "java.util.PropertyPermission" "test.src.path", "read";
-     * permission java.io.FilePermission "${test.src}/../../../../lib/testlibrary/jdk/testlibrary/testkeys",
-     * "read"; The exact path above depends on the location of the test.
-     */
-    protected static class SimpleSSLContext {
-
-        private final SSLContext ssl;
-
-        /**
-         * Loads default keystore from SimpleSSLContext source directory
-         */
-        public SimpleSSLContext() throws IOException {
-            String paths = System.getProperty("test.src.path");
-            StringTokenizer st = new StringTokenizer(paths, File.pathSeparator);
-            boolean securityExceptions = false;
-            SSLContext sslContext = null;
-            while (st.hasMoreTokens()) {
-                String path = st.nextToken();
-                try {
-                    File f = new File(path, "../../../../lib/testlibrary/jdk/testlibrary/testkeys");
-                    if (f.exists()) {
-                        try (FileInputStream fis = new FileInputStream(f)) {
-                            sslContext = init(fis);
-                            break;
-                        }
-                    }
-                } catch (SecurityException e) {
-                    // catch and ignore because permission only required
-                    // for one entry on path (at most)
-                    securityExceptions = true;
-                }
-            }
-            if (securityExceptions) {
-                System.err.println("SecurityExceptions thrown on loading testkeys");
-            }
-            ssl = sslContext;
-        }
-
-        private SSLContext init(InputStream i) throws IOException {
-            try {
-                char[] passphrase = "passphrase".toCharArray();
-                KeyStore ks = KeyStore.getInstance("JKS");
-                ks.load(i, passphrase);
-
-                KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
-                kmf.init(ks, passphrase);
-
-                TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
-                tmf.init(ks);
-
-                SSLContext ssl = SSLContext.getInstance("TLS");
-                ssl.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
-                return ssl;
-            } catch (KeyManagementException | KeyStoreException |
-                    UnrecoverableKeyException | CertificateException |
-                    NoSuchAlgorithmException e) {
-                throw new RuntimeException(e.getMessage());
-            }
-        }
-
-        public SSLContext get() {
-            return ssl;
-        }
-    }
 }
--- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/FlowTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/FlowTest.java	Mon Oct 15 11:39:10 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,8 +24,6 @@
 package jdk.internal.net.http;
 
 import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -33,12 +31,6 @@
 import java.net.InetSocketAddress;
 import java.net.Socket;
 import java.nio.ByteBuffer;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
 import java.util.List;
 import java.util.Random;
 import java.util.StringTokenizer;
@@ -53,9 +45,7 @@
 import java.util.concurrent.SubmissionPublisher;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
-import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.*;
-import javax.net.ssl.TrustManagerFactory;
 import jdk.internal.net.http.common.Utils;
 import org.testng.annotations.Test;
 import jdk.internal.net.http.common.SSLFlowDelegate;
@@ -467,80 +457,6 @@
         }
     }
 
-    /**
-     * Creates a simple usable SSLContext for SSLSocketFactory
-     * or a HttpsServer using either a given keystore or a default
-     * one in the test tree.
-     * <p>
-     * Using this class with a security manager requires the following
-     * permissions to be granted:
-     * <p>
-     * permission "java.util.PropertyPermission" "test.src.path", "read";
-     * permission java.io.FilePermission
-     * "${test.src}/../../../../lib/testlibrary/jdk/testlibrary/testkeys", "read";
-     * The exact path above depends on the location of the test.
-     */
-    static class SimpleSSLContext {
-
-        private final SSLContext ssl;
-
-        /**
-         * Loads default keystore from SimpleSSLContext source directory
-         */
-        public SimpleSSLContext() throws IOException {
-            String paths = System.getProperty("test.src.path");
-            StringTokenizer st = new StringTokenizer(paths, File.pathSeparator);
-            boolean securityExceptions = false;
-            SSLContext sslContext = null;
-            while (st.hasMoreTokens()) {
-                String path = st.nextToken();
-                try {
-                    File f = new File(path, "../../../../lib/testlibrary/jdk/testlibrary/testkeys");
-                    if (f.exists()) {
-                        try (FileInputStream fis = new FileInputStream(f)) {
-                            sslContext = init(fis);
-                            break;
-                        }
-                    }
-                } catch (SecurityException e) {
-                    // catch and ignore because permission only required
-                    // for one entry on path (at most)
-                    securityExceptions = true;
-                }
-            }
-            if (securityExceptions) {
-                System.out.println("SecurityExceptions thrown on loading testkeys");
-            }
-            ssl = sslContext;
-        }
-
-        private SSLContext init(InputStream i) throws IOException {
-            try {
-                char[] passphrase = "passphrase".toCharArray();
-                KeyStore ks = KeyStore.getInstance("JKS");
-                ks.load(i, passphrase);
-
-                KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
-                kmf.init(ks, passphrase);
-
-                TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
-                tmf.init(ks);
-
-                SSLContext ssl = SSLContext.getInstance("TLS");
-                ssl.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
-                return ssl;
-            } catch (KeyManagementException | KeyStoreException |
-                    UnrecoverableKeyException | CertificateException |
-                    NoSuchAlgorithmException e) {
-                throw new RuntimeException(e.getMessage());
-            }
-        }
-
-        public SSLContext get() {
-            return ssl;
-        }
-    }
-
     private static void sleep(int millis) {
         try {
             Thread.sleep(millis);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SimpleSSLContext.java	Mon Oct 15 11:39:10 2018 -0700
@@ -0,0 +1,112 @@
+/*
+ * 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 jdk.internal.net.http;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import java.util.StringTokenizer;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+
+/**
+ * Creates a simple usable SSLContext for SSLSocketFactory
+ * or a HttpsServer using a default keystore in the test tree.
+ * <p>
+ * Using this class with a security manager requires the following
+ * permissions to be granted:
+ * <p>
+ * permission "java.util.PropertyPermission" "test.src.path", "read";
+ * permission java.io.FilePermission "/path/to/test/lib/jdk/test/lib/testkeys", "read";
+ * The exact path above depends on the location of the test.
+ */
+public class SimpleSSLContext {
+
+    private final SSLContext ssl;
+
+    /**
+     * Loads default keystore from SimpleSSLContext source directory
+     */
+    public SimpleSSLContext() throws IOException {
+        String paths = System.getProperty("test.src.path");
+        StringTokenizer st = new StringTokenizer(paths, File.pathSeparator);
+        boolean securityExceptions = false;
+        SSLContext sslContext = null;
+        while (st.hasMoreTokens()) {
+            String path = st.nextToken();
+            try {
+                File f = new File(path, "../../../../../lib/jdk/test/lib/net/testkeys");
+                if (f.exists()) {
+                    try (FileInputStream fis = new FileInputStream(f)) {
+                        sslContext = init(fis);
+                        break;
+                    }
+                }
+            } catch (SecurityException e) {
+                // catch and ignore because permission only required
+                // for one entry on path (at most)
+                securityExceptions = true;
+            }
+        }
+        if (securityExceptions) {
+            System.out.println("SecurityExceptions thrown on loading testkeys");
+        }
+        ssl = sslContext;
+    }
+
+    private SSLContext init(InputStream i) throws IOException {
+        try {
+            char[] passphrase = "passphrase".toCharArray();
+            KeyStore ks = KeyStore.getInstance("PKCS12");
+            ks.load(i, passphrase);
+
+            KeyManagerFactory kmf = KeyManagerFactory.getInstance("PKIX");
+            kmf.init(ks, passphrase);
+
+            TrustManagerFactory tmf = TrustManagerFactory.getInstance("PKIX");
+            tmf.init(ks);
+
+            SSLContext ssl = SSLContext.getInstance("TLS");
+            ssl.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+            return ssl;
+        } catch (KeyManagementException | KeyStoreException |
+                UnrecoverableKeyException | CertificateException |
+                NoSuchAlgorithmException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+    }
+
+    public SSLContext get() {
+        return ssl;
+    }
+}
\ No newline at end of file
--- a/test/jdk/javax/net/ssl/HttpsURLConnection/Equals.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/javax/net/ssl/HttpsURLConnection/Equals.java	Mon Oct 15 11:39:10 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,9 +24,9 @@
 /**
  * @test
  * @bug 8055299
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules jdk.httpserver
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @run main/othervm -Djavax.net.debug=ssl,handshake,record Equals
  */
 import com.sun.net.httpserver.*;
@@ -34,7 +34,7 @@
 import java.io.*;
 import javax.net.ssl.*;
 import java.util.concurrent.*;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 public class Equals {
 
--- a/test/jdk/lib/testlibrary/ModuleTargetHelper.java	Sat Oct 13 19:28:10 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 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.
- */
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.lang.module.ModuleReader;
-import java.lang.module.ModuleReference;
-import java.net.URI;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import jdk.internal.module.ModuleInfo;
-import jdk.internal.module.ModuleInfo.Attributes;
-
-public class ModuleTargetHelper {
-    private ModuleTargetHelper() {}
-
-    public static final class ModuleTarget {
-        private String targetPlatform;
-
-        public ModuleTarget(String targetPlatform) {
-            this.targetPlatform = targetPlatform;
-        }
-
-        public String targetPlatform() {
-            return targetPlatform;
-        }
-    }
-
-    public static ModuleTarget getJavaBaseTarget() throws IOException {
-        Path p = Paths.get(URI.create("jrt:/modules/java.base/module-info.class"));
-        try (InputStream in = Files.newInputStream(p)) {
-            return read(in);
-        }
-    }
-
-    public static ModuleTarget read(InputStream in) throws IOException {
-        ModuleInfo.Attributes attrs = ModuleInfo.read(in, null);
-        if (attrs.target() != null) {
-            return new ModuleTarget(attrs.target().targetPlatform());
-        } else {
-            return null;
-        }
-    }
-
-    public static ModuleTarget read(ModuleReference modRef) throws IOException {
-        ModuleReader reader = modRef.open();
-        try (InputStream in = reader.open("module-info.class").get()) {
-            return read(in);
-        } finally {
-            reader.close();
-        }
-    }
-}
--- a/test/jdk/lib/testlibrary/ModuleUtils.java	Sat Oct 13 19:28:10 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +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.
- */
-
-import java.lang.module.ModuleDescriptor;
-import java.lang.module.ModuleFinder;
-import java.lang.module.ModuleReader;
-import java.lang.module.ModuleReference;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-
-
-/**
- * This class consists exclusively of static utility methods that are useful
- * for creating tests for modules.
- */
-
-public final class ModuleUtils {
-    private ModuleUtils() { }
-
-
-    /**
-     * Returns a ModuleFinder that finds modules with the given module
-     * descriptors.
-     */
-    static ModuleFinder finderOf(ModuleDescriptor... descriptors) {
-
-        // Create a ModuleReference for each module
-        Map<String, ModuleReference> namesToReference = new HashMap<>();
-
-        for (ModuleDescriptor descriptor : descriptors) {
-            String name = descriptor.name();
-
-            URI uri = URI.create("module:/" + name);
-
-            ModuleReference mref = new ModuleReference(descriptor, uri) {
-                @Override
-                public ModuleReader open() {
-                    throw new UnsupportedOperationException();
-                }
-            };
-
-            namesToReference.put(name, mref);
-        }
-
-        return new ModuleFinder() {
-            @Override
-            public Optional<ModuleReference> find(String name) {
-                Objects.requireNonNull(name);
-                return Optional.ofNullable(namesToReference.get(name));
-            }
-            @Override
-            public Set<ModuleReference> findAll() {
-                return new HashSet<>(namesToReference.values());
-            }
-        };
-    }
-
-}
--- a/test/jdk/lib/testlibrary/jdk/testlibrary/SimpleSSLContext.java	Sat Oct 13 19:28:10 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2005, 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.*;
-import java.util.concurrent.*;
-import java.io.*;
-import java.net.*;
-import java.security.*;
-import java.security.cert.*;
-import javax.net.ssl.*;
-
-/**
- * Creates a simple usable SSLContext for SSLSocketFactory
- * or a HttpsServer using either a given keystore or a default
- * one in the test tree.
- *
- * Using this class with a security manager requires the following
- * permissions to be granted:
- *
- * permission "java.util.PropertyPermission" "test.src.path", "read";
- * permission java.io.FilePermission
- *    "${test.src}/../../../lib/testlibrary/jdk/testlibrary/testkeys", "read";
- * The exact path above depends on the location of the test.
- */
-public class SimpleSSLContext {
-
-    SSLContext ssl;
-
-    /**
-     * loads default keystore from SimpleSSLContext
-     * source directory
-     */
-    public SimpleSSLContext() throws IOException {
-        try {
-            AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
-                @Override
-                public Void run() throws Exception {
-                    String paths = System.getProperty("test.src.path");
-                    StringTokenizer st = new StringTokenizer(paths, File.pathSeparator);
-                    boolean securityExceptions = false;
-                    while (st.hasMoreTokens()) {
-                        String path = st.nextToken();
-                        try {
-                            File f = new File(path, "jdk/testlibrary/testkeys");
-                            if (f.exists()) {
-                                try (FileInputStream fis = new FileInputStream(f)) {
-                                    init(fis);
-                                    return null;
-                                }
-                            }
-                        } catch (SecurityException e) {
-                            // catch and ignore because permission only required
-                            // for one entry on path (at most)
-                            securityExceptions = true;
-                        }
-                    }
-                    if (securityExceptions) {
-                        System.err.println("SecurityExceptions thrown on loading testkeys");
-                    }
-                    return null;
-                }
-            });
-        } catch (PrivilegedActionException pae) {
-            Throwable t = pae.getCause() != null ? pae.getCause() : pae;
-            if (t instanceof IOException)
-                throw (IOException)t;
-            if (t instanceof RuntimeException)
-                throw (RuntimeException)t;
-            if (t instanceof Error)
-                throw (Error)t;
-            throw new RuntimeException(t);
-        }
-    }
-
-    /**
-     * loads default keystore from given directory
-     */
-    public SimpleSSLContext(String dir) throws IOException {
-        String file = dir+"/testkeys";
-        try (FileInputStream fis = new FileInputStream(file)) {
-            init(fis);
-        }
-    }
-
-    private void init(InputStream i) throws IOException {
-        try {
-            char[] passphrase = "passphrase".toCharArray();
-            KeyStore ks = KeyStore.getInstance("JKS");
-            ks.load(i, passphrase);
-
-            KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
-            kmf.init(ks, passphrase);
-
-            TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
-            tmf.init(ks);
-
-            ssl = SSLContext.getInstance("TLS");
-            ssl.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
-        } catch (KeyManagementException e) {
-            throw new RuntimeException(e.getMessage());
-        } catch (KeyStoreException e) {
-            throw new RuntimeException(e.getMessage());
-        } catch (UnrecoverableKeyException e) {
-            throw new RuntimeException(e.getMessage());
-        } catch (CertificateException e) {
-            throw new RuntimeException(e.getMessage());
-        } catch (NoSuchAlgorithmException e) {
-            throw new RuntimeException(e.getMessage());
-        }
-    }
-
-    public SSLContext get() {
-        return ssl;
-    }
-}
Binary file test/jdk/lib/testlibrary/jdk/testlibrary/testkeys has changed
--- a/test/jdk/sun/net/ftp/FtpURLConnectionLeak.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/sun/net/ftp/FtpURLConnectionLeak.java	Mon Oct 15 11:39:10 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
@@ -30,7 +30,6 @@
  * @run main FtpURLConnectionLeak
  */
 import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URL;
@@ -44,27 +43,26 @@
         int port = server.getLocalPort();
         server.start();
         URL url = new URL("ftp://localhost:" + port + "/filedoesNotExist.txt");
-        for (int i = 0; i < 3; i++) {
-            try {
-                InputStream stream = url.openStream();
-            } catch (FileNotFoundException expectedFirstTimeAround) {
-                // should always reach this point since the path does not exist
-            } catch (IOException expected) {
-                System.out.println("caught expected " + expected);
-                int times = 1;
-                do {
-                    // give some time to close the connection...
-                    System.out.println("sleeping... " + times);
-                    Thread.sleep(times * 1000);
-                } while (server.activeClientsCount() > 0 && times++ < 5);
+        try (server) {
+            for (int i = 0; i < 3; i++) {
+                try {
+                    InputStream stream = url.openStream();
+                } catch (FileNotFoundException expected) {
+                    // should always reach this point since the path does not exist
+                    System.out.println("caught expected " + expected);
+                    int times = 1;
+                    do {
+                        // give some time to close the connection...
+                        System.out.println("sleeping... " + times);
+                        Thread.sleep(times * 1000);
+                    } while (server.activeClientsCount() > 0 && times++ < 5);
 
-                if (server.activeClientsCount() > 0) {
-                    server.killClients();
-                    throw new RuntimeException("URLConnection didn't close the" +
-                            " FTP connection on FileNotFoundException");
+                    if (server.activeClientsCount() > 0) {
+                        server.killClients();
+                        throw new RuntimeException("URLConnection didn't close the" +
+                                " FTP connection on FileNotFoundException");
+                    }
                 }
-            } finally {
-                server.terminate();
             }
         }
     }
--- a/test/jdk/sun/net/www/ftptest/FtpCommandHandler.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/sun/net/www/ftptest/FtpCommandHandler.java	Mon Oct 15 11:39:10 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 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
@@ -442,8 +442,14 @@
             // cmd.setSoTimeout(2000);
             in = new BufferedReader(new InputStreamReader(cmd.getInputStream()));
             out = new PrintStream(cmd.getOutputStream(), true, "ISO8859_1");
+            // Below corrupted message style was intentional to test 8151586, please
+            // make sure each message line not broken ftp communication (such as for
+            // message line lenght >=4, the 4th char required '-' to allow
+            // implementation thinks that it has seen multi-line reply '###-'
+            // sequence), otherwise it will affect normal ftp tests which depends
+            // on this.
             out.println("---------------------------------\n220 Java FTP test server"
-                    + " (j2se 6.0) ready.\n \n                Please send commands\n"
+                    + " (j2se 6.0) ready.\n \n   -            Please send commands\n"
                     + "-----------------------------\n\n\n");
             out.flush();
             if (auth.authType() == 0) // No auth needed
--- a/test/jdk/sun/net/www/ftptest/FtpServer.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/sun/net/www/ftptest/FtpServer.java	Mon Oct 15 11:39:10 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 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
@@ -47,7 +47,7 @@
  *
  */
 
-public class FtpServer extends Thread {
+public class FtpServer extends Thread implements AutoCloseable {
     private ServerSocket listener = null;
     private FtpFileSystemHandler fsh = null;
     private FtpAuthHandler auth = null;
@@ -134,4 +134,13 @@
 
         }
     }
+
+    @Override
+    public void close() throws Exception {
+        terminate();
+        listener.close();
+        if (activeClientsCount() > 0) {
+            killClients();
+        }
+    }
 }
--- a/test/jdk/sun/net/www/protocol/http/RedirectOnPost.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/sun/net/www/protocol/http/RedirectOnPost.java	Mon Oct 15 11:39:10 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,9 +23,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary/
+ * @library /test/lib
  * @modules jdk.httpserver
- * @build jdk.testlibrary.SimpleSSLContext
+ * @build jdk.test.lib.net.SimpleSSLContext
  * @compile RedirectOnPost.java
  * @run main/othervm RedirectOnPost
  * @bug 8029127
@@ -38,7 +38,7 @@
 import com.sun.net.httpserver.*;
 import java.util.concurrent.*;
 import javax.net.ssl.*;
-import jdk.testlibrary.SimpleSSLContext;
+import jdk.test.lib.net.SimpleSSLContext;
 
 public class RedirectOnPost {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/ModuleTargetHelper.java	Mon Oct 15 11:39:10 2018 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 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.
+ */
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.lang.module.ModuleReader;
+import java.lang.module.ModuleReference;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import jdk.internal.module.ModuleInfo;
+import jdk.internal.module.ModuleInfo.Attributes;
+
+public class ModuleTargetHelper {
+    private ModuleTargetHelper() {}
+
+    public static final class ModuleTarget {
+        private String targetPlatform;
+
+        public ModuleTarget(String targetPlatform) {
+            this.targetPlatform = targetPlatform;
+        }
+
+        public String targetPlatform() {
+            return targetPlatform;
+        }
+    }
+
+    public static ModuleTarget getJavaBaseTarget() throws IOException {
+        Path p = Paths.get(URI.create("jrt:/modules/java.base/module-info.class"));
+        try (InputStream in = Files.newInputStream(p)) {
+            return read(in);
+        }
+    }
+
+    public static ModuleTarget read(InputStream in) throws IOException {
+        ModuleInfo.Attributes attrs = ModuleInfo.read(in, null);
+        if (attrs.target() != null) {
+            return new ModuleTarget(attrs.target().targetPlatform());
+        } else {
+            return null;
+        }
+    }
+
+    public static ModuleTarget read(ModuleReference modRef) throws IOException {
+        ModuleReader reader = modRef.open();
+        try (InputStream in = reader.open("module-info.class").get()) {
+            return read(in);
+        } finally {
+            reader.close();
+        }
+    }
+}
--- a/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/SystemModulesTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/SystemModulesTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -42,7 +42,6 @@
 /**
  * @test
  * @bug 8142968 8173381
- * @library /lib/testlibrary
  * @modules java.base/jdk.internal.misc
  * @modules java.base/jdk.internal.module
  * @modules java.base/jdk.internal.org.objectweb.asm
--- a/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -44,7 +44,7 @@
 /**
  * @test
  * @bug 8142968 8173381 8174740
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules jdk.compiler jdk.jlink
  * @modules java.base/jdk.internal.module
  * @modules java.base/jdk.internal.org.objectweb.asm
--- a/test/jdk/tools/jmod/hashes/HashesTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/tools/jmod/hashes/HashesTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -237,6 +237,28 @@
               .forEach(mn -> assertTrue(ht.hashes(mn) == null));
     }
 
+    @Test
+    public static void upgradeableModule() throws IOException {
+        Path mpath = Paths.get(System.getProperty("java.home"), "jmods");
+        if (!Files.exists(mpath)) {
+            return;
+        }
+
+        Path dest = Paths.get("test4");
+        HashesTest ht = new HashesTest(dest);
+        ht.makeModule("m1");
+        ht.makeModule("java.compiler", "m1");
+        ht.makeModule("m2", "java.compiler");
+
+        ht.makeJmod("m1");
+        ht.makeJmod("m2");
+        ht.makeJmod("java.compiler",
+                    "--module-path",
+                    ht.lib.toString() + File.pathSeparator + mpath,
+                    "--hash-modules", "java\\.(?!se)|^m.*");
+
+        ht.checkHashes("java.compiler",  "m2");
+    }
 
     @Test
     public static void testImageJmods() throws IOException {
--- a/test/jdk/tools/launcher/modules/addexports/AddExportsTest.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/jdk/tools/launcher/modules/addexports/AddExportsTest.java	Mon Oct 15 11:39:10 2018 -0700
@@ -24,7 +24,8 @@
 /**
  * @test
  * @library /test/lib
- * @modules jdk.compiler
+ * @modules java.compiler
+ *          jdk.compiler
  * @build AddExportsTest jdk.test.lib.compiler.CompilerUtils
  * @run testng AddExportsTest
  * @summary Basic tests for java --add-exports
@@ -51,12 +52,15 @@
 
     private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
     private static final Path MODS_DIR = Paths.get("mods");
+    private static final Path UPGRADE_MODS_DIRS = Paths.get("upgrademods");
 
     // test module m1 that uses Unsafe
     private static final String TEST1_MODULE = "m1";
     private static final String TEST1_MAIN_CLASS = "jdk.test1.Main";
 
-
+    // test module m2 uses java.compiler internals
+    private static final String TEST2_MODULE = "m2";
+    private static final String TEST2_MAIN_CLASS = "jdk.test2.Main";
 
     // test module m3 uses m4 internals
     private static final String TEST3_MODULE = "m3";
@@ -74,7 +78,19 @@
                 "--add-exports", "java.base/jdk.internal.misc=m1");
         assertTrue(compiled, "module " + TEST1_MODULE + " did not compile");
 
+        // javac -d upgrademods/java.compiler src/java.compiler/**
+        compiled = CompilerUtils.compile(
+                SRC_DIR.resolve("java.compiler"),
+                UPGRADE_MODS_DIRS.resolve("java.compiler"));
+        assertTrue(compiled, "module java.compiler did not compile");
 
+        // javac --upgrade-module-path upgrademods -d mods/m2 src/m2/**
+        compiled = CompilerUtils.compile(
+                SRC_DIR.resolve(TEST2_MODULE),
+                MODS_DIR.resolve(TEST2_MODULE),
+                "--upgrade-module-path", UPGRADE_MODS_DIRS.toString(),
+                "--add-exports", "java.compiler/javax.tools.internal=m2");
+        assertTrue(compiled, "module " + TEST2_MODULE + " did not compile");
 
         // javac -d mods/m3 src/m3/**
         compiled = CompilerUtils.compile(
@@ -146,7 +162,25 @@
         assertTrue(exitValue == 0);
     }
 
+    /**
+     * Test --add-exports with upgraded module
+     */
+    public void testWithUpgradedModule() throws Exception {
 
+        // java --add-exports java.compiler/javax.tools.internal=m2
+        //      --upgrade-module-path upgrademods --module-path mods -m ...
+        String mid = TEST2_MODULE + "/" + TEST2_MAIN_CLASS;
+        int exitValue = executeTestJava(
+                "--add-exports", "java.compiler/javax.tools.internal=m2",
+                "--upgrade-module-path", UPGRADE_MODS_DIRS.toString(),
+                "--module-path", MODS_DIR.toString(),
+                "-m", mid)
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .getExitValue();
+
+        assertTrue(exitValue == 0);
+    }
 
     /**
      * Test --add-exports with module that is added to the set of root modules
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/launcher/modules/addexports/src/java.compiler/javax/annotation/processing/Generated.java	Mon Oct 15 11:39:10 2018 -0700
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+package javax.annotation.processing;
+
+public interface Generated {
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/launcher/modules/addexports/src/java.compiler/javax/tools/ToolsHelper.java	Mon Oct 15 11:39:10 2018 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package javax.tools;
+
+public class ToolsHelper {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/launcher/modules/addexports/src/java.compiler/javax/tools/internal/Helper.java	Mon Oct 15 11:39:10 2018 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package javax.tools.internal;
+
+public class Helper {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/launcher/modules/addexports/src/java.compiler/module-info.java	Mon Oct 15 11:39:10 2018 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module java.compiler {
+    exports javax.tools;
+    exports javax.annotation.processing;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/launcher/modules/addexports/src/m2/jdk/test2/Main.java	Mon Oct 15 11:39:10 2018 -0700
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test2;
+
+import javax.tools.internal.Helper;
+
+public class Main {
+    public static void main(String[] args) {
+        Helper h = new Helper();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/launcher/modules/addexports/src/m2/module-info.java	Mon Oct 15 11:39:10 2018 -0700
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+module m2 {
+    requires java.compiler;
+}
--- a/test/lib/jdk/test/lib/apps/LingeredApp.java	Sat Oct 13 19:28:10 2018 +0200
+++ b/test/lib/jdk/test/lib/apps/LingeredApp.java	Mon Oct 15 11:39:10 2018 -0700
@@ -26,9 +26,6 @@
 import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
 import java.io.StringReader;
 import java.nio.file.Files;
 import java.nio.file.NoSuchFileException;
@@ -43,7 +40,6 @@
 import java.util.stream.Collectors;
 import java.util.UUID;
 import jdk.test.lib.process.OutputBuffer;
-import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.process.StreamPumper;
 
 /**
@@ -137,6 +133,14 @@
     }
 
     /**
+     * @return the LingeredApp's output.
+     * Can be called after the app is run.
+     */
+    public String getProcessStdout() {
+        return stdoutBuffer.toString();
+    }
+
+    /**
      *
      * @return OutputBuffer object for the LingeredApp's output. Can only be called
      * after LingeredApp has exited.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/net/SimpleSSLContext.java	Mon Oct 15 11:39:10 2018 -0700
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.lib.net;
+
+import java.util.*;
+import java.io.*;
+import java.security.*;
+import java.security.cert.*;
+import javax.net.ssl.*;
+
+/**
+ * Creates a simple usable SSLContext for SSLSocketFactory
+ * or a HttpsServer using either a given keystore or a default
+ * one in the test tree.
+ *
+ * Using this class with a security manager requires the following
+ * permissions to be granted:
+ *
+ * permission "java.util.PropertyPermission" "test.src.path", "read";
+ * permission java.io.FilePermission "/path/to/test/lib/jdk/test/lib/testkeys", "read";
+ * The exact path above depends on the location of the test.
+ */
+public class SimpleSSLContext {
+
+    SSLContext ssl;
+
+    /**
+     * loads default keystore from SimpleSSLContext
+     * source directory
+     */
+    public SimpleSSLContext() throws IOException {
+        try {
+            AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
+                @Override
+                public Void run() throws Exception {
+                    String paths = System.getProperty("test.src.path");
+                    StringTokenizer st = new StringTokenizer(paths, File.pathSeparator);
+                    boolean securityExceptions = false;
+                    while (st.hasMoreTokens()) {
+                        String path = st.nextToken();
+                        try {
+                            File f = new File(path, "jdk/test/lib/net/testkeys");
+                            if (f.exists()) {
+                                try (FileInputStream fis = new FileInputStream(f)) {
+                                    init(fis);
+                                    return null;
+                                }
+                            }
+                        } catch (SecurityException e) {
+                            // catch and ignore because permission only required
+                            // for one entry on path (at most)
+                            securityExceptions = true;
+                        }
+                    }
+                    if (securityExceptions) {
+                        System.err.println("SecurityExceptions thrown on loading testkeys");
+                    }
+                    return null;
+                }
+            });
+        } catch (PrivilegedActionException pae) {
+            Throwable t = pae.getCause() != null ? pae.getCause() : pae;
+            if (t instanceof IOException)
+                throw (IOException)t;
+            if (t instanceof RuntimeException)
+                throw (RuntimeException)t;
+            if (t instanceof Error)
+                throw (Error)t;
+            throw new RuntimeException(t);
+        }
+    }
+
+    /**
+     * loads default keystore from given directory
+     */
+    public SimpleSSLContext(String dir) throws IOException {
+        String file = dir + "/testkeys";
+        try (FileInputStream fis = new FileInputStream(file)) {
+            init(fis);
+        }
+    }
+
+    private void init(InputStream i) throws IOException {
+        try {
+            char[] passphrase = "passphrase".toCharArray();
+            KeyStore ks = KeyStore.getInstance("PKCS12");
+            ks.load(i, passphrase);
+
+            KeyManagerFactory kmf = KeyManagerFactory.getInstance("PKIX");
+            kmf.init(ks, passphrase);
+
+            TrustManagerFactory tmf = TrustManagerFactory.getInstance("PKIX");
+            tmf.init(ks);
+
+            ssl = SSLContext.getInstance("TLS");
+            ssl.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+        } catch (KeyManagementException | KeyStoreException |
+                UnrecoverableKeyException | CertificateException |
+                NoSuchAlgorithmException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+    }
+
+    public SSLContext get() {
+        return ssl;
+    }
+}
Binary file test/lib/jdk/test/lib/net/testkeys has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/util/ModuleUtils.java	Mon Oct 15 11:39:10 2018 -0700
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+
+package jdk.test.lib.util;
+
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleFinder;
+import java.lang.module.ModuleReader;
+import java.lang.module.ModuleReference;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+
+
+/**
+ * This class consists exclusively of static utility methods that are useful
+ * for creating tests for modules.
+ */
+
+public final class ModuleUtils {
+    private ModuleUtils() { }
+
+
+    /**
+     * Returns a ModuleFinder that finds modules with the given module
+     * descriptors.
+     */
+    public static ModuleFinder finderOf(ModuleDescriptor... descriptors) {
+
+        // Create a ModuleReference for each module
+        Map<String, ModuleReference> namesToReference = new HashMap<>();
+
+        for (ModuleDescriptor descriptor : descriptors) {
+            String name = descriptor.name();
+
+            URI uri = URI.create("module:/" + name);
+
+            ModuleReference mref = new ModuleReference(descriptor, uri) {
+                @Override
+                public ModuleReader open() {
+                    throw new UnsupportedOperationException();
+                }
+            };
+
+            namesToReference.put(name, mref);
+        }
+
+        return new ModuleFinder() {
+            @Override
+            public Optional<ModuleReference> find(String name) {
+                Objects.requireNonNull(name);
+                return Optional.ofNullable(namesToReference.get(name));
+            }
+            @Override
+            public Set<ModuleReference> findAll() {
+                return new HashSet<>(namesToReference.values());
+            }
+        };
+    }
+
+}