Merge
authorduke
Wed, 05 Jul 2017 20:13:05 +0200
changeset 28269 1f52a555b105
parent 28268 2261a52528ba (current diff)
parent 28267 43cd6c8ef555 (diff)
child 28271 79adfd75cd1a
Merge
hotspot/test/testlibrary/whitebox/Makefile
hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
hotspot/test/testlibrary/whitebox/sun/hotspot/code/BlobType.java
hotspot/test/testlibrary/whitebox/sun/hotspot/code/CodeBlob.java
hotspot/test/testlibrary/whitebox/sun/hotspot/code/NMethod.java
hotspot/test/testlibrary/whitebox/sun/hotspot/cpuinfo/CPUInfo.java
hotspot/test/testlibrary/whitebox/sun/hotspot/parser/DiagnosticCommand.java
jdk/src/java.base/share/classes/sun/nio/fs/AbstractPath.java
--- a/.hgtags-top-repo	Tue Dec 30 09:44:23 2014 -0800
+++ b/.hgtags-top-repo	Wed Jul 05 20:13:05 2017 +0200
@@ -286,3 +286,4 @@
 67395f7ca2db3b52e3a62a84888487de5cb9210a jdk9-b41
 f7c11da0b0481d49cc7a65a453336c108191e821 jdk9-b42
 02ee8c65622e8bd97496d584e22fc7dcf0edc4ae jdk9-b43
+8994f5d87b3bb5e8d317d4e8ccb326da1a73684a jdk9-b44
--- a/corba/.hgtags	Tue Dec 30 09:44:23 2014 -0800
+++ b/corba/.hgtags	Wed Jul 05 20:13:05 2017 +0200
@@ -286,3 +286,4 @@
 1908b886ba1eda46fa725cf1160fe5d30fd1a7e5 jdk9-b41
 078bb11af876fe528d4b516f33ad4dd9bb60549e jdk9-b42
 9645e35616b60c5c07b4fdf11a132afc8081dfa8 jdk9-b43
+1f57bd728c9e6865ccb9d43ccd80a1c11230a32f jdk9-b44
--- a/hotspot/.hgtags	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/.hgtags	Wed Jul 05 20:13:05 2017 +0200
@@ -446,3 +446,4 @@
 1d29b13e8a515a7ea3b882f140576d5d675bc11f jdk9-b41
 38cb4fbd47e3472bd1b5ebac83bda96fe4869c4f jdk9-b42
 65a9747147b8090037541040ba67156ec914db6a jdk9-b43
+43a44b56dca61a4d766a20f0528fdd8b5ceff873 jdk9-b44
--- a/hotspot/agent/src/os/win32/windbg/sawindbg.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/agent/src/os/win32/windbg/sawindbg.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -22,6 +22,9 @@
  *
  */
 
+// Disable CRT security warning against strcpy/strcat
+#pragma warning(disable: 4996)
+
 // this is source code windbg based SA debugger agent to debug
 // Dr. Watson dump files and process snapshots.
 
--- a/hotspot/agent/src/share/native/sadis.c	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/agent/src/share/native/sadis.c	Wed Jul 05 20:13:05 2017 +0200
@@ -33,6 +33,8 @@
  */
 
 #ifdef _WINDOWS
+// Disable CRT security warning against _snprintf
+#pragma warning (disable : 4996)
 
 #define snprintf  _snprintf
 #define vsnprintf _vsnprintf
@@ -90,12 +92,8 @@
     if (errno != 0)
     {
       /* C runtime error that has no corresponding DOS error code */
-      const char *s = strerror(errno);
-      size_t n = strlen(s);
-      if (n >= len) n = len - 1;
-      strncpy(buf, s, n);
-      buf[n] = '\0';
-      return (int)n;
+      strerror_s(buf, len, errno);
+      return strlen(buf);
     }
     return 0;
 }
@@ -111,16 +109,30 @@
                                                                            jstring jrepath_s,
                                                                            jstring libname_s) {
   uintptr_t func = 0;
-  const char* error_message = NULL;
-  jboolean isCopy;
+  const char *error_message = NULL;
+  const char *jrepath = NULL;
+  const char *libname = NULL;
+  char buffer[128];
+
+#ifdef _WINDOWS
+  HINSTANCE hsdis_handle = (HINSTANCE) NULL;
+#else
+  void* hsdis_handle = NULL;
+#endif
 
-  const char * jrepath = (*env)->GetStringUTFChars(env, jrepath_s, &isCopy); // like $JAVA_HOME/jre/lib/sparc/
-  const char * libname = (*env)->GetStringUTFChars(env, libname_s, &isCopy);
-  char buffer[128];
+  jrepath = (*env)->GetStringUTFChars(env, jrepath_s, NULL); // like $JAVA_HOME/jre/lib/sparc/
+  if (jrepath == NULL || (*env)->ExceptionOccurred(env)) {
+    return 0;
+  }
+
+  libname = (*env)->GetStringUTFChars(env, libname_s, NULL);
+  if (libname == NULL || (*env)->ExceptionOccurred(env)) {
+    (*env)->ReleaseStringUTFChars(env, jrepath_s, jrepath);
+    return 0;
+  }
 
   /* Load the hsdis library */
 #ifdef _WINDOWS
-  HINSTANCE hsdis_handle;
   hsdis_handle = LoadLibrary(libname);
   if (hsdis_handle == NULL) {
     snprintf(buffer, sizeof(buffer), "%s%s", jrepath, libname);
@@ -134,7 +146,6 @@
     error_message = buffer;
   }
 #else
-  void* hsdis_handle;
   hsdis_handle = dlopen(libname, RTLD_LAZY | RTLD_GLOBAL);
   if (hsdis_handle == NULL) {
     snprintf(buffer, sizeof(buffer), "%s%s", jrepath, libname);
@@ -156,6 +167,11 @@
      * platform dependent error message.
      */
     jclass eclass = (*env)->FindClass(env, "sun/jvm/hotspot/debugger/DebuggerException");
+    if ((*env)->ExceptionOccurred(env)) {
+      /* Can't throw exception, probably OOM, so silently return 0 */
+      return (jlong) 0;
+    }
+
     (*env)->ThrowNew(env, eclass, error_message);
   }
   return (jlong)func;
@@ -184,16 +200,22 @@
 
 /* event callback binding to Disassembler.handleEvent */
 static void* event_to_env(void* env_pv, const char* event, void* arg) {
+  jlong result = 0;
   decode_env* denv = (decode_env*)env_pv;
   JNIEnv* env = denv->env;
   jstring event_string = (*env)->NewStringUTF(env, event);
-  jlong result = (*env)->CallLongMethod(env, denv->dis, denv->handle_event, denv->visitor,
-                                        event_string, (jlong) (uintptr_t)arg);
-  if ((*env)->ExceptionOccurred(env) != NULL) {
+  if ((*env)->ExceptionOccurred(env)) {
+    return NULL;
+  }
+
+  result = (*env)->CallLongMethod(env, denv->dis, denv->handle_event, denv->visitor,
+                                  event_string, (jlong) (uintptr_t)arg);
+  if ((*env)->ExceptionOccurred(env)) {
     /* ignore exceptions for now */
     (*env)->ExceptionClear(env);
-    result = 0;
+    return NULL;
   }
+
   return (void*)(uintptr_t)result;
 }
 
@@ -219,10 +241,13 @@
   }
   if (raw != NULL) {
     jstring output = (*env)->NewStringUTF(env, raw);
-    (*env)->CallVoidMethod(env, denv->dis, denv->raw_print, denv->visitor, output);
-    if ((*env)->ExceptionOccurred(env) != NULL) {
+    if (!(*env)->ExceptionOccurred(env)) {
+      /* make sure that UTF allocation doesn't cause OOM */
+      (*env)->CallVoidMethod(env, denv->dis, denv->raw_print, denv->visitor, output);
+    }
+    if ((*env)->ExceptionOccurred(env)) {
       /* ignore exceptions for now */
-      (*env)->ExceptionClear(env);
+        (*env)->ExceptionClear(env);
     }
     return (int) flen;
   }
@@ -231,11 +256,16 @@
   va_end(ap);
 
   output = (*env)->NewStringUTF(env, denv->buffer);
-  (*env)->CallVoidMethod(env, denv->dis, denv->raw_print, denv->visitor, output);
-  if ((*env)->ExceptionOccurred(env) != NULL) {
+  if (!(*env)->ExceptionOccurred(env)) {
+    /* make sure that UTF allocation doesn't cause OOM */
+    (*env)->CallVoidMethod(env, denv->dis, denv->raw_print, denv->visitor, output);
+  }
+
+  if ((*env)->ExceptionOccurred(env)) {
     /* ignore exceptions for now */
     (*env)->ExceptionClear(env);
   }
+
   return cnt;
 }
 
@@ -251,13 +281,24 @@
                                                                     jbyteArray code,
                                                                     jstring options_s,
                                                                     jlong decode_instructions_virtual) {
-  jboolean isCopy;
-  jbyte* start = (*env)->GetByteArrayElements(env, code, &isCopy);
-  jbyte* end = start + (*env)->GetArrayLength(env, code);
-  const char * options = (*env)->GetStringUTFChars(env, options_s, &isCopy);
-  jclass disclass = (*env)->GetObjectClass(env, dis);
+  jbyte *start = NULL;
+  jbyte *end = NULL;
+  jclass disclass = NULL;
+  const char *options = NULL;
+  decode_env denv;
 
-  decode_env denv;
+  start = (*env)->GetByteArrayElements(env, code, NULL);
+  if ((*env)->ExceptionOccurred(env)) {
+    return;
+  }
+  end = start + (*env)->GetArrayLength(env, code);
+  options = (*env)->GetStringUTFChars(env, options_s, NULL);
+  if ((*env)->ExceptionOccurred(env)) {
+    (*env)->ReleaseByteArrayElements(env, code, start, JNI_ABORT);
+    return;
+  }
+  disclass = (*env)->GetObjectClass(env, dis);
+
   denv.env = env;
   denv.dis = dis;
   denv.visitor = visitor;
@@ -266,6 +307,8 @@
   denv.handle_event = (*env)->GetMethodID(env, disclass, "handleEvent",
                                           "(Lsun/jvm/hotspot/asm/InstructionVisitor;Ljava/lang/String;J)J");
   if ((*env)->ExceptionOccurred(env)) {
+    (*env)->ReleaseByteArrayElements(env, code, start, JNI_ABORT);
+    (*env)->ReleaseStringUTFChars(env, options_s, options);
     return;
   }
 
@@ -273,11 +316,13 @@
   denv.raw_print = (*env)->GetMethodID(env, disclass, "rawPrint",
                                        "(Lsun/jvm/hotspot/asm/InstructionVisitor;Ljava/lang/String;)V");
   if ((*env)->ExceptionOccurred(env)) {
+    (*env)->ReleaseByteArrayElements(env, code, start, JNI_ABORT);
+    (*env)->ReleaseStringUTFChars(env, options_s, options);
     return;
   }
 
   /* decode the buffer */
-  (*(decode_func)(uintptr_t)decode_instructions_virtual)(startPc,
+  (*(decode_func)(uintptr_t)decode_instructions_virtual)((uintptr_t) startPc,
                                                          startPc + end - start,
                                                          (unsigned char*)start,
                                                          end - start,
--- a/hotspot/make/aix/makefiles/mapfile-vers-debug	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/make/aix/makefiles/mapfile-vers-debug	Wed Jul 05 20:13:05 2017 +0200
@@ -72,7 +72,6 @@
                 JVM_FillInStackTrace;
                 JVM_FindClassFromCaller;
                 JVM_FindClassFromClass;
-                JVM_FindClassFromClassLoader;
                 JVM_FindClassFromBootLoader;
                 JVM_FindLibraryEntry;
                 JVM_FindLoadedClass;
--- a/hotspot/make/aix/makefiles/mapfile-vers-product	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/make/aix/makefiles/mapfile-vers-product	Wed Jul 05 20:13:05 2017 +0200
@@ -72,7 +72,6 @@
                 JVM_FillInStackTrace;
                 JVM_FindClassFromCaller;
                 JVM_FindClassFromClass;
-                JVM_FindClassFromClassLoader;
                 JVM_FindClassFromBootLoader;
                 JVM_FindLibraryEntry;
                 JVM_FindLoadedClass;
--- a/hotspot/make/bsd/makefiles/mapfile-vers-darwin-debug	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/make/bsd/makefiles/mapfile-vers-darwin-debug	Wed Jul 05 20:13:05 2017 +0200
@@ -70,7 +70,6 @@
                 _JVM_FillInStackTrace
                 _JVM_FindClassFromCaller
                 _JVM_FindClassFromClass
-                _JVM_FindClassFromClassLoader
                 _JVM_FindClassFromBootLoader
                 _JVM_FindLibraryEntry
                 _JVM_FindLoadedClass
--- a/hotspot/make/bsd/makefiles/mapfile-vers-darwin-product	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/make/bsd/makefiles/mapfile-vers-darwin-product	Wed Jul 05 20:13:05 2017 +0200
@@ -70,7 +70,6 @@
                 _JVM_FillInStackTrace
                 _JVM_FindClassFromCaller
                 _JVM_FindClassFromClass
-                _JVM_FindClassFromClassLoader
                 _JVM_FindClassFromBootLoader
                 _JVM_FindLibraryEntry
                 _JVM_FindLoadedClass
--- a/hotspot/make/bsd/makefiles/mapfile-vers-debug	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/make/bsd/makefiles/mapfile-vers-debug	Wed Jul 05 20:13:05 2017 +0200
@@ -72,7 +72,6 @@
                 JVM_FillInStackTrace;
                 JVM_FindClassFromCaller;
                 JVM_FindClassFromClass;
-                JVM_FindClassFromClassLoader;
                 JVM_FindClassFromBootLoader;
                 JVM_FindLibraryEntry;
                 JVM_FindLoadedClass;
--- a/hotspot/make/bsd/makefiles/mapfile-vers-product	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/make/bsd/makefiles/mapfile-vers-product	Wed Jul 05 20:13:05 2017 +0200
@@ -72,7 +72,6 @@
                 JVM_FillInStackTrace;
                 JVM_FindClassFromCaller;
                 JVM_FindClassFromClass;
-                JVM_FindClassFromClassLoader;
                 JVM_FindClassFromBootLoader;
                 JVM_FindLibraryEntry;
                 JVM_FindLoadedClass;
--- a/hotspot/make/linux/makefiles/mapfile-vers-debug	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/make/linux/makefiles/mapfile-vers-debug	Wed Jul 05 20:13:05 2017 +0200
@@ -72,7 +72,6 @@
                 JVM_FillInStackTrace;
                 JVM_FindClassFromCaller;
                 JVM_FindClassFromClass;
-                JVM_FindClassFromClassLoader;
                 JVM_FindClassFromBootLoader;
                 JVM_FindLibraryEntry;
                 JVM_FindLoadedClass;
--- a/hotspot/make/linux/makefiles/mapfile-vers-product	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/make/linux/makefiles/mapfile-vers-product	Wed Jul 05 20:13:05 2017 +0200
@@ -72,7 +72,6 @@
                 JVM_FillInStackTrace;
                 JVM_FindClassFromCaller;
                 JVM_FindClassFromClass;
-                JVM_FindClassFromClassLoader;
                 JVM_FindClassFromBootLoader;
                 JVM_FindLibraryEntry;
                 JVM_FindLoadedClass;
--- a/hotspot/make/solaris/makefiles/mapfile-vers	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/make/solaris/makefiles/mapfile-vers	Wed Jul 05 20:13:05 2017 +0200
@@ -72,7 +72,6 @@
                 JVM_FillInStackTrace;
                 JVM_FindClassFromCaller;
                 JVM_FindClassFromClass;
-                JVM_FindClassFromClassLoader;
                 JVM_FindClassFromBootLoader;
                 JVM_FindLibraryEntry;
                 JVM_FindLoadedClass;
--- a/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -544,6 +544,9 @@
   cmplw(CCR0, Rindex, Rlength);
   sldi(RsxtIndex, RsxtIndex, index_shift);
   blt(CCR0, LnotOOR);
+  // Index should be in R17_tos, array should be in R4_ARG2.
+  mr(R17_tos, Rindex);
+  mr(R4_ARG2, Rarray);
   load_dispatch_table(Rtmp, (address*)Interpreter::_throw_ArrayIndexOutOfBoundsException_entry);
   mtctr(Rtmp);
   bctr();
@@ -1678,6 +1681,228 @@
   }
 }
 
+// Argument and return type profilig.
+// kills: tmp, tmp2, R0, CR0, CR1
+void InterpreterMacroAssembler::profile_obj_type(Register obj, Register mdo_addr_base,
+                                                 RegisterOrConstant mdo_addr_offs, Register tmp, Register tmp2) {
+  Label do_nothing, do_update;
+
+  // tmp2 = obj is allowed
+  assert_different_registers(obj, mdo_addr_base, tmp, R0);
+  assert_different_registers(tmp2, mdo_addr_base, tmp, R0);
+  const Register klass = tmp2;
+
+  verify_oop(obj);
+
+  ld(tmp, mdo_addr_offs, mdo_addr_base);
+
+  // Set null_seen if obj is 0.
+  cmpdi(CCR0, obj, 0);
+  ori(R0, tmp, TypeEntries::null_seen);
+  beq(CCR0, do_update);
+
+  load_klass(klass, obj);
+
+  clrrdi(R0, tmp, exact_log2(-TypeEntries::type_klass_mask));
+  // Basically same as andi(R0, tmp, TypeEntries::type_klass_mask);
+  cmpd(CCR1, R0, klass);
+  // Klass seen before, nothing to do (regardless of unknown bit).
+  //beq(CCR1, do_nothing);
+
+  andi_(R0, klass, TypeEntries::type_unknown);
+  // Already unknown. Nothing to do anymore.
+  //bne(CCR0, do_nothing);
+  crorc(/*CCR0 eq*/2, /*CCR1 eq*/4+2, /*CCR0 eq*/2); // cr0 eq = cr1 eq or cr0 ne
+  beq(CCR0, do_nothing);
+
+  clrrdi_(R0, tmp, exact_log2(-TypeEntries::type_mask));
+  orr(R0, klass, tmp); // Combine klass and null_seen bit (only used if (tmp & type_mask)==0).
+  beq(CCR0, do_update); // First time here. Set profile type.
+
+  // Different than before. Cannot keep accurate profile.
+  ori(R0, tmp, TypeEntries::type_unknown);
+
+  bind(do_update);
+  // update profile
+  std(R0, mdo_addr_offs, mdo_addr_base);
+
+  align(32, 12);
+  bind(do_nothing);
+}
+
+void InterpreterMacroAssembler::profile_arguments_type(Register callee, Register tmp1, Register tmp2, bool is_virtual) {
+  if (!ProfileInterpreter) {
+    return;
+  }
+
+  assert_different_registers(callee, tmp1, tmp2, R28_mdx);
+
+  if (MethodData::profile_arguments() || MethodData::profile_return()) {
+    Label profile_continue;
+
+    test_method_data_pointer(profile_continue);
+
+    int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size());
+
+    lbz(tmp1, in_bytes(DataLayout::tag_offset()) - off_to_start, R28_mdx);
+    cmpwi(CCR0, tmp1, is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag);
+    bne(CCR0, profile_continue);
+
+    if (MethodData::profile_arguments()) {
+      Label done;
+      int off_to_args = in_bytes(TypeEntriesAtCall::args_data_offset());
+      add(R28_mdx, off_to_args, R28_mdx);
+
+      for (int i = 0; i < TypeProfileArgsLimit; i++) {
+        if (i > 0 || MethodData::profile_return()) {
+          // If return value type is profiled we may have no argument to profile.
+          ld(tmp1, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args, R28_mdx);
+          cmpdi(CCR0, tmp1, (i+1)*TypeStackSlotEntries::per_arg_count());
+          addi(tmp1, tmp1, -i*TypeStackSlotEntries::per_arg_count());
+          blt(CCR0, done);
+        }
+        ld(tmp1, in_bytes(Method::const_offset()), callee);
+        lhz(tmp1, in_bytes(ConstMethod::size_of_parameters_offset()), tmp1);
+        // Stack offset o (zero based) from the start of the argument
+        // list, for n arguments translates into offset n - o - 1 from
+        // the end of the argument list. But there's an extra slot at
+        // the top of the stack. So the offset is n - o from Lesp.
+        ld(tmp2, in_bytes(TypeEntriesAtCall::stack_slot_offset(i))-off_to_args, R28_mdx);
+        subf(tmp1, tmp2, tmp1);
+
+        sldi(tmp1, tmp1, Interpreter::logStackElementSize);
+        ldx(tmp1, tmp1, R15_esp);
+
+        profile_obj_type(tmp1, R28_mdx, in_bytes(TypeEntriesAtCall::argument_type_offset(i))-off_to_args, tmp2, tmp1);
+
+        int to_add = in_bytes(TypeStackSlotEntries::per_arg_size());
+        addi(R28_mdx, R28_mdx, to_add);
+        off_to_args += to_add;
+      }
+
+      if (MethodData::profile_return()) {
+        ld(tmp1, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args, R28_mdx);
+        addi(tmp1, tmp1, -TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count());
+      }
+
+      bind(done);
+
+      if (MethodData::profile_return()) {
+        // We're right after the type profile for the last
+        // argument. tmp1 is the number of cells left in the
+        // CallTypeData/VirtualCallTypeData to reach its end. Non null
+        // if there's a return to profile.
+        assert(ReturnTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type");
+        sldi(tmp1, tmp1, exact_log2(DataLayout::cell_size));
+        add(R28_mdx, tmp1, R28_mdx);
+      }
+    } else {
+      assert(MethodData::profile_return(), "either profile call args or call ret");
+      update_mdp_by_constant(in_bytes(TypeEntriesAtCall::return_only_size()));
+    }
+
+    // Mdp points right after the end of the
+    // CallTypeData/VirtualCallTypeData, right after the cells for the
+    // return value type if there's one.
+    align(32, 12);
+    bind(profile_continue);
+  }
+}
+
+void InterpreterMacroAssembler::profile_return_type(Register ret, Register tmp1, Register tmp2) {
+  assert_different_registers(ret, tmp1, tmp2);
+  if (ProfileInterpreter && MethodData::profile_return()) {
+    Label profile_continue;
+
+    test_method_data_pointer(profile_continue);
+
+    if (MethodData::profile_return_jsr292_only()) {
+      // If we don't profile all invoke bytecodes we must make sure
+      // it's a bytecode we indeed profile. We can't go back to the
+      // begining of the ProfileData we intend to update to check its
+      // type because we're right after it and we don't known its
+      // length.
+      lbz(tmp1, 0, R14_bcp);
+      lbz(tmp2, Method::intrinsic_id_offset_in_bytes(), R19_method);
+      cmpwi(CCR0, tmp1, Bytecodes::_invokedynamic);
+      cmpwi(CCR1, tmp1, Bytecodes::_invokehandle);
+      cror(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2);
+      cmpwi(CCR1, tmp2, vmIntrinsics::_compiledLambdaForm);
+      cror(/*CR0 eq*/2, /*CR1 eq*/4+2, /*CR0 eq*/2);
+      bne(CCR0, profile_continue);
+    }
+
+    profile_obj_type(ret, R28_mdx, -in_bytes(ReturnTypeEntry::size()), tmp1, tmp2);
+
+    align(32, 12);
+    bind(profile_continue);
+  }
+}
+
+void InterpreterMacroAssembler::profile_parameters_type(Register tmp1, Register tmp2, Register tmp3, Register tmp4) {
+  if (ProfileInterpreter && MethodData::profile_parameters()) {
+    Label profile_continue, done;
+
+    test_method_data_pointer(profile_continue);
+
+    // Load the offset of the area within the MDO used for
+    // parameters. If it's negative we're not profiling any parameters.
+    lwz(tmp1, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset()), R28_mdx);
+    cmpwi(CCR0, tmp1, 0);
+    blt(CCR0, profile_continue);
+
+    // Compute a pointer to the area for parameters from the offset
+    // and move the pointer to the slot for the last
+    // parameters. Collect profiling from last parameter down.
+    // mdo start + parameters offset + array length - 1
+
+    // Pointer to the parameter area in the MDO.
+    const Register mdp = tmp1;
+    add(mdp, tmp1, R28_mdx);
+
+    // Pffset of the current profile entry to update.
+    const Register entry_offset = tmp2;
+    // entry_offset = array len in number of cells
+    ld(entry_offset, in_bytes(ArrayData::array_len_offset()), mdp);
+
+    int off_base = in_bytes(ParametersTypeData::stack_slot_offset(0));
+    assert(off_base % DataLayout::cell_size == 0, "should be a number of cells");
+
+    // entry_offset (number of cells)  = array len - size of 1 entry + offset of the stack slot field
+    addi(entry_offset, entry_offset, -TypeStackSlotEntries::per_arg_count() + (off_base / DataLayout::cell_size));
+    // entry_offset in bytes
+    sldi(entry_offset, entry_offset, exact_log2(DataLayout::cell_size));
+
+    Label loop;
+    align(32, 12);
+    bind(loop);
+
+    // Load offset on the stack from the slot for this parameter.
+    ld(tmp3, entry_offset, mdp);
+    sldi(tmp3, tmp3, Interpreter::logStackElementSize);
+    neg(tmp3, tmp3);
+    // Read the parameter from the local area.
+    ldx(tmp3, tmp3, R18_locals);
+
+    // Make entry_offset now point to the type field for this parameter.
+    int type_base = in_bytes(ParametersTypeData::type_offset(0));
+    assert(type_base > off_base, "unexpected");
+    addi(entry_offset, entry_offset, type_base - off_base);
+
+    // Profile the parameter.
+    profile_obj_type(tmp3, mdp, entry_offset, tmp4, tmp3);
+
+    // Go to next parameter.
+    int delta = TypeStackSlotEntries::per_arg_count() * DataLayout::cell_size + (type_base - off_base);
+    cmpdi(CCR0, entry_offset, off_base + delta);
+    addi(entry_offset, entry_offset, -delta);
+    bge(CCR0, loop);
+
+    align(32, 12);
+    bind(profile_continue);
+  }
+}
+
 // Add a InterpMonitorElem to stack (see frame_sparc.hpp).
 void InterpreterMacroAssembler::add_monitor_to_stack(bool stack_is_empty, Register Rtemp1, Register Rtemp2) {
 
@@ -2039,20 +2264,19 @@
   bne(CCR0, test);
 
   address fd = CAST_FROM_FN_PTR(address, verify_return_address);
-  unsigned int nbytes_save = 10*8; // 10 volatile gprs
-
-  save_LR_CR(Rtmp);
+  const int nbytes_save = 11*8; // volatile gprs except R0
+  save_volatile_gprs(R1_SP, -nbytes_save); // except R0
+  save_LR_CR(Rtmp); // Save in old frame.
   push_frame_reg_args(nbytes_save, Rtmp);
-  save_volatile_gprs(R1_SP, 112); // except R0
 
   load_const_optimized(Rtmp, fd, R0);
   mr_if_needed(R4_ARG2, reg);
   mr(R3_ARG1, R19_method);
   call_c(Rtmp); // call C
 
-  restore_volatile_gprs(R1_SP, 112); // except R0
   pop_frame();
   restore_LR_CR(Rtmp);
+  restore_volatile_gprs(R1_SP, -nbytes_save); // except R0
   b(skip);
 
   // Perform a more elaborate out-of-line call.
--- a/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -255,6 +255,12 @@
   void record_klass_in_profile(Register receiver, Register scratch1, Register scratch2, bool is_virtual_call);
   void record_klass_in_profile_helper(Register receiver, Register scratch1, Register scratch2, int start_row, Label& done, bool is_virtual_call);
 
+  // Argument and return type profiling.
+  void profile_obj_type(Register obj, Register mdo_addr_base, RegisterOrConstant mdo_addr_offs, Register tmp, Register tmp2);
+  void profile_arguments_type(Register callee, Register tmp1, Register tmp2, bool is_virtual);
+  void profile_return_type(Register ret, Register tmp1, Register tmp2);
+  void profile_parameters_type(Register tmp1, Register tmp2, Register tmp3, Register tmp4);
+
 #endif // !CC_INTERP
 
   // Debugging
--- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -807,6 +807,7 @@
 
 // For verify_oops.
 void MacroAssembler::save_volatile_gprs(Register dst, int offset) {
+  std(R2,  offset, dst);   offset += 8;
   std(R3,  offset, dst);   offset += 8;
   std(R4,  offset, dst);   offset += 8;
   std(R5,  offset, dst);   offset += 8;
@@ -821,6 +822,7 @@
 
 // For verify_oops.
 void MacroAssembler::restore_volatile_gprs(Register src, int offset) {
+  ld(R2,  offset, src);   offset += 8;
   ld(R3,  offset, src);   offset += 8;
   ld(R4,  offset, src);   offset += 8;
   ld(R5,  offset, src);   offset += 8;
@@ -1187,6 +1189,16 @@
   call_VM(oop_result, entry_point, check_exceptions);
 }
 
+void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3,
+                             bool check_exceptions) {
+  // R3_ARG1 is reserved for the thread
+  mr_if_needed(R4_ARG2, arg_1);
+  assert(arg_2 != R4_ARG2, "smashed argument");
+  mr_if_needed(R5_ARG3, arg_2);
+  mr_if_needed(R6_ARG4, arg_3);
+  call_VM(oop_result, entry_point, check_exceptions);
+}
+
 void MacroAssembler::call_VM_leaf(address entry_point) {
   call_VM_leaf_base(entry_point);
 }
@@ -3059,35 +3071,27 @@
   if (!VerifyOops) {
     return;
   }
-  // Will be preserved.
-  Register tmp = R11;
-  assert(oop != tmp, "precondition");
-  unsigned int nbytes_save = 10*8; // 10 volatile gprs
+
   address/* FunctionDescriptor** */fd = StubRoutines::verify_oop_subroutine_entry_address();
-  // save tmp
-  mr(R0, tmp);
-  // kill tmp
-  save_LR_CR(tmp);
+  const Register tmp = R11; // Will be preserved.
+  const int nbytes_save = 11*8; // Volatile gprs except R0.
+  save_volatile_gprs(R1_SP, -nbytes_save); // except R0
+
+  if (oop == tmp) mr(R4_ARG2, oop);
+  save_LR_CR(tmp); // save in old frame
   push_frame_reg_args(nbytes_save, tmp);
-  // restore tmp
-  mr(tmp, R0);
-  save_volatile_gprs(R1_SP, 112); // except R0
   // load FunctionDescriptor** / entry_address *
-  load_const(tmp, fd);
+  load_const_optimized(tmp, fd, R0);
   // load FunctionDescriptor* / entry_address
   ld(tmp, 0, tmp);
-  mr(R4_ARG2, oop);
-  load_const(R3_ARG1, (address)msg);
-  // call destination for its side effect
+  if (oop != tmp) mr_if_needed(R4_ARG2, oop);
+  load_const_optimized(R3_ARG1, (address)msg, R0);
+  // Call destination for its side effect.
   call_c(tmp);
-  restore_volatile_gprs(R1_SP, 112); // except R0
+
   pop_frame();
-  // save tmp
-  mr(R0, tmp);
-  // kill tmp
   restore_LR_CR(tmp);
-  // restore tmp
-  mr(tmp, R0);
+  restore_volatile_gprs(R1_SP, -nbytes_save); // except R0
 }
 
 const char* stop_types[] = {
--- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -369,6 +369,7 @@
   void call_VM(Register oop_result, address entry_point, bool check_exceptions = true);
   void call_VM(Register oop_result, address entry_point, Register arg_1, bool check_exceptions = true);
   void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, bool check_exceptions = true);
+  void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg3, bool check_exceptions = true);
   void call_VM_leaf(address entry_point);
   void call_VM_leaf(address entry_point, Register arg_1);
   void call_VM_leaf(address entry_point, Register arg_1, Register arg_2);
--- a/hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -100,10 +100,7 @@
   MacroAssembler* a = new MacroAssembler(&cb);
 
   // Patch the call.
-  if (ReoptimizeCallSequences &&
-      a->is_within_range_of_b(dest, addr_call)) {
-    a->bl(dest);
-  } else {
+  if (!ReoptimizeCallSequences || !a->is_within_range_of_b(dest, addr_call)) {
     address trampoline_stub_addr = get_trampoline();
 
     // We did not find a trampoline stub because the current codeblob
@@ -115,9 +112,12 @@
 
     // Patch the constant in the call's trampoline stub.
     NativeCallTrampolineStub_at(trampoline_stub_addr)->set_destination(dest);
+    dest = trampoline_stub_addr;
+  }
 
-    a->bl(trampoline_stub_addr);
-  }
+  OrderAccess::release();
+  a->bl(dest);
+
   ICache::ppc64_flush_icache_bytes(addr_call, code_size);
 }
 
--- a/hotspot/src/cpu/ppc/vm/ppc.ad	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/cpu/ppc/vm/ppc.ad	Wed Jul 05 20:13:05 2017 +0200
@@ -1936,8 +1936,9 @@
   // --------------------------------------------------------------------
   // Check for hi bits still needing moving. Only happens for misaligned
   // arguments to native calls.
-  if (src_hi == dst_hi)
+  if (src_hi == dst_hi) {
     return ppc64Opcode_none;               // Self copy; no move.
+  }
 
   ShouldNotReachHere();
   return ppc64Opcode_undefined;
@@ -1959,14 +1960,15 @@
 }
 
 uint MachNopNode::size(PhaseRegAlloc *ra_) const {
-   return _count * 4;
+  return _count * 4;
 }
 
 #ifndef PRODUCT
 void BoxLockNode::format(PhaseRegAlloc *ra_, outputStream *st) const {
   int offset = ra_->reg2offset(in_RegMask(0).find_first_elem());
-  int reg = ra_->get_reg_first(this);
-  st->print("ADDI %s, SP, %d \t// box node", Matcher::regName[reg], offset);
+  char reg_str[128];
+  ra_->dump_register(this, reg_str);
+  st->print("ADDI    %s, SP, %d \t// box node", reg_str, offset);
 }
 #endif
 
--- a/hotspot/src/cpu/ppc/vm/templateInterpreter_ppc.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/cpu/ppc/vm/templateInterpreter_ppc.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -91,7 +91,7 @@
 
   // Thread will be loaded to R3_ARG1.
   // Target class oop is in register R5_ARG3 by convention!
-  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ClassCastException_verbose, R17_tos, R5_ARG3));
+  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ClassCastException_verbose), R17_tos, R5_ARG3);
   // Above call must not return here since exception pending.
   DEBUG_ONLY(__ should_not_reach_here();)
   return entry;
@@ -172,6 +172,10 @@
   // Compiled code destroys templateTableBase, reload.
   __ load_const_optimized(R25_templateTableBase, (address)Interpreter::dispatch_table((TosState)0), R12_scratch2);
 
+  if (state == atos) {
+    __ profile_return_type(R3_RET, R11_scratch1, R12_scratch2);
+  }
+
   const Register cache = R11_scratch1;
   const Register size  = R12_scratch2;
   __ get_cache_and_index_at_bcp(cache, 1, index_size);
@@ -1189,6 +1193,10 @@
       __ li(R0, 1);
       __ stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread);
     }
+
+    // Argument and return type profiling.
+    __ profile_parameters_type(R3_ARG1, R4_ARG2, R5_ARG3, R6_ARG4);
+
     // Increment invocation counter and check for overflow.
     if (inc_counter) {
       generate_counter_incr(&invocation_counter_overflow, &profile_method, &profile_method_continue);
@@ -1469,6 +1477,8 @@
     __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0);
     if (ProfileInterpreter) {
       __ set_method_data_pointer_for_bcp();
+      __ ld(R11_scratch1, 0, R1_SP);
+      __ std(R28_mdx, _ijava_state_neg(mdx), R11_scratch1);
     }
 #if INCLUDE_JVMTI
     Label L_done;
@@ -1480,13 +1490,11 @@
     // The member name argument must be restored if _invokestatic is re-executed after a PopFrame call.
     // Detect such a case in the InterpreterRuntime function and return the member name argument, or NULL.
     __ ld(R4_ARG2, 0, R18_locals);
-    __ call_VM(R11_scratch1, CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null),
-               R4_ARG2, R19_method, R14_bcp);
-
-    __ cmpdi(CCR0, R11_scratch1, 0);
+    __ MacroAssembler::call_VM(R4_ARG2, CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null), R4_ARG2, R19_method, R14_bcp, false);
+    __ restore_interpreter_state(R11_scratch1, /*bcp_and_mdx_only*/ true);
+    __ cmpdi(CCR0, R4_ARG2, 0);
     __ beq(CCR0, L_done);
-
-    __ std(R11_scratch1, wordSize, R15_esp);
+    __ std(R4_ARG2, wordSize, R15_esp);
     __ bind(L_done);
 #endif // INCLUDE_JVMTI
     __ dispatch_next(vtos);
--- a/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -3235,6 +3235,8 @@
   // Load target.
   __ addi(Rrecv_klass, Rrecv_klass, base + vtableEntry::method_offset_in_bytes());
   __ ldx(Rtarget_method, Rindex, Rrecv_klass);
+  // Argument and return type profiling.
+  __ profile_arguments_type(Rtarget_method, Rrecv_klass /* scratch1 */, Rtemp /* scratch2 */, true);
   __ call_from_interpreter(Rtarget_method, Rret, Rrecv_klass /* scratch1 */, Rtemp /* scratch2 */);
 }
 
@@ -3318,6 +3320,8 @@
   __ null_check_throw(Rrecv, -1, Rscratch1);
 
   __ profile_final_call(Rrecv, Rscratch1);
+  // Argument and return type profiling.
+  __ profile_arguments_type(Rmethod, Rscratch1, Rscratch2, true);
 
   // Do the call.
   __ call_from_interpreter(Rmethod, Rret_addr, Rscratch1, Rscratch2);
@@ -3339,6 +3343,8 @@
   __ null_check_throw(Rreceiver, -1, R11_scratch1);
 
   __ profile_call(R11_scratch1, R12_scratch2);
+  // Argument and return type profiling.
+  __ profile_arguments_type(Rmethod, R11_scratch1, R12_scratch2, false);
   __ call_from_interpreter(Rmethod, Rret_addr, R11_scratch1, R12_scratch2);
 }
 
@@ -3353,6 +3359,8 @@
   prepare_invoke(byte_no, R19_method, Rret_addr, noreg, noreg, Rflags, R11_scratch1);
 
   __ profile_call(R11_scratch1, R12_scratch2);
+  // Argument and return type profiling.
+  __ profile_arguments_type(R19_method, R11_scratch1, R12_scratch2, false);
   __ call_from_interpreter(R19_method, Rret_addr, R11_scratch1, R12_scratch2);
 }
 
@@ -3374,6 +3382,8 @@
 
   // Final call case.
   __ profile_final_call(Rtemp1, Rscratch);
+  // Argument and return type profiling.
+  __ profile_arguments_type(Rindex, Rscratch, Rrecv_klass /* scratch */, true);
   // Do the final call - the index (f2) contains the method.
   __ call_from_interpreter(Rindex, Rret, Rscratch, Rrecv_klass /* scratch */);
 
@@ -3425,6 +3435,8 @@
   __ cmpdi(CCR0, Rindex, 0);
   __ beq(CCR0, Lthrow_ame);
   // Found entry. Jump off!
+  // Argument and return type profiling.
+  __ profile_arguments_type(Rindex, Rscratch1, Rscratch2, true);
   __ call_from_interpreter(Rindex, Rret_addr, Rscratch1, Rscratch2);
 
   // Vtable entry was NULL => Throw abstract method error.
@@ -3468,6 +3480,8 @@
   // to be the callsite object the bootstrap method returned. This is passed to a
   // "link" method which does the dispatch (Most likely just grabs the MH stored
   // inside the callsite and does an invokehandle).
+  // Argument and return type profiling.
+  __ profile_arguments_type(Rmethod, Rscratch1, Rscratch2, false);
   __ call_from_interpreter(Rmethod, Rret_addr, Rscratch1 /* scratch1 */, Rscratch2 /* scratch2 */);
 }
 
@@ -3488,6 +3502,8 @@
   __ profile_final_call(Rrecv, Rscratch1);
 
   // Still no call from handle => We call the method handle interpreter here.
+  // Argument and return type profiling.
+  __ profile_arguments_type(Rmethod, Rscratch1, Rscratch2, true);
   __ call_from_interpreter(Rmethod, Rret_addr, Rscratch1 /* scratch1 */, Rscratch2 /* scratch2 */);
 }
 
--- a/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -134,13 +134,44 @@
   }
 
   assert(AllocatePrefetchLines > 0, "invalid value");
-  if (AllocatePrefetchLines < 1) // Set valid value in product VM.
+  if (AllocatePrefetchLines < 1) { // Set valid value in product VM.
     AllocatePrefetchLines = 1; // Conservative value.
+  }
 
-  if (AllocatePrefetchStyle == 3 && AllocatePrefetchDistance < cache_line_size)
+  if (AllocatePrefetchStyle == 3 && AllocatePrefetchDistance < cache_line_size) {
     AllocatePrefetchStyle = 1; // Fall back if inappropriate.
+  }
 
   assert(AllocatePrefetchStyle >= 0, "AllocatePrefetchStyle should be positive");
+
+  if (UseCRC32Intrinsics) {
+    if (!FLAG_IS_DEFAULT(UseCRC32Intrinsics))
+      warning("CRC32 intrinsics  are not available on this CPU");
+    FLAG_SET_DEFAULT(UseCRC32Intrinsics, false);
+  }
+
+  // The AES intrinsic stubs require AES instruction support.
+  if (UseAES) {
+    warning("AES instructions are not available on this CPU");
+    FLAG_SET_DEFAULT(UseAES, false);
+  }
+  if (UseAESIntrinsics) {
+    if (!FLAG_IS_DEFAULT(UseAESIntrinsics))
+      warning("AES intrinsics are not available on this CPU");
+    FLAG_SET_DEFAULT(UseAESIntrinsics, false);
+  }
+
+  if (UseSHA) {
+    warning("SHA instructions are not available on this CPU");
+    FLAG_SET_DEFAULT(UseSHA, false);
+  }
+  if (UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics) {
+    warning("SHA intrinsics are not available on this CPU");
+    FLAG_SET_DEFAULT(UseSHA1Intrinsics, false);
+    FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
+    FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
+  }
+
 }
 
 void VM_Version::print_features() {
--- a/hotspot/src/os/aix/vm/osThread_aix.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os/aix/vm/osThread_aix.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2012, 2013 SAP AG. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -45,7 +45,8 @@
 
   sigemptyset(&_caller_sigmask);
 
-  _startThread_lock = new Monitor(Mutex::event, "startThread_lock", true);
+  _startThread_lock = new Monitor(Mutex::event, "startThread_lock", true,
+                                  Monitor::_safepoint_check_never);
   assert(_startThread_lock !=NULL, "check");
 }
 
--- a/hotspot/src/os/aix/vm/os_aix.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os/aix/vm/os_aix.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -124,12 +124,6 @@
 }
 #endif
 
-// Excerpts from systemcfg.h definitions newer than AIX 5.3
-#ifndef PV_7
-# define PV_7 0x200000          // Power PC 7
-# define PV_7_Compat 0x208000   // Power PC 7
-#endif
-
 #define MAX_PATH (2 * K)
 
 // for timer info max values which include all bits
@@ -140,17 +134,40 @@
 #define ERROR_MP_VMGETINFO_FAILED                    102
 #define ERROR_MP_VMGETINFO_CLAIMS_NO_SUPPORT_FOR_64K 103
 
-// the semantics in this file are thus that codeptr_t is a *real code ptr*
+// The semantics in this file are thus that codeptr_t is a *real code ptr*.
 // This means that any function taking codeptr_t as arguments will assume
 // a real codeptr and won't handle function descriptors (eg getFuncName),
 // whereas functions taking address as args will deal with function
-// descriptors (eg os::dll_address_to_library_name)
+// descriptors (eg os::dll_address_to_library_name).
 typedef unsigned int* codeptr_t;
 
-// typedefs for stackslots, stack pointers, pointers to op codes
+// Typedefs for stackslots, stack pointers, pointers to op codes.
 typedef unsigned long stackslot_t;
 typedef stackslot_t* stackptr_t;
 
+// Excerpts from systemcfg.h definitions newer than AIX 5.3.
+#ifndef PV_7
+#define PV_7 0x200000          /* Power PC 7 */
+#define PV_7_Compat 0x208000   /* Power PC 7 */
+#endif
+#ifndef PV_8
+#define PV_8 0x300000          /* Power PC 8 */
+#define PV_8_Compat 0x308000   /* Power PC 8 */
+#endif
+
+#define trcVerbose(fmt, ...) { /* PPC port */  \
+  if (Verbose) { \
+    fprintf(stderr, fmt, ##__VA_ARGS__); \
+    fputc('\n', stderr); fflush(stderr); \
+  } \
+}
+#define trc(fmt, ...)        /* PPC port */
+
+#define ERRBYE(s) { \
+    trcVerbose(s); \
+    return -1; \
+}
+
 // query dimensions of the stack of the calling thread
 static void query_stack_dimensions(address* p_stack_base, size_t* p_stack_size);
 
@@ -182,12 +199,12 @@
   return true;
 }
 
-// macro to check a given stack pointer against given stack limits and to die if test fails
+// Macro to check a given stack pointer against given stack limits and to die if test fails.
 #define CHECK_STACK_PTR(sp, stack_base, stack_size) { \
     guarantee(is_valid_stackpointer((stackptr_t)(sp), (stackptr_t)(stack_base), stack_size), "Stack Pointer Invalid"); \
 }
 
-// macro to check the current stack pointer against given stacklimits
+// Macro to check the current stack pointer against given stacklimits.
 #define CHECK_CURRENT_STACK_PTR(stack_base, stack_size) { \
   address sp; \
   sp = os::current_stack_pointer(); \
@@ -221,7 +238,7 @@
 static pid_t    _initial_pid       = 0;
 static int      SR_signum          = SIGUSR2; // Signal used to suspend/resume a thread (must be > SIGSEGV, see 4355769)
 static sigset_t SR_sigset;
-static pthread_mutex_t dl_mutex;           // Used to protect dlsym() calls */
+static pthread_mutex_t dl_mutex;              // Used to protect dlsym() calls.
 
 julong os::available_memory() {
   return Aix::available_memory();
@@ -253,7 +270,6 @@
   return false;
 }
 
-
 // Return true if user is running as root.
 
 bool os::have_special_privileges() {
@@ -284,8 +300,7 @@
 
   for (int i = 0; i < numFullDisclaimsNeeded; i ++) {
     if (::disclaim(p, maxDisclaimSize, DISCLAIM_ZEROMEM) != 0) {
-      //if (Verbose)
-      fprintf(stderr, "Cannot disclaim %p - %p (errno %d)\n", p, p + maxDisclaimSize, errno);
+      trc("Cannot disclaim %p - %p (errno %d)\n", p, p + maxDisclaimSize, errno);
       return false;
     }
     p += maxDisclaimSize;
@@ -293,8 +308,7 @@
 
   if (lastDisclaimSize > 0) {
     if (::disclaim(p, lastDisclaimSize, DISCLAIM_ZEROMEM) != 0) {
-      //if (Verbose)
-        fprintf(stderr, "Cannot disclaim %p - %p (errno %d)\n", p, p + lastDisclaimSize, errno);
+      trc("Cannot disclaim %p - %p (errno %d)\n", p, p + lastDisclaimSize, errno);
       return false;
     }
   }
@@ -334,11 +348,11 @@
 
 void os::Aix::initialize_system_info() {
 
-  // get the number of online(logical) cpus instead of configured
+  // Get the number of online(logical) cpus instead of configured.
   os::_processor_count = sysconf(_SC_NPROCESSORS_ONLN);
   assert(_processor_count > 0, "_processor_count must be > 0");
 
-  // retrieve total physical storage
+  // Retrieve total physical storage.
   os::Aix::meminfo_t mi;
   if (!os::Aix::get_meminfo(&mi)) {
     fprintf(stderr, "os::Aix::get_meminfo failed.\n"); fflush(stderr);
@@ -513,7 +527,6 @@
 
 } // end os::Aix::query_multipage_support()
 
-// The code for this method was initially derived from the version in os_linux.cpp.
 void os::init_system_properties_values() {
 
 #define DEFAULT_LIBPATH "/usr/lib:/lib"
@@ -603,10 +616,11 @@
   sigaction(sig, (struct sigaction*)NULL, &oact);
   void* ohlr = oact.sa_sigaction ? CAST_FROM_FN_PTR(void*, oact.sa_sigaction)
     : CAST_FROM_FN_PTR(void*, oact.sa_handler);
-  if (ohlr == CAST_FROM_FN_PTR(void*, SIG_IGN))
+  if (ohlr == CAST_FROM_FN_PTR(void*, SIG_IGN)) {
     return true;
-  else
+  } else {
     return false;
+  }
 }
 
 void os::Aix::signal_sets_init() {
@@ -780,6 +794,9 @@
 
   // get the processor version from _system_configuration
   switch (_system_configuration.version) {
+  case PV_8:
+    strcpy(pci->version, "Power PC 8");
+    break;
   case PV_7:
     strcpy(pci->version, "Power PC 7");
     break;
@@ -807,6 +824,9 @@
   case PV_7_Compat:
     strcpy(pci->version, "PV_7_Compat");
     break;
+  case PV_8_Compat:
+    strcpy(pci->version, "PV_8_Compat");
+    break;
   default:
     strcpy(pci->version, "unknown");
   }
@@ -942,7 +962,9 @@
 
   pthread_attr_destroy(&attr);
 
-  if (ret != 0) {
+  if (ret == 0) {
+    // PPC port traceOsMisc(("Created New Thread : pthread-id %u", tid));
+  } else {
     if (PrintMiscellaneous && (Verbose || WizardMode)) {
       perror("pthread_create()");
     }
@@ -1103,8 +1125,7 @@
   if (os::Aix::on_pase()) {
     Unimplemented();
     return 0;
-  }
-  else {
+  } else {
     // On AIX use the precision of processors real time clock
     // or time base registers.
     timebasestruct_t time;
@@ -1152,7 +1173,6 @@
   }
 }
 
-
 char * os::local_time_string(char *buf, size_t buflen) {
   struct tm t;
   time_t long_time;
@@ -1190,7 +1210,6 @@
   if (abort_hook != NULL) {
     abort_hook();
   }
-
 }
 
 // Note: os::abort() might be called very early during initialization, or
@@ -1222,8 +1241,7 @@
 // from src/solaris/hpi/src/system_md.c
 
 size_t os::lasterror(char *buf, size_t len) {
-
-  if (errno == 0)  return 0;
+  if (errno == 0) return 0;
 
   const char *s = ::strerror(errno);
   size_t n = ::strlen(s);
@@ -1236,6 +1254,7 @@
 }
 
 intx os::current_thread_id() { return (intx)pthread_self(); }
+
 int os::current_process_id() {
 
   // This implementation returns a unique pid, the pid of the
@@ -1372,9 +1391,9 @@
   if (offset) {
     *offset = -1;
   }
-  if (buf) {
-    buf[0] = '\0';
-  }
+  // Buf is not optional, but offset is optional.
+  assert(buf != NULL, "sanity check");
+  buf[0] = '\0';
 
   // Resolve function ptr literals first.
   addr = resolve_function_descriptor_to_code_pointer(addr);
@@ -1407,12 +1426,9 @@
     return 0;
   }
 
-  if (Verbose) {
-    fprintf(stderr, "pc outside any module");
-  }
+  trcVerbose("pc outside any module");
 
   return -1;
-
 }
 
 bool os::dll_address_to_library_name(address addr, char* buf,
@@ -1420,9 +1436,9 @@
   if (offset) {
     *offset = -1;
   }
-  if (buf) {
-      buf[0] = '\0';
-  }
+  // Buf is not optional, but offset is optional.
+  assert(buf != NULL, "sanity check");
+  buf[0] = '\0';
 
   // Resolve function ptr literals first.
   addr = resolve_function_descriptor_to_code_pointer(addr);
@@ -1437,7 +1453,7 @@
 }
 
 // Loads .dll/.so and in case of error it checks if .dll/.so was built
-// for the same architecture as Hotspot is running on
+// for the same architecture as Hotspot is running on.
 void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
 
   if (ebuf && ebuflen > 0) {
@@ -1600,7 +1616,6 @@
   st->cr();
 }
 
-
 static void print_signal_handler(outputStream* st, int sig,
                                  char* buf, size_t buflen);
 
@@ -1624,7 +1639,7 @@
 
 static char saved_jvm_path[MAXPATHLEN] = {0};
 
-// Find the full path to the current module, libjvm.so or libjvm_g.so
+// Find the full path to the current module, libjvm.so.
 void os::jvm_path(char *buf, jint buflen) {
   // Error checking.
   if (buflen < MAXPATHLEN) {
@@ -1695,7 +1710,7 @@
   // Do not block out synchronous signals in the signal handler.
   // Blocking synchronous signals only makes sense if you can really
   // be sure that those signals won't happen during signal handling,
-  // when the blocking applies.  Normal signal handlers are lean and
+  // when the blocking applies. Normal signal handlers are lean and
   // do not cause signals. But our signal handlers tend to be "risky"
   // - secondary SIGSEGV, SIGILL, SIGBUS' may and do happen.
   // On AIX, PASE there was a case where a SIGSEGV happened, followed
@@ -2861,13 +2876,9 @@
   param.sched_priority = newpri;
   int ret = pthread_setschedparam(thr, policy, &param);
 
-  if (Verbose) {
-    if (ret == 0) {
-      fprintf(stderr, "changed priority of thread %d to %d\n", (int)thr, newpri);
-    } else {
-      fprintf(stderr, "Could not changed priority for thread %d to %d (error %d, %s)\n",
-              (int)thr, newpri, ret, strerror(ret));
-    }
+  if (ret != 0) {
+    trcVerbose("Could not change priority for thread %d to %d (error %d, %s)",
+        (int)thr, newpri, ret, strerror(ret));
   }
   return (ret == 0) ? OS_OK : OS_ERR;
 }
@@ -2988,7 +2999,6 @@
   errno = old_errno;
 }
 
-
 static int SR_initialize() {
   struct sigaction act;
   char *s;
@@ -3187,7 +3197,6 @@
   JVM_handle_aix_signal(sig, info, uc, true);
 }
 
-
 // This boolean allows users to forward their own non-matching signals
 // to JVM_handle_aix_signal, harmlessly.
 bool os::Aix::signal_handlers_are_installed = false;
@@ -3381,7 +3390,7 @@
     set_signal_handler(SIGDANGER, true);
 
     if (libjsig_is_loaded) {
-      // Tell libjsig jvm finishes setting signal handlers
+      // Tell libjsig jvm finishes setting signal handlers.
       (*end_signal_setting)();
     }
 
@@ -3397,7 +3406,7 @@
         tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled");
         check_signals = false;
       }
-      // need to initialize check_signal_done
+      // Need to initialize check_signal_done.
       ::sigemptyset(&check_signal_done);
     }
   }
@@ -3471,7 +3480,6 @@
   st->cr();
 }
 
-
 #define DO_SIGNAL_CHECK(sig) \
   if (!sigismember(&check_signal_done, sig)) \
     os::Aix::check_signal_handler(sig)
@@ -3532,7 +3540,6 @@
     ? CAST_FROM_FN_PTR(address, act.sa_sigaction)
     : CAST_FROM_FN_PTR(address, act.sa_handler);
 
-
   switch(sig) {
   case SIGSEGV:
   case SIGBUS:
@@ -3685,15 +3692,13 @@
   pthread_mutex_init(&dl_mutex, NULL);
 }
 
-// this is called _after_ the global arguments have been parsed
+// This is called _after_ the global arguments have been parsed.
 jint os::init_2(void) {
 
-  if (Verbose) {
-    fprintf(stderr, "processor count: %d\n", os::_processor_count);
-    fprintf(stderr, "physical memory: %lu\n", Aix::_physical_memory);
-  }
-
-  // initially build up the loaded dll map
+  trcVerbose("processor count: %d", os::_processor_count);
+  trcVerbose("physical memory: %lu", Aix::_physical_memory);
+
+  // Initially build up the loaded dll map.
   LoadedLibraries::reload();
 
   const int page_size = Aix::page_size();
@@ -3743,7 +3748,7 @@
       }
 
       if (map_address != (address) MAP_FAILED) {
-        // map succeeded, but polling_page is not at wished address, unmap and continue.
+        // Map succeeded, but polling_page is not at wished address, unmap and continue.
         ::munmap(map_address, map_size);
         map_address = (address) MAP_FAILED;
       }
@@ -3797,7 +3802,7 @@
 
   // Make the stack size a multiple of the page size so that
   // the yellow/red zones can be guarded.
-  // note that this can be 0, if no default stacksize was set
+  // Note that this can be 0, if no default stacksize was set.
   JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes, vm_page_size()));
 
   Aix::libpthread_init();
@@ -4088,7 +4093,6 @@
   return fd;
 }
 
-
 // create binary file, rewriting existing file if required
 int os::create_binary_file(const char* path, bool rewrite_existing) {
   int oflags = O_WRONLY | O_CREAT;
@@ -4169,7 +4173,6 @@
   return mapped_address;
 }
 
-
 // Remap a block of memory.
 char* os::pd_remap_memory(int fd, const char* file_name, size_t file_offset,
                           char *addr, size_t bytes, bool read_only,
@@ -4217,14 +4220,14 @@
   jlong sys_time = 0;
   jlong user_time = 0;
 
-  // reimplemented using getthrds64().
+  // Reimplemented using getthrds64().
   //
-  // goes like this:
+  // Works like this:
   // For the thread in question, get the kernel thread id. Then get the
   // kernel thread statistics using that id.
   //
   // This only works of course when no pthread scheduling is used,
-  // ie there is a 1:1 relationship to kernel threads.
+  // i.e. there is a 1:1 relationship to kernel threads.
   // On AIX, see AIXTHREAD_SCOPE variable.
 
   pthread_t pthtid = thread->osthread()->pthread_id();
@@ -4371,14 +4374,12 @@
   memset(&uts, 0, sizeof(uts));
   strcpy(uts.sysname, "?");
   if (::uname(&uts) == -1) {
-    fprintf(stderr, "uname failed (%d)\n", errno);
+    trc("uname failed (%d)", errno);
     guarantee(0, "Could not determine whether we run on AIX or PASE");
   } else {
-    if (Verbose) {
-      fprintf(stderr,"uname says: sysname \"%s\" version \"%s\" release \"%s\" "
-              "node \"%s\" machine \"%s\"\n",
-              uts.sysname, uts.version, uts.release, uts.nodename, uts.machine);
-    }
+    trcVerbose("uname says: sysname \"%s\" version \"%s\" release \"%s\" "
+               "node \"%s\" machine \"%s\"\n",
+               uts.sysname, uts.version, uts.release, uts.nodename, uts.machine);
     const int major = atoi(uts.version);
     assert(major > 0, "invalid OS version");
     const int minor = atoi(uts.release);
@@ -4390,12 +4391,10 @@
       // We run on AIX. We do not support versions older than AIX 5.3.
       _on_pase = 0;
       if (_os_version < 0x0503) {
-        fprintf(stderr, "AIX release older than AIX 5.3 not supported.\n");
+        trc("AIX release older than AIX 5.3 not supported.");
         assert(false, "AIX release too old.");
       } else {
-        if (Verbose) {
-          fprintf(stderr, "We run on AIX %d.%d\n", major, minor);
-        }
+        trcVerbose("We run on AIX %d.%d\n", major, minor);
       }
     } else {
       assert(false, "unknown OS");
@@ -4403,7 +4402,6 @@
   }
 
   guarantee(_on_pase != -1 && _os_version, "Could not determine AIX/OS400 release");
-
 } // end: os::Aix::initialize_os_info()
 
 // Scan environment for important settings which might effect the VM.
@@ -4441,12 +4439,10 @@
   // Note: Setting XPG_SUS_ENV in the process is too late. Must be set earlier (before
   // exec() ? before loading the libjvm ? ....)
   p = ::getenv("XPG_SUS_ENV");
-  if (Verbose) {
-    fprintf(stderr, "XPG_SUS_ENV=%s.\n", p ? p : "<unset>");
-  }
+  trcVerbose("XPG_SUS_ENV=%s.", p ? p : "<unset>");
   if (p && strcmp(p, "ON") == 0) {
     _xpg_sus_mode = 1;
-    fprintf(stderr, "Unsupported setting: XPG_SUS_ENV=ON\n");
+    trc("Unsupported setting: XPG_SUS_ENV=ON");
     // This is not supported. Worst of all, it changes behaviour of mmap MAP_FIXED to
     // clobber address ranges. If we ever want to support that, we have to do some
     // testing first.
@@ -4458,10 +4454,7 @@
   // Switch off AIX internal (pthread) guard pages. This has
   // immediate effect for any pthread_create calls which follow.
   p = ::getenv("AIXTHREAD_GUARDPAGES");
-  if (Verbose) {
-    fprintf(stderr, "AIXTHREAD_GUARDPAGES=%s.\n", p ? p : "<unset>");
-    fprintf(stderr, "setting AIXTHREAD_GUARDPAGES=0.\n");
-  }
+  trcVerbose("AIXTHREAD_GUARDPAGES=%s.", p ? p : "<unset>");
   rc = ::putenv("AIXTHREAD_GUARDPAGES=0");
   guarantee(rc == 0, "");
 
@@ -4479,7 +4472,7 @@
   assert(os::Aix::on_aix(), "AIX only");
 
   if (!libperfstat::init()) {
-    fprintf(stderr, "libperfstat initialization failed.\n");
+    trc("libperfstat initialization failed.");
     assert(false, "libperfstat initialization failed");
   } else {
     if (Verbose) {
@@ -4651,7 +4644,6 @@
   return abstime;
 }
 
-
 // Test-and-clear _Event, always leaves _Event set to 0, returns immediately.
 // Conceptually TryPark() should be equivalent to park(0).
 
@@ -4732,7 +4724,7 @@
   while (_Event < 0) {
     status = pthread_cond_timedwait(_cond, _mutex, &abst);
     assert_status(status == 0 || status == ETIMEDOUT,
-          status, "cond_timedwait");
+                  status, "cond_timedwait");
     if (!FilterSpuriousWakeups) break;         // previous semantics
     if (status == ETIMEDOUT) break;
     // We consume and ignore EINTR and spurious wakeups.
@@ -4866,9 +4858,9 @@
   // Optional fast-path check:
   // Return immediately if a permit is available.
   if (_counter > 0) {
-      _counter = 0;
-      OrderAccess::fence();
-      return;
+    _counter = 0;
+    OrderAccess::fence();
+    return;
   }
 
   Thread* thread = Thread::current();
@@ -4890,7 +4882,6 @@
     unpackTime(&absTime, isAbsolute, time);
   }
 
-
   // Enter safepoint region
   // Beware of deadlocks such as 6317397.
   // The per-thread Parker:: mutex is a classic leaf-lock.
@@ -4978,7 +4969,6 @@
   }
 }
 
-
 extern char** environ;
 
 // Run the specified command in a separate process. Return its exit value,
@@ -4997,44 +4987,43 @@
   } else if (pid == 0) {
     // child process
 
-    // try to be consistent with system(), which uses "/usr/bin/sh" on AIX
+    // Try to be consistent with system(), which uses "/usr/bin/sh" on AIX.
     execve("/usr/bin/sh", argv, environ);
 
     // execve failed
     _exit(-1);
 
-  } else  {
+  } else {
     // copied from J2SE ..._waitForProcessExit() in UNIXProcess_md.c; we don't
     // care about the actual exit code, for now.
 
     int status;
 
-    // Wait for the child process to exit.  This returns immediately if
+    // Wait for the child process to exit. This returns immediately if
     // the child has already exited. */
     while (waitpid(pid, &status, 0) < 0) {
-        switch (errno) {
+      switch (errno) {
         case ECHILD: return 0;
         case EINTR: break;
         default: return -1;
-        }
+      }
     }
 
     if (WIFEXITED(status)) {
-       // The child exited normally; get its exit code.
-       return WEXITSTATUS(status);
+      // The child exited normally; get its exit code.
+      return WEXITSTATUS(status);
     } else if (WIFSIGNALED(status)) {
-       // The child exited because of a signal
-       // The best value to return is 0x80 + signal number,
-       // because that is what all Unix shells do, and because
-       // it allows callers to distinguish between process exit and
-       // process death by signal.
-       return 0x80 + WTERMSIG(status);
+      // The child exited because of a signal.
+      // The best value to return is 0x80 + signal number,
+      // because that is what all Unix shells do, and because
+      // it allows callers to distinguish between process exit and
+      // process death by signal.
+      return 0x80 + WTERMSIG(status);
     } else {
-       // Unknown exit code; pass it through
-       return status;
+      // Unknown exit code; pass it through.
+      return status;
     }
   }
-  // Remove warning.
   return -1;
 }
 
@@ -5049,7 +5038,7 @@
   struct stat statbuf;
   char buf[MAXPATHLEN];
   char libmawtpath[MAXPATHLEN];
-  const char *xawtstr  = "/xawt/libmawt.so";
+  const char *xawtstr = "/xawt/libmawt.so";
   const char *new_xawtstr = "/libawt_xawt.so";
 
   char *p;
@@ -5090,6 +5079,9 @@
     return 0;
   }
 
+  jio_snprintf(buffer, bufferSize, "%s/core or core.%d",
+                                               p, current_process_id());
+
   return strlen(buffer);
 }
 
--- a/hotspot/src/os/aix/vm/os_aix.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os/aix/vm/os_aix.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -209,7 +209,7 @@
     return _can_use_16M_pages == 1 ? true : false;
   }
 
-  static address   ucontext_get_pc(ucontext_t* uc);
+  static address   ucontext_get_pc(const ucontext_t* uc);
   static intptr_t* ucontext_get_sp(ucontext_t* uc);
   static intptr_t* ucontext_get_fp(ucontext_t* uc);
   // Set PC into context. Needed for continuation after signal.
--- a/hotspot/src/os/bsd/vm/osThread_bsd.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os/bsd/vm/osThread_bsd.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,8 @@
 
   sigemptyset(&_caller_sigmask);
 
-  _startThread_lock = new Monitor(Mutex::event, "startThread_lock", true);
+  _startThread_lock = new Monitor(Mutex::event, "startThread_lock", true,
+                                  Monitor::_safepoint_check_never);
   assert(_startThread_lock !=NULL, "check");
 }
 
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -4673,7 +4673,7 @@
 // Get the default path to the core file
 // Returns the length of the string
 int os::get_core_path(char* buffer, size_t bufferSize) {
-  int n = jio_snprintf(buffer, bufferSize, "/cores");
+  int n = jio_snprintf(buffer, bufferSize, "/cores/core.%d", current_process_id());
 
   // Truncate if theoretical string was longer than bufferSize
   n = MIN2(n, (int)bufferSize);
--- a/hotspot/src/os/linux/vm/osThread_linux.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os/linux/vm/osThread_linux.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,8 @@
 
   sigemptyset(&_caller_sigmask);
 
-  _startThread_lock = new Monitor(Mutex::event, "startThread_lock", true);
+  _startThread_lock = new Monitor(Mutex::event, "startThread_lock", true,
+                                  Monitor::_safepoint_check_never);
   assert(_startThread_lock !=NULL, "check");
 }
 
--- a/hotspot/src/os/linux/vm/os_linux.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os/linux/vm/os_linux.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -5988,13 +5988,70 @@
 // Get the default path to the core file
 // Returns the length of the string
 int os::get_core_path(char* buffer, size_t bufferSize) {
-  const char* p = get_current_directory(buffer, bufferSize);
-
-  if (p == NULL) {
-    assert(p != NULL, "failed to get current directory");
+  /*
+   * Max length of /proc/sys/kernel/core_pattern is 128 characters.
+   * See https://www.kernel.org/doc/Documentation/sysctl/kernel.txt
+   */
+  const int core_pattern_len = 129;
+  char core_pattern[core_pattern_len] = {0};
+
+  int core_pattern_file = ::open("/proc/sys/kernel/core_pattern", O_RDONLY);
+  if (core_pattern_file != -1) {
+    ssize_t ret = ::read(core_pattern_file, core_pattern, core_pattern_len);
+    ::close(core_pattern_file);
+
+    if (ret > 0) {
+      char *last_char = core_pattern + strlen(core_pattern) - 1;
+
+      if (*last_char == '\n') {
+        *last_char = '\0';
+      }
+    }
+  }
+
+  if (strlen(core_pattern) == 0) {
     return 0;
   }
 
+  char *pid_pos = strstr(core_pattern, "%p");
+  size_t written;
+
+  if (core_pattern[0] == '/') {
+    written = jio_snprintf(buffer, bufferSize, core_pattern);
+  } else {
+    char cwd[PATH_MAX];
+
+    const char* p = get_current_directory(cwd, PATH_MAX);
+    if (p == NULL) {
+      assert(p != NULL, "failed to get current directory");
+      return 0;
+    }
+
+    if (core_pattern[0] == '|') {
+      written = jio_snprintf(buffer, bufferSize,
+                        "\"%s\" (or dumping to %s/core.%d)",
+                                     &core_pattern[1], p, current_process_id());
+    } else {
+      written = jio_snprintf(buffer, bufferSize, "%s/%s", p, core_pattern);
+    }
+  }
+
+  if ((written >= 0) && (written < bufferSize)
+            && (pid_pos == NULL) && (core_pattern[0] != '|')) {
+    int core_uses_pid_file = ::open("/proc/sys/kernel/core_uses_pid", O_RDONLY);
+
+    if (core_uses_pid_file != -1) {
+      char core_uses_pid = 0;
+      ssize_t ret = ::read(core_uses_pid_file, &core_uses_pid, 1);
+      ::close(core_uses_pid_file);
+
+      if (core_uses_pid == '1'){
+        jio_snprintf(buffer + written, bufferSize - written,
+                                          ".%d", current_process_id());
+      }
+    }
+  }
+
   return strlen(buffer);
 }
 
--- a/hotspot/src/os/posix/vm/os_posix.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os/posix/vm/os_posix.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -51,15 +51,24 @@
   struct rlimit rlim;
   bool success;
 
-  n = get_core_path(buffer, bufferSize);
+  char core_path[PATH_MAX];
+  n = get_core_path(core_path, PATH_MAX);
 
-  if (getrlimit(RLIMIT_CORE, &rlim) != 0) {
-    jio_snprintf(buffer + n, bufferSize - n, "/core or core.%d (may not exist)", current_process_id());
+  if (n <= 0) {
+    jio_snprintf(buffer, bufferSize, "core.%d (may not exist)", current_process_id());
+    success = true;
+#ifdef LINUX
+  } else if (core_path[0] == '"') { // redirect to user process
+    jio_snprintf(buffer, bufferSize, "Core dumps may be processed with %s", core_path);
+    success = true;
+#endif
+  } else if (getrlimit(RLIMIT_CORE, &rlim) != 0) {
+    jio_snprintf(buffer, bufferSize, "%s (may not exist)", core_path);
     success = true;
   } else {
     switch(rlim.rlim_cur) {
       case RLIM_INFINITY:
-        jio_snprintf(buffer + n, bufferSize - n, "/core or core.%d", current_process_id());
+        jio_snprintf(buffer, bufferSize, "%s", core_path);
         success = true;
         break;
       case 0:
@@ -67,11 +76,12 @@
         success = false;
         break;
       default:
-        jio_snprintf(buffer + n, bufferSize - n, "/core or core.%d (max size %lu kB). To ensure a full core dump, try \"ulimit -c unlimited\" before starting Java again", current_process_id(), (unsigned long)(rlim.rlim_cur >> 10));
+        jio_snprintf(buffer, bufferSize, "%s (max size %lu kB). To ensure a full core dump, try \"ulimit -c unlimited\" before starting Java again", core_path, (unsigned long)(rlim.rlim_cur >> 10));
         success = true;
         break;
     }
   }
+
   VMError::report_coredump_status(buffer, success);
 }
 
@@ -89,8 +99,8 @@
     } else {
       stack[frame_idx ++] = fr.pc();
     }
-    if (fr.fp() == NULL || os::is_first_C_frame(&fr)
-        ||fr.sender_pc() == NULL || fr.cb() != NULL) break;
+    if (fr.fp() == NULL || fr.cb() != NULL ||
+        fr.sender_pc() == NULL || os::is_first_C_frame(&fr)) break;
 
     if (fr.sender_pc() && !os::is_first_C_frame(&fr)) {
       fr = os::get_sender_for_C_frame(&fr);
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -5979,6 +5979,9 @@
     return 0;
   }
 
+  jio_snprintf(buffer, bufferSize, "%s/core or core.%d",
+                                              p, current_process_id());
+
   return strlen(buffer);
 }
 
--- a/hotspot/src/os/windows/vm/os_windows.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os/windows/vm/os_windows.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -3768,7 +3768,6 @@
   return NULL;
 }
 
-#define MAX_EXIT_HANDLES PRODUCT_ONLY(32)   NOT_PRODUCT(128)
 #define EXIT_TIMEOUT     PRODUCT_ONLY(1000) NOT_PRODUCT(4000) /* 1 sec in product, 4 sec in debug */
 
 static BOOL CALLBACK init_crit_sect_call(PINIT_ONCE, PVOID pcrit_sect, PVOID*) {
@@ -3787,7 +3786,7 @@
     // _endthreadex().
     // Should be large enough to avoid blocking the exiting thread due to lack of
     // a free slot.
-    static HANDLE handles[MAX_EXIT_HANDLES];
+    static HANDLE handles[MAXIMUM_WAIT_OBJECTS];
     static int handle_count = 0;
 
     static INIT_ONCE init_once_crit_sect = INIT_ONCE_STATIC_INIT;
@@ -3809,32 +3808,34 @@
           if (res == WAIT_TIMEOUT) {
             handles[j++] = handles[i];
           } else {
-            if (res != WAIT_OBJECT_0) {
-              warning("WaitForSingleObject failed in %s: %d\n", __FILE__, __LINE__);
-              // Don't keep the handle, if we failed waiting for it.
+            if (res == WAIT_FAILED) {
+              warning("WaitForSingleObject failed (%u) in %s: %d\n",
+                      GetLastError(), __FILE__, __LINE__);
             }
+            // Don't keep the handle, if we failed waiting for it.
             CloseHandle(handles[i]);
           }
         }
 
         // If there's no free slot in the array of the kept handles, we'll have to
         // wait until at least one thread completes exiting.
-        if ((handle_count = j) == MAX_EXIT_HANDLES) {
+        if ((handle_count = j) == MAXIMUM_WAIT_OBJECTS) {
           // Raise the priority of the oldest exiting thread to increase its chances
           // to complete sooner.
           SetThreadPriority(handles[0], THREAD_PRIORITY_ABOVE_NORMAL);
-          res = WaitForMultipleObjects(MAX_EXIT_HANDLES, handles, FALSE, EXIT_TIMEOUT);
-          if (res >= WAIT_OBJECT_0 && res < (WAIT_OBJECT_0 + MAX_EXIT_HANDLES)) {
+          res = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, handles, FALSE, EXIT_TIMEOUT);
+          if (res >= WAIT_OBJECT_0 && res < (WAIT_OBJECT_0 + MAXIMUM_WAIT_OBJECTS)) {
             i = (res - WAIT_OBJECT_0);
-            handle_count = MAX_EXIT_HANDLES - 1;
+            handle_count = MAXIMUM_WAIT_OBJECTS - 1;
             for (; i < handle_count; ++i) {
               handles[i] = handles[i + 1];
             }
           } else {
-            warning("WaitForMultipleObjects %s in %s: %d\n",
-                    (res == WAIT_FAILED ? "failed" : "timed out"), __FILE__, __LINE__);
+            warning("WaitForMultipleObjects %s (%u) in %s: %d\n",
+                    (res == WAIT_FAILED ? "failed" : "timed out"),
+                    GetLastError(), __FILE__, __LINE__);
             // Don't keep handles, if we failed waiting for them.
-            for (i = 0; i < MAX_EXIT_HANDLES; ++i) {
+            for (i = 0; i < MAXIMUM_WAIT_OBJECTS; ++i) {
               CloseHandle(handles[i]);
             }
             handle_count = 0;
@@ -3846,7 +3847,8 @@
         hthr = GetCurrentThread();
         if (!DuplicateHandle(hproc, hthr, hproc, &handles[handle_count],
                              0, FALSE, DUPLICATE_SAME_ACCESS)) {
-          warning("DuplicateHandle failed in %s: %d\n", __FILE__, __LINE__);
+          warning("DuplicateHandle failed (%u) in %s: %d\n",
+                  GetLastError(), __FILE__, __LINE__);
         } else {
           ++handle_count;
         }
@@ -3869,9 +3871,10 @@
             SetThreadPriority(handles[i], THREAD_PRIORITY_ABOVE_NORMAL);
           }
           res = WaitForMultipleObjects(handle_count, handles, TRUE, EXIT_TIMEOUT);
-          if (res < WAIT_OBJECT_0 || res >= (WAIT_OBJECT_0 + MAX_EXIT_HANDLES)) {
-            warning("WaitForMultipleObjects %s in %s: %d\n",
-                    (res == WAIT_FAILED ? "failed" : "timed out"), __FILE__, __LINE__);
+          if (res == WAIT_FAILED || res == WAIT_TIMEOUT) {
+            warning("WaitForMultipleObjects %s (%u) in %s: %d\n",
+                    (res == WAIT_FAILED ? "failed" : "timed out"),
+                    GetLastError(), __FILE__, __LINE__);
           }
           for (i = 0; i < handle_count; ++i) {
             CloseHandle(handles[i]);
@@ -3909,7 +3912,6 @@
   return exit_code;
 }
 
-#undef MAX_EXIT_HANDLES
 #undef EXIT_TIMEOUT
 
 void os::win32::setmode_streams() {
--- a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -91,8 +91,9 @@
 
 // Frame information (pc, sp, fp) retrieved via ucontext
 // always looks like a C-frame according to the frame
-// conventions in frame_ppc64.hpp.
-address os::Aix::ucontext_get_pc(ucontext_t * uc) {
+// conventions in frame_ppc.hpp.
+
+address os::Aix::ucontext_get_pc(const ucontext_t * uc) {
   return (address)uc->uc_mcontext.jmp_context.iar;
 }
 
@@ -486,7 +487,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 // thread stack
 
-size_t os::Aix::min_stack_allowed = 768*K;
+size_t os::Aix::min_stack_allowed = 128*K;
 
 // Aix is always in floating stack mode. The stack size for a new
 // thread can be set via pthread_attr_setstacksize().
@@ -499,7 +500,7 @@
   // because of the strange 'fallback logic' in os::create_thread().
   // Better set CompilerThreadStackSize in globals_<os_cpu>.hpp if you want to
   // specify a different stack size for compiler threads!
-  size_t s = (thr_type == os::compiler_thread ? 4 * M : 1024 * K);
+  size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
   return s;
 }
 
--- a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -23,8 +23,8 @@
  *
  */
 
-#ifndef OS_CPU_AIX_OJDKPPC_VM_OS_AIX_PPC_HPP
-#define OS_CPU_AIX_OJDKPPC_VM_OS_AIX_PPC_HPP
+#ifndef OS_CPU_AIX_PPC_VM_OS_AIX_PPC_HPP
+#define OS_CPU_AIX_PPC_VM_OS_AIX_PPC_HPP
 
   static void setup_fpu() {}
 
@@ -32,4 +32,4 @@
   // Note: Currently only used in 64 bit Windows implementations
   static bool register_code_area(char *low, char *high) { return true; }
 
-#endif // OS_CPU_AIX_OJDKPPC_VM_OS_AIX_PPC_HPP
+#endif // OS_CPU_AIX_PPC_VM_OS_AIX_PPC_HPP
--- a/hotspot/src/os_cpu/aix_ppc/vm/prefetch_aix_ppc.inline.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os_cpu/aix_ppc/vm/prefetch_aix_ppc.inline.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -23,8 +23,8 @@
  *
  */
 
-#ifndef OS_CPU_AIX_PPC_64_VM_PREFETCH_AIX_PPC_64_INLINE_HPP
-#define OS_CPU_AIX_PPC_64_VM_PREFETCH_AIX_PPC_64_INLINE_HPP
+#ifndef OS_CPU_AIX_PPC_VM_PREFETCH_AIX_PPC_INLINE_HPP
+#define OS_CPU_AIX_PPC_VM_PREFETCH_AIX_PPC_INLINE_HPP
 
 #include "runtime/prefetch.hpp"
 
@@ -55,4 +55,4 @@
 #endif
 }
 
-#endif // OS_CPU_AIX_PPC_64_VM_PREFETCH_AIX_PPC_64_INLINE_HPP
+#endif // OS_CPU_AIX_PPC_VM_PREFETCH_AIX_PPC_INLINE_HPP
--- a/hotspot/src/os_cpu/aix_ppc/vm/threadLS_aix_ppc.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os_cpu/aix_ppc/vm/threadLS_aix_ppc.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -23,8 +23,8 @@
  *
  */
 
-#ifndef OS_CPU_AIX_OJDKPPC_VM_THREADLS_AIX_PPC_HPP
-#define OS_CPU_AIX_OJDKPPC_VM_THREADLS_AIX_PPC_HPP
+#ifndef OS_CPU_AIX_PPC_VM_THREADLS_AIX_PPC_HPP
+#define OS_CPU_AIX_PPC_VM_THREADLS_AIX_PPC_HPP
 
   // Processor dependent parts of ThreadLocalStorage
 
@@ -33,4 +33,4 @@
     return (Thread *) os::thread_local_storage_at(thread_index());
   }
 
-#endif // OS_CPU_AIX_OJDKPPC_VM_THREADLS_AIX_PPC_HPP
+#endif // OS_CPU_AIX_PPC_VM_THREADLS_AIX_PPC_HPP
--- a/hotspot/src/os_cpu/aix_ppc/vm/thread_aix_ppc.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os_cpu/aix_ppc/vm/thread_aix_ppc.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -23,8 +23,8 @@
  *
  */
 
-#ifndef OS_CPU_AIX_OJDKPPC_VM_THREAD_AIX_PPC_HPP
-#define OS_CPU_AIX_OJDKPPC_VM_THREAD_AIX_PPC_HPP
+#ifndef OS_CPU_AIX_PPC_VM_THREAD_AIX_PPC_HPP
+#define OS_CPU_AIX_PPC_VM_THREAD_AIX_PPC_HPP
 
  private:
   void pd_initialize() {
@@ -76,4 +76,4 @@
 
   intptr_t* last_interpreter_fp() { return _last_interpreter_fp; }
 
-#endif // OS_CPU_AIX_OJDKPPC_VM_THREAD_AIX_PPC_HPP
+#endif // OS_CPU_AIX_PPC_VM_THREAD_AIX_PPC_HPP
--- a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -453,7 +453,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 // thread stack
 
-size_t os::Linux::min_stack_allowed = 768*K;
+size_t os::Linux::min_stack_allowed = 128*K;
 
 bool os::Linux::supports_variable_stack_size() { return true; }
 
--- a/hotspot/src/share/vm/classfile/classLoaderData.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -81,7 +81,8 @@
   _metaspace(NULL), _unloading(false), _klasses(NULL),
   _claimed(0), _jmethod_ids(NULL), _handles(NULL), _deallocate_list(NULL),
   _next(NULL), _dependencies(dependencies),
-  _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true)) {
+  _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true,
+                            Monitor::_safepoint_check_never)) {
     // empty
 }
 
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -83,9 +83,11 @@
   // Note: this requires that CFLspace c'tors
   // are called serially in the order in which the locks are
   // are acquired in the program text. This is true today.
-  _freelistLock(_lockRank--, "CompactibleFreeListSpace._lock", true),
+  _freelistLock(_lockRank--, "CompactibleFreeListSpace._lock", true,
+                Monitor::_safepoint_check_sometimes),
   _parDictionaryAllocLock(Mutex::leaf - 1,  // == rank(ExpandHeap_lock) - 1
-                          "CompactibleFreeListSpace._dict_par_lock", true),
+                          "CompactibleFreeListSpace._dict_par_lock", true,
+                          Monitor::_safepoint_check_never),
   _rescan_task_size(CardTableModRefBS::card_size_in_words * BitsPerWord *
                     CMSRescanMultiple),
   _marking_task_size(CardTableModRefBS::card_size_in_words * BitsPerWord *
@@ -152,8 +154,7 @@
   // Initialize locks for parallel case.
   for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
     _indexedFreeListParLocks[i] = new Mutex(Mutex::leaf - 1, // == ExpandHeap_lock - 1
-                                            "a freelist par lock",
-                                            true);
+                                            "a freelist par lock", true, Mutex::_safepoint_check_sometimes);
     DEBUG_ONLY(
       _indexedFreeList[i].set_protecting_lock(_indexedFreeListParLocks[i]);
     )
@@ -2559,12 +2560,12 @@
      x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,   \
      x }
 
-// Initialize with default setting of CMSParPromoteBlocksToClaim, _not_
-// OldPLABSize, whose static default is different; if overridden at the
+// Initialize with default setting for CMS, _not_
+// generic OldPLABSize, whose static default is different; if overridden at the
 // command-line, this will get reinitialized via a call to
 // modify_initialization() below.
 AdaptiveWeightedAverage CFLS_LAB::_blocks_to_claim[]    =
-  VECTOR_257(AdaptiveWeightedAverage(OldPLABWeight, (float)CMSParPromoteBlocksToClaim));
+  VECTOR_257(AdaptiveWeightedAverage(OldPLABWeight, (float)CFLS_LAB::_default_dynamic_old_plab_size));
 size_t CFLS_LAB::_global_num_blocks[]  = VECTOR_257(0);
 uint   CFLS_LAB::_global_num_workers[] = VECTOR_257(0);
 
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -690,6 +690,9 @@
   void get_from_global_pool(size_t word_sz, AdaptiveFreeList<FreeChunk>* fl);
 
 public:
+  static const int _default_dynamic_old_plab_size = 16;
+  static const int _default_static_old_plab_size  = 50;
+
   CFLS_LAB(CompactibleFreeListSpace* cfls);
 
   // Allocate and return a block of the given size, or else return NULL.
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -42,6 +42,7 @@
 #include "gc_implementation/shared/isGCActiveMark.hpp"
 #include "gc_interface/collectedHeap.inline.hpp"
 #include "memory/allocation.hpp"
+#include "memory/cardGeneration.inline.hpp"
 #include "memory/cardTableRS.hpp"
 #include "memory/collectorPolicy.hpp"
 #include "memory/gcLocker.inline.hpp"
@@ -479,7 +480,9 @@
   _restart_addr(NULL),
   _overflow_list(NULL),
   _stats(cmsGen),
-  _eden_chunk_lock(new Mutex(Mutex::leaf + 1, "CMS_eden_chunk_lock", true)),
+  _eden_chunk_lock(new Mutex(Mutex::leaf + 1, "CMS_eden_chunk_lock", true,
+                             //verify that this lock should be acquired with safepoint check.
+                             Monitor::_safepoint_check_sometimes)),
   _eden_chunk_array(NULL),     // may be set in ctor body
   _eden_chunk_capacity(0),     // -- ditto --
   _eden_chunk_index(0),        // -- ditto --
@@ -1608,14 +1611,15 @@
 
   // If the collection is being acquired from the background
   // collector, there may be references on the discovered
-  // references lists that have NULL referents (being those
-  // that were concurrently cleared by a mutator) or
-  // that are no longer active (having been enqueued concurrently
-  // by the mutator).
-  // Scrub the list of those references because Mark-Sweep-Compact
-  // code assumes referents are not NULL and that all discovered
-  // Reference objects are active.
-  ref_processor()->clean_up_discovered_references();
+  // references lists.  Abandon those references, since some
+  // of them may have become unreachable after concurrent
+  // discovery; the STW compacting collector will redo discovery
+  // more precisely, without being subject to floating garbage.
+  // Leaving otherwise unreachable references in the discovered
+  // lists would require special handling.
+  ref_processor()->disable_discovery();
+  ref_processor()->abandon_partial_discovery();
+  ref_processor()->verify_no_references_recorded();
 
   if (first_state > Idling) {
     save_heap_summary();
@@ -1681,7 +1685,7 @@
   ReferenceProcessorMTDiscoveryMutator rp_mut_discovery(ref_processor(), false);
 
   ref_processor()->set_enqueuing_is_done(false);
-  ref_processor()->enable_discovery(false /*verify_disabled*/, false /*check_no_refs*/);
+  ref_processor()->enable_discovery();
   ref_processor()->setup_policy(clear_all_soft_refs);
   // If an asynchronous collection finishes, the _modUnionTable is
   // all clear.  If we are assuming the collection from an asynchronous
@@ -2998,7 +3002,7 @@
                     Mutex::_no_safepoint_check_flag);
     checkpointRootsInitialWork();
     // enable ("weak") refs discovery
-    rp->enable_discovery(true /*verify_disabled*/, true /*check_no_refs*/);
+    rp->enable_discovery();
     _collectorState = Marking;
   }
   SpecializationStats::print();
@@ -5945,7 +5949,8 @@
 CMSBitMap::CMSBitMap(int shifter, int mutex_rank, const char* mutex_name):
   _bm(),
   _shifter(shifter),
-  _lock(mutex_rank >= 0 ? new Mutex(mutex_rank, mutex_name, true) : NULL)
+  _lock(mutex_rank >= 0 ? new Mutex(mutex_rank, mutex_name, true,
+                                    Monitor::_safepoint_check_sometimes) : NULL)
 {
   _bmStartWord = 0;
   _bmWordSize  = 0;
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -187,7 +187,8 @@
 
  public:
   CMSMarkStack():
-    _par_lock(Mutex::event, "CMSMarkStack._par_lock", true),
+    _par_lock(Mutex::event, "CMSMarkStack._par_lock", true,
+              Monitor::_safepoint_check_never),
     _hit_limit(0),
     _failed_double(0) {}
 
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,8 @@
   // The 0th worker in notified by mutator threads and has a special monitor.
   // The last worker is used for young gen rset size sampling.
   if (worker_id > 0) {
-    _monitor = new Monitor(Mutex::nonleaf, "Refinement monitor", true);
+    _monitor = new Monitor(Mutex::nonleaf, "Refinement monitor", true,
+                           Monitor::_safepoint_check_never);
   } else {
     _monitor = DirtyCardQ_CBL_mon;
   }
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -971,7 +971,7 @@
   // Start Concurrent Marking weak-reference discovery.
   ReferenceProcessor* rp = g1h->ref_processor_cm();
   // enable ("weak") refs discovery
-  rp->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
+  rp->enable_discovery();
   rp->setup_policy(false); // snapshot the soft ref policy to be used in this cycle
 
   SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set();
--- a/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -254,25 +254,23 @@
 HeapRegion* SurvivorGCAllocRegion::allocate_new_region(size_t word_size,
                                                        bool force) {
   assert(!force, "not supported for GC alloc regions");
-  return _g1h->new_gc_alloc_region(word_size, count(), GCAllocForSurvived);
+  return _g1h->new_gc_alloc_region(word_size, count(), InCSetState::Young);
 }
 
 void SurvivorGCAllocRegion::retire_region(HeapRegion* alloc_region,
                                           size_t allocated_bytes) {
-  _g1h->retire_gc_alloc_region(alloc_region, allocated_bytes,
-                               GCAllocForSurvived);
+  _g1h->retire_gc_alloc_region(alloc_region, allocated_bytes, InCSetState::Young);
 }
 
 HeapRegion* OldGCAllocRegion::allocate_new_region(size_t word_size,
                                                   bool force) {
   assert(!force, "not supported for GC alloc regions");
-  return _g1h->new_gc_alloc_region(word_size, count(), GCAllocForTenured);
+  return _g1h->new_gc_alloc_region(word_size, count(), InCSetState::Old);
 }
 
 void OldGCAllocRegion::retire_region(HeapRegion* alloc_region,
                                      size_t allocated_bytes) {
-  _g1h->retire_gc_alloc_region(alloc_region, allocated_bytes,
-                               GCAllocForTenured);
+  _g1h->retire_gc_alloc_region(alloc_region, allocated_bytes, InCSetState::Old);
 }
 
 HeapRegion* OldGCAllocRegion::release() {
--- a/hotspot/src/share/vm/gc_implementation/g1/g1Allocator.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1Allocator.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -113,15 +113,16 @@
 G1ParGCAllocBuffer::G1ParGCAllocBuffer(size_t gclab_word_size) :
   ParGCAllocBuffer(gclab_word_size), _retired(true) { }
 
-HeapWord* G1ParGCAllocator::allocate_slow(GCAllocPurpose purpose, size_t word_sz, AllocationContext_t context) {
-  HeapWord* obj = NULL;
-  size_t gclab_word_size = _g1h->desired_plab_sz(purpose);
+HeapWord* G1ParGCAllocator::allocate_direct_or_new_plab(InCSetState dest,
+                                                        size_t word_sz,
+                                                        AllocationContext_t context) {
+  size_t gclab_word_size = _g1h->desired_plab_sz(dest);
   if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) {
-    G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose, context);
+    G1ParGCAllocBuffer* alloc_buf = alloc_buffer(dest, context);
     add_to_alloc_buffer_waste(alloc_buf->words_remaining());
     alloc_buf->retire(false /* end_of_gc */, false /* retain */);
 
-    HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size, context);
+    HeapWord* buf = _g1h->par_allocate_during_gc(dest, gclab_word_size, context);
     if (buf == NULL) {
       return NULL; // Let caller handle allocation failure.
     }
@@ -129,30 +130,33 @@
     alloc_buf->set_word_size(gclab_word_size);
     alloc_buf->set_buf(buf);
 
-    obj = alloc_buf->allocate(word_sz);
+    HeapWord* const obj = alloc_buf->allocate(word_sz);
     assert(obj != NULL, "buffer was definitely big enough...");
+    return obj;
   } else {
-    obj = _g1h->par_allocate_during_gc(purpose, word_sz, context);
+    return _g1h->par_allocate_during_gc(dest, word_sz, context);
   }
-  return obj;
 }
 
 G1DefaultParGCAllocator::G1DefaultParGCAllocator(G1CollectedHeap* g1h) :
-            G1ParGCAllocator(g1h),
-            _surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)),
-            _tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)) {
-
-  _alloc_buffers[GCAllocForSurvived] = &_surviving_alloc_buffer;
-  _alloc_buffers[GCAllocForTenured]  = &_tenured_alloc_buffer;
-
+  G1ParGCAllocator(g1h),
+  _surviving_alloc_buffer(g1h->desired_plab_sz(InCSetState::Young)),
+  _tenured_alloc_buffer(g1h->desired_plab_sz(InCSetState::Old)) {
+  for (uint state = 0; state < InCSetState::Num; state++) {
+    _alloc_buffers[state] = NULL;
+  }
+  _alloc_buffers[InCSetState::Young] = &_surviving_alloc_buffer;
+  _alloc_buffers[InCSetState::Old]  = &_tenured_alloc_buffer;
 }
 
 void G1DefaultParGCAllocator::retire_alloc_buffers() {
-  for (int ap = 0; ap < GCAllocPurposeCount; ++ap) {
-    size_t waste = _alloc_buffers[ap]->words_remaining();
-    add_to_alloc_buffer_waste(waste);
-    _alloc_buffers[ap]->flush_stats_and_retire(_g1h->stats_for_purpose((GCAllocPurpose)ap),
-                                               true /* end_of_gc */,
-                                               false /* retain */);
+  for (uint state = 0; state < InCSetState::Num; state++) {
+    G1ParGCAllocBuffer* const buf = _alloc_buffers[state];
+    if (buf != NULL) {
+      add_to_alloc_buffer_waste(buf->words_remaining());
+      buf->flush_stats_and_retire(_g1h->alloc_buffer_stats(state),
+                                  true /* end_of_gc */,
+                                  false /* retain */);
+    }
   }
 }
--- a/hotspot/src/share/vm/gc_implementation/g1/g1Allocator.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1Allocator.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -27,14 +27,9 @@
 
 #include "gc_implementation/g1/g1AllocationContext.hpp"
 #include "gc_implementation/g1/g1AllocRegion.hpp"
+#include "gc_implementation/g1/g1InCSetState.hpp"
 #include "gc_implementation/shared/parGCAllocBuffer.hpp"
 
-enum GCAllocPurpose {
-  GCAllocForTenured,
-  GCAllocForSurvived,
-  GCAllocPurposeCount
-};
-
 // Base class for G1 allocators.
 class G1Allocator : public CHeapObj<mtGC> {
   friend class VMStructs;
@@ -178,20 +173,40 @@
 protected:
   G1CollectedHeap* _g1h;
 
+  // The survivor alignment in effect in bytes.
+  // == 0 : don't align survivors
+  // != 0 : align survivors to that alignment
+  // These values were chosen to favor the non-alignment case since some
+  // architectures have a special compare against zero instructions.
+  const uint _survivor_alignment_bytes;
+
   size_t _alloc_buffer_waste;
   size_t _undo_waste;
 
   void add_to_alloc_buffer_waste(size_t waste) { _alloc_buffer_waste += waste; }
   void add_to_undo_waste(size_t waste)         { _undo_waste += waste; }
 
-  HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz, AllocationContext_t context);
+  virtual void retire_alloc_buffers() = 0;
+  virtual G1ParGCAllocBuffer* alloc_buffer(InCSetState dest, AllocationContext_t context) = 0;
 
-  virtual void retire_alloc_buffers() = 0;
-  virtual G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose, AllocationContext_t context) = 0;
+  // Calculate the survivor space object alignment in bytes. Returns that or 0 if
+  // there are no restrictions on survivor alignment.
+  static uint calc_survivor_alignment_bytes() {
+    assert(SurvivorAlignmentInBytes >= ObjectAlignmentInBytes, "sanity");
+    if (SurvivorAlignmentInBytes == ObjectAlignmentInBytes) {
+      // No need to align objects in the survivors differently, return 0
+      // which means "survivor alignment is not used".
+      return 0;
+    } else {
+      assert(SurvivorAlignmentInBytes > 0, "sanity");
+      return SurvivorAlignmentInBytes;
+    }
+  }
 
 public:
   G1ParGCAllocator(G1CollectedHeap* g1h) :
-    _g1h(g1h), _alloc_buffer_waste(0), _undo_waste(0) {
+    _g1h(g1h), _survivor_alignment_bytes(calc_survivor_alignment_bytes()),
+    _alloc_buffer_waste(0), _undo_waste(0) {
   }
 
   static G1ParGCAllocator* create_allocator(G1CollectedHeap* g1h);
@@ -199,24 +214,40 @@
   size_t alloc_buffer_waste() { return _alloc_buffer_waste; }
   size_t undo_waste() {return _undo_waste; }
 
-  HeapWord* allocate(GCAllocPurpose purpose, size_t word_sz, AllocationContext_t context) {
-    HeapWord* obj = NULL;
-    if (purpose == GCAllocForSurvived) {
-      obj = alloc_buffer(purpose, context)->allocate_aligned(word_sz, SurvivorAlignmentInBytes);
+  // Allocate word_sz words in dest, either directly into the regions or by
+  // allocating a new PLAB. Returns the address of the allocated memory, NULL if
+  // not successful.
+  HeapWord* allocate_direct_or_new_plab(InCSetState dest,
+                                        size_t word_sz,
+                                        AllocationContext_t context);
+
+  // Allocate word_sz words in the PLAB of dest.  Returns the address of the
+  // allocated memory, NULL if not successful.
+  HeapWord* plab_allocate(InCSetState dest,
+                          size_t word_sz,
+                          AllocationContext_t context) {
+    G1ParGCAllocBuffer* buffer = alloc_buffer(dest, context);
+    if (_survivor_alignment_bytes == 0) {
+      return buffer->allocate(word_sz);
     } else {
-      obj = alloc_buffer(purpose, context)->allocate(word_sz);
+      return buffer->allocate_aligned(word_sz, _survivor_alignment_bytes);
     }
+  }
+
+  HeapWord* allocate(InCSetState dest, size_t word_sz,
+                     AllocationContext_t context) {
+    HeapWord* const obj = plab_allocate(dest, word_sz, context);
     if (obj != NULL) {
       return obj;
     }
-    return allocate_slow(purpose, word_sz, context);
+    return allocate_direct_or_new_plab(dest, word_sz, context);
   }
 
-  void undo_allocation(GCAllocPurpose purpose, HeapWord* obj, size_t word_sz, AllocationContext_t context) {
-    if (alloc_buffer(purpose, context)->contains(obj)) {
-      assert(alloc_buffer(purpose, context)->contains(obj + word_sz - 1),
+  void undo_allocation(InCSetState dest, HeapWord* obj, size_t word_sz, AllocationContext_t context) {
+    if (alloc_buffer(dest, context)->contains(obj)) {
+      assert(alloc_buffer(dest, context)->contains(obj + word_sz - 1),
              "should contain whole object");
-      alloc_buffer(purpose, context)->undo_allocation(obj, word_sz);
+      alloc_buffer(dest, context)->undo_allocation(obj, word_sz);
     } else {
       CollectedHeap::fill_with_object(obj, word_sz);
       add_to_undo_waste(word_sz);
@@ -227,13 +258,17 @@
 class G1DefaultParGCAllocator : public G1ParGCAllocator {
   G1ParGCAllocBuffer  _surviving_alloc_buffer;
   G1ParGCAllocBuffer  _tenured_alloc_buffer;
-  G1ParGCAllocBuffer* _alloc_buffers[GCAllocPurposeCount];
+  G1ParGCAllocBuffer* _alloc_buffers[InCSetState::Num];
 
 public:
   G1DefaultParGCAllocator(G1CollectedHeap* g1h);
 
-  virtual G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose, AllocationContext_t context) {
-    return _alloc_buffers[purpose];
+  virtual G1ParGCAllocBuffer* alloc_buffer(InCSetState dest, AllocationContext_t context) {
+    assert(dest.is_valid(),
+           err_msg("Allocation buffer index out-of-bounds: " CSETSTATE_FORMAT, dest.value()));
+    assert(_alloc_buffers[dest.value()] != NULL,
+           err_msg("Allocation buffer is NULL: " CSETSTATE_FORMAT, dest.value()));
+    return _alloc_buffers[dest.value()];
   }
 
   virtual void retire_alloc_buffers() ;
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1301,7 +1301,7 @@
       // Temporarily clear the STW ref processor's _is_alive_non_header field.
       ReferenceProcessorIsAliveMutator stw_rp_is_alive_null(ref_processor_stw(), NULL);
 
-      ref_processor_stw()->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
+      ref_processor_stw()->enable_discovery();
       ref_processor_stw()->setup_policy(do_clear_all_soft_refs);
 
       // Do collection work
@@ -1886,13 +1886,12 @@
 
   initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
 
-  // Create the gen rem set (and barrier set) for the entire reserved region.
-  _rem_set = collector_policy()->create_rem_set(reserved_region());
-  set_barrier_set(rem_set()->bs());
-  if (!barrier_set()->is_a(BarrierSet::G1SATBCTLogging)) {
-    vm_exit_during_initialization("G1 requires a G1SATBLoggingCardTableModRefBS");
-    return JNI_ENOMEM;
-  }
+  // Create the barrier set for the entire reserved region.
+  G1SATBCardTableLoggingModRefBS* bs
+    = new G1SATBCardTableLoggingModRefBS(reserved_region());
+  bs->initialize();
+  assert(bs->is_a(BarrierSet::G1SATBCTLogging), "sanity");
+  set_barrier_set(bs);
 
   // Also create a G1 rem set.
   _g1_rem_set = new G1RemSet(this, g1_barrier_set());
@@ -3153,8 +3152,6 @@
         failures = true;
       }
     }
-    if (!silent) gclog_or_tty->print("RemSet ");
-    rem_set()->verify();
 
     if (G1StringDedup::is_enabled()) {
       if (!silent) gclog_or_tty->print("StrDedup ");
@@ -3750,8 +3747,7 @@
       // reference processing currently works in G1.
 
       // Enable discovery in the STW reference processor
-      ref_processor_stw()->enable_discovery(true /*verify_disabled*/,
-                                            true /*verify_no_refs*/);
+      ref_processor_stw()->enable_discovery();
 
       {
         // We want to temporarily turn off discovery by the
@@ -3819,6 +3815,8 @@
 
         register_humongous_regions_with_in_cset_fast_test();
 
+        assert(check_cset_fast_test(), "Inconsistency in the InCSetState table.");
+
         _cm->note_start_of_gc();
         // We should not verify the per-thread SATB buffers given that
         // we have not filtered them yet (we'll do so during the
@@ -4048,29 +4046,6 @@
   return true;
 }
 
-size_t G1CollectedHeap::desired_plab_sz(GCAllocPurpose purpose)
-{
-  size_t gclab_word_size;
-  switch (purpose) {
-    case GCAllocForSurvived:
-      gclab_word_size = _survivor_plab_stats.desired_plab_sz();
-      break;
-    case GCAllocForTenured:
-      gclab_word_size = _old_plab_stats.desired_plab_sz();
-      break;
-    default:
-      assert(false, "unknown GCAllocPurpose");
-      gclab_word_size = _old_plab_stats.desired_plab_sz();
-      break;
-  }
-
-  // Prevent humongous PLAB sizes for two reasons:
-  // * PLABs are allocated using a similar paths as oops, but should
-  //   never be in a humongous region
-  // * Allowing humongous PLABs needlessly churns the region free lists
-  return MIN2(_humongous_object_threshold_in_words, gclab_word_size);
-}
-
 void G1CollectedHeap::init_for_evac_failure(OopsInHeapRegionClosure* cl) {
   _drain_in_progress = false;
   set_evac_failure_closure(cl);
@@ -4196,35 +4171,6 @@
   }
 }
 
-HeapWord* G1CollectedHeap::par_allocate_during_gc(GCAllocPurpose purpose,
-                                                  size_t word_size,
-                                                  AllocationContext_t context) {
-  if (purpose == GCAllocForSurvived) {
-    HeapWord* result = survivor_attempt_allocation(word_size, context);
-    if (result != NULL) {
-      return result;
-    } else {
-      // Let's try to allocate in the old gen in case we can fit the
-      // object there.
-      return old_attempt_allocation(word_size, context);
-    }
-  } else {
-    assert(purpose ==  GCAllocForTenured, "sanity");
-    HeapWord* result = old_attempt_allocation(word_size, context);
-    if (result != NULL) {
-      return result;
-    } else {
-      // Let's try to allocate in the survivors in case we can fit the
-      // object there.
-      return survivor_attempt_allocation(word_size, context);
-    }
-  }
-
-  ShouldNotReachHere();
-  // Trying to keep some compilers happy.
-  return NULL;
-}
-
 void G1ParCopyHelper::mark_object(oop obj) {
   assert(!_g1->heap_region_containing(obj)->in_collection_set(), "should not mark objects in the CSet");
 
@@ -4267,15 +4213,14 @@
 
   assert(_worker_id == _par_scan_state->queue_num(), "sanity");
 
-  G1CollectedHeap::in_cset_state_t state = _g1->in_cset_state(obj);
-
-  if (state == G1CollectedHeap::InCSet) {
+  const InCSetState state = _g1->in_cset_state(obj);
+  if (state.is_in_cset()) {
     oop forwardee;
     markOop m = obj->mark();
     if (m->is_marked()) {
       forwardee = (oop) m->decode_pointer();
     } else {
-      forwardee = _par_scan_state->copy_to_survivor_space(obj, m);
+      forwardee = _par_scan_state->copy_to_survivor_space(state, obj, m);
     }
     assert(forwardee != NULL, "forwardee should not be NULL");
     oopDesc::encode_store_heap_oop(p, forwardee);
@@ -4289,7 +4234,7 @@
       do_klass_barrier(p, forwardee);
     }
   } else {
-    if (state == G1CollectedHeap::IsHumongous) {
+    if (state.is_humongous()) {
       _g1->set_humongous_is_live(obj);
     }
     // The object is not in collection set. If we're a root scanning
@@ -4609,7 +4554,7 @@
 G1CollectedHeap::
 g1_process_roots(OopClosure* scan_non_heap_roots,
                  OopClosure* scan_non_heap_weak_roots,
-                 OopsInHeapRegionClosure* scan_rs,
+                 G1ParPushHeapRSClosure* scan_rs,
                  CLDClosure* scan_strong_clds,
                  CLDClosure* scan_weak_clds,
                  CodeBlobClosure* scan_strong_code,
@@ -4933,7 +4878,7 @@
   }
 };
 
-Monitor* G1CodeCacheUnloadingTask::_lock = new Monitor(Mutex::leaf, "Code Cache Unload lock");
+Monitor* G1CodeCacheUnloadingTask::_lock = new Monitor(Mutex::leaf, "Code Cache Unload lock", false, Monitor::_safepoint_check_never);
 
 class G1KlassCleaningTask : public StackObj {
   BoolObjectClosure*                      _is_alive;
@@ -5145,17 +5090,17 @@
     oop obj = *p;
     assert(obj != NULL, "the caller should have filtered out NULL values");
 
-    G1CollectedHeap::in_cset_state_t cset_state = _g1->in_cset_state(obj);
-    if (cset_state == G1CollectedHeap::InNeither) {
+    const InCSetState cset_state = _g1->in_cset_state(obj);
+    if (!cset_state.is_in_cset_or_humongous()) {
       return;
     }
-    if (cset_state == G1CollectedHeap::InCSet) {
+    if (cset_state.is_in_cset()) {
       assert( obj->is_forwarded(), "invariant" );
       *p = obj->forwardee();
     } else {
       assert(!obj->is_forwarded(), "invariant" );
-      assert(cset_state == G1CollectedHeap::IsHumongous,
-             err_msg("Only allowed InCSet state is IsHumongous, but is %d", cset_state));
+      assert(cset_state.is_humongous(),
+             err_msg("Only allowed InCSet state is IsHumongous, but is %d", cset_state.value()));
       _g1->set_humongous_is_live(obj);
     }
   }
@@ -5640,8 +5585,6 @@
 
   init_for_evac_failure(NULL);
 
-  rem_set()->prepare_for_younger_refs_iterate(true);
-
   assert(dirty_card_queue_set().completed_buffers_num() == 0, "Should be empty");
   double start_par_time_sec = os::elapsedTime();
   double end_par_time_sec;
@@ -5951,6 +5894,70 @@
   heap_region_iterate(&cl);
   guarantee(!cl.failures(), "bitmap verification");
 }
+
+class G1CheckCSetFastTableClosure : public HeapRegionClosure {
+ private:
+  bool _failures;
+ public:
+  G1CheckCSetFastTableClosure() : HeapRegionClosure(), _failures(false) { }
+
+  virtual bool doHeapRegion(HeapRegion* hr) {
+    uint i = hr->hrm_index();
+    InCSetState cset_state = (InCSetState) G1CollectedHeap::heap()->_in_cset_fast_test.get_by_index(i);
+    if (hr->is_humongous()) {
+      if (hr->in_collection_set()) {
+        gclog_or_tty->print_cr("\n## humongous region %u in CSet", i);
+        _failures = true;
+        return true;
+      }
+      if (cset_state.is_in_cset()) {
+        gclog_or_tty->print_cr("\n## inconsistent cset state %d for humongous region %u", cset_state.value(), i);
+        _failures = true;
+        return true;
+      }
+      if (hr->is_continues_humongous() && cset_state.is_humongous()) {
+        gclog_or_tty->print_cr("\n## inconsistent cset state %d for continues humongous region %u", cset_state.value(), i);
+        _failures = true;
+        return true;
+      }
+    } else {
+      if (cset_state.is_humongous()) {
+        gclog_or_tty->print_cr("\n## inconsistent cset state %d for non-humongous region %u", cset_state.value(), i);
+        _failures = true;
+        return true;
+      }
+      if (hr->in_collection_set() != cset_state.is_in_cset()) {
+        gclog_or_tty->print_cr("\n## in CSet %d / cset state %d inconsistency for region %u",
+                               hr->in_collection_set(), cset_state.value(), i);
+        _failures = true;
+        return true;
+      }
+      if (cset_state.is_in_cset()) {
+        if (hr->is_young() != (cset_state.is_young())) {
+          gclog_or_tty->print_cr("\n## is_young %d / cset state %d inconsistency for region %u",
+                                 hr->is_young(), cset_state.value(), i);
+          _failures = true;
+          return true;
+        }
+        if (hr->is_old() != (cset_state.is_old())) {
+          gclog_or_tty->print_cr("\n## is_old %d / cset state %d inconsistency for region %u",
+                                 hr->is_old(), cset_state.value(), i);
+          _failures = true;
+          return true;
+        }
+      }
+    }
+    return false;
+  }
+
+  bool failures() const { return _failures; }
+};
+
+bool G1CollectedHeap::check_cset_fast_test() {
+  G1CheckCSetFastTableClosure cl;
+  _hrm.iterate(&cl);
+  return !cl.failures();
+}
 #endif // PRODUCT
 
 void G1CollectedHeap::cleanUpCardTable() {
@@ -6519,20 +6526,20 @@
 
 HeapRegion* G1CollectedHeap::new_gc_alloc_region(size_t word_size,
                                                  uint count,
-                                                 GCAllocPurpose ap) {
+                                                 InCSetState dest) {
   assert(FreeList_lock->owned_by_self(), "pre-condition");
 
-  if (count < g1_policy()->max_regions(ap)) {
-    bool survivor = (ap == GCAllocForSurvived);
+  if (count < g1_policy()->max_regions(dest)) {
+    const bool is_survivor = (dest.is_young());
     HeapRegion* new_alloc_region = new_region(word_size,
-                                              !survivor,
+                                              !is_survivor,
                                               true /* do_expand */);
     if (new_alloc_region != NULL) {
       // We really only need to do this for old regions given that we
       // should never scan survivors. But it doesn't hurt to do it
       // for survivors too.
       new_alloc_region->record_timestamp();
-      if (survivor) {
+      if (is_survivor) {
         new_alloc_region->set_survivor();
         _hr_printer.alloc(new_alloc_region, G1HRPrinter::Survivor);
         check_bitmaps("Survivor Region Allocation", new_alloc_region);
@@ -6544,8 +6551,6 @@
       bool during_im = g1_policy()->during_initial_mark_pause();
       new_alloc_region->note_start_of_copying(during_im);
       return new_alloc_region;
-    } else {
-      g1_policy()->note_alloc_region_limit_reached(ap);
     }
   }
   return NULL;
@@ -6553,11 +6558,11 @@
 
 void G1CollectedHeap::retire_gc_alloc_region(HeapRegion* alloc_region,
                                              size_t allocated_bytes,
-                                             GCAllocPurpose ap) {
+                                             InCSetState dest) {
   bool during_im = g1_policy()->during_initial_mark_pause();
   alloc_region->note_end_of_copying(during_im);
   g1_policy()->record_bytes_copied_during_gc(allocated_bytes);
-  if (ap == GCAllocForSurvived) {
+  if (dest.is_young()) {
     young_list()->add_survivor_region(alloc_region);
   } else {
     _old_set.add(alloc_region);
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -32,6 +32,7 @@
 #include "gc_implementation/g1/g1AllocRegion.hpp"
 #include "gc_implementation/g1/g1BiasedArray.hpp"
 #include "gc_implementation/g1/g1HRPrinter.hpp"
+#include "gc_implementation/g1/g1InCSetState.hpp"
 #include "gc_implementation/g1/g1MonitoringSupport.hpp"
 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
 #include "gc_implementation/g1/g1YCTypes.hpp"
@@ -213,6 +214,9 @@
   friend class G1MarkSweep;
   friend class HeapRegionClaimer;
 
+  // Testing classes.
+  friend class G1CheckCSetFastTableClosure;
+
 private:
   // The one and only G1CollectedHeap, so static functions can find it.
   static G1CollectedHeap* _g1h;
@@ -547,15 +551,9 @@
   // allocation region, either by picking one or expanding the
   // heap, and then allocate a block of the given size. The block
   // may not be a humongous - it must fit into a single heap region.
-  HeapWord* par_allocate_during_gc(GCAllocPurpose purpose,
-                                   size_t word_size,
-                                   AllocationContext_t context);
-
-  HeapWord* allocate_during_gc_slow(GCAllocPurpose purpose,
-                                    HeapRegion*    alloc_region,
-                                    bool           par,
-                                    size_t         word_size);
-
+  inline HeapWord* par_allocate_during_gc(InCSetState dest,
+                                          size_t word_size,
+                                          AllocationContext_t context);
   // Ensure that no further allocations can happen in "r", bearing in mind
   // that parallel threads might be attempting allocations.
   void par_allocate_remaining_space(HeapRegion* r);
@@ -577,9 +575,9 @@
 
   // For GC alloc regions.
   HeapRegion* new_gc_alloc_region(size_t word_size, uint count,
-                                  GCAllocPurpose ap);
+                                  InCSetState dest);
   void retire_gc_alloc_region(HeapRegion* alloc_region,
-                              size_t allocated_bytes, GCAllocPurpose ap);
+                              size_t allocated_bytes, InCSetState dest);
 
   // - if explicit_gc is true, the GC is for a System.gc() or a heap
   //   inspection request and should collect the entire heap
@@ -640,26 +638,11 @@
   // (Rounds up to a HeapRegion boundary.)
   bool expand(size_t expand_bytes);
 
-  // Returns the PLAB statistics given a purpose.
-  PLABStats* stats_for_purpose(GCAllocPurpose purpose) {
-    PLABStats* stats = NULL;
+  // Returns the PLAB statistics for a given destination.
+  inline PLABStats* alloc_buffer_stats(InCSetState dest);
 
-    switch (purpose) {
-    case GCAllocForSurvived:
-      stats = &_survivor_plab_stats;
-      break;
-    case GCAllocForTenured:
-      stats = &_old_plab_stats;
-      break;
-    default:
-      assert(false, "unrecognized GCAllocPurpose");
-    }
-
-    return stats;
-  }
-
-  // Determines PLAB size for a particular allocation purpose.
-  size_t desired_plab_sz(GCAllocPurpose purpose);
+  // Determines PLAB size for a given destination.
+  inline size_t desired_plab_sz(InCSetState dest);
 
   inline AllocationContextStats& allocation_context_stats();
 
@@ -683,8 +666,11 @@
   void register_humongous_regions_with_in_cset_fast_test();
   // We register a region with the fast "in collection set" test. We
   // simply set to true the array slot corresponding to this region.
-  void register_region_with_in_cset_fast_test(HeapRegion* r) {
-    _in_cset_fast_test.set_in_cset(r->hrm_index());
+  void register_young_region_with_in_cset_fast_test(HeapRegion* r) {
+    _in_cset_fast_test.set_in_young(r->hrm_index());
+  }
+  void register_old_region_with_in_cset_fast_test(HeapRegion* r) {
+    _in_cset_fast_test.set_in_old(r->hrm_index());
   }
 
   // This is a fast test on whether a reference points into the
@@ -821,7 +807,7 @@
   // In the sequential case this param will be ignored.
   void g1_process_roots(OopClosure* scan_non_heap_roots,
                         OopClosure* scan_non_heap_weak_roots,
-                        OopsInHeapRegionClosure* scan_rs,
+                        G1ParPushHeapRSClosure* scan_rs,
                         CLDClosure* scan_strong_clds,
                         CLDClosure* scan_weak_clds,
                         CodeBlobClosure* scan_strong_code,
@@ -1181,6 +1167,9 @@
   // appropriate error messages and crash.
   void check_bitmaps(const char* caller) PRODUCT_RETURN;
 
+  // Do sanity check on the contents of the in-cset fast test table.
+  bool check_cset_fast_test() PRODUCT_RETURN_( return true; );
+
   // verify_region_sets() performs verification over the region
   // lists. It will be compiled in the product code to be used when
   // necessary (i.e., during heap verification).
@@ -1276,53 +1265,15 @@
 
   inline bool is_in_cset_or_humongous(const oop obj);
 
-  enum in_cset_state_t {
-   InNeither,           // neither in collection set nor humongous
-   InCSet,              // region is in collection set only
-   IsHumongous          // region is a humongous start region
-  };
  private:
-  // Instances of this class are used for quick tests on whether a reference points
-  // into the collection set or is a humongous object (points into a humongous
-  // object).
-  // Each of the array's elements denotes whether the corresponding region is in
-  // the collection set or a humongous region.
-  // We use this to quickly reclaim humongous objects: by making a humongous region
-  // succeed this test, we sort-of add it to the collection set. During the reference
-  // iteration closures, when we see a humongous region, we simply mark it as
-  // referenced, i.e. live.
-  class G1FastCSetBiasedMappedArray : public G1BiasedMappedArray<char> {
-   protected:
-    char default_value() const { return G1CollectedHeap::InNeither; }
-   public:
-    void set_humongous(uintptr_t index) {
-      assert(get_by_index(index) != InCSet, "Should not overwrite InCSet values");
-      set_by_index(index, G1CollectedHeap::IsHumongous);
-    }
-
-    void clear_humongous(uintptr_t index) {
-      set_by_index(index, G1CollectedHeap::InNeither);
-    }
-
-    void set_in_cset(uintptr_t index) {
-      assert(get_by_index(index) != G1CollectedHeap::IsHumongous, "Should not overwrite IsHumongous value");
-      set_by_index(index, G1CollectedHeap::InCSet);
-    }
-
-    bool is_in_cset_or_humongous(HeapWord* addr) const { return get_by_address(addr) != G1CollectedHeap::InNeither; }
-    bool is_in_cset(HeapWord* addr) const { return get_by_address(addr) == G1CollectedHeap::InCSet; }
-    G1CollectedHeap::in_cset_state_t at(HeapWord* addr) const { return (G1CollectedHeap::in_cset_state_t)get_by_address(addr); }
-    void clear() { G1BiasedMappedArray<char>::clear(); }
-  };
-
   // This array is used for a quick test on whether a reference points into
   // the collection set or not. Each of the array's elements denotes whether the
   // corresponding region is in the collection set or not.
-  G1FastCSetBiasedMappedArray _in_cset_fast_test;
+  G1InCSetStateFastTestBiasedMappedArray _in_cset_fast_test;
 
  public:
 
-  inline in_cset_state_t in_cset_state(const oop obj);
+  inline InCSetState in_cset_state(const oop obj);
 
   // Return "TRUE" iff the given object address is in the reserved
   // region of g1.
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -35,6 +35,41 @@
 #include "runtime/orderAccess.inline.hpp"
 #include "utilities/taskqueue.hpp"
 
+PLABStats* G1CollectedHeap::alloc_buffer_stats(InCSetState dest) {
+  switch (dest.value()) {
+    case InCSetState::Young:
+      return &_survivor_plab_stats;
+    case InCSetState::Old:
+      return &_old_plab_stats;
+    default:
+      ShouldNotReachHere();
+      return NULL; // Keep some compilers happy
+  }
+}
+
+size_t G1CollectedHeap::desired_plab_sz(InCSetState dest) {
+  size_t gclab_word_size = alloc_buffer_stats(dest)->desired_plab_sz();
+  // Prevent humongous PLAB sizes for two reasons:
+  // * PLABs are allocated using a similar paths as oops, but should
+  //   never be in a humongous region
+  // * Allowing humongous PLABs needlessly churns the region free lists
+  return MIN2(_humongous_object_threshold_in_words, gclab_word_size);
+}
+
+HeapWord* G1CollectedHeap::par_allocate_during_gc(InCSetState dest,
+                                                  size_t word_size,
+                                                  AllocationContext_t context) {
+  switch (dest.value()) {
+    case InCSetState::Young:
+      return survivor_attempt_allocation(word_size, context);
+    case InCSetState::Old:
+      return old_attempt_allocation(word_size, context);
+    default:
+      ShouldNotReachHere();
+      return NULL; // Keep some compilers happy
+  }
+}
+
 // Inline functions for G1CollectedHeap
 
 inline AllocationContextStats& G1CollectedHeap::allocation_context_stats() {
@@ -203,7 +238,7 @@
   return _in_cset_fast_test.is_in_cset_or_humongous((HeapWord*)obj);
 }
 
-G1CollectedHeap::in_cset_state_t G1CollectedHeap::in_cset_state(const oop obj) {
+InCSetState G1CollectedHeap::in_cset_state(const oop obj) {
   return _in_cset_fast_test.at((HeapWord*)obj);
 }
 
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1437,18 +1437,6 @@
   return young_list_length < young_list_max_length;
 }
 
-uint G1CollectorPolicy::max_regions(int purpose) {
-  switch (purpose) {
-    case GCAllocForSurvived:
-      return _max_survivor_regions;
-    case GCAllocForTenured:
-      return REGIONS_UNLIMITED;
-    default:
-      ShouldNotReachHere();
-      return REGIONS_UNLIMITED;
-  };
-}
-
 void G1CollectorPolicy::update_max_gc_locker_expansion() {
   uint expansion_region_num = 0;
   if (GCLockerEdenExpansionPercent > 0) {
@@ -1634,7 +1622,7 @@
   hr->set_next_in_collection_set(_collection_set);
   _collection_set = hr;
   _collection_set_bytes_used_before += hr->used();
-  _g1->register_region_with_in_cset_fast_test(hr);
+  _g1->register_old_region_with_in_cset_fast_test(hr);
   size_t rs_length = hr->rem_set()->occupied();
   _recorded_rs_lengths += rs_length;
   _old_cset_region_length += 1;
@@ -1767,7 +1755,7 @@
   hr->set_in_collection_set(true);
   assert( hr->next_in_collection_set() == NULL, "invariant");
 
-  _g1->register_region_with_in_cset_fast_test(hr);
+  _g1->register_young_region_with_in_cset_fast_test(hr);
 }
 
 // Add the region at the RHS of the incremental cset
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -881,28 +881,20 @@
 public:
   uint tenuring_threshold() const { return _tenuring_threshold; }
 
-  inline GCAllocPurpose
-    evacuation_destination(HeapRegion* src_region, uint age, size_t word_sz) {
-      if (age < _tenuring_threshold && src_region->is_young()) {
-        return GCAllocForSurvived;
-      } else {
-        return GCAllocForTenured;
-      }
-  }
-
-  inline bool track_object_age(GCAllocPurpose purpose) {
-    return purpose == GCAllocForSurvived;
-  }
-
   static const uint REGIONS_UNLIMITED = (uint) -1;
 
-  uint max_regions(int purpose);
-
-  // The limit on regions for a particular purpose is reached.
-  void note_alloc_region_limit_reached(int purpose) {
-    if (purpose == GCAllocForSurvived) {
-      _tenuring_threshold = 0;
+  uint max_regions(InCSetState dest) {
+    switch (dest.value()) {
+      case InCSetState::Young:
+        return _max_survivor_regions;
+      case InCSetState::Old:
+        return REGIONS_UNLIMITED;
+      default:
+        assert(false, err_msg("Unknown dest state: " CSETSTATE_FORMAT, dest.value()));
+        break;
     }
+    // keep some compilers happy
+    return 0;
   }
 
   void note_start_adding_survivor_regions() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1InCSetState.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1INCSETSTATE_HPP
+#define SHARE_VM_GC_IMPLEMENTATION_G1_G1INCSETSTATE_HPP
+
+#include "gc_implementation/g1/g1BiasedArray.hpp"
+#include "memory/allocation.hpp"
+
+// Per-region state during garbage collection.
+struct InCSetState {
+ public:
+  // We use different types to represent the state value. Particularly SPARC puts
+  // values in structs from "left to right", i.e. MSB to LSB. This results in many
+  // unnecessary shift operations when loading and storing values of this type.
+  // This degrades performance significantly (>10%) on that platform.
+  // Other tested ABIs do not seem to have this problem, and actually tend to
+  // favor smaller types, so we use the smallest usable type there.
+#ifdef SPARC
+  #define CSETSTATE_FORMAT INTPTR_FORMAT
+  typedef intptr_t in_cset_state_t;
+#else
+  #define CSETSTATE_FORMAT "%d"
+  typedef int8_t in_cset_state_t;
+#endif
+ private:
+  in_cset_state_t _value;
+ public:
+  enum {
+    // Selection of the values were driven to micro-optimize the encoding and
+    // frequency of the checks.
+    // The most common check is whether the region is in the collection set or not.
+    // This encoding allows us to use an != 0 check which in some architectures
+    // (x86*) can be encoded slightly more efficently than a normal comparison
+    // against zero.
+    // The same situation occurs when checking whether the region is humongous
+    // or not, which is encoded by values < 0.
+    // The other values are simply encoded in increasing generation order, which
+    // makes getting the next generation fast by a simple increment.
+    Humongous    = -1,    // The region is humongous - note that actually any value < 0 would be possible here.
+    NotInCSet    =  0,    // The region is not in the collection set.
+    Young        =  1,    // The region is in the collection set and a young region.
+    Old          =  2,    // The region is in the collection set and an old region.
+    Num
+  };
+
+  InCSetState(in_cset_state_t value = NotInCSet) : _value(value) {
+    assert(is_valid(), err_msg("Invalid state %d", _value));
+  }
+
+  in_cset_state_t value() const        { return _value; }
+
+  void set_old()                       { _value = Old; }
+
+  bool is_in_cset_or_humongous() const { return _value != NotInCSet; }
+  bool is_in_cset() const              { return _value > NotInCSet; }
+  bool is_humongous() const            { return _value < NotInCSet; }
+  bool is_young() const                { return _value == Young; }
+  bool is_old() const                  { return _value == Old; }
+
+#ifdef ASSERT
+  bool is_default() const              { return !is_in_cset_or_humongous(); }
+  bool is_valid() const                { return (_value >= Humongous) && (_value < Num); }
+  bool is_valid_gen() const            { return (_value >= Young && _value <= Old); }
+#endif
+};
+
+// Instances of this class are used for quick tests on whether a reference points
+// into the collection set and into which generation or is a humongous object
+//
+// Each of the array's elements indicates whether the corresponding region is in
+// the collection set and if so in which generation, or a humongous region.
+//
+// We use this to speed up reference processing during young collection and
+// quickly reclaim humongous objects. For the latter, by making a humongous region
+// succeed this test, we sort-of add it to the collection set. During the reference
+// iteration closures, when we see a humongous region, we then simply mark it as
+// referenced, i.e. live.
+class G1InCSetStateFastTestBiasedMappedArray : public G1BiasedMappedArray<InCSetState> {
+ protected:
+  InCSetState default_value() const { return InCSetState::NotInCSet; }
+ public:
+  void set_humongous(uintptr_t index) {
+    assert(get_by_index(index).is_default(),
+           err_msg("State at index " INTPTR_FORMAT" should be default but is " CSETSTATE_FORMAT, index, get_by_index(index).value()));
+    set_by_index(index, InCSetState::Humongous);
+  }
+
+  void clear_humongous(uintptr_t index) {
+    set_by_index(index, InCSetState::NotInCSet);
+  }
+
+  void set_in_young(uintptr_t index) {
+    assert(get_by_index(index).is_default(),
+           err_msg("State at index " INTPTR_FORMAT" should be default but is " CSETSTATE_FORMAT, index, get_by_index(index).value()));
+    set_by_index(index, InCSetState::Young);
+  }
+
+  void set_in_old(uintptr_t index) {
+    assert(get_by_index(index).is_default(),
+           err_msg("State at index " INTPTR_FORMAT" should be default but is " CSETSTATE_FORMAT, index, get_by_index(index).value()));
+    set_by_index(index, InCSetState::Old);
+  }
+
+  bool is_in_cset_or_humongous(HeapWord* addr) const { return at(addr).is_in_cset_or_humongous(); }
+  bool is_in_cset(HeapWord* addr) const { return at(addr).is_in_cset(); }
+  InCSetState at(HeapWord* addr) const { return get_by_address(addr); }
+  void clear() { G1BiasedMappedArray<InCSetState>::clear(); }
+};
+
+#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1INCSETSTATE_HPP
--- a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -26,6 +26,7 @@
 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1OOPCLOSURES_HPP
 
 #include "memory/iterator.hpp"
+#include "oops/markOop.hpp"
 
 class HeapRegion;
 class G1CollectedHeap;
@@ -239,14 +240,14 @@
   G1CollectedHeap* _g1;
   G1RemSet* _g1_rem_set;
   HeapRegion* _from;
-  OopsInHeapRegionClosure* _push_ref_cl;
+  G1ParPushHeapRSClosure* _push_ref_cl;
   bool _record_refs_into_cset;
   uint _worker_i;
 
 public:
   G1UpdateRSOrPushRefOopClosure(G1CollectedHeap* g1h,
                                 G1RemSet* rs,
-                                OopsInHeapRegionClosure* push_ref_cl,
+                                G1ParPushHeapRSClosure* push_ref_cl,
                                 bool record_refs_into_cset,
                                 uint worker_i = 0);
 
@@ -256,7 +257,8 @@
   }
 
   bool self_forwarded(oop obj) {
-    bool result = (obj->is_forwarded() && (obj->forwardee()== obj));
+    markOop m = obj->mark();
+    bool result = (m->is_marked() && ((oop)m->decode_pointer() == obj));
     return result;
   }
 
--- a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -67,8 +67,8 @@
 
   if (!oopDesc::is_null(heap_oop)) {
     oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
-    G1CollectedHeap::in_cset_state_t state = _g1->in_cset_state(obj);
-    if (state == G1CollectedHeap::InCSet) {
+    const InCSetState state = _g1->in_cset_state(obj);
+    if (state.is_in_cset()) {
       // We're not going to even bother checking whether the object is
       // already forwarded or not, as this usually causes an immediate
       // stall. We'll try to prefetch the object (for write, given that
@@ -87,7 +87,7 @@
 
       _par_scan_state->push_on_queue(p);
     } else {
-      if (state == G1CollectedHeap::IsHumongous) {
+      if (state.is_humongous()) {
         _g1->set_humongous_is_live(obj);
       }
       _par_scan_state->update_rs(_from, p, _worker_id);
--- a/hotspot/src/share/vm/gc_implementation/g1/g1PageBasedVirtualSpace.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1PageBasedVirtualSpace.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -131,6 +131,9 @@
   _committed.set_range(start, start + size_in_pages);
 
   MemRegion result((HeapWord*)page_start(start), byte_size_for_pages(size_in_pages) / HeapWordSize);
+  if (AlwaysPreTouch) {
+    os::pretouch_memory((char*)result.start(), (char*)result.end());
+  }
   return result;
 }
 
--- a/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -38,6 +38,7 @@
     _g1_rem(g1h->g1_rem_set()),
     _hash_seed(17), _queue_num(queue_num),
     _term_attempts(0),
+    _tenuring_threshold(g1h->g1_policy()->tenuring_threshold()),
     _age_table(false), _scanner(g1h, rp),
     _strong_roots_time(0), _term_time(0) {
   _scanner.set_par_scan_thread_state(this);
@@ -59,6 +60,12 @@
 
   _g1_par_allocator = G1ParGCAllocator::create_allocator(_g1h);
 
+  _dest[InCSetState::NotInCSet]    = InCSetState::NotInCSet;
+  // The dest for Young is used when the objects are aged enough to
+  // need to be moved to the next space.
+  _dest[InCSetState::Young]        = InCSetState::Old;
+  _dest[InCSetState::Old]          = InCSetState::Old;
+
   _start = os::elapsedTime();
 }
 
@@ -150,52 +157,94 @@
   } while (!_refs->is_empty());
 }
 
-oop G1ParScanThreadState::copy_to_survivor_space(oop const old,
+HeapWord* G1ParScanThreadState::allocate_in_next_plab(InCSetState const state,
+                                                      InCSetState* dest,
+                                                      size_t word_sz,
+                                                      AllocationContext_t const context) {
+  assert(state.is_in_cset_or_humongous(), err_msg("Unexpected state: " CSETSTATE_FORMAT, state.value()));
+  assert(dest->is_in_cset_or_humongous(), err_msg("Unexpected dest: " CSETSTATE_FORMAT, dest->value()));
+
+  // Right now we only have two types of regions (young / old) so
+  // let's keep the logic here simple. We can generalize it when necessary.
+  if (dest->is_young()) {
+    HeapWord* const obj_ptr = _g1_par_allocator->allocate(InCSetState::Old,
+                                                          word_sz, context);
+    if (obj_ptr == NULL) {
+      return NULL;
+    }
+    // Make sure that we won't attempt to copy any other objects out
+    // of a survivor region (given that apparently we cannot allocate
+    // any new ones) to avoid coming into this slow path.
+    _tenuring_threshold = 0;
+    dest->set_old();
+    return obj_ptr;
+  } else {
+    assert(dest->is_old(), err_msg("Unexpected dest: " CSETSTATE_FORMAT, dest->value()));
+    // no other space to try.
+    return NULL;
+  }
+}
+
+InCSetState G1ParScanThreadState::next_state(InCSetState const state, markOop const m, uint& age) {
+  if (state.is_young()) {
+    age = !m->has_displaced_mark_helper() ? m->age()
+                                          : m->displaced_mark_helper()->age();
+    if (age < _tenuring_threshold) {
+      return state;
+    }
+  }
+  return dest(state);
+}
+
+oop G1ParScanThreadState::copy_to_survivor_space(InCSetState const state,
+                                                 oop const old,
                                                  markOop const old_mark) {
-  size_t word_sz = old->size();
-  HeapRegion* from_region = _g1h->heap_region_containing_raw(old);
+  const size_t word_sz = old->size();
+  HeapRegion* const from_region = _g1h->heap_region_containing_raw(old);
   // +1 to make the -1 indexes valid...
-  int       young_index = from_region->young_index_in_cset()+1;
+  const int young_index = from_region->young_index_in_cset()+1;
   assert( (from_region->is_young() && young_index >  0) ||
          (!from_region->is_young() && young_index == 0), "invariant" );
-  G1CollectorPolicy* g1p = _g1h->g1_policy();
-  uint age = old_mark->has_displaced_mark_helper() ? old_mark->displaced_mark_helper()->age()
-                                                   : old_mark->age();
-  GCAllocPurpose alloc_purpose = g1p->evacuation_destination(from_region, age,
-                                                             word_sz);
-  AllocationContext_t context = from_region->allocation_context();
-  HeapWord* obj_ptr = _g1_par_allocator->allocate(alloc_purpose, word_sz, context);
+  const AllocationContext_t context = from_region->allocation_context();
+
+  uint age = 0;
+  InCSetState dest_state = next_state(state, old_mark, age);
+  HeapWord* obj_ptr = _g1_par_allocator->plab_allocate(dest_state, word_sz, context);
+
+  // PLAB allocations should succeed most of the time, so we'll
+  // normally check against NULL once and that's it.
+  if (obj_ptr == NULL) {
+    obj_ptr = _g1_par_allocator->allocate_direct_or_new_plab(dest_state, word_sz, context);
+    if (obj_ptr == NULL) {
+      obj_ptr = allocate_in_next_plab(state, &dest_state, word_sz, context);
+      if (obj_ptr == NULL) {
+        // This will either forward-to-self, or detect that someone else has
+        // installed a forwarding pointer.
+        return _g1h->handle_evacuation_failure_par(this, old);
+      }
+    }
+  }
+
+  assert(obj_ptr != NULL, "when we get here, allocation should have succeeded");
 #ifndef PRODUCT
   // Should this evacuation fail?
   if (_g1h->evacuation_should_fail()) {
-    if (obj_ptr != NULL) {
-      _g1_par_allocator->undo_allocation(alloc_purpose, obj_ptr, word_sz, context);
-      obj_ptr = NULL;
-    }
+    // Doing this after all the allocation attempts also tests the
+    // undo_allocation() method too.
+    _g1_par_allocator->undo_allocation(dest_state, obj_ptr, word_sz, context);
+    return _g1h->handle_evacuation_failure_par(this, old);
   }
 #endif // !PRODUCT
 
-  if (obj_ptr == NULL) {
-    // This will either forward-to-self, or detect that someone else has
-    // installed a forwarding pointer.
-    return _g1h->handle_evacuation_failure_par(this, old);
-  }
-
-  oop obj = oop(obj_ptr);
-
   // We're going to allocate linearly, so might as well prefetch ahead.
   Prefetch::write(obj_ptr, PrefetchCopyIntervalInBytes);
 
-  oop forward_ptr = old->forward_to_atomic(obj);
+  const oop obj = oop(obj_ptr);
+  const oop forward_ptr = old->forward_to_atomic(obj);
   if (forward_ptr == NULL) {
     Copy::aligned_disjoint_words((HeapWord*) old, obj_ptr, word_sz);
 
-    // alloc_purpose is just a hint to allocate() above, recheck the type of region
-    // we actually allocated from and update alloc_purpose accordingly
-    HeapRegion* to_region = _g1h->heap_region_containing_raw(obj_ptr);
-    alloc_purpose = to_region->is_young() ? GCAllocForSurvived : GCAllocForTenured;
-
-    if (g1p->track_object_age(alloc_purpose)) {
+    if (dest_state.is_young()) {
       if (age < markOopDesc::max_age) {
         age++;
       }
@@ -215,13 +264,19 @@
     }
 
     if (G1StringDedup::is_enabled()) {
-      G1StringDedup::enqueue_from_evacuation(from_region->is_young(),
-                                             to_region->is_young(),
+      const bool is_from_young = state.is_young();
+      const bool is_to_young = dest_state.is_young();
+      assert(is_from_young == _g1h->heap_region_containing_raw(old)->is_young(),
+             "sanity");
+      assert(is_to_young == _g1h->heap_region_containing_raw(obj)->is_young(),
+             "sanity");
+      G1StringDedup::enqueue_from_evacuation(is_from_young,
+                                             is_to_young,
                                              queue_num(),
                                              obj);
     }
 
-    size_t* surv_young_words = surviving_young_words();
+    size_t* const surv_young_words = surviving_young_words();
     surv_young_words[young_index] += word_sz;
 
     if (obj->is_objArray() && arrayOop(obj)->length() >= ParGCArrayScanChunk) {
@@ -232,14 +287,13 @@
       oop* old_p = set_partial_array_mask(old);
       push_on_queue(old_p);
     } else {
-      // No point in using the slower heap_region_containing() method,
-      // given that we know obj is in the heap.
-      _scanner.set_region(_g1h->heap_region_containing_raw(obj));
+      HeapRegion* const to_region = _g1h->heap_region_containing_raw(obj_ptr);
+      _scanner.set_region(to_region);
       obj->oop_iterate_backwards(&_scanner);
     }
+    return obj;
   } else {
-    _g1_par_allocator->undo_allocation(alloc_purpose, obj_ptr, word_sz, context);
-    obj = forward_ptr;
+    _g1_par_allocator->undo_allocation(dest_state, obj_ptr, word_sz, context);
+    return forward_ptr;
   }
-  return obj;
 }
--- a/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -46,14 +46,16 @@
   G1SATBCardTableModRefBS* _ct_bs;
   G1RemSet* _g1_rem;
 
-  G1ParGCAllocator*   _g1_par_allocator;
-
-  ageTable            _age_table;
+  G1ParGCAllocator* _g1_par_allocator;
 
-  G1ParScanClosure    _scanner;
+  ageTable          _age_table;
+  InCSetState       _dest[InCSetState::Num];
+  // Local tenuring threshold.
+  uint              _tenuring_threshold;
+  G1ParScanClosure  _scanner;
 
-  size_t           _alloc_buffer_waste;
-  size_t           _undo_waste;
+  size_t            _alloc_buffer_waste;
+  size_t            _undo_waste;
 
   OopsInHeapRegionClosure*      _evac_failure_cl;
 
@@ -82,6 +84,14 @@
   DirtyCardQueue& dirty_card_queue()             { return _dcq;  }
   G1SATBCardTableModRefBS* ctbs()                { return _ct_bs; }
 
+  InCSetState dest(InCSetState original) const {
+    assert(original.is_valid(),
+           err_msg("Original state invalid: " CSETSTATE_FORMAT, original.value()));
+    assert(_dest[original.value()].is_valid_gen(),
+           err_msg("Dest state is invalid: " CSETSTATE_FORMAT, _dest[original.value()].value()));
+    return _dest[original.value()];
+  }
+
  public:
   G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp);
   ~G1ParScanThreadState();
@@ -112,7 +122,6 @@
       }
     }
   }
- public:
 
   void set_evac_failure_closure(OopsInHeapRegionClosure* evac_failure_cl) {
     _evac_failure_cl = evac_failure_cl;
@@ -193,9 +202,20 @@
   template <class T> inline void deal_with_reference(T* ref_to_scan);
 
   inline void dispatch_reference(StarTask ref);
+
+  // Tries to allocate word_sz in the PLAB of the next "generation" after trying to
+  // allocate into dest. State is the original (source) cset state for the object
+  // that is allocated for.
+  // Returns a non-NULL pointer if successful, and updates dest if required.
+  HeapWord* allocate_in_next_plab(InCSetState const state,
+                                  InCSetState* dest,
+                                  size_t word_sz,
+                                  AllocationContext_t const context);
+
+  inline InCSetState next_state(InCSetState const state, markOop const m, uint& age);
  public:
 
-  oop copy_to_survivor_space(oop const obj, markOop const old_mark);
+  oop copy_to_survivor_space(InCSetState const state, oop const obj, markOop const old_mark);
 
   void trim_queue();
 
--- a/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.inline.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.inline.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -38,21 +38,21 @@
   // set, due to (benign) races in the claim mechanism during RSet scanning more
   // than one thread might claim the same card. So the same card may be
   // processed multiple times. So redo this check.
-  G1CollectedHeap::in_cset_state_t in_cset_state = _g1h->in_cset_state(obj);
-  if (in_cset_state == G1CollectedHeap::InCSet) {
+  const InCSetState in_cset_state = _g1h->in_cset_state(obj);
+  if (in_cset_state.is_in_cset()) {
     oop forwardee;
     markOop m = obj->mark();
     if (m->is_marked()) {
       forwardee = (oop) m->decode_pointer();
     } else {
-      forwardee = copy_to_survivor_space(obj, m);
+      forwardee = copy_to_survivor_space(in_cset_state, obj, m);
     }
     oopDesc::encode_store_heap_oop(p, forwardee);
-  } else if (in_cset_state == G1CollectedHeap::IsHumongous) {
+  } else if (in_cset_state.is_humongous()) {
     _g1h->set_humongous_is_live(obj);
   } else {
-    assert(in_cset_state == G1CollectedHeap::InNeither,
-           err_msg("In_cset_state must be InNeither here, but is %d", in_cset_state));
+    assert(!in_cset_state.is_in_cset_or_humongous(),
+           err_msg("In_cset_state must be NotInCSet here, but is " CSETSTATE_FORMAT, in_cset_state.value()));
   }
 
   assert(obj != NULL, "Must be");
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -80,7 +80,7 @@
     _prev_period_summary()
 {
   _seq_task = new SubTasksDone(NumSeqTasks);
-  _cset_rs_update_cl = NEW_C_HEAP_ARRAY(OopsInHeapRegionClosure*, n_workers(), mtGC);
+  _cset_rs_update_cl = NEW_C_HEAP_ARRAY(G1ParPushHeapRSClosure*, n_workers(), mtGC);
   for (uint i = 0; i < n_workers(); i++) {
     _cset_rs_update_cl[i] = NULL;
   }
@@ -94,14 +94,14 @@
   for (uint i = 0; i < n_workers(); i++) {
     assert(_cset_rs_update_cl[i] == NULL, "it should be");
   }
-  FREE_C_HEAP_ARRAY(OopsInHeapRegionClosure*, _cset_rs_update_cl);
+  FREE_C_HEAP_ARRAY(G1ParPushHeapRSClosure*, _cset_rs_update_cl);
 }
 
 class ScanRSClosure : public HeapRegionClosure {
   size_t _cards_done, _cards;
   G1CollectedHeap* _g1h;
 
-  OopsInHeapRegionClosure* _oc;
+  G1ParPushHeapRSClosure* _oc;
   CodeBlobClosure* _code_root_cl;
 
   G1BlockOffsetSharedArray* _bot_shared;
@@ -113,7 +113,7 @@
   bool   _try_claimed;
 
 public:
-  ScanRSClosure(OopsInHeapRegionClosure* oc,
+  ScanRSClosure(G1ParPushHeapRSClosure* oc,
                 CodeBlobClosure* code_root_cl,
                 uint worker_i) :
     _oc(oc),
@@ -135,8 +135,7 @@
   void scanCard(size_t index, HeapRegion *r) {
     // Stack allocate the DirtyCardToOopClosure instance
     HeapRegionDCTOC cl(_g1h, r, _oc,
-                       CardTableModRefBS::Precise,
-                       HeapRegionDCTOC::IntoCSFilterKind);
+                       CardTableModRefBS::Precise);
 
     // Set the "from" region in the closure.
     _oc->set_region(r);
@@ -231,7 +230,7 @@
   size_t cards_looked_up() { return _cards;}
 };
 
-void G1RemSet::scanRS(OopsInHeapRegionClosure* oc,
+void G1RemSet::scanRS(G1ParPushHeapRSClosure* oc,
                       CodeBlobClosure* code_root_cl,
                       uint worker_i) {
   double rs_time_start = os::elapsedTime();
@@ -301,7 +300,7 @@
   HeapRegionRemSet::cleanup();
 }
 
-void G1RemSet::oops_into_collection_set_do(OopsInHeapRegionClosure* oc,
+void G1RemSet::oops_into_collection_set_do(G1ParPushHeapRSClosure* oc,
                                            CodeBlobClosure* code_root_cl,
                                            uint worker_i) {
 #if CARD_REPEAT_HISTO
@@ -417,7 +416,7 @@
 G1UpdateRSOrPushRefOopClosure::
 G1UpdateRSOrPushRefOopClosure(G1CollectedHeap* g1h,
                               G1RemSet* rs,
-                              OopsInHeapRegionClosure* push_ref_cl,
+                              G1ParPushHeapRSClosure* push_ref_cl,
                               bool record_refs_into_cset,
                               uint worker_i) :
   _g1(g1h), _g1_rem_set(rs), _from(NULL),
@@ -518,7 +517,7 @@
   ct_freq_note_card(_ct_bs->index_for(start));
 #endif
 
-  OopsInHeapRegionClosure* oops_in_heap_closure = NULL;
+  G1ParPushHeapRSClosure* oops_in_heap_closure = NULL;
   if (check_for_refs_into_cset) {
     // ConcurrentG1RefineThreads have worker numbers larger than what
     // _cset_rs_update_cl[] is set up to handle. But those threads should
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -33,6 +33,7 @@
 class G1CollectedHeap;
 class CardTableModRefBarrierSet;
 class ConcurrentG1Refine;
+class G1ParPushHeapRSClosure;
 
 // A G1RemSet in which each heap region has a rem set that records the
 // external heap references into it.  Uses a mod ref bs to track updates,
@@ -68,7 +69,7 @@
 
   // Used for caching the closure that is responsible for scanning
   // references into the collection set.
-  OopsInHeapRegionClosure** _cset_rs_update_cl;
+  G1ParPushHeapRSClosure** _cset_rs_update_cl;
 
   // Print the given summary info
   virtual void print_summary_info(G1RemSetSummary * summary, const char * header = NULL);
@@ -95,7 +96,7 @@
   // partitioning the work to be done. It should be the same as
   // the "i" passed to the calling thread's work(i) function.
   // In the sequential case this param will be ignored.
-  void oops_into_collection_set_do(OopsInHeapRegionClosure* blk,
+  void oops_into_collection_set_do(G1ParPushHeapRSClosure* blk,
                                    CodeBlobClosure* code_root_cl,
                                    uint worker_i);
 
@@ -107,7 +108,7 @@
   void prepare_for_oops_into_collection_set_do();
   void cleanup_after_oops_into_collection_set_do();
 
-  void scanRS(OopsInHeapRegionClosure* oc,
+  void scanRS(G1ParPushHeapRSClosure* oc,
               CodeBlobClosure* code_root_cl,
               uint worker_i);
 
--- a/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,7 @@
 #include "runtime/thread.inline.hpp"
 
 G1SATBCardTableModRefBS::G1SATBCardTableModRefBS(MemRegion whole_heap) :
-    CardTableModRefBSForCTRS(whole_heap)
+    CardTableModRefBS(whole_heap)
 {
   _kind = G1SATBCT;
 }
--- a/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
 // This barrier is specialized to use a logging barrier to support
 // snapshot-at-the-beginning marking.
 
-class G1SATBCardTableModRefBS: public CardTableModRefBSForCTRS {
+class G1SATBCardTableModRefBS: public CardTableModRefBS {
 protected:
   enum G1CardValues {
     g1_young_gen = CT_MR_BS_last_reserved << 1
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -48,93 +48,55 @@
 size_t HeapRegion::CardsPerRegion    = 0;
 
 HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
-                                 HeapRegion* hr, ExtendedOopClosure* cl,
-                                 CardTableModRefBS::PrecisionStyle precision,
-                                 FilterKind fk) :
+                                 HeapRegion* hr,
+                                 G1ParPushHeapRSClosure* cl,
+                                 CardTableModRefBS::PrecisionStyle precision) :
   DirtyCardToOopClosure(hr, cl, precision, NULL),
-  _hr(hr), _fk(fk), _g1(g1) { }
+  _hr(hr), _rs_scan(cl), _g1(g1) { }
 
 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
                                                    OopClosure* oc) :
   _r_bottom(r->bottom()), _r_end(r->end()), _oc(oc) { }
 
-template<class ClosureType>
-HeapWord* walk_mem_region_loop(ClosureType* cl, G1CollectedHeap* g1h,
-                               HeapRegion* hr,
-                               HeapWord* cur, HeapWord* top) {
-  oop cur_oop = oop(cur);
-  size_t oop_size = hr->block_size(cur);
-  HeapWord* next_obj = cur + oop_size;
-  while (next_obj < top) {
-    // Keep filtering the remembered set.
-    if (!g1h->is_obj_dead(cur_oop, hr)) {
-      // Bottom lies entirely below top, so we can call the
-      // non-memRegion version of oop_iterate below.
-      cur_oop->oop_iterate(cl);
-    }
-    cur = next_obj;
-    cur_oop = oop(cur);
-    oop_size = hr->block_size(cur);
-    next_obj = cur + oop_size;
-  }
-  return cur;
-}
-
 void HeapRegionDCTOC::walk_mem_region(MemRegion mr,
                                       HeapWord* bottom,
                                       HeapWord* top) {
   G1CollectedHeap* g1h = _g1;
   size_t oop_size;
-  ExtendedOopClosure* cl2 = NULL;
-
-  FilterIntoCSClosure intoCSFilt(this, g1h, _cl);
-  FilterOutOfRegionClosure outOfRegionFilt(_hr, _cl);
-
-  switch (_fk) {
-  case NoFilterKind:          cl2 = _cl; break;
-  case IntoCSFilterKind:      cl2 = &intoCSFilt; break;
-  case OutOfRegionFilterKind: cl2 = &outOfRegionFilt; break;
-  default:                    ShouldNotReachHere();
-  }
+  HeapWord* cur = bottom;
 
   // Start filtering what we add to the remembered set. If the object is
   // not considered dead, either because it is marked (in the mark bitmap)
   // or it was allocated after marking finished, then we add it. Otherwise
   // we can safely ignore the object.
-  if (!g1h->is_obj_dead(oop(bottom), _hr)) {
-    oop_size = oop(bottom)->oop_iterate(cl2, mr);
+  if (!g1h->is_obj_dead(oop(cur), _hr)) {
+    oop_size = oop(cur)->oop_iterate(_rs_scan, mr);
   } else {
-    oop_size = _hr->block_size(bottom);
+    oop_size = _hr->block_size(cur);
   }
 
-  bottom += oop_size;
-
-  if (bottom < top) {
-    // We replicate the loop below for several kinds of possible filters.
-    switch (_fk) {
-    case NoFilterKind:
-      bottom = walk_mem_region_loop(_cl, g1h, _hr, bottom, top);
-      break;
+  cur += oop_size;
 
-    case IntoCSFilterKind: {
-      FilterIntoCSClosure filt(this, g1h, _cl);
-      bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top);
-      break;
-    }
-
-    case OutOfRegionFilterKind: {
-      FilterOutOfRegionClosure filt(_hr, _cl);
-      bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top);
-      break;
-    }
-
-    default:
-      ShouldNotReachHere();
+  if (cur < top) {
+    oop cur_oop = oop(cur);
+    oop_size = _hr->block_size(cur);
+    HeapWord* next_obj = cur + oop_size;
+    while (next_obj < top) {
+      // Keep filtering the remembered set.
+      if (!g1h->is_obj_dead(cur_oop, _hr)) {
+        // Bottom lies entirely below top, so we can call the
+        // non-memRegion version of oop_iterate below.
+        cur_oop->oop_iterate(_rs_scan);
+      }
+      cur = next_obj;
+      cur_oop = oop(cur);
+      oop_size = _hr->block_size(cur);
+      next_obj = cur + oop_size;
     }
 
     // Last object. Need to do dead-obj filtering here too.
-    if (!g1h->is_obj_dead(oop(bottom), _hr)) {
-      oop(bottom)->oop_iterate(cl2, mr);
+    if (!g1h->is_obj_dead(oop(cur), _hr)) {
+      oop(cur)->oop_iterate(_rs_scan, mr);
     }
   }
 }
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -67,17 +67,9 @@
 // sets.
 
 class HeapRegionDCTOC : public DirtyCardToOopClosure {
-public:
-  // Specification of possible DirtyCardToOopClosure filtering.
-  enum FilterKind {
-    NoFilterKind,
-    IntoCSFilterKind,
-    OutOfRegionFilterKind
-  };
-
-protected:
+private:
   HeapRegion* _hr;
-  FilterKind _fk;
+  G1ParPushHeapRSClosure* _rs_scan;
   G1CollectedHeap* _g1;
 
   // Walk the given memory region from bottom to (actual) top
@@ -90,9 +82,9 @@
 
 public:
   HeapRegionDCTOC(G1CollectedHeap* g1,
-                  HeapRegion* hr, ExtendedOopClosure* cl,
-                  CardTableModRefBS::PrecisionStyle precision,
-                  FilterKind fk);
+                  HeapRegion* hr,
+                  G1ParPushHeapRSClosure* cl,
+                  CardTableModRefBS::PrecisionStyle precision);
 };
 
 // The complicating factor is that BlockOffsetTable diverged
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -805,7 +805,7 @@
 HeapRegionRemSet::HeapRegionRemSet(G1BlockOffsetSharedArray* bosa,
                                    HeapRegion* hr)
   : _bosa(bosa),
-    _m(Mutex::leaf, FormatBuffer<128>("HeapRegionRemSet lock #%u", hr->hrm_index()), true),
+    _m(Mutex::leaf, FormatBuffer<128>("HeapRegionRemSet lock #%u", hr->hrm_index()), true, Monitor::_safepoint_check_never),
     _code_roots(), _other_regions(hr, &_m), _iter_state(Unclaimed), _iter_claimed(0) {
   reset_for_par_iteration();
 }
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/gcTaskManager.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/gcTaskManager.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -400,7 +400,8 @@
   assert(workers() != 0, "no workers");
   _monitor = new Monitor(Mutex::barrier,                // rank
                          "GCTaskManager monitor",       // name
-                         Mutex::_allow_vm_block_flag);  // allow_vm_block
+                         Mutex::_allow_vm_block_flag,   // allow_vm_block
+                         Monitor::_safepoint_check_never);
   // The queue for the GCTaskManager must be a CHeapObj.
   GCTaskQueue* unsynchronized_queue = GCTaskQueue::create_on_c_heap();
   _queue = SynchronizedGCTaskQueue::create(unsynchronized_queue, lock());
@@ -1125,7 +1126,8 @@
     } else {
       result = new Monitor(Mutex::barrier,                  // rank
                            "MonitorSupply monitor",         // name
-                           Mutex::_allow_vm_block_flag);    // allow_vm_block
+                           Mutex::_allow_vm_block_flag,     // allow_vm_block
+                           Monitor::_safepoint_check_never);
     }
     guarantee(result != NULL, "shouldn't return NULL");
     assert(!result->is_locked(), "shouldn't be locked");
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -195,7 +195,7 @@
 
     COMPILER2_PRESENT(DerivedPointerTable::clear());
 
-    ref_processor()->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
+    ref_processor()->enable_discovery();
     ref_processor()->setup_policy(clear_all_softrefs);
 
     mark_sweep_phase1(clear_all_softrefs);
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -41,31 +41,24 @@
 
   // Closure accessors
   static OopClosure* mark_and_push_closure()   { return &MarkSweep::mark_and_push_closure; }
-  static VoidClosure* follow_stack_closure()   { return (VoidClosure*)&MarkSweep::follow_stack_closure; }
+  static VoidClosure* follow_stack_closure()   { return &MarkSweep::follow_stack_closure; }
   static CLDClosure* follow_cld_closure()      { return &MarkSweep::follow_cld_closure; }
-  static OopClosure* adjust_pointer_closure()  { return (OopClosure*)&MarkSweep::adjust_pointer_closure; }
+  static OopClosure* adjust_pointer_closure()  { return &MarkSweep::adjust_pointer_closure; }
   static CLDClosure* adjust_cld_closure()      { return &MarkSweep::adjust_cld_closure; }
-  static BoolObjectClosure* is_alive_closure() { return (BoolObjectClosure*)&MarkSweep::is_alive; }
+  static BoolObjectClosure* is_alive_closure() { return &MarkSweep::is_alive; }
 
- debug_only(public:)  // Used for PSParallelCompact debugging
   // Mark live objects
   static void mark_sweep_phase1(bool clear_all_softrefs);
   // Calculate new addresses
   static void mark_sweep_phase2();
- debug_only(private:) // End used for PSParallelCompact debugging
   // Update pointers
   static void mark_sweep_phase3();
   // Move objects to new positions
   static void mark_sweep_phase4();
 
- debug_only(public:)  // Used for PSParallelCompact debugging
   // Temporary data structures for traversal and storing/restoring marks
   static void allocate_stacks();
   static void deallocate_stacks();
-  static void set_ref_processor(ReferenceProcessor* rp) {  // delete this method
-    _ref_processor = rp;
-  }
- debug_only(private:) // End used for PSParallelCompact debugging
 
   // If objects are left in eden after a collection, try to move the boundary
   // and absorb them into the old gen.  Returns true if eden was emptied.
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -2069,7 +2069,7 @@
 
     COMPILER2_PRESENT(DerivedPointerTable::clear());
 
-    ref_processor()->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
+    ref_processor()->enable_discovery();
     ref_processor()->setup_policy(maximum_heap_compaction);
 
     bool marked_for_unloading = false;
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -147,6 +147,10 @@
     claimed_stack_depth()->push(p);
   }
 
+  inline void promotion_trace_event(oop new_obj, oop old_obj, size_t obj_size,
+                                    uint age, bool tenured,
+                                    const PSPromotionLAB* lab);
+
  protected:
   static OopStarTaskQueueSet* stack_array_depth()   { return _stack_array_depth; }
  public:
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -64,6 +64,33 @@
   claim_or_forward_internal_depth(p);
 }
 
+inline void PSPromotionManager::promotion_trace_event(oop new_obj, oop old_obj,
+                                                      size_t obj_size,
+                                                      uint age, bool tenured,
+                                                      const PSPromotionLAB* lab) {
+  // Skip if memory allocation failed
+  if (new_obj != NULL) {
+    const ParallelScavengeTracer* gc_tracer = PSScavenge::gc_tracer();
+
+    if (lab != NULL) {
+      // Promotion of object through newly allocated PLAB
+      if (gc_tracer->should_report_promotion_in_new_plab_event()) {
+        size_t obj_bytes = obj_size * HeapWordSize;
+        size_t lab_size = lab->capacity();
+        gc_tracer->report_promotion_in_new_plab_event(old_obj->klass(), obj_bytes,
+                                                      age, tenured, lab_size);
+      }
+    } else {
+      // Promotion of object directly to heap
+      if (gc_tracer->should_report_promotion_outside_plab_event()) {
+        size_t obj_bytes = obj_size * HeapWordSize;
+        gc_tracer->report_promotion_outside_plab_event(old_obj->klass(), obj_bytes,
+                                                       age, tenured);
+      }
+    }
+  }
+}
+
 //
 // This method is pretty bulky. It would be nice to split it up
 // into smaller submethods, but we need to be careful not to hurt
@@ -85,11 +112,11 @@
     bool new_obj_is_tenured = false;
     size_t new_obj_size = o->size();
 
+    // Find the objects age, MT safe.
+    uint age = (test_mark->has_displaced_mark_helper() /* o->has_displaced_mark() */) ?
+      test_mark->displaced_mark_helper()->age() : test_mark->age();
+
     if (!promote_immediately) {
-      // Find the objects age, MT safe.
-      uint age = (test_mark->has_displaced_mark_helper() /* o->has_displaced_mark() */) ?
-        test_mark->displaced_mark_helper()->age() : test_mark->age();
-
       // Try allocating obj in to-space (unless too old)
       if (age < PSScavenge::tenuring_threshold()) {
         new_obj = (oop) _young_lab.allocate(new_obj_size);
@@ -98,6 +125,7 @@
           if (new_obj_size > (YoungPLABSize / 2)) {
             // Allocate this object directly
             new_obj = (oop)young_space()->cas_allocate(new_obj_size);
+            promotion_trace_event(new_obj, o, new_obj_size, age, false, NULL);
           } else {
             // Flush and fill
             _young_lab.flush();
@@ -107,6 +135,7 @@
               _young_lab.initialize(MemRegion(lab_base, YoungPLABSize));
               // Try the young lab allocation again.
               new_obj = (oop) _young_lab.allocate(new_obj_size);
+              promotion_trace_event(new_obj, o, new_obj_size, age, false, &_young_lab);
             } else {
               _young_gen_is_full = true;
             }
@@ -132,6 +161,7 @@
           if (new_obj_size > (OldPLABSize / 2)) {
             // Allocate this object directly
             new_obj = (oop)old_gen()->cas_allocate(new_obj_size);
+            promotion_trace_event(new_obj, o, new_obj_size, age, true, NULL);
           } else {
             // Flush and fill
             _old_lab.flush();
@@ -148,6 +178,7 @@
               _old_lab.initialize(MemRegion(lab_base, OldPLABSize));
               // Try the old lab allocation again.
               new_obj = (oop) _old_lab.allocate(new_obj_size);
+              promotion_trace_event(new_obj, o, new_obj_size, age, true, &_old_lab);
             }
           }
         }
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -362,7 +362,7 @@
 
     COMPILER2_PRESENT(DerivedPointerTable::clear());
 
-    reference_processor()->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
+    reference_processor()->enable_discovery();
     reference_processor()->setup_policy(false);
 
     // We track how much was promoted to the next generation for
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -92,6 +92,7 @@
 
   // Private accessors
   static CardTableExtension* const card_table()       { assert(_card_table != NULL, "Sanity"); return _card_table; }
+  static const ParallelScavengeTracer* gc_tracer() { return &_gc_tracer; }
 
  public:
   // Accessors
--- a/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -88,7 +88,8 @@
 
 SurrogateLockerThread::SurrogateLockerThread() :
   JavaThread(&_sltLoop),
-  _monitor(Mutex::nonleaf, "SLTMonitor"),
+  _monitor(Mutex::nonleaf, "SLTMonitor", false,
+           Monitor::_safepoint_check_sometimes),
   _buffer(empty)
 {}
 
--- a/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -63,9 +63,7 @@
 }
 
 void MutableSpace::pretouch_pages(MemRegion mr) {
-  for (volatile char *p = (char*)mr.start(); p < (char*)mr.end(); p += os::vm_page_size()) {
-    char t = *p; *p = t;
-  }
+  os::pretouch_memory((char*)mr.start(), (char*)mr.end());
 }
 
 void MutableSpace::initialize(MemRegion mr,
--- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -394,7 +394,11 @@
     // during deoptimization so the interpreter needs to skip it when
     // the frame is popped.
     thread->set_do_not_unlock_if_synchronized(true);
+#ifdef CC_INTERP
+    return (address) -1;
+#else
     return Interpreter::remove_activation_entry();
+#endif
   }
 
   // Need to do this check first since when _do_not_unlock_if_synchronized
--- a/hotspot/src/share/vm/memory/cardTableRS.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/memory/cardTableRS.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -33,24 +33,13 @@
 #include "runtime/java.hpp"
 #include "runtime/os.hpp"
 #include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc_implementation/g1/concurrentMark.hpp"
-#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
-#endif // INCLUDE_ALL_GCS
 
 CardTableRS::CardTableRS(MemRegion whole_heap) :
   GenRemSet(),
   _cur_youngergen_card_val(youngergenP1_card)
 {
-#if INCLUDE_ALL_GCS
-  if (UseG1GC) {
-      _ct_bs = new G1SATBCardTableLoggingModRefBS(whole_heap);
-  } else {
-    _ct_bs = new CardTableModRefBSForCTRS(whole_heap);
-  }
-#else
+  guarantee(Universe::heap()->kind() == CollectedHeap::GenCollectedHeap, "sanity");
   _ct_bs = new CardTableModRefBSForCTRS(whole_heap);
-#endif
   _ct_bs->initialize();
   set_bs(_ct_bs);
   _last_cur_val_in_gen = NEW_C_HEAP_ARRAY3(jbyte, GenCollectedHeap::max_gens + 1,
--- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -70,6 +70,7 @@
 
 GenCollectedHeap::GenCollectedHeap(GenCollectorPolicy *policy) :
   SharedHeap(policy),
+  _rem_set(NULL),
   _gen_policy(policy),
   _gen_process_roots_tasks(new SubTasksDone(GCH_PS_NumElements)),
   _full_collections_completed(0)
@@ -465,7 +466,7 @@
           // atomic wrt other collectors in this configuration, we
           // are guaranteed to have empty discovered ref lists.
           if (rp->discovery_is_atomic()) {
-            rp->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
+            rp->enable_discovery();
             rp->setup_policy(do_clear_all_soft_refs);
           } else {
             // collect() below will enable discovery as appropriate
--- a/hotspot/src/share/vm/memory/genCollectedHeap.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,6 +66,9 @@
   Generation* _gens[max_gens];
   GenerationSpec** _gen_specs;
 
+  // The singleton Gen Remembered Set.
+  GenRemSet* _rem_set;
+
   // The generational collector policy.
   GenCollectorPolicy* _gen_policy;
 
@@ -383,6 +386,10 @@
     return _n_gens;
   }
 
+  // This function returns the "GenRemSet" object that allows us to scan
+  // generations in a fully generational heap.
+  GenRemSet* rem_set() { return _rem_set; }
+
   // Convenience function to be used in situations where the heap type can be
   // asserted to be this type.
   static GenCollectedHeap* heap();
--- a/hotspot/src/share/vm/memory/genOopClosures.inline.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/memory/genOopClosures.inline.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@
   _gen_boundary = _gen->reserved().start();
   // Barrier set for the heap, must be set after heap is initialized
   if (_rs == NULL) {
-    GenRemSet* rs = SharedHeap::heap()->rem_set();
+    GenRemSet* rs = GenCollectedHeap::heap()->rem_set();
     _rs = (CardTableRS*)rs;
   }
 }
--- a/hotspot/src/share/vm/memory/generation.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/memory/generation.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -297,7 +297,7 @@
 
 void Generation::younger_refs_in_space_iterate(Space* sp,
                                                OopsInGenClosure* cl) {
-  GenRemSet* rs = SharedHeap::heap()->rem_set();
+  GenRemSet* rs = GenCollectedHeap::heap()->rem_set();
   rs->younger_refs_in_space_iterate(sp, cl);
 }
 
--- a/hotspot/src/share/vm/memory/metaspace.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/memory/metaspace.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -792,7 +792,8 @@
 Mutex* const SpaceManager::_expand_lock =
   new Mutex(SpaceManager::_expand_lock_rank,
             SpaceManager::_expand_lock_name,
-            Mutex::_allow_vm_block_flag);
+            Mutex::_allow_vm_block_flag,
+            Monitor::_safepoint_check_never);
 
 void VirtualSpaceNode::inc_container_count() {
   assert_lock_strong(SpaceManager::expand_lock());
--- a/hotspot/src/share/vm/memory/referenceProcessor.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/memory/referenceProcessor.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -68,10 +68,10 @@
   _pending_list_uses_discovered_field = JDK_Version::current().pending_list_uses_discovered_field();
 }
 
-void ReferenceProcessor::enable_discovery(bool verify_disabled, bool check_no_refs) {
+void ReferenceProcessor::enable_discovery(bool check_no_refs) {
 #ifdef ASSERT
   // Verify that we're not currently discovering refs
-  assert(!verify_disabled || !_discovering_refs, "nested call?");
+  assert(!_discovering_refs, "nested call?");
 
   if (check_no_refs) {
     // Verify that the discovered lists are empty
@@ -963,52 +963,6 @@
   return total_list_count;
 }
 
-void ReferenceProcessor::clean_up_discovered_references() {
-  // loop over the lists
-  for (uint i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
-    if (TraceReferenceGC && PrintGCDetails && ((i % _max_num_q) == 0)) {
-      gclog_or_tty->print_cr(
-        "\nScrubbing %s discovered list of Null referents",
-        list_name(i));
-    }
-    clean_up_discovered_reflist(_discovered_refs[i]);
-  }
-}
-
-void ReferenceProcessor::clean_up_discovered_reflist(DiscoveredList& refs_list) {
-  assert(!discovery_is_atomic(), "Else why call this method?");
-  DiscoveredListIterator iter(refs_list, NULL, NULL);
-  while (iter.has_next()) {
-    iter.load_ptrs(DEBUG_ONLY(true /* allow_null_referent */));
-    oop next = java_lang_ref_Reference::next(iter.obj());
-    assert(next->is_oop_or_null(), err_msg("Expected an oop or NULL for next field at " PTR_FORMAT, p2i(next)));
-    // If referent has been cleared or Reference is not active,
-    // drop it.
-    if (iter.referent() == NULL || next != NULL) {
-      debug_only(
-        if (PrintGCDetails && TraceReferenceGC) {
-          gclog_or_tty->print_cr("clean_up_discovered_list: Dropping Reference: "
-            INTPTR_FORMAT " with next field: " INTPTR_FORMAT
-            " and referent: " INTPTR_FORMAT,
-            (void *)iter.obj(), (void *)next, (void *)iter.referent());
-        }
-      )
-      // Remove Reference object from list
-      iter.remove();
-      iter.move_to_next();
-    } else {
-      iter.next();
-    }
-  }
-  NOT_PRODUCT(
-    if (PrintGCDetails && TraceReferenceGC) {
-      gclog_or_tty->print(
-        " Removed %d Refs with NULL referents out of %d discovered Refs",
-        iter.removed(), iter.processed());
-    }
-  )
-}
-
 inline DiscoveredList* ReferenceProcessor::get_discovered_list(ReferenceType rt) {
   uint id = 0;
   // Determine the queue index to use for this object.
--- a/hotspot/src/share/vm/memory/referenceProcessor.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/memory/referenceProcessor.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -353,19 +353,6 @@
                                       GCTimer*           gc_timer,
                                       GCId               gc_id);
 
-  // Delete entries in the discovered lists that have
-  // either a null referent or are not active. Such
-  // Reference objects can result from the clearing
-  // or enqueueing of Reference objects concurrent
-  // with their discovery by a (concurrent) collector.
-  // For a definition of "active" see java.lang.ref.Reference;
-  // Refs are born active, become inactive when enqueued,
-  // and never become active again. The state of being
-  // active is encoded as follows: A Ref is active
-  // if and only if its "next" field is NULL.
-  void clean_up_discovered_references();
-  void clean_up_discovered_reflist(DiscoveredList& refs_list);
-
   // Returns the name of the discovered reference list
   // occupying the i / _num_q slot.
   const char* list_name(uint i);
@@ -439,7 +426,7 @@
   void      set_span(MemRegion span) { _span = span; }
 
   // start and stop weak ref discovery
-  void enable_discovery(bool verify_disabled, bool check_no_refs);
+  void enable_discovery(bool check_no_refs = true);
   void disable_discovery()  { _discovering_refs = false; }
   bool discovery_enabled()  { return _discovering_refs;  }
 
@@ -517,7 +504,7 @@
 
   ~NoRefDiscovery() {
     if (_was_discovering_refs) {
-      _rp->enable_discovery(true /*verify_disabled*/, false /*check_no_refs*/);
+      _rp->enable_discovery(false /*check_no_refs*/);
     }
   }
 };
--- a/hotspot/src/share/vm/memory/sharedHeap.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/memory/sharedHeap.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -58,7 +58,6 @@
 SharedHeap::SharedHeap(CollectorPolicy* policy_) :
   CollectedHeap(),
   _collector_policy(policy_),
-  _rem_set(NULL),
   _strong_roots_scope(NULL),
   _strong_roots_parity(0),
   _process_strong_tasks(new SubTasksDone(SH_PS_NumElements)),
@@ -152,7 +151,7 @@
   }
 }
 
-Monitor* SharedHeap::StrongRootsScope::_lock = new Monitor(Mutex::leaf, "StrongRootsScope lock", false);
+Monitor* SharedHeap::StrongRootsScope::_lock = new Monitor(Mutex::leaf, "StrongRootsScope lock", false, Monitor::_safepoint_check_never);
 
 void SharedHeap::StrongRootsScope::mark_worker_done_with_threads(uint n_workers) {
   // The Thread work barrier is only needed by G1 Class Unloading.
--- a/hotspot/src/share/vm/memory/sharedHeap.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/memory/sharedHeap.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -114,10 +114,6 @@
   // set the static pointer "_sh" to that instance.
   static SharedHeap* _sh;
 
-  // and the Gen Remembered Set, at least one good enough to scan the perm
-  // gen.
-  GenRemSet* _rem_set;
-
   // A gc policy, controls global gc resource issues
   CollectorPolicy *_collector_policy;
 
@@ -152,10 +148,6 @@
   // Initialization of ("weak") reference processing support
   virtual void ref_processing_init();
 
-  // This function returns the "GenRemSet" object that allows us to scan
-  // generations in a fully generational heap.
-  GenRemSet* rem_set() { return _rem_set; }
-
   // Iteration functions.
   void oop_iterate(ExtendedOopClosure* cl) = 0;
 
--- a/hotspot/src/share/vm/memory/tenuredGeneration.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/memory/tenuredGeneration.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -28,6 +28,7 @@
 #include "gc_implementation/shared/parGCAllocBuffer.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/blockOffsetTable.inline.hpp"
+#include "memory/cardGeneration.inline.hpp"
 #include "memory/generationSpec.hpp"
 #include "memory/genMarkSweep.hpp"
 #include "memory/genOopClosures.inline.hpp"
--- a/hotspot/src/share/vm/opto/callnode.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/opto/callnode.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -658,7 +658,7 @@
 
 void CallNode::dump_spec(outputStream *st) const {
   st->print(" ");
-  tf()->dump_on(st);
+  if (tf() != NULL)  tf()->dump_on(st);
   if (_cnt != COUNT_UNKNOWN)  st->print(" C=%f",_cnt);
   if (jvms() != NULL)  jvms()->dump_spec(st);
 }
--- a/hotspot/src/share/vm/opto/lcm.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/opto/lcm.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -417,8 +417,15 @@
   for (DUIterator_Last i2min, i2 = old_tst->last_outs(i2min); i2 >= i2min; --i2)
     old_tst->last_out(i2)->set_req(0, nul_chk);
   // Clean-up any dead code
-  for (uint i3 = 0; i3 < old_tst->req(); i3++)
+  for (uint i3 = 0; i3 < old_tst->req(); i3++) {
+    Node* in = old_tst->in(i3);
     old_tst->set_req(i3, NULL);
+    if (in->outcnt() == 0) {
+      // Remove dead input node
+      in->disconnect_inputs(NULL, C);
+      block->find_remove(in);
+    }
+  }
 
   latency_from_uses(nul_chk);
   latency_from_uses(best);
--- a/hotspot/src/share/vm/opto/loopnode.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/opto/loopnode.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1147,7 +1147,7 @@
 // Dump special per-node info
 #ifndef PRODUCT
 void CountedLoopEndNode::dump_spec(outputStream *st) const {
-  if( in(TestValue)->is_Bool() ) {
+  if( in(TestValue) != NULL && in(TestValue)->is_Bool() ) {
     BoolTest bt( test_trip()); // Added this for g++.
 
     st->print("[");
--- a/hotspot/src/share/vm/opto/machnode.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/opto/machnode.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -473,8 +473,13 @@
 // Print any per-operand special info
 void MachNode::dump_spec(outputStream *st) const {
   uint cnt = num_opnds();
-  for( uint i=0; i<cnt; i++ )
-    _opnds[i]->dump_spec(st);
+  for( uint i=0; i<cnt; i++ ) {
+    if (_opnds[i] != NULL) {
+      _opnds[i]->dump_spec(st);
+    } else {
+      st->print(" _");
+    }
+  }
   const TypePtr *t = adr_type();
   if( t ) {
     Compile* C = Compile::current();
@@ -493,7 +498,11 @@
 //=============================================================================
 #ifndef PRODUCT
 void MachTypeNode::dump_spec(outputStream *st) const {
-  _bottom_type->dump_on(st);
+  if (_bottom_type != NULL) {
+    _bottom_type->dump_on(st);
+  } else {
+    st->print(" NULL");
+  }
 }
 #endif
 
@@ -635,7 +644,7 @@
 #ifndef PRODUCT
 void MachCallNode::dump_spec(outputStream *st) const {
   st->print("# ");
-  tf()->dump_on(st);
+  if (tf() != NULL)  tf()->dump_on(st);
   if (_cnt != COUNT_UNKNOWN)  st->print(" C=%f",_cnt);
   if (jvms() != NULL)  jvms()->dump_spec(st);
 }
--- a/hotspot/src/share/vm/opto/memnode.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/opto/memnode.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -4370,7 +4370,7 @@
   st->print(" {");
   Node* base_mem = base_memory();
   for( uint i = Compile::AliasIdxRaw; i < req(); i++ ) {
-    Node* mem = memory_at(i);
+    Node* mem = (in(i) != NULL) ? memory_at(i) : base_mem;
     if (mem == base_mem) { st->print(" -"); continue; }
     st->print( " N%d:", mem->_idx );
     Compile::current()->get_adr_type(i)->dump_on(st);
--- a/hotspot/src/share/vm/prims/jvm.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/prims/jvm.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -700,23 +700,7 @@
 
 // Returns a class loaded by the bootstrap class loader; or null
 // if not found.  ClassNotFoundException is not thrown.
-//
-// Rationale behind JVM_FindClassFromBootLoader
-// a> JVM_FindClassFromClassLoader was never exported in the export tables.
-// b> because of (a) java.dll has a direct dependecy on the  unexported
-//    private symbol "_JVM_FindClassFromClassLoader@20".
-// c> the launcher cannot use the private symbol as it dynamically opens
-//    the entry point, so if something changes, the launcher will fail
-//    unexpectedly at runtime, it is safest for the launcher to dlopen a
-//    stable exported interface.
-// d> re-exporting JVM_FindClassFromClassLoader as public, will cause its
-//    signature to change from _JVM_FindClassFromClassLoader@20 to
-//    JVM_FindClassFromClassLoader and will not be backward compatible
-//    with older JDKs.
-// Thus a public/stable exported entry point is the right solution,
-// public here means public in linker semantics, and is exported only
-// to the JDK, and is not intended to be a public API.
-
+// FindClassFromBootLoader is exported to the launcher for windows.
 JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env,
                                               const char* name))
   JVMWrapper2("JVM_FindClassFromBootLoader %s", name);
@@ -740,33 +724,6 @@
   return (jclass) JNIHandles::make_local(env, k->java_mirror());
 JVM_END
 
-// Not used; JVM_FindClassFromCaller replaces this.
-JVM_ENTRY(jclass, JVM_FindClassFromClassLoader(JNIEnv* env, const char* name,
-                                               jboolean init, jobject loader,
-                                               jboolean throwError))
-  JVMWrapper3("JVM_FindClassFromClassLoader %s throw %s", name,
-               throwError ? "error" : "exception");
-  // Java libraries should ensure that name is never null...
-  if (name == NULL || (int)strlen(name) > Symbol::max_length()) {
-    // It's impossible to create this class;  the name cannot fit
-    // into the constant pool.
-    if (throwError) {
-      THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name);
-    } else {
-      THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name);
-    }
-  }
-  TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL);
-  Handle h_loader(THREAD, JNIHandles::resolve(loader));
-  jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
-                                               Handle(), throwError, THREAD);
-
-  if (TraceClassResolution && result != NULL) {
-    trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
-  }
-  return result;
-JVM_END
-
 // Find a class with this name in this loader, using the caller's protection domain.
 JVM_ENTRY(jclass, JVM_FindClassFromCaller(JNIEnv* env, const char* name,
                                           jboolean init, jobject loader,
--- a/hotspot/src/share/vm/prims/jvm.h	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/prims/jvm.h	Wed Jul 05 20:13:05 2017 +0200
@@ -335,15 +335,6 @@
 JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
 
 /*
- * Find a class from a given class loader. Throw ClassNotFoundException
- * or NoClassDefFoundError depending on the value of the last
- * argument.
- */
-JNIEXPORT jclass JNICALL
-JVM_FindClassFromClassLoader(JNIEnv *env, const char *name, jboolean init,
-                             jobject loader, jboolean throwError);
-
-/*
  * Find a class from a boot class loader. Returns NULL if class not found.
  */
 JNIEXPORT jclass JNICALL
--- a/hotspot/src/share/vm/prims/whitebox.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/prims/whitebox.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -69,6 +69,14 @@
 bool WhiteBox::_used = false;
 volatile bool WhiteBox::compilation_locked = false;
 
+class VM_WhiteBoxOperation : public VM_Operation {
+ public:
+  VM_WhiteBoxOperation()                         { }
+  VMOp_Type type()                  const        { return VMOp_WhiteBoxOperation; }
+  bool allow_nested_vm_operations() const        { return true; }
+};
+
+
 WB_ENTRY(jlong, WB_GetObjectAddress(JNIEnv* env, jobject o, jobject obj))
   return (jlong)(void*)JNIHandles::resolve(obj);
 WB_END
@@ -404,6 +412,43 @@
   return env->FromReflectedMethod(method);
 }
 
+// Deoptimizes all compiled frames and makes nmethods not entrant if it's requested
+class VM_WhiteBoxDeoptimizeFrames : public VM_WhiteBoxOperation {
+ private:
+  int _result;
+  const bool _make_not_entrant;
+ public:
+  VM_WhiteBoxDeoptimizeFrames(bool make_not_entrant) :
+        _result(0), _make_not_entrant(make_not_entrant) { }
+  int  result() const { return _result; }
+
+  void doit() {
+    for (JavaThread* t = Threads::first(); t != NULL; t = t->next()) {
+      if (t->has_last_Java_frame()) {
+        for (StackFrameStream fst(t, UseBiasedLocking); !fst.is_done(); fst.next()) {
+          frame* f = fst.current();
+          if (f->can_be_deoptimized() && !f->is_deoptimized_frame()) {
+            RegisterMap* reg_map = fst.register_map();
+            Deoptimization::deoptimize(t, *f, reg_map);
+            if (_make_not_entrant) {
+                nmethod* nm = CodeCache::find_nmethod(f->pc());
+                assert(nm != NULL, "sanity check");
+                nm->make_not_entrant();
+            }
+            ++_result;
+          }
+        }
+      }
+    }
+  }
+};
+
+WB_ENTRY(jint, WB_DeoptimizeFrames(JNIEnv* env, jobject o, jboolean make_not_entrant))
+  VM_WhiteBoxDeoptimizeFrames op(make_not_entrant == JNI_TRUE);
+  VMThread::execute(&op);
+  return op.result();
+WB_END
+
 WB_ENTRY(void, WB_DeoptimizeAll(JNIEnv* env, jobject o))
   MutexLockerEx mu(Compile_lock);
   CodeCache::mark_all_nmethods_for_deoptimization();
@@ -526,13 +571,6 @@
   return (mh->queued_for_compilation() || nm != NULL);
 WB_END
 
-class VM_WhiteBoxOperation : public VM_Operation {
- public:
-  VM_WhiteBoxOperation()                         { }
-  VMOp_Type type()                  const        { return VMOp_WhiteBoxOperation; }
-  bool allow_nested_vm_operations() const        { return true; }
-};
-
 class AlwaysFalseClosure : public BoolObjectClosure {
  public:
   bool do_object_b(oop p) { return false; }
@@ -761,7 +799,6 @@
   }
 WB_END
 
-
 WB_ENTRY(void, WB_LockCompilation(JNIEnv* env, jobject o, jlong timeout))
   WhiteBox::compilation_locked = true;
 WB_END
@@ -1078,6 +1115,14 @@
   return (jlong) MetaspaceGC::capacity_until_GC();
 WB_END
 
+WB_ENTRY(void, WB_AssertMatchingSafepointCalls(JNIEnv* env, jobject o, jboolean mutexSafepointValue, jboolean attemptedNoSafepointValue))
+  Monitor::SafepointCheckRequired sfpt_check_required = mutexSafepointValue ?
+                                           Monitor::_safepoint_check_always :
+                                           Monitor::_safepoint_check_never;
+  MutexLockerEx ml(new Mutex(Mutex::leaf, "SFPT_Test_lock", true, sfpt_check_required),
+                   attemptedNoSafepointValue == JNI_TRUE);
+WB_END
+
 //Some convenience methods to deal with objects from java
 int WhiteBox::offset_for_field(const char* field_name, oop object,
     Symbol* signature_symbol) {
@@ -1201,6 +1246,7 @@
   {CC"NMTChangeTrackingLevel", CC"()Z",               (void*)&WB_NMTChangeTrackingLevel},
   {CC"NMTGetHashSize",      CC"()I",                  (void*)&WB_NMTGetHashSize     },
 #endif // INCLUDE_NMT
+  {CC"deoptimizeFrames",   CC"(Z)I",                  (void*)&WB_DeoptimizeFrames  },
   {CC"deoptimizeAll",      CC"()V",                   (void*)&WB_DeoptimizeAll     },
   {CC"deoptimizeMethod",   CC"(Ljava/lang/reflect/Executable;Z)I",
                                                       (void*)&WB_DeoptimizeMethod  },
@@ -1274,6 +1320,7 @@
   {CC"getCodeBlob",        CC"(J)[Ljava/lang/Object;",(void*)&WB_GetCodeBlob        },
   {CC"getThreadStackSize", CC"()J",                   (void*)&WB_GetThreadStackSize },
   {CC"getThreadRemainingStackSize", CC"()J",          (void*)&WB_GetThreadRemainingStackSize },
+  {CC"assertMatchingSafepointCalls", CC"(ZZ)V",       (void*)&WB_AssertMatchingSafepointCalls },
 };
 
 #undef CC
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -925,9 +925,9 @@
                     "Warning: support for %s was removed in %s\n",
                     fuzzy_matched->_name,
                     version);
-      }
     }
   }
+  }
 
   // allow for commandline "commenting out" options like -XX:#+Verbose
   return arg[0] == '#';
@@ -1382,41 +1382,24 @@
   if (FLAG_IS_DEFAULT(SurvivorRatio) && MaxTenuringThreshold == 0) {
     FLAG_SET_ERGO(uintx, SurvivorRatio, MAX2((uintx)1024, SurvivorRatio));
   }
-  // If OldPLABSize is set and CMSParPromoteBlocksToClaim is not,
-  // set CMSParPromoteBlocksToClaim equal to OldPLABSize.
-  // This is done in order to make ParNew+CMS configuration to work
-  // with YoungPLABSize and OldPLABSize options.
-  // See CR 6362902.
-  if (!FLAG_IS_DEFAULT(OldPLABSize)) {
-    if (FLAG_IS_DEFAULT(CMSParPromoteBlocksToClaim)) {
-      // OldPLABSize is not the default value but CMSParPromoteBlocksToClaim
-      // is.  In this situation let CMSParPromoteBlocksToClaim follow
-      // the value (either from the command line or ergonomics) of
-      // OldPLABSize.  Following OldPLABSize is an ergonomics decision.
-      FLAG_SET_ERGO(uintx, CMSParPromoteBlocksToClaim, OldPLABSize);
+
+  // OldPLABSize is interpreted in CMS as not the size of the PLAB in words,
+  // but rather the number of free blocks of a given size that are used when
+  // replenishing the local per-worker free list caches.
+  if (FLAG_IS_DEFAULT(OldPLABSize)) {
+    if (!FLAG_IS_DEFAULT(ResizeOldPLAB) && !ResizeOldPLAB) {
+      // OldPLAB sizing manually turned off: Use a larger default setting,
+      // unless it was manually specified. This is because a too-low value
+      // will slow down scavenges.
+      FLAG_SET_ERGO(uintx, OldPLABSize, CFLS_LAB::_default_static_old_plab_size); // default value before 6631166
     } else {
-      // OldPLABSize and CMSParPromoteBlocksToClaim are both set.
-      // CMSParPromoteBlocksToClaim is a collector-specific flag, so
-      // we'll let it to take precedence.
-      jio_fprintf(defaultStream::error_stream(),
-                  "Both OldPLABSize and CMSParPromoteBlocksToClaim"
-                  " options are specified for the CMS collector."
-                  " CMSParPromoteBlocksToClaim will take precedence.\n");
+      FLAG_SET_DEFAULT(OldPLABSize, CFLS_LAB::_default_dynamic_old_plab_size); // old CMSParPromoteBlocksToClaim default
     }
   }
-  if (!FLAG_IS_DEFAULT(ResizeOldPLAB) && !ResizeOldPLAB) {
-    // OldPLAB sizing manually turned off: Use a larger default setting,
-    // unless it was manually specified. This is because a too-low value
-    // will slow down scavenges.
-    if (FLAG_IS_DEFAULT(CMSParPromoteBlocksToClaim)) {
-      FLAG_SET_ERGO(uintx, CMSParPromoteBlocksToClaim, 50); // default value before 6631166
-    }
-  }
-  // Overwrite OldPLABSize which is the variable we will internally use everywhere.
-  FLAG_SET_ERGO(uintx, OldPLABSize, CMSParPromoteBlocksToClaim);
+
   // If either of the static initialization defaults have changed, note this
   // modification.
-  if (!FLAG_IS_DEFAULT(CMSParPromoteBlocksToClaim) || !FLAG_IS_DEFAULT(OldPLABWeight)) {
+  if (!FLAG_IS_DEFAULT(OldPLABSize) || !FLAG_IS_DEFAULT(OldPLABWeight)) {
     CFLS_LAB::modify_initialization(OldPLABSize, OldPLABWeight);
   }
   if (PrintGCDetails && Verbose) {
@@ -2997,17 +2980,20 @@
 #endif
     // -D
     } else if (match_option(option, "-D", &tail)) {
-      if (match_option(option, "-Djava.endorsed.dirs=", &tail)) {
+      const char* value;
+      if (match_option(option, "-Djava.endorsed.dirs=", &value) &&
+            *value!= '\0' && strcmp(value, "\"\"") != 0) {
         // abort if -Djava.endorsed.dirs is set
         jio_fprintf(defaultStream::output_stream(),
-          "-Djava.endorsed.dirs is not supported. Endorsed standards and standalone APIs\n"
-          "in modular form will be supported via the concept of upgradeable modules.\n");
+          "-Djava.endorsed.dirs=%s is not supported. Endorsed standards and standalone APIs\n"
+          "in modular form will be supported via the concept of upgradeable modules.\n", value);
         return JNI_EINVAL;
       }
-      if (match_option(option, "-Djava.ext.dirs=", &tail)) {
+      if (match_option(option, "-Djava.ext.dirs=", &value) &&
+            *value != '\0' && strcmp(value, "\"\"") != 0) {
         // abort if -Djava.ext.dirs is set
         jio_fprintf(defaultStream::output_stream(),
-          "-Djava.ext.dirs is not supported.  Use -classpath instead.\n");
+          "-Djava.ext.dirs=%s is not supported.  Use -classpath instead.\n", value);
         return JNI_EINVAL;
       }
 
@@ -3222,52 +3208,6 @@
         FLAG_SET_CMDLINE(bool, NeverTenure, false);
         FLAG_SET_CMDLINE(bool, AlwaysTenure, false);
       }
-    } else if (match_option(option, "-XX:+CMSPermGenSweepingEnabled") ||
-               match_option(option, "-XX:-CMSPermGenSweepingEnabled")) {
-      jio_fprintf(defaultStream::error_stream(),
-        "Please use CMSClassUnloadingEnabled in place of "
-        "CMSPermGenSweepingEnabled in the future\n");
-    } else if (match_option(option, "-XX:+UseGCTimeLimit")) {
-      FLAG_SET_CMDLINE(bool, UseGCOverheadLimit, true);
-      jio_fprintf(defaultStream::error_stream(),
-        "Please use -XX:+UseGCOverheadLimit in place of "
-        "-XX:+UseGCTimeLimit in the future\n");
-    } else if (match_option(option, "-XX:-UseGCTimeLimit")) {
-      FLAG_SET_CMDLINE(bool, UseGCOverheadLimit, false);
-      jio_fprintf(defaultStream::error_stream(),
-        "Please use -XX:-UseGCOverheadLimit in place of "
-        "-XX:-UseGCTimeLimit in the future\n");
-    // The TLE options are for compatibility with 1.3 and will be
-    // removed without notice in a future release.  These options
-    // are not to be documented.
-    } else if (match_option(option, "-XX:MaxTLERatio=", &tail)) {
-      // No longer used.
-    } else if (match_option(option, "-XX:+ResizeTLE")) {
-      FLAG_SET_CMDLINE(bool, ResizeTLAB, true);
-    } else if (match_option(option, "-XX:-ResizeTLE")) {
-      FLAG_SET_CMDLINE(bool, ResizeTLAB, false);
-    } else if (match_option(option, "-XX:+PrintTLE")) {
-      FLAG_SET_CMDLINE(bool, PrintTLAB, true);
-    } else if (match_option(option, "-XX:-PrintTLE")) {
-      FLAG_SET_CMDLINE(bool, PrintTLAB, false);
-    } else if (match_option(option, "-XX:TLEFragmentationRatio=", &tail)) {
-      // No longer used.
-    } else if (match_option(option, "-XX:TLESize=", &tail)) {
-      julong long_tlab_size = 0;
-      ArgsRange errcode = parse_memory_size(tail, &long_tlab_size, 1);
-      if (errcode != arg_in_range) {
-        jio_fprintf(defaultStream::error_stream(),
-                    "Invalid TLAB size: %s\n", option->optionString);
-        describe_range_error(errcode);
-        return JNI_EINVAL;
-      }
-      FLAG_SET_CMDLINE(uintx, TLABSize, long_tlab_size);
-    } else if (match_option(option, "-XX:TLEThreadRatio=", &tail)) {
-      // No longer used.
-    } else if (match_option(option, "-XX:+UseTLE")) {
-      FLAG_SET_CMDLINE(bool, UseTLAB, true);
-    } else if (match_option(option, "-XX:-UseTLE")) {
-      FLAG_SET_CMDLINE(bool, UseTLAB, false);
     } else if (match_option(option, "-XX:+DisplayVMOutputToStderr")) {
       FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, false);
       FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true);
@@ -3291,44 +3231,6 @@
       // disable scavenge before parallel mark-compact
       FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
 #endif
-    } else if (match_option(option, "-XX:CMSParPromoteBlocksToClaim=", &tail)) {
-      julong cms_blocks_to_claim = (julong)atol(tail);
-      FLAG_SET_CMDLINE(uintx, CMSParPromoteBlocksToClaim, cms_blocks_to_claim);
-      jio_fprintf(defaultStream::error_stream(),
-        "Please use -XX:OldPLABSize in place of "
-        "-XX:CMSParPromoteBlocksToClaim in the future\n");
-    } else if (match_option(option, "-XX:ParCMSPromoteBlocksToClaim=", &tail)) {
-      julong cms_blocks_to_claim = (julong)atol(tail);
-      FLAG_SET_CMDLINE(uintx, CMSParPromoteBlocksToClaim, cms_blocks_to_claim);
-      jio_fprintf(defaultStream::error_stream(),
-        "Please use -XX:OldPLABSize in place of "
-        "-XX:ParCMSPromoteBlocksToClaim in the future\n");
-    } else if (match_option(option, "-XX:ParallelGCOldGenAllocBufferSize=", &tail)) {
-      julong old_plab_size = 0;
-      ArgsRange errcode = parse_memory_size(tail, &old_plab_size, 1);
-      if (errcode != arg_in_range) {
-        jio_fprintf(defaultStream::error_stream(),
-                    "Invalid old PLAB size: %s\n", option->optionString);
-        describe_range_error(errcode);
-        return JNI_EINVAL;
-      }
-      FLAG_SET_CMDLINE(uintx, OldPLABSize, old_plab_size);
-      jio_fprintf(defaultStream::error_stream(),
-                  "Please use -XX:OldPLABSize in place of "
-                  "-XX:ParallelGCOldGenAllocBufferSize in the future\n");
-    } else if (match_option(option, "-XX:ParallelGCToSpaceAllocBufferSize=", &tail)) {
-      julong young_plab_size = 0;
-      ArgsRange errcode = parse_memory_size(tail, &young_plab_size, 1);
-      if (errcode != arg_in_range) {
-        jio_fprintf(defaultStream::error_stream(),
-                    "Invalid young PLAB size: %s\n", option->optionString);
-        describe_range_error(errcode);
-        return JNI_EINVAL;
-      }
-      FLAG_SET_CMDLINE(uintx, YoungPLABSize, young_plab_size);
-      jio_fprintf(defaultStream::error_stream(),
-                  "Please use -XX:YoungPLABSize in place of "
-                  "-XX:ParallelGCToSpaceAllocBufferSize in the future\n");
     } else if (match_option(option, "-XX:CMSMarkStackSize=", &tail) ||
                match_option(option, "-XX:G1MarkStackSize=", &tail)) {
       julong stack_size = 0;
@@ -3339,6 +3241,9 @@
         describe_range_error(errcode);
         return JNI_EINVAL;
       }
+      jio_fprintf(defaultStream::error_stream(),
+        "Please use -XX:MarkStackSize in place of "
+        "-XX:CMSMarkStackSize or -XX:G1MarkStackSize in the future\n");
       FLAG_SET_CMDLINE(uintx, MarkStackSize, stack_size);
     } else if (match_option(option, "-XX:CMSMarkStackSizeMax=", &tail)) {
       julong max_stack_size = 0;
@@ -3350,6 +3255,9 @@
         describe_range_error(errcode);
         return JNI_EINVAL;
       }
+      jio_fprintf(defaultStream::error_stream(),
+         "Please use -XX:MarkStackSizeMax in place of "
+         "-XX:CMSMarkStackSizeMax in the future\n");
       FLAG_SET_CMDLINE(uintx, MarkStackSizeMax, max_stack_size);
     } else if (match_option(option, "-XX:ParallelMarkingThreads=", &tail) ||
                match_option(option, "-XX:ParallelCMSThreads=", &tail)) {
@@ -3359,6 +3267,9 @@
                     "Invalid concurrent threads: %s\n", option->optionString);
         return JNI_EINVAL;
       }
+      jio_fprintf(defaultStream::error_stream(),
+        "Please use -XX:ConcGCThreads in place of "
+        "-XX:ParallelMarkingThreads or -XX:ParallelCMSThreads in the future\n");
       FLAG_SET_CMDLINE(uintx, ConcGCThreads, conc_threads);
     } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) {
       julong max_direct_memory_size = 0;
--- a/hotspot/src/share/vm/runtime/globals.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1341,7 +1341,7 @@
   develop(bool, TraceClassInitialization, false,                            \
           "Trace class initialization")                                     \
                                                                             \
-  develop(bool, TraceExceptions, false,                                     \
+  product(bool, TraceExceptions, false,                                     \
           "Trace exceptions")                                               \
                                                                             \
   develop(bool, TraceICs, false,                                            \
@@ -1472,7 +1472,8 @@
           "Size of young gen promotion LAB's (in HeapWords)")               \
                                                                             \
   product(uintx, OldPLABSize, 1024,                                         \
-          "Size of old gen promotion LAB's (in HeapWords)")                 \
+          "Size of old gen promotion LAB's (in HeapWords), or Number        \
+          of blocks to attempt to claim when refilling CMS LAB's")          \
                                                                             \
   product(uintx, GCTaskTimeStampEntries, 200,                               \
           "Number of time stamp entries per gc worker thread")              \
@@ -1583,14 +1584,10 @@
           "The number of cards in each chunk of the parallel chunks used "  \
           "during card table scanning")                                     \
                                                                             \
-  product(uintx, CMSParPromoteBlocksToClaim, 16,                            \
-          "Number of blocks to attempt to claim when refilling CMS LAB's "  \
-          "for parallel GC")                                                \
-                                                                            \
   product(uintx, OldPLABWeight, 50,                                         \
           "Percentage (0-100) used to weight the current sample when "      \
           "computing exponentially decaying average for resizing "          \
-          "CMSParPromoteBlocksToClaim")                                     \
+          "OldPLABSize")                                                    \
                                                                             \
   product(bool, ResizeOldPLAB, true,                                        \
           "Dynamically resize (old gen) promotion LAB's")                   \
--- a/hotspot/src/share/vm/runtime/mutex.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/runtime/mutex.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -895,6 +895,11 @@
 // of Mutex-Monitor and instead directly address the underlying design flaw.
 
 void Monitor::lock(Thread * Self) {
+  // Ensure that the Monitor requires/allows safepoint checks.
+  assert(_safepoint_check_required != Monitor::_safepoint_check_never,
+         err_msg("This lock should never have a safepoint check: %s",
+                 name()));
+
 #ifdef CHECK_UNHANDLED_OOPS
   // Clear unhandled oops so we get a crash right away.  Only clear for non-vm
   // or GC threads.
@@ -953,6 +958,10 @@
 // thread state set to be in VM, the safepoint synchronization code will deadlock!
 
 void Monitor::lock_without_safepoint_check(Thread * Self) {
+  // Ensure that the Monitor does not require or allow safepoint checks.
+  assert(_safepoint_check_required != Monitor::_safepoint_check_always,
+         err_msg("This lock should always have a safepoint check: %s",
+                 name()));
   assert(_owner != Self, "invariant");
   ILock(Self);
   assert(_owner == NULL, "invariant");
@@ -1082,6 +1091,12 @@
 
 bool Monitor::wait(bool no_safepoint_check, long timeout,
                    bool as_suspend_equivalent) {
+  // Make sure safepoint checking is used properly.
+  assert(!(_safepoint_check_required == Monitor::_safepoint_check_never && no_safepoint_check == false),
+         err_msg("This lock should never have a safepoint check: %s", name()));
+  assert(!(_safepoint_check_required == Monitor::_safepoint_check_always && no_safepoint_check == true),
+         err_msg("This lock should always have a safepoint check: %s", name()));
+
   Thread * const Self = Thread::current();
   assert(_owner == Self, "invariant");
   assert(ILocked(), "invariant");
@@ -1168,11 +1183,13 @@
 
 Monitor::Monitor() { ClearMonitor(this); }
 
-Monitor::Monitor(int Rank, const char * name, bool allow_vm_block) {
+Monitor::Monitor(int Rank, const char * name, bool allow_vm_block,
+                 SafepointCheckRequired safepoint_check_required) {
   ClearMonitor(this, name);
 #ifdef ASSERT
   _allow_vm_block  = allow_vm_block;
   _rank            = Rank;
+  NOT_PRODUCT(_safepoint_check_required = safepoint_check_required;)
 #endif
 }
 
@@ -1180,11 +1197,13 @@
   assert((UNS(_owner)|UNS(_LockWord.FullWord)|UNS(_EntryList)|UNS(_WaitSet)|UNS(_OnDeck)) == 0, "");
 }
 
-Mutex::Mutex(int Rank, const char * name, bool allow_vm_block) {
+Mutex::Mutex(int Rank, const char * name, bool allow_vm_block,
+             SafepointCheckRequired safepoint_check_required) {
   ClearMonitor((Monitor *) this, name);
 #ifdef ASSERT
   _allow_vm_block   = allow_vm_block;
   _rank             = Rank;
+  NOT_PRODUCT(_safepoint_check_required = safepoint_check_required;)
 #endif
 }
 
--- a/hotspot/src/share/vm/runtime/mutex.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/runtime/mutex.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -154,6 +154,24 @@
     _as_suspend_equivalent_flag = true
   };
 
+  // Locks can be acquired with or without safepoint check.
+  // Monitor::lock and Monitor::lock_without_safepoint_check
+  // checks these flags when acquiring a lock to ensure
+  // consistent checking for each lock.
+  // A few existing locks will sometimes have a safepoint check and
+  // sometimes not, but these locks are set up in such a way to avoid deadlocks.
+  enum SafepointCheckRequired {
+    _safepoint_check_never,       // Monitors with this value will cause errors
+                                  // when acquired with a safepoint check.
+    _safepoint_check_sometimes,   // Certain locks are called sometimes with and
+                                  // sometimes without safepoint checks. These
+                                  // locks will not produce errors when locked.
+    _safepoint_check_always       // Causes error if locked without a safepoint
+                                  // check.
+  };
+
+  NOT_PRODUCT(SafepointCheckRequired _safepoint_check_required;)
+
   enum WaitResults {
     CONDVAR_EVENT,         // Wait returned because of condition variable notification
     INTERRUPT_EVENT,       // Wait returned because waiting thread was interrupted
@@ -175,7 +193,8 @@
    Monitor() ;
 
  public:
-  Monitor(int rank, const char *name, bool allow_vm_block=false);
+  Monitor(int rank, const char *name, bool allow_vm_block = false,
+          SafepointCheckRequired safepoint_check_required = _safepoint_check_always);
   ~Monitor();
 
   // Wait until monitor is notified (or times out).
@@ -261,7 +280,8 @@
 
 class Mutex : public Monitor {      // degenerate Monitor
  public:
-   Mutex (int rank, const char *name, bool allow_vm_block=false);
+   Mutex(int rank, const char *name, bool allow_vm_block = false,
+         SafepointCheckRequired safepoint_check_required = _safepoint_check_always);
    ~Mutex () ;
  private:
    bool notify ()    { ShouldNotReachHere(); return false; }
--- a/hotspot/src/share/vm/runtime/mutexLocker.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/runtime/mutexLocker.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -167,131 +167,133 @@
 }
 #endif
 
-#define def(var, type, pri, vm_block) {                           \
-  var = new type(Mutex::pri, #var, vm_block);                     \
-  assert(_num_mutex < MAX_NUM_MUTEX,                              \
-                    "increase MAX_NUM_MUTEX");                    \
-  _mutex_array[_num_mutex++] = var;                               \
+#define def(var, type, pri, vm_block, safepoint_check_allowed ) {      \
+  var = new type(Mutex::pri, #var, vm_block, safepoint_check_allowed); \
+  assert(_num_mutex < MAX_NUM_MUTEX, "increase MAX_NUM_MUTEX");        \
+  _mutex_array[_num_mutex] = var;                                      \
 }
 
 void mutex_init() {
-  def(tty_lock                     , Mutex  , event,       true ); // allow to lock in VM
+  def(tty_lock                     , Mutex  , event,       true,  Monitor::_safepoint_check_never);      // allow to lock in VM
 
-  def(CGC_lock                   , Monitor, special,     true ); // coordinate between fore- and background GC
-  def(STS_lock                   , Monitor, leaf,        true );
+  def(CGC_lock                     , Monitor, special,     true,  Monitor::_safepoint_check_never);      // coordinate between fore- and background GC
+  def(STS_lock                     , Monitor, leaf,        true,  Monitor::_safepoint_check_never);
+
   if (UseConcMarkSweepGC || UseG1GC) {
-    def(FullGCCount_lock           , Monitor, leaf,        true ); // in support of ExplicitGCInvokesConcurrent
+    def(FullGCCount_lock           , Monitor, leaf,        true,  Monitor::_safepoint_check_never);      // in support of ExplicitGCInvokesConcurrent
   }
   if (UseG1GC) {
-    def(CMark_lock                 , Monitor, nonleaf,     true ); // coordinate concurrent mark thread
-    def(CMRegionStack_lock         , Mutex,   leaf,        true );
-    def(SATB_Q_FL_lock             , Mutex  , special,     true );
-    def(SATB_Q_CBL_mon             , Monitor, nonleaf,     true );
-    def(Shared_SATB_Q_lock         , Mutex,   nonleaf,     true );
 
-    def(DirtyCardQ_FL_lock         , Mutex  , special,     true );
-    def(DirtyCardQ_CBL_mon         , Monitor, nonleaf,     true );
-    def(Shared_DirtyCardQ_lock     , Mutex,   nonleaf,     true );
+    def(CMark_lock                 , Monitor, nonleaf,     true,  Monitor::_safepoint_check_never);      // coordinate concurrent mark thread
+    def(CMRegionStack_lock         , Mutex,   leaf,        true,  Monitor::_safepoint_check_never);
+    def(SATB_Q_FL_lock             , Mutex  , special,     true,  Monitor::_safepoint_check_never);
+    def(SATB_Q_CBL_mon             , Monitor, nonleaf,     true,  Monitor::_safepoint_check_never);
+    def(Shared_SATB_Q_lock         , Mutex,   nonleaf,     true,  Monitor::_safepoint_check_never);
+
+    def(DirtyCardQ_FL_lock         , Mutex  , special,     true,  Monitor::_safepoint_check_never);
+    def(DirtyCardQ_CBL_mon         , Monitor, nonleaf,     true,  Monitor::_safepoint_check_never);
+    def(Shared_DirtyCardQ_lock     , Mutex,   nonleaf,     true,  Monitor::_safepoint_check_never);
 
-    def(FreeList_lock              , Mutex,   leaf     ,   true );
-    def(SecondaryFreeList_lock     , Monitor, leaf     ,   true );
-    def(OldSets_lock               , Mutex  , leaf     ,   true );
-    def(RootRegionScan_lock        , Monitor, leaf     ,   true );
-    def(MMUTracker_lock            , Mutex  , leaf     ,   true );
-    def(HotCardCache_lock          , Mutex  , special  ,   true );
-    def(EvacFailureStack_lock      , Mutex  , nonleaf  ,   true );
+    def(FreeList_lock              , Mutex,   leaf     ,   true,  Monitor::_safepoint_check_never);
+    def(SecondaryFreeList_lock     , Monitor, leaf     ,   true,  Monitor::_safepoint_check_never);
+    def(OldSets_lock               , Mutex  , leaf     ,   true,  Monitor::_safepoint_check_never);
+    def(RootRegionScan_lock        , Monitor, leaf     ,   true,  Monitor::_safepoint_check_never);
+    def(MMUTracker_lock            , Mutex  , leaf     ,   true,  Monitor::_safepoint_check_never);
+    def(HotCardCache_lock          , Mutex  , special  ,   true,  Monitor::_safepoint_check_never);
+    def(EvacFailureStack_lock      , Mutex  , nonleaf  ,   true,  Monitor::_safepoint_check_never);
 
-    def(StringDedupQueue_lock      , Monitor, leaf,        true );
-    def(StringDedupTable_lock      , Mutex  , leaf,        true );
+    def(StringDedupQueue_lock      , Monitor, leaf,        true,  Monitor::_safepoint_check_never);
+    def(StringDedupTable_lock      , Mutex  , leaf,        true,  Monitor::_safepoint_check_never);
   }
-  def(ParGCRareEvent_lock          , Mutex  , leaf     ,   true );
-  def(DerivedPointerTableGC_lock   , Mutex,   leaf,        true );
-  def(CodeCache_lock               , Monitor, special,     true );
-  def(Interrupt_lock               , Monitor, special,     true ); // used for interrupt processing
-  def(RawMonitor_lock              , Mutex,   special,     true );
-  def(OopMapCacheAlloc_lock        , Mutex,   leaf,        true ); // used for oop_map_cache allocation.
+  def(ParGCRareEvent_lock          , Mutex  , leaf     ,   true,  Monitor::_safepoint_check_sometimes);
+  def(DerivedPointerTableGC_lock   , Mutex,   leaf,        true,  Monitor::_safepoint_check_never);
+  def(CodeCache_lock               , Mutex  , special,     true,  Monitor::_safepoint_check_never);
+  def(Interrupt_lock               , Monitor, special,     true,  Monitor::_safepoint_check_never);      // used for interrupt processing
+  def(RawMonitor_lock              , Mutex,   special,     true,  Monitor::_safepoint_check_never);
+  def(OopMapCacheAlloc_lock        , Mutex,   leaf,        true,  Monitor::_safepoint_check_always);     // used for oop_map_cache allocation.
 
-  def(Patching_lock                , Mutex  , special,     true ); // used for safepointing and code patching.
-  def(ObjAllocPost_lock            , Monitor, special,     false);
-  def(Service_lock                 , Monitor, special,     true ); // used for service thread operations
-  def(JmethodIdCreation_lock       , Mutex  , leaf,        true ); // used for creating jmethodIDs.
+  def(Patching_lock                , Mutex  , special,     true,  Monitor::_safepoint_check_never);      // used for safepointing and code patching.
+  def(ObjAllocPost_lock            , Monitor, special,     false, Monitor::_safepoint_check_never);
+  def(Service_lock                 , Monitor, special,     true,  Monitor::_safepoint_check_never);      // used for service thread operations
+  def(JmethodIdCreation_lock       , Mutex  , leaf,        true,  Monitor::_safepoint_check_always);     // used for creating jmethodIDs.
 
-  def(SystemDictionary_lock        , Monitor, leaf,        true ); // lookups done by VM thread
-  def(PackageTable_lock            , Mutex  , leaf,        false);
-  def(InlineCacheBuffer_lock       , Mutex  , leaf,        true );
-  def(VMStatistic_lock             , Mutex  , leaf,        false);
-  def(ExpandHeap_lock              , Mutex  , leaf,        true ); // Used during compilation by VM thread
-  def(JNIHandleBlockFreeList_lock  , Mutex  , leaf,        true ); // handles are used by VM thread
-  def(SignatureHandlerLibrary_lock , Mutex  , leaf,        false);
-  def(SymbolTable_lock             , Mutex  , leaf+2,      true );
-  def(StringTable_lock             , Mutex  , leaf,        true );
-  def(ProfilePrint_lock            , Mutex  , leaf,        false); // serial profile printing
-  def(ExceptionCache_lock          , Mutex  , leaf,        false); // serial profile printing
-  def(OsrList_lock                 , Mutex  , leaf,        true );
-  def(Debug1_lock                  , Mutex  , leaf,        true );
+  def(SystemDictionary_lock        , Monitor, leaf,        true,  Monitor::_safepoint_check_always);     // lookups done by VM thread
+  def(PackageTable_lock            , Mutex  , leaf,        false, Monitor::_safepoint_check_always);
+  def(InlineCacheBuffer_lock       , Mutex  , leaf,        true,  Monitor::_safepoint_check_always);
+  def(VMStatistic_lock             , Mutex  , leaf,        false, Monitor::_safepoint_check_always);
+  def(ExpandHeap_lock              , Mutex  , leaf,        true,  Monitor::_safepoint_check_always);     // Used during compilation by VM thread
+  def(JNIHandleBlockFreeList_lock  , Mutex  , leaf,        true,  Monitor::_safepoint_check_never);      // handles are used by VM thread
+  def(SignatureHandlerLibrary_lock , Mutex  , leaf,        false, Monitor::_safepoint_check_always);
+  def(SymbolTable_lock             , Mutex  , leaf+2,      true,  Monitor::_safepoint_check_always);
+  def(StringTable_lock             , Mutex  , leaf,        true,  Monitor::_safepoint_check_always);
+  def(ProfilePrint_lock            , Mutex  , leaf,        false, Monitor::_safepoint_check_always);     // serial profile printing
+  def(ExceptionCache_lock          , Mutex  , leaf,        false, Monitor::_safepoint_check_always);     // serial profile printing
+  def(OsrList_lock                 , Mutex  , leaf,        true,  Monitor::_safepoint_check_never);
+  def(Debug1_lock                  , Mutex  , leaf,        true,  Monitor::_safepoint_check_never);
 #ifndef PRODUCT
-  def(FullGCALot_lock              , Mutex  , leaf,        false); // a lock to make FullGCALot MT safe
+  def(FullGCALot_lock              , Mutex  , leaf,        false, Monitor::_safepoint_check_always);     // a lock to make FullGCALot MT safe
 #endif
-  def(BeforeExit_lock              , Monitor, leaf,        true );
-  def(PerfDataMemAlloc_lock        , Mutex  , leaf,        true ); // used for allocating PerfData memory for performance data
-  def(PerfDataManager_lock         , Mutex  , leaf,        true ); // used for synchronized access to PerfDataManager resources
+  def(BeforeExit_lock              , Monitor, leaf,        true,  Monitor::_safepoint_check_always);
+  def(PerfDataMemAlloc_lock        , Mutex  , leaf,        true,  Monitor::_safepoint_check_always);     // used for allocating PerfData memory for performance data
+  def(PerfDataManager_lock         , Mutex  , leaf,        true,  Monitor::_safepoint_check_always);     // used for synchronized access to PerfDataManager resources
 
   // CMS_modUnionTable_lock                   leaf
-  // CMS_bitMap_lock                          leaf + 1
-  // CMS_freeList_lock                        leaf + 2
+  // CMS_bitMap_lock                          leaf 1
+  // CMS_freeList_lock                        leaf 2
 
-  def(Safepoint_lock               , Monitor, safepoint,   true ); // locks SnippetCache_lock/Threads_lock
+  def(Safepoint_lock               , Monitor, safepoint,   true,  Monitor::_safepoint_check_sometimes);  // locks SnippetCache_lock/Threads_lock
 
-  def(Threads_lock                 , Monitor, barrier,     true );
+  def(Threads_lock                 , Monitor, barrier,     true,  Monitor::_safepoint_check_sometimes);
 
-  def(VMOperationQueue_lock        , Monitor, nonleaf,     true ); // VM_thread allowed to block on these
-  def(VMOperationRequest_lock      , Monitor, nonleaf,     true );
-  def(RetData_lock                 , Mutex  , nonleaf,     false);
-  def(Terminator_lock              , Monitor, nonleaf,     true );
-  def(VtableStubs_lock             , Mutex  , nonleaf,     true );
-  def(Notify_lock                  , Monitor, nonleaf,     true );
-  def(JNIGlobalHandle_lock         , Mutex  , nonleaf,     true ); // locks JNIHandleBlockFreeList_lock
-  def(JNICritical_lock             , Monitor, nonleaf,     true ); // used for JNI critical regions
-  def(AdapterHandlerLibrary_lock   , Mutex  , nonleaf,     true);
+  def(VMOperationQueue_lock        , Monitor, nonleaf,     true,  Monitor::_safepoint_check_sometimes);  // VM_thread allowed to block on these
+  def(VMOperationRequest_lock      , Monitor, nonleaf,     true,  Monitor::_safepoint_check_sometimes);
+  def(RetData_lock                 , Mutex  , nonleaf,     false, Monitor::_safepoint_check_always);
+  def(Terminator_lock              , Monitor, nonleaf,     true,  Monitor::_safepoint_check_sometimes);
+  def(VtableStubs_lock             , Mutex  , nonleaf,     true,  Monitor::_safepoint_check_always);
+  def(Notify_lock                  , Monitor, nonleaf,     true,  Monitor::_safepoint_check_always);
+  def(JNIGlobalHandle_lock         , Mutex  , nonleaf,     true,  Monitor::_safepoint_check_always);     // locks JNIHandleBlockFreeList_lock
+  def(JNICritical_lock             , Monitor, nonleaf,     true,  Monitor::_safepoint_check_always);     // used for JNI critical regions
+  def(AdapterHandlerLibrary_lock   , Mutex  , nonleaf,     true,  Monitor::_safepoint_check_always);
   if (UseConcMarkSweepGC) {
-    def(SLT_lock                   , Monitor, nonleaf,     false );
-                    // used in CMS GC for locking PLL lock
+    def(SLT_lock                   , Monitor, nonleaf,     false, Monitor::_safepoint_check_never);      // used in CMS GC for locking PLL lock
   }
-  def(Heap_lock                    , Monitor, nonleaf+1,   false);
-  def(JfieldIdCreation_lock        , Mutex  , nonleaf+1,   true ); // jfieldID, Used in VM_Operation
-  def(MemberNameTable_lock         , Mutex  , nonleaf+1,   false); // Used to protect MemberNameTable
+
+  def(Heap_lock                    , Monitor, nonleaf+1,   false, Monitor::_safepoint_check_sometimes);
+  def(JfieldIdCreation_lock        , Mutex  , nonleaf+1,   true,  Monitor::_safepoint_check_always);     // jfieldID, Used in VM_Operation
+  def(MemberNameTable_lock         , Mutex  , nonleaf+1,   false, Monitor::_safepoint_check_always);     // Used to protect MemberNameTable
 
-  def(CompiledIC_lock              , Mutex  , nonleaf+2,   false); // locks VtableStubs_lock, InlineCacheBuffer_lock
-  def(CompileTaskAlloc_lock        , Mutex  , nonleaf+2,   true );
-  def(CompileStatistics_lock       , Mutex  , nonleaf+2,   false);
-  def(MultiArray_lock              , Mutex  , nonleaf+2,   false); // locks SymbolTable_lock
+  def(CompiledIC_lock              , Mutex  , nonleaf+2,   false, Monitor::_safepoint_check_always);     // locks VtableStubs_lock, InlineCacheBuffer_lock
+  def(CompileTaskAlloc_lock        , Mutex  , nonleaf+2,   true,  Monitor::_safepoint_check_always);
+  def(CompileStatistics_lock       , Mutex  , nonleaf+2,   false, Monitor::_safepoint_check_always);
+  def(MultiArray_lock              , Mutex  , nonleaf+2,   false, Monitor::_safepoint_check_always);     // locks SymbolTable_lock
 
-  def(JvmtiThreadState_lock        , Mutex  , nonleaf+2,   false); // Used by JvmtiThreadState/JvmtiEventController
-  def(JvmtiPendingEvent_lock       , Monitor, nonleaf,     false); // Used by JvmtiCodeBlobEvents
-  def(Management_lock              , Mutex  , nonleaf+2,   false); // used for JVM management
+  def(JvmtiThreadState_lock        , Mutex  , nonleaf+2,   false, Monitor::_safepoint_check_always);     // Used by JvmtiThreadState/JvmtiEventController
+  def(JvmtiPendingEvent_lock       , Monitor, nonleaf,     false, Monitor::_safepoint_check_never);      // Used by JvmtiCodeBlobEvents
+  def(Management_lock              , Mutex  , nonleaf+2,   false, Monitor::_safepoint_check_always);     // used for JVM management
 
-  def(Compile_lock                 , Mutex  , nonleaf+3,   true );
-  def(MethodData_lock              , Mutex  , nonleaf+3,   false);
+  def(Compile_lock                 , Mutex  , nonleaf+3,   true,  Monitor::_safepoint_check_sometimes);
+  def(MethodData_lock              , Mutex  , nonleaf+3,   false, Monitor::_safepoint_check_always);
 
-  def(MethodCompileQueue_lock      , Monitor, nonleaf+4,   true );
-  def(Debug2_lock                  , Mutex  , nonleaf+4,   true );
-  def(Debug3_lock                  , Mutex  , nonleaf+4,   true );
-  def(ProfileVM_lock               , Monitor, special,   false); // used for profiling of the VMThread
-  def(CompileThread_lock           , Monitor, nonleaf+5,   false );
-  def(PeriodicTask_lock            , Monitor, nonleaf+5,   true);
+  def(MethodCompileQueue_lock      , Monitor, nonleaf+4,   true,  Monitor::_safepoint_check_always);
+  def(Debug2_lock                  , Mutex  , nonleaf+4,   true,  Monitor::_safepoint_check_never);
+  def(Debug3_lock                  , Mutex  , nonleaf+4,   true,  Monitor::_safepoint_check_never);
+  def(ProfileVM_lock               , Monitor, special,     false, Monitor::_safepoint_check_never);      // used for profiling of the VMThread
+  def(CompileThread_lock           , Monitor, nonleaf+5,   false, Monitor::_safepoint_check_always);
+  def(PeriodicTask_lock            , Monitor, nonleaf+5,   true,  Monitor::_safepoint_check_sometimes);
   if (WhiteBoxAPI) {
-    def(Compilation_lock           , Monitor, leaf,        false );
+    def(Compilation_lock           , Monitor, leaf,        false, Monitor::_safepoint_check_never);
   }
+
 #ifdef INCLUDE_TRACE
-  def(JfrMsg_lock                  , Monitor, leaf,        true);
-  def(JfrBuffer_lock               , Mutex,   leaf,        true);
-  def(JfrThreadGroups_lock         , Mutex,   leaf,        true);
-  def(JfrStream_lock               , Mutex,   nonleaf,     true);
-  def(JfrStacktrace_lock           , Mutex,   special,     true);
+  def(JfrMsg_lock                  , Monitor, leaf,        true,  Monitor::_safepoint_check_always);
+  def(JfrBuffer_lock               , Mutex,   leaf,        true,  Monitor::_safepoint_check_never);
+  def(JfrThreadGroups_lock         , Mutex,   leaf,        true,  Monitor::_safepoint_check_always);
+  def(JfrStream_lock               , Mutex,   nonleaf,     true,  Monitor::_safepoint_check_never);
+  def(JfrStacktrace_lock           , Mutex,   special,     true,  Monitor::_safepoint_check_sometimes);
 #endif
 
 #ifndef SUPPORTS_NATIVE_CX8
-  def(UnsafeJlong_lock             , Mutex,   special,     false);
+  def(UnsafeJlong_lock             , Mutex,   special,     false, Monitor::_safepoint_check_never);
 #endif
 }
 
--- a/hotspot/src/share/vm/runtime/os.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/runtime/os.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1588,6 +1588,11 @@
   return res;
 }
 
+void os::pretouch_memory(char* start, char* end) {
+  for (volatile char *p = start; p < end; p += os::vm_page_size()) {
+    *p = 0;
+  }
+}
 
 char* os::map_memory(int fd, const char* file_name, size_t file_offset,
                            char *addr, size_t bytes, bool read_only,
--- a/hotspot/src/share/vm/runtime/os.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/runtime/os.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -311,6 +311,12 @@
   static bool   uncommit_memory(char* addr, size_t bytes);
   static bool   release_memory(char* addr, size_t bytes);
 
+  // Touch memory pages that cover the memory range from start to end (exclusive)
+  // to make the OS back the memory range with actual memory.
+  // Current implementation may not touch the last page if unaligned addresses
+  // are passed.
+  static void   pretouch_memory(char* start, char* end);
+
   enum ProtType { MEM_PROT_NONE, MEM_PROT_READ, MEM_PROT_RW, MEM_PROT_RWX };
   static bool   protect_memory(char* addr, size_t bytes, ProtType prot,
                                bool is_committed = true);
--- a/hotspot/src/share/vm/runtime/sweeper.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/runtime/sweeper.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -158,7 +158,7 @@
 Tickspan NMethodSweeper::_peak_sweep_time;                     // Peak time for a full sweep
 Tickspan NMethodSweeper::_peak_sweep_fraction_time;            // Peak time sweeping one fraction
 
-Monitor* NMethodSweeper::_stat_lock = new Monitor(Mutex::special, "Sweeper::Statistics", true);
+Monitor* NMethodSweeper::_stat_lock = new Monitor(Mutex::special, "Sweeper::Statistics", true, Monitor::_safepoint_check_sometimes);
 
 class MarkActivationClosure: public CodeBlobClosure {
 public:
--- a/hotspot/src/share/vm/runtime/thread.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -230,7 +230,8 @@
   _visited_for_critical_count = false;
 #endif
 
-  _SR_lock = new Monitor(Mutex::suspend_resume, "SR_lock", true);
+  _SR_lock = new Monitor(Mutex::suspend_resume, "SR_lock", true,
+                         Monitor::_safepoint_check_sometimes);
   _suspend_flags = 0;
 
   // thread-specific hashCode stream generator state - Marsaglia shift-xor form
--- a/hotspot/src/share/vm/runtime/virtualspace.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/runtime/virtualspace.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -615,19 +615,7 @@
   }
 
   if (pre_touch || AlwaysPreTouch) {
-    int vm_ps = os::vm_page_size();
-    for (char* curr = previous_high;
-         curr < unaligned_new_high;
-         curr += vm_ps) {
-      // Note the use of a write here; originally we tried just a read, but
-      // since the value read was unused, the optimizer removed the read.
-      // If we ever have a concurrent touchahead thread, we'll want to use
-      // a read, to avoid the potential of overwriting data (if a mutator
-      // thread beats the touchahead thread to a page).  There are various
-      // ways of making sure this read is not optimized away: for example,
-      // generating the code for a read procedure at runtime.
-      *curr = 0;
-    }
+    os::pretouch_memory(previous_high, unaligned_new_high);
   }
 
   _high += bytes;
--- a/hotspot/src/share/vm/runtime/vmThread.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/runtime/vmThread.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -214,7 +214,8 @@
   _vm_queue = new VMOperationQueue();
   guarantee(_vm_queue != NULL, "just checking");
 
-  _terminate_lock = new Monitor(Mutex::safepoint, "VMThread::_terminate_lock", true);
+  _terminate_lock = new Monitor(Mutex::safepoint, "VMThread::_terminate_lock", true,
+                                Monitor::_safepoint_check_never);
 
   if (UsePerfData) {
     // jvmstat performance counters
--- a/hotspot/src/share/vm/runtime/vm_operations.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/runtime/vm_operations.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -391,7 +391,8 @@
   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint already");
 
   Thread * thr_cur = ThreadLocalStorage::get_thread_slow();
-  Monitor timer(Mutex::leaf, "VM_Exit timer", true);
+  Monitor timer(Mutex::leaf, "VM_Exit timer", true,
+                Monitor::_safepoint_check_never);
 
   // Compiler threads need longer wait because they can access VM data directly
   // while in native. If they are active and some structures being used are
--- a/hotspot/src/share/vm/services/diagnosticFramework.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/services/diagnosticFramework.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -487,7 +487,7 @@
   }
 }
 
-Mutex* DCmdFactory::_dcmdFactory_lock = new Mutex(Mutex::leaf, "DCmdFactory", true);
+Mutex* DCmdFactory::_dcmdFactory_lock = new Mutex(Mutex::leaf, "DCmdFactory", true, Monitor::_safepoint_check_never);
 bool DCmdFactory::_send_jmx_notification = false;
 
 DCmdFactory* DCmdFactory::factory(DCmdSource source, const char* name, size_t len) {
--- a/hotspot/src/share/vm/services/memoryManager.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/services/memoryManager.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -198,7 +198,8 @@
 GCMemoryManager::GCMemoryManager() : MemoryManager() {
   _num_collections = 0;
   _last_gc_stat = NULL;
-  _last_gc_lock = new Mutex(Mutex::leaf, "_last_gc_lock", true);
+  _last_gc_lock = new Mutex(Mutex::leaf, "_last_gc_lock", true,
+                            Monitor::_safepoint_check_never);
   _current_gc_stat = NULL;
   _num_gc_threads = 1;
   _notification_enabled = false;
--- a/hotspot/src/share/vm/utilities/decoder.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/utilities/decoder.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,9 @@
 AbstractDecoder*  Decoder::_error_handler_decoder = NULL;
 NullDecoder       Decoder::_do_nothing_decoder;
 Mutex*            Decoder::_shared_decoder_lock = new Mutex(Mutex::native,
-                                "SharedDecoderLock");
+                                "SharedDecoderLock",
+                                false,
+                                Monitor::_safepoint_check_never);
 
 AbstractDecoder* Decoder::get_shared_instance() {
   assert(_shared_decoder_lock != NULL && _shared_decoder_lock->owned_by_self(),
--- a/hotspot/src/share/vm/utilities/events.hpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/utilities/events.hpp	Wed Jul 05 20:13:05 2017 +0200
@@ -90,7 +90,7 @@
     _length(length),
     _count(0),
     _index(0),
-    _mutex(Mutex::event, name) {
+    _mutex(Mutex::event, name, false, Monitor::_safepoint_check_never) {
     _records = new EventRecord<T>[length];
   }
 
--- a/hotspot/src/share/vm/utilities/workgroup.cpp	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/src/share/vm/utilities/workgroup.cpp	Wed Jul 05 20:13:05 2017 +0200
@@ -46,7 +46,8 @@
   // Other initialization.
   _monitor = new Monitor(/* priority */       Mutex::leaf,
                          /* name */           "WorkGroup monitor",
-                         /* allow_vm_block */ are_GC_task_threads);
+                         /* allow_vm_block */ are_GC_task_threads,
+                                              Monitor::_safepoint_check_sometimes);
   assert(monitor() != NULL, "Failed to allocate monitor");
   _terminate = false;
   _task = NULL;
@@ -378,12 +379,13 @@
 // *** WorkGangBarrierSync
 
 WorkGangBarrierSync::WorkGangBarrierSync()
-  : _monitor(Mutex::safepoint, "work gang barrier sync", true),
+  : _monitor(Mutex::safepoint, "work gang barrier sync", true,
+             Monitor::_safepoint_check_never),
     _n_workers(0), _n_completed(0), _should_reset(false), _aborted(false) {
 }
 
 WorkGangBarrierSync::WorkGangBarrierSync(uint n_workers, const char* name)
-  : _monitor(Mutex::safepoint, name, true),
+  : _monitor(Mutex::safepoint, name, true, Monitor::_safepoint_check_never),
     _n_workers(n_workers), _n_completed(0), _should_reset(false), _aborted(false) {
 }
 
--- a/hotspot/test/TEST.groups	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/TEST.groups	Wed Jul 05 20:13:05 2017 +0200
@@ -50,6 +50,9 @@
 # runs those tests that only require compact1 and compact2 API's.
 #
 
+hotspot_all = \
+  /
+
 # Full JDK can run all tests
 #
 jdk = \
@@ -202,7 +205,6 @@
 compact1_minimal = \
   serviceability/ \
   compiler/ \
-  testlibrary_tests/ \
   sanity/ \
   runtime/ \
   gc/ \
@@ -407,7 +409,9 @@
   -closed/compiler/loopopts/8021898
 
 hotspot_gc = \
-  sanity/ExecuteInternalVMTests.java
+  sanity/ExecuteInternalVMTests.java \
+  gc/ \
+  -gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java
 
 hotspot_runtime = \
   runtime/ \
@@ -426,19 +430,22 @@
  -runtime/7158988/FieldMonitor.java
 
 hotspot_runtime_closed = \
-  sanity/ExecuteInternalVMTests.java
+  sanity/ExecuteInternalVMTests.java \
+  testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java
 
 hotspot_serviceability = \
   sanity/ExecuteInternalVMTests.java \
   serviceability/dcmd/compiler
 
-hotspot_all = \
+hotspot_jprt = \
+  :hotspot_wbapitest \
   :hotspot_compiler_1 \
   :hotspot_compiler_2 \
   :hotspot_compiler_3 \
   :hotspot_compiler_closed \
   :hotspot_gc \
   :hotspot_runtime \
+  :hotspot_runtime_closed \
   :hotspot_serviceability
 
 #All tests that depends on nashorn extension.
--- a/hotspot/test/compiler/arguments/BMISupportedCPUTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/arguments/BMISupportedCPUTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -60,8 +60,11 @@
           VM will be launched with following flags:
           -XX:+<tested option> -version
         */
+        String errorString = String.format("JVM should start with '-XX:+%s'"
+                + " flag without any warnings", optionName);
         CommandLineOptionTest.verifySameJVMStartup(null,
-                new String[] { warningMessage }, ExitCode.OK,
+                new String[] { warningMessage }, errorString, errorString,
+                ExitCode.OK,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
         /*
@@ -69,8 +72,11 @@
           VM will be launched with following flags:
           -XX:-<tested option> -version
         */
+        errorString = String.format("JVM should start with '-XX:-%s'"
+                + " flag without any warnings", optionName);
         CommandLineOptionTest.verifySameJVMStartup(null,
-                new String[] { warningMessage }, ExitCode.OK,
+                new String[] { warningMessage }, errorString,
+                errorString, ExitCode.OK,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
 
         /*
@@ -78,7 +84,9 @@
           VM will be launched with following flags:
           -version
         */
-        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true");
+        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true",
+                String.format("Option '%s' is expected to have default value "
+                    + "'true'", optionName));
 
         /*
           Verify that option could be explicitly turned off.
@@ -86,6 +94,8 @@
           -XX:-<tested option> -version
         */
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                String.format("Option '%s' is set to have value 'false'",
+                    optionName),
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
     }
 }
--- a/hotspot/test/compiler/arguments/BMIUnsupportedCPUTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/arguments/BMIUnsupportedCPUTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -75,9 +75,13 @@
           warning. VM will be launched with following options:
           -XX:+<tested option> -version
         */
+        String errorString = String.format("JVM should start with '-XX:+%s' "
+                + "flag, but output should contain warning.", optionName);
         CommandLineOptionTest.verifySameJVMStartup(
                 new String[] { warningMessage }, new String[] { errorMessage },
-                ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(
+                errorString, String.format("Option '%s' is unsupported.%n"
+                + "Warning expected to be shown.", optionName), ExitCode.OK,
+                CommandLineOptionTest.prepareBooleanFlag(
                         optionName, true));
 
         /*
@@ -85,15 +89,21 @@
           VM will be launched with following options:
           -XX:-<tested option> -version
         */
+        errorString = String.format("JVM should start with '-XX:-%s' flag "
+                        + "without any warnings", optionName);
         CommandLineOptionTest.verifySameJVMStartup(null,
-                new String[] { warningMessage, errorMessage }, ExitCode.OK,
+                new String[] { warningMessage, errorMessage },
+                errorString, errorString, ExitCode.OK,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
 
         /*
-          Verify that on unsupported CPUs option is off by default.
-          VM will be launched with following options: -version
-        */
-        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false");
+         * Verify that on unsupported CPUs option is off by default. VM will be
+         * launched with following options: -version
+         */
+        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                String.format("Option '%s' is expected to have default value "
+                        + "'false' since feature required is not supported "
+                        + "on CPU", optionName));
 
         /*
           Verify that on unsupported CPUs option will be off even if
@@ -101,6 +111,9 @@
           following options: -XX:+<tested option> -version
         */
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                String.format("Option '%s' is expected to have default value"
+                        + " 'false' since feature required is not supported on"
+                        + " CPU even if user set another value.", optionName),
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
     }
@@ -118,11 +131,17 @@
           with following options: -XX:[+-]<tested option> -version
         */
         CommandLineOptionTest.verifySameJVMStartup(
-                new String[] { errorMessage }, null, ExitCode.FAIL,
+                new String[] { errorMessage }, null,
+                String.format("JVM startup should fail with '-XX:+%s' flag."
+                        + "%nOption should be unknown (non-X86CPU).",
+                        optionName), "", ExitCode.FAIL,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
         CommandLineOptionTest.verifySameJVMStartup(
-                new String[] { errorMessage }, null, ExitCode.FAIL,
+                new String[] { errorMessage }, null,
+                String.format("JVM startup should fail with '-XX:-%s' flag."
+                        + "%nOption should be unknown (non-X86CPU)",
+                        optionName), "", ExitCode.FAIL,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
     }
 }
--- a/hotspot/test/compiler/arguments/CheckCompileThresholdScaling.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/arguments/CheckCompileThresholdScaling.java	Wed Jul 05 20:13:05 2017 +0200
@@ -330,7 +330,7 @@
         } catch (RuntimeException e) {
             // Check if tiered compilation is available in this JVM
             // Version. Throw exception only if it is available.
-            if (!(tiered && out.getOutput().contains("Client VM warning: TieredCompilation is disabled in this release."))) {
+            if (!(tiered && out.getOutput().contains("TieredCompilation is disabled in this release."))) {
                 throw new RuntimeException(e);
             }
         }
--- a/hotspot/test/compiler/arguments/TestUseBMI1InstructionsOnSupportedCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/arguments/TestUseBMI1InstructionsOnSupportedCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 8031321
  * @summary Verify processing of UseBMI1Instructions option on CPU with
  *          BMI1 feature support.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestUseBMI1InstructionsOnSupportedCPU
  *        BMISupportedCPUTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/arguments/TestUseBMI1InstructionsOnUnsupportedCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/arguments/TestUseBMI1InstructionsOnUnsupportedCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 8031321
  * @summary Verify processing of UseBMI1Instructions option on CPU without
  *          BMI1 feature support.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestUseBMI1InstructionsOnUnsupportedCPU
  *        BMIUnsupportedCPUTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/arguments/TestUseCountLeadingZerosInstructionOnSupportedCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/arguments/TestUseCountLeadingZerosInstructionOnSupportedCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 8031321
  * @summary Verify processing of UseCountLeadingZerosInstruction option
  *          on CPU with LZCNT support.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestUseCountLeadingZerosInstructionOnSupportedCPU
  *        BMISupportedCPUTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/arguments/TestUseCountLeadingZerosInstructionOnUnsupportedCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/arguments/TestUseCountLeadingZerosInstructionOnUnsupportedCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 8031321
  * @summary Verify processing of UseCountLeadingZerosInstruction option
  *          on CPU without LZCNT support.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestUseCountLeadingZerosInstructionOnUnsupportedCPU
  *        BMIUnsupportedCPUTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnSupportedCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnSupportedCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 8031321
  * @summary Verify processing of UseCountTrailingZerosInstruction option
  *          on CPU with TZCNT (BMI1 feature) support.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestUseCountTrailingZerosInstructionOnSupportedCPU
  *        BMISupportedCPUTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
@@ -59,6 +59,9 @@
           -XX:-UseBMI1Instructions -version
         */
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                "Option 'UseCountTrailingZerosInstruction' should have "
+                    + "'false' value if all BMI1 instructions are explicitly"
+                    + " disabled (-XX:-UseBMI1Instructions flag used)",
                 TestUseCountTrailingZerosInstructionOnSupportedCPU.DISABLE_BMI);
 
         /*
@@ -68,6 +71,9 @@
           -XX:+UseCountTrailingZerosInstruction -version
         */
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true",
+                "Option 'UseCountTrailingZerosInstruction' should be able to "
+                    + "be turned on even if all BMI1 instructions are "
+                    + "disabled (-XX:-UseBMI1Instructions flag used)",
                 TestUseCountTrailingZerosInstructionOnSupportedCPU.DISABLE_BMI,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
     }
--- a/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnUnsupportedCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnUnsupportedCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 8031321
  * @summary Verify processing of UseCountTrailingZerosInstruction option
  *          on CPU without TZCNT instruction (BMI1 feature) support.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestUseCountTrailingZerosInstructionOnUnsupportedCPU
  *        BMIUnsupportedCPUTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
@@ -59,6 +59,9 @@
           -XX:+UseBMI1Instructions -version
         */
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                "Feature bmi1 is not supported on current CPU. Option "
+                    + "UseCountTrailingZerosInstruction should have 'false'"
+                    + " value",
                 TestUseCountTrailingZerosInstructionOnUnsupportedCPU.
                         ENABLE_BMI);
 
@@ -68,6 +71,9 @@
           -version
         */
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                    "Feature bmi1 is not supported on current CPU. Option "
+                    + "UseCountTrailingZerosInstruction should have 'false'"
+                    + " value",
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true),
                 TestUseCountTrailingZerosInstructionOnUnsupportedCPU.
                         ENABLE_BMI);
--- a/hotspot/test/compiler/c2/6589834/Test_ia32.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/c2/6589834/Test_ia32.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6589834
  * @summary Safepoint placed between stack pointer increment and decrement leads
  *          to interpreter's stack corruption after deoptimization.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build ClassFileInstaller sun.hotspot.WhiteBox com.oracle.java.testlibrary.*
  *        Test_ia32 InlinedArrayCloneTestCase
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java	Wed Jul 05 20:13:05 2017 +0200
@@ -33,7 +33,7 @@
  * @test TestAnonymousClassUnloading
  * @bug 8054402
  * @summary "Tests unloading of anonymous classes."
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @compile TestAnonymousClassUnloading.java
  * @run main ClassFileInstaller TestAnonymousClassUnloading
  *                              sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/classUnloading/methodUnloading/TestMethodUnloading.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/classUnloading/methodUnloading/TestMethodUnloading.java	Wed Jul 05 20:13:05 2017 +0200
@@ -31,7 +31,7 @@
  * @test MethodUnloadingTest
  * @bug 8029443
  * @summary "Tests the unloading of methods to to class unloading"
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestMethodUnloading
  * @build WorkerClass
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/codecache/CheckSegmentedCodeCache.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/codecache/CheckSegmentedCodeCache.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
 /*
  * @test CheckSegmentedCodeCache
  * @bug 8015774
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @summary "Checks VM options related to the segmented code cache"
  * @build CheckSegmentedCodeCache
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -34,7 +34,7 @@
 /*
  * @test OverflowCodeCacheTest
  * @bug 8059550
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build OverflowCodeCacheTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestAndnI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/TestAndnI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031321
  * @summary Verify that results of computations are the same w/
  *          and w/o usage of ANDN instruction
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestAndnI BMITestRunner Expr
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestAndnL.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/TestAndnL.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031321
  * @summary Verify that results of computations are the same w/
  *          and w/o usage of ANDN instruction
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestAndnL BMITestRunner Expr
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsiI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsiI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031321
  * @summary Verify that results of computations are the same w/
  *          and w/o usage of BLSI instruction
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestBlsiI BMITestRunner Expr
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsiL.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsiL.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031321
  * @summary Verify that results of computations are the same w/
  *          and w/o usage of BLSI instruction
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestBlsiL BMITestRunner Expr
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsmskI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsmskI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031321
  * @summary Verify that results of computations are the same w/
  *          and w/o usage of BLSMSK instruction
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestBlsmskI BMITestRunner Expr
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsmskL.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsmskL.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031321
  * @summary Verify that results of computations are the same w/
  *          and w/o usage of BLSMSK instruction
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestBlsmskL BMITestRunner Expr
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsrI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsrI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031321
  * @summary Verify that results of computations are the same w/
  *          and w/o usage of BLSR instruction
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestBlsrI BMITestRunner Expr
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsrL.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsrL.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031321
  * @summary Verify that results of computations are the same w/
  *          and w/o usage of BLSR instruction
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestBlsrL BMITestRunner Expr
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestLzcntI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/TestLzcntI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031321
  * @summary Verify that results of computations are the same w/
  *          and w/o usage of intrinsic
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestLzcntI BMITestRunner Expr
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestLzcntL.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/TestLzcntL.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031321
  * @summary Verify that results of computations are the same w/
  *          and w/o usage of intrinsic
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestLzcntL BMITestRunner Expr
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestTzcntI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/TestTzcntI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031321
  * @summary Verify that results of computations are the same w/
  *          and w/o usage of intrinsic
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestTzcntI BMITestRunner Expr
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestTzcntL.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/TestTzcntL.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031321
  * @summary Verify that results of computations are the same w/
  *          and w/o usage of intrinsic
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestTzcntL BMITestRunner Expr
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/AddnTestI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/AddnTestI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8031321
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @library /testlibrary /../../test/lib /compiler/whitebox ..
  * @build AddnTestI
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/AddnTestL.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/AddnTestL.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8031321
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @library /testlibrary /../../test/lib /compiler/whitebox ..
  * @build AddnTestL
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsiTestI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsiTestI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8031321
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @library /testlibrary /../../test/lib /compiler/whitebox ..
  * @build BlsiTestI
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsiTestL.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsiTestL.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8031321
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @library /testlibrary /../../test/lib /compiler/whitebox ..
  * @build BlsiTestL
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsmskTestI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsmskTestI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8031321
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @library /testlibrary /../../test/lib /compiler/whitebox ..
  * @build BlsmskTestI
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsmskTestL.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsmskTestL.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8031321
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @library /testlibrary /../../test/lib /compiler/whitebox ..
  * @build BlsmskTestL
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsrTestI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsrTestI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8031321
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @library /testlibrary /../../test/lib /compiler/whitebox ..
  * @build BlsrTestI
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsrTestL.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsrTestL.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8031321
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @library /testlibrary /../../test/lib /compiler/whitebox ..
  * @build BlsrTestL
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8031321
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @library /testlibrary /../../test/lib /compiler/whitebox ..
  * @build LZcntTestI
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestL.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestL.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8031321
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @library /testlibrary /../../test/lib /compiler/whitebox ..
  * @build LZcntTestL
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8031321
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @library /testlibrary /../../test/lib /compiler/whitebox ..
  * @build TZcntTestI
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestL.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestL.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8031321
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @library /testlibrary /../../test/lib /compiler/whitebox ..
  * @build TZcntTestL
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/classcast/NullCheckDroppingsTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/classcast/NullCheckDroppingsTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test NullCheckDroppingsTest
  * @bug 8054492
  * @summary "Casting can result in redundant null checks in generated code"
- * @library /testlibrary /testlibrary/whitebox /testlibrary/com/oracle/java/testlibrary
+ * @library /testlibrary /../../test/lib /testlibrary/com/oracle/java/testlibrary
  * @build NullCheckDroppingsTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactIntTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactIntTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
+ * @library /testlibrary /../../test/lib /compiler/whitebox
  *          /compiler/testlibrary
  * @build AddExactIntTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactLongTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactLongTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
+ * @library /testlibrary /../../test/lib /compiler/whitebox
  *          /compiler/testlibrary
  * @build AddExactLongTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactIntTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactIntTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
+ * @library /testlibrary /../../test/lib /compiler/whitebox
  *          /compiler/testlibrary
  * @build DecrementExactIntTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactLongTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactLongTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
+ * @library /testlibrary /../../test/lib /compiler/whitebox
  *          /compiler/testlibrary
  * @build DecrementExactLongTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactIntTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactIntTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
+ * @library /testlibrary /../../test/lib /compiler/whitebox
  *          /compiler/testlibrary
  * @build IncrementExactIntTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactLongTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactLongTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
+ * @library /testlibrary /../../test/lib /compiler/whitebox
  *          /compiler/testlibrary
  * @build IncrementExactLongTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactIntTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactIntTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
+ * @library /testlibrary /../../test/lib /compiler/whitebox
  *          /compiler/testlibrary
  * @build MultiplyExactIntTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactLongTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactLongTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
+ * @library /testlibrary /../../test/lib /compiler/whitebox
  *          /compiler/testlibrary
  * @build MultiplyExactLongTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactIntTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactIntTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
+ * @library /testlibrary /../../test/lib /compiler/whitebox
  *          /compiler/testlibrary
  * @build NegateExactIntTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactLongTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactLongTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
+ * @library /testlibrary /../../test/lib /compiler/whitebox
  *          /compiler/testlibrary
  * @build NegateExactLongTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactIntTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactIntTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
+ * @library /testlibrary /../../test/lib /compiler/whitebox
  *          /compiler/testlibrary
  * @build SubtractExactIntTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactLongTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactLongTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
+ * @library /testlibrary /../../test/lib /compiler/whitebox
  *          /compiler/testlibrary
  * @build SubtractExactLongTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnSupportedCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnSupportedCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @bug 8035968
  * @summary Verify UseSHA1Intrinsics option processing on supported CPU,
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases
+ * @library /testlibrary /../../test/lib /compiler/testlibrary testcases
  * @build TestUseSHA1IntrinsicsOptionOnSupportedCPU
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnUnsupportedCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnUnsupportedCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @bug 8035968
  * @summary Verify UseSHA1Intrinsics option processing on unsupported CPU,
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases
+ * @library /testlibrary /../../test/lib /compiler/testlibrary testcases
  * @build TestUseSHA1IntrinsicsOptionOnUnsupportedCPU
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnSupportedCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnSupportedCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @bug 8035968
  * @summary Verify UseSHA256Intrinsics option processing on supported CPU,
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases
+ * @library /testlibrary /../../test/lib /compiler/testlibrary testcases
  * @build TestUseSHA256IntrinsicsOptionOnSupportedCPU
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnUnsupportedCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnUnsupportedCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @bug 8035968
  * @summary Verify UseSHA256Intrinsics option processing on unsupported CPU,
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases
+ * @library /testlibrary /../../test/lib /compiler/testlibrary testcases
  * @build TestUseSHA256IntrinsicsOptionOnUnsupportedCPU
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnSupportedCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnSupportedCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @bug 8035968
  * @summary Verify UseSHA512Intrinsics option processing on supported CPU.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases
+ * @library /testlibrary /../../test/lib /compiler/testlibrary testcases
  * @build TestUseSHA512IntrinsicsOptionOnSupportedCPU
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnUnsupportedCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnUnsupportedCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @bug 8035968
  * @summary Verify UseSHA512Intrinsics option processing on unsupported CPU,
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases
+ * @library /testlibrary /../../test/lib /compiler/testlibrary testcases
  * @build TestUseSHA512IntrinsicsOptionOnUnsupportedCPU
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnSupportedCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnSupportedCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @bug 8035968
  * @summary Verify UseSHA option processing on supported CPU,
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases
+ * @library /testlibrary /../../test/lib /compiler/testlibrary testcases
  * @build TestUseSHAOptionOnSupportedCPU
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnUnsupportedCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnUnsupportedCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @bug 8035968
  * @summary Verify UseSHA option processing on unsupported CPU.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary testcases
+ * @library /testlibrary /../../test/lib /compiler/testlibrary testcases
  * @build TestUseSHAOptionOnUnsupportedCPU
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -41,30 +41,42 @@
 
     @Override
     protected void verifyWarnings() throws Throwable {
+        String shouldPassMessage = String.format("JVM should start with "
+                + "option '%s' without any warnings", optionName);
         // Verify that on non-x86 and non-SPARC CPU usage of SHA-related
         // options will not cause any warnings.
         CommandLineOptionTest.verifySameJVMStartup(null,
-                new String[] { ".*" + optionName + ".*" }, ExitCode.OK,
+                new String[] { ".*" + optionName + ".*" }, shouldPassMessage,
+                shouldPassMessage, ExitCode.OK,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
         CommandLineOptionTest.verifySameJVMStartup(null,
-                new String[] { ".*" + optionName + ".*" }, ExitCode.OK,
+                new String[] { ".*" + optionName + ".*" }, shouldPassMessage,
+                shouldPassMessage, ExitCode.OK,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
     }
 
     @Override
     protected void verifyOptionValues() throws Throwable {
         // Verify that option is disabled by default.
-        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false");
+        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                String.format("Option '%s' should be disabled by default",
+                        optionName));
 
         // Verify that option is disabled even if it was explicitly enabled
         // using CLI options.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                String.format("Option '%s' should be off on unsupported "
+                        + "CPU even if set to true directly", optionName),
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
         // Verify that option is disabled when it explicitly disabled
         // using CLI options.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                String.format("Option '%s' should be off on unsupported CPU"
+                        + " even if '%s' flag set to JVM", optionName,
+                        CommandLineOptionTest.prepareBooleanFlag(
+                        SHAOptionsBase.USE_SHA_OPTION, true)),
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
     }
 }
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedSparcCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedSparcCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -39,17 +39,24 @@
 
     @Override
     protected void verifyWarnings() throws Throwable {
+
+        String shouldPassMessage = String.format("JVM should start with option"
+                + " '%s' without any warnings", optionName);
         // Verify that there are no warning when option is explicitly enabled.
         CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
                         SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
-                }, ExitCode.OK,
+                }, shouldPassMessage, shouldPassMessage, ExitCode.OK,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
         // Verify that option could be disabled even if +UseSHA was passed to
         // JVM.
         CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
                         SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
-                }, ExitCode.OK,
+                }, shouldPassMessage, String.format("It should be able to "
+                        + "disable option '%s' even if %s was passed to JVM",
+                        optionName, CommandLineOptionTest.prepareBooleanFlag(
+                            SHAOptionsBase.USE_SHA_OPTION, true)),
+                ExitCode.OK,
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true),
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
@@ -58,7 +65,11 @@
         // all SHA intrinsics via -UseSHA without any warnings.
         CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
                         SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
-                }, ExitCode.OK,
+                }, shouldPassMessage, String.format("It should be able to "
+                        + "enable option '%s' even if %s was passed to JVM",
+                        optionName, CommandLineOptionTest.prepareBooleanFlag(
+                            SHAOptionsBase.USE_SHA_OPTION, false)),
+                ExitCode.OK,
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, false),
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
@@ -66,19 +77,30 @@
 
     @Override
     protected void verifyOptionValues() throws Throwable {
-        // Verify that on supported CPU option is enabled by default.
-        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true");
+        // Verify that "It should be able to disable option "
+
+        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true",
+                String.format("Option '%s' should be enabled by default",
+                        optionName));
 
         // Verify that it is possible to explicitly enable the option.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true",
+                String.format("Option '%s' was set to have value 'true'",
+                        optionName),
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
         // Verify that it is possible to explicitly disable the option.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                String.format("Option '%s' was set to have value 'false'",
+                        optionName),
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
 
         // verify that option is disabled when -UseSHA was passed to JVM.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                String.format("Option '%s' should have value 'false' when %s"
+                        + " flag set to JVM", optionName,
+                        CommandLineOptionTest.prepareBooleanFlag(
+                            SHAOptionsBase.USE_SHA_OPTION, false)),
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true),
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, false));
@@ -86,6 +108,10 @@
         // Verify that it is possible to explicitly disable the tested option
         // even if +UseSHA was passed to JVM.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                String.format("Option '%s' should have value 'false' if set so"
+                        + " even if %s flag set to JVM", optionName,
+                        CommandLineOptionTest.prepareBooleanFlag(
+                            SHAOptionsBase.USE_SHA_OPTION, true)),
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true),
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -41,25 +41,35 @@
 
     @Override
     protected void verifyWarnings() throws Throwable {
+        String shouldPassMessage = String.format("JVM startup should pass with"
+                + "option '-XX:-%s' without any warnings", optionName);
         //Verify that option could be disabled without any warnings.
         CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
                         SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
-                }, ExitCode.OK,
+                }, shouldPassMessage, shouldPassMessage, ExitCode.OK,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
     }
 
     @Override
     protected void verifyOptionValues() throws Throwable {
         // Verify that option is disabled by default.
-        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false");
+        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                String.format("Option '%s' should be disabled by default",
+                        optionName));
 
         // Verify that option is disabled even if it was explicitly enabled
         // using CLI options.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                String.format("Option '%s' should be off on unsupported "
+                        + "SparcCPU even if set to true directly", optionName),
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
         // Verify that option is disabled when +UseSHA was passed to JVM.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                String.format("Option '%s' should be off on unsupported "
+                        + "SparcCPU even if %s flag set to JVM",
+                        optionName, CommandLineOptionTest.prepareBooleanFlag(
+                            SHAOptionsBase.USE_SHA_OPTION, true)),
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true));
     }
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -38,33 +38,45 @@
 
     @Override
     protected void verifyWarnings() throws Throwable {
+        String shouldPassMessage = String.format("JVM should start with '-XX:+"
+                + "%s' flag, but output should contain warning.", optionName);
         // Verify that when the tested option is explicitly enabled, then
         // a warning will occur in VM output.
         CommandLineOptionTest.verifySameJVMStartup(new String[] {
                         SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
-                }, null, ExitCode.OK,
+                }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
+        shouldPassMessage = String.format("JVM should start with '-XX:-%s' "
+                + "flag without any warnings", optionName);
         // Verify that the tested option could be explicitly disabled without
         // a warning.
         CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
                         SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
-                }, ExitCode.OK,
+                }, shouldPassMessage, shouldPassMessage, ExitCode.OK,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, false));
     }
 
     @Override
     protected void verifyOptionValues() throws Throwable {
         // Verify that the tested option is disabled by default.
-        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false");
+        CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                String.format("Option '%s' should be disabled by default",
+                        optionName));
 
         // Verify that it is not possible to explicitly enable the option.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                String.format("Option '%s' should be off on unsupported "
+                        + "X86CPU even if set to true directly", optionName),
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
 
         // Verify that the tested option is disabled even if +UseSHA was passed
         // to JVM.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false",
+                String.format("Option '%s' should be off on unsupported "
+                        + "X86CPU even if %s flag set to JVM",
+                        optionName, CommandLineOptionTest.prepareBooleanFlag(
+                            SHAOptionsBase.USE_SHA_OPTION, true)),
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true));
     }
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedSparcCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -50,10 +50,13 @@
     }
     @Override
     protected void verifyWarnings() throws Throwable {
-        // Verify that attempt to enable the tested option will cause a warning.
+        String shouldPassMessage = String.format("JVM should start with "
+                + "'-XX:+%s' flag, but output should contain warning.",
+                optionName);
+        // Verify that attempt to enable the tested option will cause a warning
         CommandLineOptionTest.verifySameJVMStartup(new String[] {
                         SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
-                }, null, ExitCode.OK,
+                }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
     }
 }
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedSparcCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedSparcCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -39,16 +39,22 @@
                 IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE));
 
         Asserts.assertEQ(optionName, SHAOptionsBase.USE_SHA_OPTION,
-                "Test case should be used for " + SHAOptionsBase.USE_SHA_OPTION
-                        + " option only.");
+                String.format("Test case should be used for '%s' option only.",
+                        SHAOptionsBase.USE_SHA_OPTION));
     }
 
     @Override
     protected void verifyWarnings() throws Throwable {
+        String shouldPassMessage = String.format("JVM startup should pass when"
+                        + " %s was passed and all UseSHA*Intrinsics options "
+                        + "were disabled",
+                        CommandLineOptionTest.prepareBooleanFlag(
+                            SHAOptionsBase.USE_SHA_OPTION, true));
         // Verify that there will be no warnings when +UseSHA was passed and
         // all UseSHA*Intrinsics options were disabled.
         CommandLineOptionTest.verifySameJVMStartup(
-                null, new String[] { ".*UseSHA.*" }, ExitCode.OK,
+                null, new String[] { ".*UseSHA.*" }, shouldPassMessage,
+                shouldPassMessage, ExitCode.OK,
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true),
                 CommandLineOptionTest.prepareBooleanFlag(
@@ -61,10 +67,12 @@
 
     @Override
     protected void verifyOptionValues() throws Throwable {
-        // Verify that UseSHA is disabled when all UseSHA*Intrinscs are
+        // Verify that UseSHA is disabled when all UseSHA*Intrinsics are
         // disabled.
         CommandLineOptionTest.verifyOptionValueForSameVM(
-                SHAOptionsBase.USE_SHA_OPTION, "false",
+                SHAOptionsBase.USE_SHA_OPTION, "false", String.format(
+                "'%s' option should be disabled when all UseSHA*Intrinsics are"
+                        + " disabled", SHAOptionsBase.USE_SHA_OPTION),
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, false),
                 CommandLineOptionTest.prepareBooleanFlag(
@@ -73,9 +81,14 @@
                         SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, false));
 
         CommandLineOptionTest.verifyOptionValueForSameVM(
-                // Verify that UseSHA is disabled when all UseSHA*Intrinscs are
+                // Verify that UseSHA is disabled when all UseSHA*Intrinsics are
                 // disabled even if it was explicitly enabled.
                 SHAOptionsBase.USE_SHA_OPTION, "false",
+                String.format("'%s' option should be disabled when all "
+                        + "UseSHA*Intrinsics are disabled even if %s flag set "
+                        + "to JVM", SHAOptionsBase.USE_SHA_OPTION,
+                        CommandLineOptionTest.prepareBooleanFlag(
+                             SHAOptionsBase.USE_SHA_OPTION, true)),
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true),
                 CommandLineOptionTest.prepareBooleanFlag(
@@ -89,6 +102,11 @@
         // if all UseSHA*Intrinsics options were enabled.
         CommandLineOptionTest.verifyOptionValueForSameVM(
                 SHAOptionsBase.USE_SHA_OPTION, "false",
+                String.format("'%s' option should be disabled if %s flag "
+                        + "set even if all UseSHA*Intrinsics were enabled",
+                        SHAOptionsBase.USE_SHA_OPTION,
+                        CommandLineOptionTest.prepareBooleanFlag(
+                            SHAOptionsBase.USE_SHA_OPTION, false)),
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, false),
                 CommandLineOptionTest.prepareBooleanFlag(
--- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedSparcCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedSparcCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -48,18 +48,24 @@
     @Override
     protected void verifyWarnings() throws Throwable {
         // Verify that attempt to use UseSHA option will cause a warning.
+        String shouldPassMessage = String.format("JVM startup should pass with"
+                + " '%s' option on unsupported SparcCPU, but there should be"
+                + "the message shown.", optionName);
         CommandLineOptionTest.verifySameJVMStartup(new String[] {
                         SHAOptionsBase.getWarningForUnsupportedCPU(optionName)
-                }, null, ExitCode.OK,
+                }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK,
                 CommandLineOptionTest.prepareBooleanFlag(optionName, true));
     }
 
     @Override
     protected void verifyOptionValues() throws Throwable {
         // Verify that UseSHA option remains disabled even if all
-        // UseSHA*Intrincs options were enabled.
+        // UseSHA*Intrinsics were enabled.
         CommandLineOptionTest.verifyOptionValueForSameVM(
-                SHAOptionsBase.USE_SHA_OPTION, "false",
+                SHAOptionsBase.USE_SHA_OPTION, "false", String.format(
+                    "%s option should be disabled on unsupported SparcCPU"
+                        + " even if all UseSHA*Intrinsics options were enabled.",
+                    SHAOptionsBase.USE_SHA_OPTION),
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, true),
                 CommandLineOptionTest.prepareBooleanFlag(
@@ -68,9 +74,14 @@
                         SHAOptionsBase.USE_SHA512_INTRINSICS_OPTION, true));
 
         // Verify that UseSHA option remains disabled even if all
-        // UseSHA*Intrincs options were enabled and UseSHA was enabled as well.
+        // UseSHA*Intrinsics options were enabled and UseSHA was enabled as well.
         CommandLineOptionTest.verifyOptionValueForSameVM(
-                SHAOptionsBase.USE_SHA_OPTION, "false",
+                SHAOptionsBase.USE_SHA_OPTION, "false", String.format(
+                    "%s option should be disabled on unsupported SparcCPU"
+                        + " even if all UseSHA*Intrinsics options were enabled"
+                        + " and %s was enabled as well",
+                    SHAOptionsBase.USE_SHA_OPTION,
+                    SHAOptionsBase.USE_SHA_OPTION),
                 CommandLineOptionTest.prepareBooleanFlag(
                         SHAOptionsBase.USE_SHA_OPTION, true),
                 CommandLineOptionTest.prepareBooleanFlag(
--- a/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA1Intrinsics.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA1Intrinsics.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @bug 8035968
  * @summary Verify that SHA-1 intrinsic is actually used.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary ../
+ * @library /testlibrary /../../test/lib /compiler/testlibrary ../
  * @build TestSHA intrinsics.Verifier TestSHA1Intrinsics
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA1MultiBlockIntrinsics.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA1MultiBlockIntrinsics.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @test
  * @bug 8035968
  * @summary Verify that SHA-1 multi block intrinsic is actually used.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary ../
+ * @library /testlibrary /../../test/lib /compiler/testlibrary ../
  * @build TestSHA intrinsics.Verifier TestSHA1MultiBlockIntrinsics
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA256Intrinsics.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA256Intrinsics.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @test
  * @bug 8035968
  * @summary Verify that SHA-256 intrinsic is actually used.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary ../
+ * @library /testlibrary /../../test/lib /compiler/testlibrary ../
  * @build TestSHA intrinsics.Verifier TestSHA256Intrinsics
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA256MultiBlockIntrinsics.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA256MultiBlockIntrinsics.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @test
  * @bug 8035968
  * @summary Verify that SHA-256 multi block intrinsic is actually used.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary ../
+ * @library /testlibrary /../../test/lib /compiler/testlibrary ../
  * @build TestSHA intrinsics.Verifier TestSHA256MultiBlockIntrinsics
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA512Intrinsics.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA512Intrinsics.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @test
  * @bug 8035968
  * @summary Verify that SHA-512 intrinsic is actually used.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary ../
+ * @library /testlibrary /../../test/lib /compiler/testlibrary ../
  * @build TestSHA intrinsics.Verifier TestSHA512Intrinsics
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA512MultiBlockIntrinsics.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA512MultiBlockIntrinsics.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @test
  * @bug 8035968
  * @summary Verify that SHA-512 multi block intrinsic is actually used.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary ../
+ * @library /testlibrary /../../test/lib /compiler/testlibrary ../
  * @build TestSHA intrinsics.Verifier TestSHA512MultiBlockIntrinsics
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rangechecks/TestRangeCheckSmearing.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rangechecks/TestRangeCheckSmearing.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @bug 8066103
  * @summary C2's range check smearing allows out of bound array accesses
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox /testlibrary/com/oracle/java/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/whitebox
  * @build TestRangeCheckSmearing
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  * @run main ClassFileInstaller com.oracle.java.testlibrary.Platform
--- a/hotspot/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -121,7 +121,9 @@
      */
     protected void runNonX86TestCases() throws Throwable {
         CommandLineOptionTest.verifySameJVMStartup(
-                new String[] { errorMessage }, null, ExitCode.FAIL,
+                new String[] { errorMessage }, null,
+                String.format("Option '%s' should be unknown on non-X86CPUs.%n"
+                + "JVM startup should fail", optionName), "", ExitCode.FAIL,
                 prepareOptionValue(defaultValue));
     }
 
@@ -136,12 +138,18 @@
 
     protected void verifyJVMStartup() throws Throwable {
         String optionValue = prepareOptionValue(defaultValue);
+        String shouldFailMessage = String.format("VM option '%s' is "
+                + "experimental.%nVM startup expected to fail without "
+                + "-XX:+UnlockExperimentalVMOptions option", optionName);
+        String shouldPassMessage = String.format("VM option '%s' is "
+                + "experimental%nVM startup should pass with "
+                + "-XX:+UnlockExperimentalVMOptions option", optionName);
         if (isExperimental) {
             // verify that option is experimental
             CommandLineOptionTest.verifySameJVMStartup(
                     new String[] { experimentalOptionError },
-                    new String[] { errorMessage }, ExitCode.FAIL,
-                    optionValue);
+                    new String[] { errorMessage }, shouldFailMessage,
+                    shouldFailMessage, ExitCode.FAIL, optionValue);
             // verify that it could be passed if experimental options
             // are unlocked
             CommandLineOptionTest.verifySameJVMStartup(null,
@@ -149,13 +157,19 @@
                             experimentalOptionError,
                             errorMessage
                     },
+                    shouldPassMessage,
+                    "JVM should start without any warnings or errors",
                     ExitCode.OK,
                     CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                     optionValue);
         } else {
             // verify that option could be passed
             CommandLineOptionTest.verifySameJVMStartup(null,
-                    new String[]{errorMessage}, ExitCode.OK, optionValue);
+                    new String[]{errorMessage},
+                    String.format("VM startup shuld pass with '%s' option",
+                            optionName),
+                    "JVM should start without any warnings or errors",
+                    ExitCode.OK, optionValue);
         }
     }
 
@@ -164,10 +178,14 @@
         if (isExperimental) {
             CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
                     defaultValue,
+                    String.format("Option '%s' is expected to have '%s' "
+                            + "default value", optionName, defaultValue),
                     CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
         } else {
             CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
-                    defaultValue);
+                    defaultValue,
+                    String.format("Option '%s' is expected to have '%s' "
+                            + "default value", optionName, defaultValue));
         }
         // verify other specified option values
         if (optionValues == null) {
@@ -178,11 +196,15 @@
             if (isExperimental) {
                 CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
                         value,
+                        String.format("Option '%s' is set to have '%s' value",
+                                optionName, value),
                         CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                         prepareOptionValue(value));
             } else {
                 CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
-                        value, prepareOptionValue(value));
+                        value,
+                        String.format("Option '%s' is set to have '%s' value",
+                                optionName, value), prepareOptionValue(value));
             }
         }
     }
--- a/hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -131,10 +131,14 @@
         }
         options.add(prepareOptionValue(value));
 
+        String errorString =  String.format("JVM should start with option '%s'"
+                + "'%nWarnings should be shown: %s", optionName,
+                isWarningExpected);
         CommandLineOptionTest.verifySameJVMStartup(
                 (isWarningExpected ? warnings : null),
                 (isWarningExpected ? null : warnings),
-                ExitCode.OK, options.toArray(new String[options.size()]));
+                errorString, errorString, ExitCode.OK,
+                options.toArray(new String[options.size()]));
     }
 
     private void verifyOptionValues(String value, boolean useRTMLocking,
@@ -149,6 +153,9 @@
         options.add(prepareOptionValue(value));
 
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
-                expectedValue, options.toArray(new String[options.size()]));
+                expectedValue, String.format("Option '%s' should have '%s' "
+                        + "value if '%s' flag set",
+                        optionName, expectedValue, prepareOptionValue(value)),
+                options.toArray(new String[options.size()]));
     }
 }
--- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsBase.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsBase.java	Wed Jul 05 20:13:05 2017 +0200
@@ -47,27 +47,42 @@
     protected void verifyJVMStartup() throws Throwable {
         if (Platform.isServer()) {
             if (!Platform.isDebugBuild()) {
+                String shouldFailMessage = String.format("VM option '%s' is "
+                        + "diagnostic%nJVM startup should fail without "
+                        + "-XX:\\+UnlockDiagnosticVMOptions flag", optionName);
+                String shouldPassMessage = String.format("VM option '%s' is "
+                        + "diagnostic%nJVM startup should pass with "
+                        + "-XX:\\+UnlockDiagnosticVMOptions in debug build",
+                        optionName);
                 String errorMessage = CommandLineOptionTest.
                         getDiagnosticOptionErrorMessage(optionName);
                 // verify that option is actually diagnostic
                 CommandLineOptionTest.verifySameJVMStartup(
-                        new String[] { errorMessage }, null, ExitCode.FAIL,
+                        new String[] { errorMessage }, null, shouldFailMessage,
+                        shouldFailMessage, ExitCode.FAIL,
                         prepareOptionValue("true"));
 
                 CommandLineOptionTest.verifySameJVMStartup(null,
-                        new String[] { errorMessage }, ExitCode.OK,
+                        new String[] { errorMessage }, shouldPassMessage,
+                        shouldPassMessage + "without any warnings", ExitCode.OK,
                         CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                         prepareOptionValue("true"));
             } else {
-                CommandLineOptionTest.verifySameJVMStartup(
-                        null, null, ExitCode.OK, prepareOptionValue("true"));
+                String shouldPassMessage = String.format("JVM startup should "
+                                + "pass with '%s' option in debug build",
+                                optionName);
+                CommandLineOptionTest.verifySameJVMStartup(null, null,
+                        shouldPassMessage, shouldPassMessage,
+                        ExitCode.OK, prepareOptionValue("true"));
             }
         } else {
             String errorMessage = CommandLineOptionTest.
                     getUnrecognizedOptionErrorMessage(optionName);
-
+            String shouldFailMessage =  String.format("JVM startup should fail"
+                    + " with '%s' option in not debug build", optionName);
             CommandLineOptionTest.verifySameJVMStartup(
-                    new String[]{errorMessage}, null, ExitCode.FAIL,
+                    new String[]{errorMessage}, null, shouldFailMessage,
+                    shouldFailMessage, ExitCode.FAIL,
                     CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                     prepareOptionValue("true"));
         }
@@ -79,6 +94,9 @@
             // Verify default value
             CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
                     TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE,
+                    String.format("Option '%s' should have '%s' default value",
+                            optionName,
+                       TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE),
                     CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS);
         }
     }
--- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify PrintPreciseRTMLockingStatistics on CPUs with
  *          rtm support and on VM with rtm locking support,
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -53,18 +53,28 @@
         // verify default value
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
                 TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE,
+                String.format("Option '%s' should have '%s' default value on"
+                        + " supported CPU", optionName,
+                TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE),
                 CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:+UseRTMLocking");
 
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
                 TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE,
+                String.format("Option '%s' should have '%s' default value on"
+                        + " supported CPU when -XX:-UseRTMLocking flag set",
+                        optionName,
+                       TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE),
                 CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:-UseRTMLocking", prepareOptionValue("true"));
 
         // verify that option could be turned on
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true",
+                String.format("Option '%s' should have 'true' value when set "
+                        + "on supported CPU and -XX:+UseRTMLocking flag set",
+                        optionName),
                 CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:+UseRTMLocking", prepareOptionValue("true"));
--- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify PrintPreciseRTMLockingStatistics on CPUs without
  *          rtm support and/or unsupported VM.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnSupportedConfig.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnSupportedConfig.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify RTMAbortRatio option processing on CPU with rtm
  *          support and on VM with rtm locking support.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestRTMAbortRatioOptionOnSupportedConfig
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify RTMAbortRatio option processing on CPU without rtm
  *          support or on VM that does not support rtm locking.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestRTMAbortRatioOptionOnUnsupportedConfig
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify RTMTotalCountIncrRate option processing on CPU with
  *          rtm support and on VM with rtm locking support.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestRTMTotalCountIncrRateOptionOnSupportedConfig
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java	Wed Jul 05 20:13:05 2017 +0200
@@ -32,7 +32,7 @@
  * @bug 8031320
  * @summary Verify RTMTotalCountIncrRate option processing on CPU without
  *          rtm support and/or on VM without rtm locking support.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestRTMTotalCountIncrRateOptionOnUnsupportedConfig
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify UseRTMDeopt option processing on CPUs with rtm support
  *          when rtm locking is supported by VM.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestUseRTMDeoptOptionOnSupportedConfig
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -51,26 +51,40 @@
 
     @Override
     public void runTestCases() throws Throwable {
+        String shouldPassMessage = " JVM should startup with option '"
+                + "-XX:+UseRTMDeopt' without any warnings";
         // verify that option could be turned on
         CommandLineOptionTest.verifySameJVMStartup(
-                null, null, ExitCode.OK, "-XX:+UseRTMDeopt");
+                null, null, shouldPassMessage, shouldPassMessage, ExitCode.OK,
+                "-XX:+UseRTMDeopt");
+        shouldPassMessage = " JVM should startup with option '"
+                + "-XX:-UseRTMDeopt' without any warnings";
         // verify that option could be turned off
         CommandLineOptionTest.verifySameJVMStartup(
-                null, null, ExitCode.OK, "-XX:-UseRTMDeopt");
-        // verify default value
-        CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMDeopt",
-                TestUseRTMDeoptOptionOnSupportedConfig.DEFAULT_VALUE);
+                null, null, shouldPassMessage, shouldPassMessage, ExitCode.OK,
+                "-XX:-UseRTMDeopt");
+        String defValMessage = String.format("UseRTMDeopt should have '%s'"
+                                    + "default value",
+                        TestUseRTMDeoptOptionOnSupportedConfig.DEFAULT_VALUE);
         // verify default value
         CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMDeopt",
                 TestUseRTMDeoptOptionOnSupportedConfig.DEFAULT_VALUE,
+                defValMessage);
+        // verify default value
+        CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMDeopt",
+                TestUseRTMDeoptOptionOnSupportedConfig.DEFAULT_VALUE,
+                defValMessage,
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:+UseRTMLocking");
         // verify that option is off when UseRTMLocking is off
-        CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMDeopt", "false",
+        CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMDeopt",
+                "false", "UseRTMDeopt should be off when UseRTMLocking is off",
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:-UseRTMLocking", "-XX:+UseRTMDeopt");
         // verify that option could be turned on
         CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMDeopt", "true",
+                "UseRTMDeopt should be on when UseRTMLocking is on and "
+                        + "'-XX:+UseRTMDeopt' flag set",
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:+UseRTMLocking", "-XX:+UseRTMDeopt");
     }
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify UseRTMDeopt option processing on CPUs without rtm support
  *          or on VMs without rtm locking support.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestUseRTMDeoptOptionOnUnsupportedConfig
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -50,7 +50,8 @@
         super(new NotPredicate(new AndPredicate(new SupportedCPU(),
                         new SupportedVM())),
                 "UseRTMDeopt", true, false,
-                TestUseRTMDeoptOptionOnUnsupportedConfig.DEFAULT_VALUE, "true");
+                TestUseRTMDeoptOptionOnUnsupportedConfig.DEFAULT_VALUE,
+                "true");
     }
 
     @Override
@@ -58,11 +59,16 @@
         super.verifyJVMStartup();
         // verify default value
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
-                defaultValue);
+                defaultValue, String.format("'%s' should have '%s' "
+                        + "default value on unsupported configs.",
+                        optionName, DEFAULT_VALUE));
         // verify that until RTMLocking is not used, value
         // will be set to default false.
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
-                defaultValue, "-XX:+UseRTMDeopt");
+                defaultValue, String.format("'%s' should be off on unsupported"
+                        + " configs even if '-XX:+%s' flag set", optionName,
+                        optionName),
+                "-XX:+UseRTMDeopt");
     }
 
     public static void main(String args[]) throws Throwable {
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify UseRTMForStackLocks option processing on CPU with
  *          rtm support when VM supports rtm locking.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestUseRTMForStackLocksOptionOnSupportedConfig
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -58,43 +58,67 @@
         String warningMessage
                 = RTMGenericCommandLineOptionTest.RTM_FOR_STACK_LOCKS_WARNING;
 
+        String shouldFailMessage = " VM option 'UseRTMForStackLocks' is "
+                + "experimental%nJVM startup should fail without "
+                + "-XX:+UnlockExperimentalVMOptions flag";
+
         CommandLineOptionTest.verifySameJVMStartup(
-                new String[] { errorMessage }, null, ExitCode.FAIL,
+                new String[] { errorMessage }, null, shouldFailMessage,
+                shouldFailMessage + "%nError message expected", ExitCode.FAIL,
                 "-XX:+UseRTMForStackLocks");
+        String shouldPassMessage = " VM option 'UseRTMForStackLocks'"
+                + " is experimental%nJVM startup should pass with "
+                + "-XX:+UnlockExperimentalVMOptions flag";
         // verify that we get a warning when trying to use rtm for stack
         // lock, but not using rtm locking.
         CommandLineOptionTest.verifySameJVMStartup(
-                new String[] { warningMessage }, null, ExitCode.OK,
+                new String[] { warningMessage }, null, shouldPassMessage,
+                "There should be warning when trying to use rtm for stack "
+                        + "lock, but not using rtm locking", ExitCode.OK,
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:+UseRTMForStackLocks",
                 "-XX:-UseRTMLocking");
         // verify that we don't get a warning when no using rtm for stack
         // lock and not using rtm locking.
         CommandLineOptionTest.verifySameJVMStartup(null,
-                new String[] { warningMessage }, ExitCode.OK,
+                new String[] { warningMessage }, shouldPassMessage,
+                "There should not be any warning when use both "
+                        + "-XX:-UseRTMForStackLocks and -XX:-UseRTMLocking "
+                        + "flags",
+                ExitCode.OK,
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:-UseRTMForStackLocks",
                 "-XX:-UseRTMLocking");
         // verify that we don't get a warning when using rtm for stack
         // lock and using rtm locking.
         CommandLineOptionTest.verifySameJVMStartup(null,
-                new String[] { warningMessage }, ExitCode.OK,
+                new String[] { warningMessage }, shouldPassMessage,
+                "There should not be any warning when use both "
+                        + "-XX:+UseRTMForStackLocks and -XX:+UseRTMLocking"
+                        + " flags",
+                ExitCode.OK,
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:+UseRTMForStackLocks",
                 "-XX:+UseRTMLocking");
         // verify that default value if false
         CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMForStackLocks",
                 TestUseRTMForStackLocksOptionOnSupportedConfig.DEFAULT_VALUE,
+                "Default value of option 'UseRTMForStackLocks' should be false",
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
         // verify that default value is false even with +UseRTMLocking
         CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMForStackLocks",
                 TestUseRTMForStackLocksOptionOnSupportedConfig.DEFAULT_VALUE,
+                "Default value of option 'UseRTMForStackLocks' should be false",
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:+UseRTMLocking");
         // verify that we can turn the option on
         CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMForStackLocks",
-                "true", CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
-                "-XX:+UseRTMLocking", "-XX:+UseRTMForStackLocks");
+                        "true", "Value of option 'UseRTMForStackLocks' should "
+                                + "be able to be set as 'true' when both "
+                                + "-XX:+UseRTMForStackLocks and "
+                                + "-XX:+UseRTMLocking flags used",
+                        CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
+                        "-XX:+UseRTMLocking", "-XX:+UseRTMForStackLocks");
     }
 
     public static void main(String args[]) throws Throwable {
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify UseRTMForStackLocks option processing on CPUs without
  *          rtm support and/or on VMs without rtm locking support.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestUseRTMForStackLocksOptionOnUnsupportedConfig
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -57,33 +57,50 @@
 
     @Override
     protected void runX86SupportedVMTestCases() throws Throwable {
+        String shouldFailMessage = String.format("VM option '%s' is "
+                + "experimental%nJVM startup should fail without "
+                + "-XX:+UnlockExperimentalVMOptions flag", optionName);
+
         // verify that option is experimental
         CommandLineOptionTest.verifySameJVMStartup(
-                new String[]{ experimentalOptionError },
-                null, ExitCode.FAIL, prepareOptionValue("true"));
+                new String[] { experimentalOptionError }, null,
+                shouldFailMessage, shouldFailMessage + "%nError message "
+                        + "should be shown", ExitCode.FAIL,
+                prepareOptionValue("true"));
 
         CommandLineOptionTest.verifySameJVMStartup(
-                new String[]{ experimentalOptionError },
-                null, ExitCode.FAIL, prepareOptionValue("false"));
+                new String[]{ experimentalOptionError }, null,
+                shouldFailMessage, shouldFailMessage + "%nError message "
+                        + "should be shown", ExitCode.FAIL,
+                prepareOptionValue("false"));
 
+        String shouldPassMessage = String.format("VM option '%s' is "
+                + " experimental%nJVM startup should pass with "
+                + "-XX:+UnlockExperimentalVMOptions flag", optionName);
         // verify that if we turn it on, then VM output will contain
         // warning saying that this option could be turned on only
         // when we use rtm locking
         CommandLineOptionTest.verifySameJVMStartup(
                 new String[]{
                     RTMGenericCommandLineOptionTest.RTM_FOR_STACK_LOCKS_WARNING
-                },
-                null, ExitCode.OK,
+                }, null, shouldPassMessage, "There should be warning when try "
+                    + "to use rtm for stack lock, but not using rtm locking",
+                ExitCode.OK,
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 prepareOptionValue("true")
         );
         // verify that options is turned off by default
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
                 TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,
+                String.format("Default value of option '%s' should be '%s'",
+                        optionName, DEFAULT_VALUE),
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
         // verify that it could not be turned on without rtm locking
         CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
                 TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,
+                String.format("Value of '%s' shouldn't able to be set to "
+                        + "'true' without setting -XX:+UseRTMLocking flag",
+                        optionName),
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 prepareOptionValue("true"));
     }
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify UseRTMLocking option processing on CPU with rtm support and
  *          on VM with rtm-locking support.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestUseRTMLockingOptionOnSupportedConfig
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -54,12 +54,16 @@
         String unrecongnizedOption
                 =  CommandLineOptionTest.getUnrecognizedOptionErrorMessage(
                 "UseRTMLocking");
+        String shouldPassMessage = "VM option 'UseRTMLocking' is experimental"
+                + "%nJVM startup should pass with "
+                + "-XX:+UnlockExperimentalVMOptions flag";
         // verify that there are no warning or error in VM output
         CommandLineOptionTest.verifySameJVMStartup(null,
                 new String[]{
                         RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR,
                         unrecongnizedOption
-                }, ExitCode.OK,
+                }, shouldPassMessage, "There should not be any warning when use"
+                        + "with -XX:+UnlockExperimentalVMOptions", ExitCode.OK,
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:+UseRTMLocking"
         );
@@ -68,21 +72,28 @@
                 new String[]{
                         RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR,
                         unrecongnizedOption
-                }, ExitCode.OK,
+                }, shouldPassMessage, "There should not be any warning when use"
+                        + "with -XX:+UnlockExperimentalVMOptions", ExitCode.OK,
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:-UseRTMLocking"
         );
         // verify that UseRTMLocking is of by default
         CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",
                 TestUseRTMLockingOptionOnSupportedConfig.DEFAULT_VALUE,
+                String.format("Default value of option 'UseRTMLocking' should "
+                    + "be '%s'", DEFAULT_VALUE),
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
         // verify that we can change UseRTMLocking value
         CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",
                 TestUseRTMLockingOptionOnSupportedConfig.DEFAULT_VALUE,
+                String.format("Default value of option 'UseRTMLocking' should "
+                    + "be '%s'", DEFAULT_VALUE),
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:-UseRTMLocking");
         CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",
-                "true", CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
+                "true", "Value of 'UseRTMLocking' should be set "
+                        + "to 'true' if -XX:+UseRTMLocking flag set",
+                CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:+UseRTMLocking");
     }
 
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify UseRTMLocking option processing on CPU without
  *          rtm support.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestUseRTMLockingOptionOnUnsupportedCPU
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -59,33 +59,44 @@
         String errorMessage = RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR;
 
         if (Platform.isX86() || Platform.isX64()) {
+            String shouldFailMessage = "JVM startup should fail with option "
+                    + "-XX:+UseRTMLocking on unsupported CPU";
             // verify that we get an error when use +UseRTMLocking
             // on unsupported CPU
             CommandLineOptionTest.verifySameJVMStartup(
                     new String[] { errorMessage },
-                    new String[] { unrecongnizedOption },
+                    new String[] { unrecongnizedOption }, shouldFailMessage,
+                    shouldFailMessage + ". Error message should be shown",
                     ExitCode.FAIL, "-XX:+UseRTMLocking");
+
+            String shouldPassMessage = "JVM startup should pass with option "
+                    + "-XX:-UseRTMLocking even on unsupported CPU";
             // verify that we can pass -UseRTMLocking without
             // getting any error messages
-            CommandLineOptionTest.verifySameJVMStartup(
-                    null,
-                    new String[]{
-                            errorMessage,
-                            unrecongnizedOption
-                    }, ExitCode.OK, "-XX:-UseRTMLocking");
+            CommandLineOptionTest.verifySameJVMStartup(null, new String[] {
+                    errorMessage, unrecongnizedOption }, shouldPassMessage,
+                    shouldPassMessage + " without any warnings", ExitCode.OK,
+                    "-XX:-UseRTMLocking");
 
             // verify that UseRTMLocking is false by default
             CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",
-                    TestUseRTMLockingOptionOnUnsupportedCPU.DEFAULT_VALUE);
+                    TestUseRTMLockingOptionOnUnsupportedCPU.DEFAULT_VALUE,
+                    String.format("Default value of option 'UseRTMLocking' "
+                        +"should be '%s'", DEFAULT_VALUE));
         } else {
+            String shouldFailMessage = "RTMLocking should be unrecognized"
+                    + " on non-x86 CPUs. JVM startup should fail."
+                    + "Error message should be shown";
             // verify that on non-x86 CPUs RTMLocking could not be used
             CommandLineOptionTest.verifySameJVMStartup(
                     new String[] { unrecongnizedOption },
-                    null, ExitCode.FAIL, "-XX:+UseRTMLocking");
+                    null, shouldFailMessage, shouldFailMessage,
+                    ExitCode.FAIL, "-XX:+UseRTMLocking");
 
             CommandLineOptionTest.verifySameJVMStartup(
                     new String[] { unrecongnizedOption },
-                    null, ExitCode.FAIL, "-XX:-UseRTMLocking");
+                    null, shouldFailMessage, shouldFailMessage,
+                    ExitCode.FAIL, "-XX:-UseRTMLocking");
         }
     }
 
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedVM.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedVM.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify UseRTMLocking option processing on CPU with rtm support
  *          in case when VM should not support this option.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestUseRTMLockingOptionOnUnsupportedVM
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -54,17 +54,26 @@
     public void runTestCases() throws Throwable {
         String errorMessage
                 = RTMGenericCommandLineOptionTest.RTM_UNSUPPORTED_VM_ERROR;
+        String shouldFailMessage = "JVM startup should fail with option "
+                + "-XX:+UseRTMLocking even on unsupported VM. Error message"
+                + " should be shown";
+        String shouldPassMessage = "JVM startup should pass with option "
+                + "-XX:-UseRTMLocking even on unsupported VM";
         // verify that we can't use +UseRTMLocking
         CommandLineOptionTest.verifySameJVMStartup(
-                new String[] { errorMessage }, null, ExitCode.FAIL,
-                "-XX:+UseRTMLocking");
+                new String[] { errorMessage }, null, shouldFailMessage,
+                shouldFailMessage, ExitCode.FAIL,
+                 "-XX:+UseRTMLocking");
         // verify that we can turn it off
         CommandLineOptionTest.verifySameJVMStartup(null,
-                new String[] { errorMessage }, ExitCode.OK,
+                new String[] { errorMessage }, shouldPassMessage,
+                shouldPassMessage + " without any warnings", ExitCode.OK,
                 "-XX:-UseRTMLocking");
         // verify that it is off by default
         CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",
-                TestUseRTMLockingOptionOnUnsupportedVM.DEFAULT_VALUE);
+                TestUseRTMLockingOptionOnUnsupportedVM.DEFAULT_VALUE,
+                String.format("Default value of option 'UseRTMLocking' should"
+                    + " be '%s'", DEFAULT_VALUE));
     }
 
     public static void main(String args[]) throws Throwable {
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify processing of UseRTMLocking and UseBiasedLocking
  *          options combination on CPU and VM with rtm support.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestUseRTMLockingOptionWithBiasedLocking
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -51,25 +51,44 @@
     public void runTestCases() throws Throwable {
         String warningMessage
                 = RTMGenericCommandLineOptionTest.RTM_BIASED_LOCKING_WARNING;
+        String shouldPassMessage = "JVM startup should pass with both "
+                + "-XX:+UseRTMLocking and "
+                + "-XX:-UseBiasedLocking flags set without any warnings";
         // verify that we will not get a warning
         CommandLineOptionTest.verifySameJVMStartup(null,
-                new String[] { warningMessage }, ExitCode.OK,
+                new String[] { warningMessage }, shouldPassMessage,
+                shouldPassMessage, ExitCode.OK,
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:+UseRTMLocking", "-XX:-UseBiasedLocking");
+
         // verify that we will get a warning
         CommandLineOptionTest.verifySameJVMStartup(
-                new String[] { warningMessage }, null, ExitCode.OK,
+                new String[] { warningMessage }, null,
+                "JVM startup should pass when both -XX:+UseRTMLocking and "
+                        + "-XX:+UseBiasedLocking flags set",
+                "Flags -XX:+UseRTMLocking"
+                        + " and -XX:+UseBiasedLocking conflicts. "
+                        + "Warning should be shown.", ExitCode.OK,
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:+UseRTMLocking", "-XX:+UseBiasedLocking");
         // verify that UseBiasedLocking is false when we use rtm locking
         CommandLineOptionTest.verifyOptionValueForSameVM("UseBiasedLocking",
-                "false", CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
+                "false",
+                "Value of option 'UseBiasedLocking' should be false if"
+                        + "-XX:+UseRTMLocking flag set.",
+                CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
                 "-XX:+UseRTMLocking");
         // verify that we can't turn on biased locking when
         // using rtm locking
-        CommandLineOptionTest.verifyOptionValueForSameVM("UseBiasedLocking",
-                "false", CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
-                "-XX:+UseRTMLocking", "-XX:+UseBiasedLocking");
+        CommandLineOptionTest
+                .verifyOptionValueForSameVM(
+                        "UseBiasedLocking",
+                        "false",
+                        "Value of option 'UseBiasedLocking' should be false if"
+                                + "both -XX:+UseRTMLocking and "
+                                + "-XX:+UseBiasedLocking flags set.",
+                        CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
+                        "-XX:+UseRTMLocking", "-XX:+UseBiasedLocking");
     }
 
     public static void main(String args[]) throws Throwable {
--- a/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify that RTMAbortRatio affects amount of aborts before
  *          deoptimization.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestRTMAbortRatio
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMAbortThreshold.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortThreshold.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify that RTMAbortThreshold option affects
  *          amount of aborts after which abort ratio is calculated.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestRTMAbortThreshold
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java	Wed Jul 05 20:13:05 2017 +0200
@@ -29,7 +29,7 @@
  *          caused by reason other then rtm_state_change will reset
  *          method's RTM state. And if we don't use RTMDeopt, then
  *          RTM state remain the same after such deoptimization.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestRTMAfterNonRTMDeopt
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify that on high abort ratio method will be recompiled
  *          without rtm locking.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestRTMDeoptOnHighAbortRatio
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @test
  * @bug 8031320
  * @summary Verify that on low abort ratio method will be recompiled.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestRTMDeoptOnLowAbortRatio
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMLockingCalculationDelay.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingCalculationDelay.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify that RTMLockingCalculationDelay affect when
  *          abort ratio calculation is started.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestRTMLockingCalculationDelay
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify that RTMLockingThreshold affects rtm state transition
  *          ProfileRTM => UseRTM.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestRTMLockingThreshold
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMRetryCount.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestRTMRetryCount.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @test
  * @bug 8031320
  * @summary Verify that RTMRetryCount affects actual amount of retries.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestRTMRetryCount
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMSpinLoopCount.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestRTMSpinLoopCount.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify that RTMSpinLoopCount affects time spent
  *          between locking attempts.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestRTMSpinLoopCount
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify that RTMTotalCountIncrRate option affects
  *          RTM locking statistics.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestRTMTotalCountIncrRate
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMAfterLockInflation.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMAfterLockInflation.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify that rtm locking is used for stack locks before
  *          inflation and after it used for inflated locks.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestUseRTMAfterLockInflation
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMDeopt.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMDeopt.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify that UseRTMDeopt affects uncommon trap installation in
  *          copmpiled methods with synchronized block.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestUseRTMDeopt
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMForInflatedLocks.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMForInflatedLocks.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @test
  * @bug 8031320
  * @summary Verify that rtm locking is used for inflated locks.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestUseRTMForInflatedLocks
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMForStackLocks.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMForStackLocks.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @test
  * @bug 8031320
  * @summary Verify that rtm locking is used for stack locks.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestUseRTMForStackLocks
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMXendForLockBusy.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMXendForLockBusy.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify that UseRTMXendForLockBusy option affects
  *          method behaviour if lock is busy.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestUseRTMXendForLockBusy
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/method_options/TestNoRTMLockElidingOption.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/method_options/TestNoRTMLockElidingOption.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8031320
  * @summary Verify that NoRTMLockEliding option could be applied to
  *          specified method and that such method will not use rtm.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestNoRTMLockElidingOption
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/method_options/TestUseRTMLockElidingOption.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/method_options/TestUseRTMLockElidingOption.java	Wed Jul 05 20:13:05 2017 +0200
@@ -28,7 +28,7 @@
  * @summary Verify that UseRTMLockEliding option could be applied to
  *          specified method and that such method will not be deoptimized
  *          on high abort ratio.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestUseRTMLockElidingOption
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java	Wed Jul 05 20:13:05 2017 +0200
@@ -29,7 +29,7 @@
  *          on overall aborts and locks count and count of aborts of
  *          different types. Test also verify that VM output does not
  *          contain rtm locking statistics when it should not.
- * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @library /testlibrary /../../test/lib /compiler/testlibrary
  * @build TestPrintPreciseRTMLockingStatistics
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/runtime/8010927/Test8010927.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/runtime/8010927/Test8010927.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @bug 8010927
  * @summary Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
- * @library /testlibrary/whitebox /testlibrary
+ * @library /../../test/lib /testlibrary
  * @build Test8010927
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/stable/TestStableBoolean.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/stable/TestStableBoolean.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
 /*
  * @test TestStableBoolean
  * @summary tests on stable fields and arrays
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestStableBoolean StableConfiguration sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
--- a/hotspot/test/compiler/stable/TestStableByte.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/stable/TestStableByte.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
 /*
  * @test TestStableByte
  * @summary tests on stable fields and arrays
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestStableByte StableConfiguration sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
--- a/hotspot/test/compiler/stable/TestStableChar.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/stable/TestStableChar.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
 /*
  * @test TestStableChar
  * @summary tests on stable fields and arrays
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestStableChar StableConfiguration sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
--- a/hotspot/test/compiler/stable/TestStableDouble.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/stable/TestStableDouble.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
 /*
  * @test TestStableDouble
  * @summary tests on stable fields and arrays
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestStableDouble StableConfiguration sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
--- a/hotspot/test/compiler/stable/TestStableFloat.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/stable/TestStableFloat.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
 /*
  * @test TestStableFloat
  * @summary tests on stable fields and arrays
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestStableFloat StableConfiguration sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
--- a/hotspot/test/compiler/stable/TestStableInt.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/stable/TestStableInt.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
 /*
  * @test TestStableInt
  * @summary tests on stable fields and arrays
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestStableInt StableConfiguration sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
--- a/hotspot/test/compiler/stable/TestStableLong.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/stable/TestStableLong.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
 /*
  * @test TestStableLong
  * @summary tests on stable fields and arrays
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestStableLong StableConfiguration sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
--- a/hotspot/test/compiler/stable/TestStableObject.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/stable/TestStableObject.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
 /*
  * @test TestStableObject
  * @summary tests on stable fields and arrays
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestStableObject StableConfiguration sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
--- a/hotspot/test/compiler/stable/TestStableShort.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/stable/TestStableShort.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
 /*
  * @test TestStableShort
  * @summary tests on stable fields and arrays
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestStableShort StableConfiguration sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/tiered/ConstantGettersTransitionsTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.reflect.Executable;
+import java.util.concurrent.Callable;
+
+/**
+ * @test ConstantGettersTransitionsTest
+ * @library /testlibrary /../../test/lib /compiler/whitebox
+ * @build TransitionsTestExecutor ConstantGettersTransitionsTest
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ *                   -XX:+WhiteBoxAPI -XX:+TieredCompilation
+ *                   -XX:CompileCommand=compileonly,ConstantGettersTestCase$TrivialMethods::*
+ *                   TransitionsTestExecutor ConstantGettersTransitionsTest
+ * @summary Test the correctness of compilation level transitions for constant getters methods
+ */
+public class ConstantGettersTransitionsTest extends LevelTransitionTest {
+    public static void main(String[] args) {
+        assert (!CompilerWhiteBoxTest.skipOnTieredCompilation(false));
+
+        // run test cases
+        for (TestCase testCase : ConstantGettersTestCase.values()) {
+            new ConstantGettersTransitionsTest(testCase).runTest();
+        }
+    }
+
+    @Override
+    protected boolean isTrivial() {
+        return true;
+    }
+
+    private ConstantGettersTransitionsTest(TestCase testCase) {
+        super(testCase);
+    }
+}
+
+enum ConstantGettersTestCase implements CompilerWhiteBoxTest.TestCase {
+    ICONST_M1,
+    ICONST_0,
+    ICONST_1,
+    ICONST_2,
+    ICONST_3,
+    ICONST_4,
+    ICONST_5,
+    LCONST_0,
+    LCONST_1,
+    FCONST_0,
+    FCONST_1,
+    FCONST_2,
+    DCONST_0,
+    DCONST_1,
+    DCONST_W,
+    BYTE,
+    SHORT,
+    CHAR;
+
+    private final Executable executable;
+    private final Callable<Integer> callable;
+
+    @Override
+    public Executable getExecutable() {
+        return executable;
+    }
+
+    @Override
+    public Callable<Integer> getCallable() {
+        return callable;
+    }
+
+    @Override
+    public boolean isOsr() {
+        return false;
+    }
+
+    private ConstantGettersTestCase() {
+        String name = "make" + this.name();
+        this.executable = LevelTransitionTest.Helper.getMethod(TrivialMethods.class, name);
+        this.callable = LevelTransitionTest.Helper.getCallable(new TrivialMethods(), name);
+    }
+
+    /**
+     * Contains methods that load constants with certain types of bytecodes
+     * See JVMS 2.11.2. Load and Store Instructions
+     * Note that it doesn't have a method for ldc_w instruction
+     */
+    private static class TrivialMethods {
+        public static int makeICONST_M1() {
+            return -1;
+        }
+
+        public static int makeICONST_0() {
+            return 0;
+        }
+
+        public static int makeICONST_1() {
+            return 1;
+        }
+
+        public static int makeICONST_2() {
+            return 2;
+        }
+
+        public static int makeICONST_3() {
+            return 3;
+        }
+
+        public static int makeICONST_4() {
+            return 4;
+        }
+
+        public static int makeICONST_5() {
+            return 5;
+        }
+
+        public static long makeLCONST_0() {
+            return 0L;
+        }
+
+        public static long makeLCONST_1() {
+            return 1L;
+        }
+
+        public static float makeFCONST_0() {
+            return 0F;
+        }
+
+        public static float makeFCONST_1() {
+            return 1F;
+        }
+
+        public static float makeFCONST_2() {
+            return 2F;
+        }
+
+        public static double makeDCONST_0() {
+            return 0D;
+        }
+
+        public static double makeDCONST_1() {
+            return 1D;
+        }
+
+        public static double makeDCONST_W() {
+            // ldc2_w
+            return Double.MAX_VALUE;
+        }
+
+        public static Object makeOBJECT() {
+            // aconst_null
+            return null;
+        }
+
+        public static byte makeBYTE() {
+            // bipush
+            return (byte) 0x7F;
+        }
+
+        public static short makeSHORT() {
+            // sipush
+            return (short) 0x7FFF;
+        }
+
+        public static char makeCHAR() {
+            // ldc
+            return (char) 0xFFFF;
+        }
+
+        public static boolean makeBOOLEAN() {
+            return true;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/tiered/LevelTransitionTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.reflect.Executable;
+import java.lang.reflect.Method;
+import java.util.Objects;
+import java.util.concurrent.Callable;
+
+/**
+ * @test LevelTransitionTest
+ * @library /testlibrary /../../test/lib /compiler/whitebox
+ * @build TransitionsTestExecutor LevelTransitionTest
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ *                   -XX:+WhiteBoxAPI -XX:+TieredCompilation
+ *                   -XX:CompileCommand=compileonly,SimpleTestCase$Helper::*
+ *                   -XX:CompileCommand=compileonly,ExtendedTestCase$CompileMethodHolder::*
+ *                   TransitionsTestExecutor LevelTransitionTest
+ * @summary Test the correctness of compilation level transitions for different methods
+ */
+public class LevelTransitionTest extends TieredLevelsTest {
+    /** Shows if method was profiled by being executed on levels 2 or 3 */
+    protected boolean isMethodProfiled;
+    private int transitionCount;
+
+    public static void main(String[] args) throws Throwable {
+        assert (!CompilerWhiteBoxTest.skipOnTieredCompilation(false));
+
+        CompilerWhiteBoxTest.main(LevelTransitionTest::new, args);
+        // run extended test cases
+        for (TestCase testCase : ExtendedTestCase.values()) {
+            new LevelTransitionTest(testCase).runTest();
+        }
+    }
+
+    protected LevelTransitionTest(TestCase testCase) {
+        super(testCase);
+        isMethodProfiled = testCase.isOsr(); // OSR methods were already profiled by warmup
+        transitionCount = 0;
+    }
+
+    @Override
+    protected void test() throws Exception {
+        checkTransitions();
+        deoptimize();
+        printInfo();
+        if (testCase.isOsr()) {
+            // deoptimization makes the following transitions be unstable
+            // methods go to level 3 before 4 because of uncommon_trap and reprofile
+            return;
+        }
+        checkTransitions();
+    }
+
+    /**
+     * Makes and verifies transitions between compilation levels
+     */
+    protected void checkTransitions() {
+        checkNotCompiled();
+        boolean finish = false;
+        while (!finish) {
+            System.out.printf("Level transition #%d%n", ++transitionCount);
+            int newLevel;
+            int current = getCompLevel();
+            int expected = getNextLevel(current);
+            if (current == expected) {
+                // if we are on expected level, just execute it more
+                // to ensure that the level won't change
+                System.out.printf("Method %s is already on expected level %d%n", method, expected);
+                compile();
+                newLevel = getCompLevel();
+                finish = true;
+            } else {
+                newLevel = changeCompLevel();
+                finish = false;
+            }
+            System.out.printf("Method %s is compiled on level %d. Expected level is %d%n", method, newLevel, expected);
+            checkLevel(expected, newLevel);
+            printInfo();
+        };
+    }
+
+    /**
+     * Gets next expected level for the test case on each transition.
+     *
+     * @param currentLevel a level the test case is compiled on
+     * @return expected compilation level
+     */
+    protected int getNextLevel(int currentLevel) {
+        int nextLevel = currentLevel;
+        switch (currentLevel) {
+            case CompilerWhiteBoxTest.COMP_LEVEL_NONE:
+                nextLevel = isMethodProfiled ? CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION
+                        : CompilerWhiteBoxTest.COMP_LEVEL_FULL_PROFILE;
+                break;
+            case CompilerWhiteBoxTest.COMP_LEVEL_LIMITED_PROFILE:
+            case CompilerWhiteBoxTest.COMP_LEVEL_FULL_PROFILE:
+                nextLevel = CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION;
+                isMethodProfiled = true;
+                break;
+        }
+        nextLevel = isTrivial() ? CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE : nextLevel;
+        return Math.min(nextLevel, CompilerWhiteBoxTest.TIERED_STOP_AT_LEVEL);
+    }
+
+    /**
+     * Determines if tested method should be handled as trivial
+     *
+     * @return {@code true} for trivial methods, {@code false} otherwise
+     */
+    protected boolean isTrivial() {
+        return testCase == ExtendedTestCase.ACCESSOR_TEST
+                || testCase == SimpleTestCase.METHOD_TEST
+                || testCase == SimpleTestCase.STATIC_TEST
+                || (testCase == ExtendedTestCase.TRIVIAL_CODE_TEST && isMethodProfiled);
+    }
+
+    /**
+     * Invokes {@linkplain #method} until its compilation level is changed.
+     * Note that if the level won't change, it will be an endless loop
+     *
+     * @return compilation level the {@linkplain #method} was compiled on
+     */
+    protected int changeCompLevel() {
+        int currentLevel = getCompLevel();
+        int newLevel = currentLevel;
+        int result = 0;
+        while (currentLevel == newLevel) {
+            result = compile(1);
+            if (WHITE_BOX.isMethodCompiled(method, testCase.isOsr())) {
+                newLevel = getCompLevel();
+            }
+        }
+        return newLevel;
+    }
+
+    protected static class Helper {
+        /**
+         * Gets method from a specified class using its name
+         *
+         * @param aClass type method belongs to
+         * @param name   the name of the method
+         * @return {@link Method} that represents corresponding class method
+         */
+        public static Method getMethod(Class<?> aClass, String name) {
+            Method method;
+            try {
+                method = aClass.getDeclaredMethod(name);
+            } catch (NoSuchMethodException e) {
+                throw new Error("TESTBUG: Unable to get method " + name, e);
+            }
+            return method;
+        }
+
+        /**
+         * Gets {@link Callable} that invokes given method from the given object
+         *
+         * @param object the object the specified method is invoked from
+         * @param name   the name of the method
+         */
+        public static Callable<Integer> getCallable(Object object, String name) {
+            Method method = getMethod(object.getClass(), name);
+            return () -> {
+                try {
+                    return Objects.hashCode(method.invoke(object));
+                } catch (ReflectiveOperationException e) {
+                    throw new Error("TESTBUG: Invocation failure", e);
+                }
+            };
+        }
+    }
+}
+
+enum ExtendedTestCase implements CompilerWhiteBoxTest.TestCase {
+    ACCESSOR_TEST("accessor"),
+    NONTRIVIAL_METHOD_TEST("nonTrivialMethod"),
+    TRIVIAL_CODE_TEST("trivialCode");
+
+    private final Executable executable;
+    private final Callable<Integer> callable;
+
+    @Override
+    public Executable getExecutable() {
+        return executable;
+    }
+
+    @Override
+    public Callable<Integer> getCallable() {
+        return callable;
+    }
+
+    @Override
+    public boolean isOsr() {
+        return false;
+    }
+
+    private ExtendedTestCase(String methodName) {
+        this.executable = LevelTransitionTest.Helper.getMethod(CompileMethodHolder.class, methodName);
+        this.callable = LevelTransitionTest.Helper.getCallable(new CompileMethodHolder(), methodName);
+    }
+
+    private static class CompileMethodHolder {
+        private final int iter = 10;
+        private int field = 42;
+
+        /** Non-trivial method for threshold policy: contains loops */
+        public int nonTrivialMethod() {
+            int acc = 0;
+            for (int i = 0; i < iter; i++) {
+                acc += i;
+            }
+            return acc;
+        }
+
+        /** Field accessor method */
+        public int accessor() {
+            return field;
+        }
+
+        /** Method considered as trivial by amount of code */
+        public int trivialCode() {
+            int var = 0xBAAD_C0DE;
+            var *= field;
+            return var;
+        }
+    }
+}
--- a/hotspot/test/compiler/tiered/NonTieredLevelsTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
 
 /**
  * @test NonTieredLevelsTest
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
+ * @library /testlibrary /../../test/lib /compiler/whitebox
  * @build NonTieredLevelsTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -55,9 +55,7 @@
 
     }
     public static void main(String[] args) throws Exception {
-        if (TIERED_COMPILATION) {
-            System.err.println("Test isn't applicable w/ enabled "
-                    + "TieredCompilation. Skip test.");
+        if (CompilerWhiteBoxTest.skipOnTieredCompilation(true)) {
             return;
         }
         CompilerWhiteBoxTest.main(NonTieredLevelsTest::new, args);
--- a/hotspot/test/compiler/tiered/TieredLevelsTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/tiered/TieredLevelsTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,7 +23,7 @@
 
 /**
  * @test TieredLevelsTest
- * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
+ * @library /testlibrary /../../test/lib /compiler/whitebox
  * @build TieredLevelsTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -35,16 +35,14 @@
  * @author igor.ignatyev@oracle.com
  */
 public class TieredLevelsTest extends CompLevelsTest {
-    public static void main(String[] args) throws Exception {
-        if (!TIERED_COMPILATION) {
-            System.err.println("Test isn't applicable w/ disabled "
-                    + "TieredCompilation. Skip test.");
+    public static void main(String[] args) throws Exception, Throwable {
+        if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) {
             return;
         }
         CompilerWhiteBoxTest.main(TieredLevelsTest::new, args);
     }
 
-    private TieredLevelsTest(TestCase testCase) {
+    protected TieredLevelsTest(TestCase testCase) {
         super(testCase);
         // to prevent inlining of #method
         WHITE_BOX.testSetDontInlineMethod(method, true);
@@ -77,14 +75,18 @@
         }
     }
 
-
     @Override
     protected void checkLevel(int expected, int actual) {
         if (expected == COMP_LEVEL_FULL_PROFILE
                 && actual == COMP_LEVEL_LIMITED_PROFILE) {
             // for simple method full_profile may be replaced by limited_profile
+            if (IS_VERBOSE) {
+                System.out.printf("Level check: full profiling was replaced "
+                        + "by limited profiling. Expected: %d, actual:%d",
+                        expected, actual);
+            }
             return;
         }
         super.checkLevel(expected, actual);
-   }
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/tiered/TransitionsTestExecutor.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Executes given test in a separate VM with enabled Tiered Compilation for
+ * CompilationPolicyChoice 2 and 3
+ */
+public class TransitionsTestExecutor {
+    public static void main(String[] args) throws Throwable {
+        if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) {
+            return;
+        }
+        if (args.length != 1) {
+            throw new Error("TESTBUG: Test name should be specified");
+        }
+        executeTestFor(2, args[0]);
+        executeTestFor(3, args[0]);
+    }
+
+    private static void executeTestFor(int compilationPolicy, String testName) throws Throwable {
+        String policy = "-XX:CompilationPolicyChoice=" + compilationPolicy;
+
+        // Get runtime arguments including VM options given to this executor
+        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
+        List<String> vmArgs = runtime.getInputArguments();
+
+        // Construct execution command with compilation policy choice and test name
+        List<String> args = new ArrayList<>(vmArgs);
+        Collections.addAll(args, policy, testName);
+
+        OutputAnalyzer out = ProcessTools.executeTestJvm(args.toArray(new String[args.size()]));
+        int exitCode = out.getExitValue();
+        if (exitCode != 0) {
+            throw new Error("Test execution failed with exit code " + exitCode);
+        }
+    }
+}
--- a/hotspot/test/compiler/types/correctness/CorrectnessTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/types/correctness/CorrectnessTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test CorrectnessTest
  * @bug 8038418
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @ignore 8066173
  * @compile execution/TypeConflict.java execution/TypeProfile.java
  *          execution/MethodHandleDelegate.java
--- a/hotspot/test/compiler/types/correctness/OffTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/types/correctness/OffTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test CorrectnessTest
  * @bug 8038418
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @ignore 8066173
  * @compile execution/TypeConflict.java execution/TypeProfile.java
  *          execution/MethodHandleDelegate.java
--- a/hotspot/test/compiler/uncommontrap/8009761/Test8009761.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/uncommontrap/8009761/Test8009761.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
 /*
  * @test
  * @bug 8009761
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @summary Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
  * @build Test8009761
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -34,7 +34,7 @@
 /*
  * @test AllocationCodeBlobTest
  * @bug 8059624 8064669
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build AllocationCodeBlobTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/ClearMethodStateTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/whitebox/ClearMethodStateTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
 /*
  * @test ClearMethodStateTest
  * @bug 8006683 8007288 8022832
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build ClearMethodStateTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -38,19 +38,19 @@
  */
 public abstract class CompilerWhiteBoxTest {
     /** {@code CompLevel::CompLevel_none} -- Interpreter */
-    protected static int COMP_LEVEL_NONE = 0;
+    protected static final int COMP_LEVEL_NONE = 0;
     /** {@code CompLevel::CompLevel_any}, {@code CompLevel::CompLevel_all} */
-    protected static int COMP_LEVEL_ANY = -1;
+    protected static final int COMP_LEVEL_ANY = -1;
     /** {@code CompLevel::CompLevel_simple} -- C1 */
-    protected static int COMP_LEVEL_SIMPLE = 1;
+    protected static final int COMP_LEVEL_SIMPLE = 1;
     /** {@code CompLevel::CompLevel_limited_profile} -- C1, invocation &amp; backedge counters */
-    protected static int COMP_LEVEL_LIMITED_PROFILE = 2;
+    protected static final int COMP_LEVEL_LIMITED_PROFILE = 2;
     /** {@code CompLevel::CompLevel_full_profile} -- C1, invocation &amp; backedge counters + mdo */
-    protected static int COMP_LEVEL_FULL_PROFILE = 3;
+    protected static final int COMP_LEVEL_FULL_PROFILE = 3;
     /** {@code CompLevel::CompLevel_full_optimization} -- C2 or Shark */
-    protected static int COMP_LEVEL_FULL_OPTIMIZATION = 4;
+    protected static final int COMP_LEVEL_FULL_OPTIMIZATION = 4;
     /** Maximal value for CompLevel */
-    protected static int COMP_LEVEL_MAX = COMP_LEVEL_FULL_OPTIMIZATION;
+    protected static final int COMP_LEVEL_MAX = COMP_LEVEL_FULL_OPTIMIZATION;
 
     /** Instance of WhiteBox */
     protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
@@ -336,14 +336,22 @@
         System.out.printf("%n%s:%n", method);
         System.out.printf("\tcompilable:\t%b%n",
                 WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, false));
-        System.out.printf("\tcompiled:\t%b%n",
-                WHITE_BOX.isMethodCompiled(method, false));
+        boolean isCompiled = WHITE_BOX.isMethodCompiled(method, false);
+        System.out.printf("\tcompiled:\t%b%n", isCompiled);
+        if (isCompiled) {
+            System.out.printf("\tcompile_id:\t%d%n",
+                    NMethod.get(method, false).compile_id);
+        }
         System.out.printf("\tcomp_level:\t%d%n",
                 WHITE_BOX.getMethodCompilationLevel(method, false));
         System.out.printf("\tosr_compilable:\t%b%n",
                 WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, true));
-        System.out.printf("\tosr_compiled:\t%b%n",
-                WHITE_BOX.isMethodCompiled(method, true));
+        isCompiled = WHITE_BOX.isMethodCompiled(method, true);
+        System.out.printf("\tosr_compiled:\t%b%n", isCompiled);
+        if (isCompiled) {
+            System.out.printf("\tosr_compile_id:\t%d%n",
+                    NMethod.get(method, true).compile_id);
+        }
         System.out.printf("\tosr_comp_level:\t%d%n",
                 WHITE_BOX.getMethodCompilationLevel(method, true));
         System.out.printf("\tin_queue:\t%b%n",
@@ -426,6 +434,22 @@
         }
         return result;
     }
+
+    /**
+     * Skip the test for the specified value of Tiered Compilation
+     * @param value of TieredCompilation the test should not run with
+     * @return {@code true} if the test should be skipped,
+     *         {@code false} otherwise
+     */
+    protected static boolean skipOnTieredCompilation(boolean value) {
+        if (value == CompilerWhiteBoxTest.TIERED_COMPILATION) {
+            System.err.println("Test isn't applicable w/ "
+                    + (value ? "enabled" : "disabled")
+                    + "TieredCompilation. Skip test.");
+            return true;
+        }
+        return false;
+    }
 }
 
 enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
--- a/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test DeoptimizeAllTest
  * @bug 8006683 8007288 8022832
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build DeoptimizeAllTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/whitebox/DeoptimizeFramesTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test DeoptimizeFramesTest
+ * @bug 8028595
+ * @library /testlibrary /../../test/lib
+ * @build DeoptimizeFramesTest
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ *                   -XX:+WhiteBoxAPI -Xmixed
+ *                   -XX:CompileCommand=compileonly,DeoptimizeFramesTest$TestCaseImpl::method
+ *                   -XX:-DeoptimizeRandom DeoptimizeFramesTest true
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ *                   -XX:+WhiteBoxAPI -Xmixed
+ *                   -XX:CompileCommand=compileonly,DeoptimizeFramesTest$TestCaseImpl::method
+ *                   -XX:-DeoptimizeRandom DeoptimizeFramesTest false
+ * @summary testing of WB::deoptimizeFrames()
+ */
+import java.lang.reflect.Executable;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Phaser;
+
+import sun.hotspot.code.NMethod;
+import com.oracle.java.testlibrary.Asserts;
+import com.oracle.java.testlibrary.InfiniteLoop;
+
+public class DeoptimizeFramesTest extends CompilerWhiteBoxTest {
+    private final boolean makeNotEntrant;
+    private final Phaser phaser;
+
+    private DeoptimizeFramesTest(boolean makeNotEntrant, Phaser phaser) {
+        super(new TestCaseImpl(phaser));
+        // to prevent inlining of #method
+        WHITE_BOX.testSetDontInlineMethod(method, true);
+        this.makeNotEntrant = makeNotEntrant;
+        this.phaser = phaser;
+        System.out.printf("DeoptimizeFramesTest(makeNotEntrant = %b)%n",
+                makeNotEntrant);
+    }
+
+    public static void main(String[] args) throws Exception {
+        Asserts.assertEQ(args.length, 1,
+                "[TESTBUG] args should contain 1 element");
+        new DeoptimizeFramesTest(Boolean.valueOf(args[0]), new Phaser()).runTest();
+    }
+
+    @Override
+    protected void test() throws Exception {
+        compile();
+        checkCompiled();
+        NMethod nm = NMethod.get(method, testCase.isOsr());
+
+        WHITE_BOX.deoptimizeFrames(makeNotEntrant);
+        // #method should still be compiled, since it didn't have frames on stack
+        checkCompiled();
+        NMethod nm2 = NMethod.get(method, testCase.isOsr());
+        Asserts.assertEQ(nm.compile_id, nm2.compile_id,
+                "should be the same nmethod");
+
+        phaser.register();
+        Thread t = new Thread(() -> compile(1));
+        t.start();
+        // pass 1st phase, #method is on stack
+        int p = phaser.arriveAndAwaitAdvance();
+        WHITE_BOX.deoptimizeFrames(makeNotEntrant);
+        // pass 2nd phase, #method can exit
+        phaser.awaitAdvance(phaser.arriveAndDeregister());
+
+        try {
+            t.join();
+        } catch (InterruptedException e) {
+            throw new Error("method '" + method + "' is still executing", e);
+        }
+
+        // invoke one more time to recompile not entrant if any
+        compile(1);
+
+        nm2 = NMethod.get(method, testCase.isOsr());
+        if (makeNotEntrant) {
+            if (nm2 != null) {
+                Asserts.assertNE(nm.compile_id, nm2.compile_id,
+                        String.format("compilation %d can't be available", nm.compile_id));
+            }
+        } else {
+            Asserts.assertEQ(nm.compile_id, nm2.compile_id, "should be the same nmethod");
+        }
+    }
+
+
+    private static class TestCaseImpl implements TestCase {
+        private static final Executable EXECUTABLE;
+        static {
+            try {
+                EXECUTABLE = TestCaseImpl.class.getDeclaredMethod("method");
+            } catch (NoSuchMethodException e) {
+                throw new Error("[TESTBUG] method not found", e);
+            }
+        }
+
+        private final Phaser phaser;
+
+        public TestCaseImpl(Phaser phaser) {
+            this.phaser = phaser;
+            phaser.register();
+        }
+
+        @Override
+        public String name() {
+            return "2phases";
+        }
+
+        @Override
+        public Executable getExecutable() {
+            return EXECUTABLE;
+        }
+
+        @Override
+        public Callable<Integer> getCallable() {
+            return () -> {
+                return method();
+            };
+        }
+
+        @Override
+        public boolean isOsr() {
+            return false;
+        }
+
+        private int method() {
+            phaser.arriveAndAwaitAdvance();
+            phaser.arriveAndAwaitAdvance();
+            return 0;
+        }
+    }
+}
--- a/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test DeoptimizeMethodTest
  * @bug 8006683 8007288 8022832
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build DeoptimizeMethodTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/DeoptimizeMultipleOSRTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/whitebox/DeoptimizeMultipleOSRTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -28,7 +28,7 @@
 /*
  * @test DeoptimizeMultipleOSRTest
  * @bug 8061817
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build DeoptimizeMultipleOSRTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test EnqueueMethodForCompilationTest
  * @bug 8006683 8007288 8022832
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build EnqueueMethodForCompilationTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -34,7 +34,7 @@
 /*
  * @test
  * @bug 8059624 8064669
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build ForceNMethodSweepTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -33,7 +33,7 @@
 /*
  * @test GetCodeHeapEntriesTest
  * @bug 8059624
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build GetCodeHeapEntriesTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/GetNMethodTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/whitebox/GetNMethodTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -29,7 +29,7 @@
 /*
  * @test GetNMethodTest
  * @bug 8038240
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build GetNMethodTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test IsMethodCompilableTest
  * @bug 8007270 8006683 8007288 8022832
- * @library /testlibrary /testlibrary/whitebox /testlibrary/com/oracle/java/testlibrary
+ * @library /testlibrary /../../test/lib /testlibrary/com/oracle/java/testlibrary
  * @build IsMethodCompilableTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/LockCompilationTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/whitebox/LockCompilationTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test LockCompilationTest
  * @bug 8059624
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build LockCompilationTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test MakeMethodNotCompilableTest
  * @bug 8012322 8006683 8007288 8022832
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build MakeMethodNotCompilableTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test SetDontInlineMethodTest
  * @bug 8006683 8007288 8022832
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build SetDontInlineMethodTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test SetForceInlineMethodTest
  * @bug 8006683 8007288 8022832
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build SetForceInlineMethodTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/TestSmallHeap.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestSmallHeap
+ * @bug 8067438
+ * @requires vm.gc=="null"
+ * @summary Verify that starting the VM with a small heap works
+ * @library /testlibrary
+ * @run main/othervm -Xmx4m -XX:+UseParallelGC TestSmallHeap
+ * @run main/othervm -Xmx4m -XX:+UseSerialGC TestSmallHeap
+ * @run main/othervm -Xmx4m -XX:+UseG1GC TestSmallHeap
+ * @run main/othervm -Xmx4m -XX:+UseConcMarkSweepGC -XX:CMSMarkStackSizeMax=1032 TestSmallHeap
+ *
+ * Note: It would be nice to verify the minimal supported heap size here,
+ * but that turns out to be quite tricky since we align the heap size based
+ * on the card table size. And the card table size is aligned based on the
+ * minimal pages size provided by the os. This means that on most platforms,
+ * where the minimal page size is 4k, we get a minimal heap size of 2m but
+ * on Solaris/Sparc we have a page size of 8k and get a minimal heap size
+ * of 8m.
+ * There is also no check in the VM for verifying that the maximum heap size
+ * is larger than the supported minimal heap size. This means that specifying
+ * -Xmx1m on the command line is fine but will give a heap of 2m (or 4m).
+ * To work around these rather strange behaviors this test uses 4m for all
+ * platforms.
+ */
+
+import sun.management.ManagementFactoryHelper;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class TestSmallHeap {
+
+    public static void main(String[] args) {
+        String maxHeap = ManagementFactoryHelper.getDiagnosticMXBean().getVMOption("MaxHeapSize").getValue();
+        String expectedMaxHeap = "4194304";
+        assertEQ(maxHeap, expectedMaxHeap);
+    }
+}
--- a/hotspot/test/gc/arguments/TestCMSHeapSizeFlags.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/arguments/TestCMSHeapSizeFlags.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @key gc
  * @bug 8006088
  * @summary Tests argument processing for initial and maximum heap size for the CMS collector
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestCMSHeapSizeFlags TestMaxHeapSizeTools
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/arguments/TestG1HeapSizeFlags.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/arguments/TestG1HeapSizeFlags.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @key gc
  * @bug 8006088
  * @summary Tests argument processing for initial and maximum heap size for the G1 collector
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestG1HeapSizeFlags TestMaxHeapSizeTools
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/arguments/TestMinInitialErgonomics.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/arguments/TestMinInitialErgonomics.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @key gc
  * @bug 8006088
  * @summary Test ergonomics decisions related to minimum and initial heap size.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestMinInitialErgonomics TestMaxHeapSizeTools
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @bug 8006088
  * @summary Tests argument processing for initial and maximum heap size for the
  * parallel collectors.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestParallelHeapSizeFlags TestMaxHeapSizeTools
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/arguments/TestSerialHeapSizeFlags.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/arguments/TestSerialHeapSizeFlags.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @key gc
  * @bug 8006088
  * @summary Tests argument processing for initial and maximum heap size for the Serial collector
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestSerialHeapSizeFlags TestMaxHeapSizeTools
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/arguments/TestSurvivorAlignmentInBytesOption.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/arguments/TestSurvivorAlignmentInBytesOption.java	Wed Jul 05 20:13:05 2017 +0200
@@ -22,29 +22,24 @@
  */
 
 import com.oracle.java.testlibrary.ExitCode;
-import com.oracle.java.testlibrary.Utils;
 import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
 
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
 /**
  * @test
  * @bug 8031323
  * @summary Verify SurvivorAlignmentInBytes option processing.
  * @library /testlibrary
+ * @requires vm.opt.SurvivorAlignmentInBytes == null
+ *           & vm.opt.ObjectAlignmentInBytes == null
+ *           & vm.opt.UnlockExperimentalVMOptions == null
+ *           & (vm.opt.IgnoreUnrecognizedVMOptions == null
+ *              | vm.opt.IgnoreUnrecognizedVMOptions == "false")
  * @run main TestSurvivorAlignmentInBytesOption
  */
 public class TestSurvivorAlignmentInBytesOption {
-    private static final String[] FILTERED_VM_OPTIONS
-            = Utils.getFilteredTestJavaOpts(
-            "UnlockExperimentalVMOptions",
-            "SurvivorAlignmentInBytes",
-            "ObjectAlignmentInBytes");
-
     public static void main(String args[]) throws Throwable {
         String optionName = "SurvivorAlignmentInBytes";
+        String unlockExperimentalVMOpts = "UnlockExperimentalVMOptions";
         String optionIsExperimental
                 = CommandLineOptionTest.getExperimentalOptionErrorMessage(
                 optionName);
@@ -56,65 +51,84 @@
         // Verify that without -XX:+UnlockExperimentalVMOptions usage of
         // SurvivorAlignmentInBytes option will cause JVM startup failure
         // with the warning message saying that that option is experimental.
+        String shouldFailMessage = String.format("JVM option '%s' is "
+                + "experimental.%nJVM startup should fail without "
+                + "-XX:+UnlockExperimentalVMOptions option", optionName);
         CommandLineOptionTest.verifyJVMStartup(
-                new String[]{optionIsExperimental}, null, ExitCode.FAIL, false,
-                TestSurvivorAlignmentInBytesOption.prepareOptions(
-                        "-XX:-UnlockExperimentalVMOptions",
-                        CommandLineOptionTest.prepareNumericFlag(
-                                optionName, 64)));
+                new String[]{optionIsExperimental}, null,
+                shouldFailMessage, shouldFailMessage,
+                ExitCode.FAIL, false,
+                "-XX:-UnlockExperimentalVMOptions",
+                CommandLineOptionTest.prepareBooleanFlag(
+                        unlockExperimentalVMOpts, false),
+                CommandLineOptionTest.prepareNumericFlag(optionName, 64));
 
         // Verify that with -XX:+UnlockExperimentalVMOptions passed to JVM
         // usage of SurvivorAlignmentInBytes option won't cause JVM startup
         // failure.
+        String shouldPassMessage = String.format("JVM option '%s' is "
+                + "experimental.%nJVM startup should pass with "
+                + "-XX:+UnlockExperimentalVMOptions option", optionName);
+        String noWarningMessage = "There should be no warnings when use "
+                + "with -XX:+UnlockExperimentalVMOptions option";
         CommandLineOptionTest.verifyJVMStartup(
-                null, new String[]{optionIsExperimental}, ExitCode.OK, false,
-                TestSurvivorAlignmentInBytesOption.prepareOptions(
-                        CommandLineOptionTest.prepareNumericFlag(
-                                optionName, 64)));
+                null, new String[]{optionIsExperimental},
+                shouldPassMessage, noWarningMessage,
+                ExitCode.OK, false,
+                CommandLineOptionTest.prepareBooleanFlag(
+                        unlockExperimentalVMOpts, true),
+                CommandLineOptionTest.prepareNumericFlag(optionName, 64));
 
-        // Verify that if specified SurvivorAlignmentInBytes is lower then
+        // Verify that if specified SurvivorAlignmentInBytes is lower than
         // ObjectAlignmentInBytes, then the JVM startup will fail with
         // appropriate error message.
+        shouldFailMessage = String.format("JVM startup should fail with "
+                + "'%s' option value lower than ObjectAlignmentInBytes", optionName);
         CommandLineOptionTest.verifyJVMStartup(
-                new String[]{valueIsTooSmall}, null, ExitCode.FAIL, false,
-                TestSurvivorAlignmentInBytesOption.prepareOptions(
-                        CommandLineOptionTest.prepareNumericFlag(
-                                optionName, 2)));
+                new String[]{valueIsTooSmall}, null,
+                shouldFailMessage, shouldFailMessage,
+                ExitCode.FAIL, false,
+                CommandLineOptionTest.prepareBooleanFlag(
+                        unlockExperimentalVMOpts, true),
+                CommandLineOptionTest.prepareNumericFlag(optionName, 2));
 
         // Verify that if specified SurvivorAlignmentInBytes value is not
         // a power of 2 then the JVM startup will fail with appropriate error
         // message.
+        shouldFailMessage = String.format("JVM startup should fail with "
+                + "'%s' option value is not a power of 2", optionName);
         CommandLineOptionTest.verifyJVMStartup(
-                new String[]{mustBePowerOf2}, null, ExitCode.FAIL, false,
-                TestSurvivorAlignmentInBytesOption.prepareOptions(
-                        CommandLineOptionTest.prepareNumericFlag(
-                                optionName, 127)));
+                new String[]{mustBePowerOf2}, null,
+                shouldFailMessage, shouldFailMessage,
+                ExitCode.FAIL, false,
+                CommandLineOptionTest.prepareBooleanFlag(
+                        unlockExperimentalVMOpts, true),
+                CommandLineOptionTest.prepareNumericFlag(optionName, 127));
 
         // Verify that if SurvivorAlignmentInBytes has correct value, then
         // the JVM will be started without errors.
+        shouldPassMessage = String.format("JVM startup should pass with "
+                + "correct '%s' option value", optionName);
+        noWarningMessage = String.format("There should be no warnings when use "
+                + "correct '%s' option value", optionName);
         CommandLineOptionTest.verifyJVMStartup(
                 null, new String[]{".*SurvivorAlignmentInBytes.*"},
+                shouldPassMessage, noWarningMessage,
                 ExitCode.OK, false,
-                TestSurvivorAlignmentInBytesOption.prepareOptions(
-                        CommandLineOptionTest.prepareNumericFlag(
-                                optionName, 128)));
+                CommandLineOptionTest.prepareBooleanFlag(
+                        unlockExperimentalVMOpts, true),
+                CommandLineOptionTest.prepareNumericFlag(optionName, 128));
 
         // Verify that we can setup different SurvivorAlignmentInBytes values.
         for (int alignment = 32; alignment <= 128; alignment *= 2) {
+            shouldPassMessage = String.format("JVM startup should pass with "
+                    + "'%s' = %d", optionName, alignment);
             CommandLineOptionTest.verifyOptionValue(optionName,
-                    Integer.toString(alignment), false,
-                    TestSurvivorAlignmentInBytesOption.prepareOptions(
-                            CommandLineOptionTest.prepareNumericFlag(
-                                    optionName, alignment)));
+                    Integer.toString(alignment), shouldPassMessage,
+                    CommandLineOptionTest.prepareBooleanFlag(
+                            unlockExperimentalVMOpts, true),
+                    CommandLineOptionTest.prepareNumericFlag(
+                            optionName, alignment));
         }
     }
-
-    private static String[] prepareOptions(String... options) {
-        List<String> finalOptions = new LinkedList<>();
-        Collections.addAll(finalOptions,
-                TestSurvivorAlignmentInBytesOption.FILTERED_VM_OPTIONS);
-        finalOptions.add(CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
-        Collections.addAll(finalOptions, options);
-        return finalOptions.toArray(new String[finalOptions.size()]);
-    }
 }
--- a/hotspot/test/gc/arguments/TestUseCompressedOopsErgo.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/arguments/TestUseCompressedOopsErgo.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @key gc
  * @bug 8010722
  * @summary Tests ergonomics for UseCompressedOops.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestUseCompressedOopsErgo TestUseCompressedOopsErgoTools
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @key gc
  * @bug 8049831
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestCMSClassUnloadingEnabledHWM
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/class_unloading/TestG1ClassUnloadingHWM.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/class_unloading/TestG1ClassUnloadingHWM.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @key gc
  * @bug 8049831
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestG1ClassUnloadingHWM
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/g1/TestHumongousCodeCacheRoots.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/g1/TestHumongousCodeCacheRoots.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @key regression
  * @key gc
  * @bug 8027756
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestHumongousCodeCacheRoots
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 8038423
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData00
  * @run driver/timeout=720 TestShrinkAuxiliaryData00
  */
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
  * @requires vm.gc=="G1" | vm.gc=="null"
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData05
  * @run driver/timeout=720 TestShrinkAuxiliaryData05
  */
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
  * @requires vm.gc=="G1" | vm.gc=="null"
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData10
  * @run driver/timeout=720 TestShrinkAuxiliaryData10
  */
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
  * @requires vm.gc=="G1" | vm.gc=="null"
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData15
  * @run driver/timeout=720 TestShrinkAuxiliaryData15
  */
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
  * @requires vm.gc=="G1" | vm.gc=="null"
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData20
  * @run driver/timeout=720 TestShrinkAuxiliaryData20
  */
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
  * @requires vm.gc=="G1" | vm.gc=="null"
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData25
  * @run driver/timeout=720 TestShrinkAuxiliaryData25
  */
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,7 +27,7 @@
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
  * @requires vm.gc=="G1" | vm.gc=="null"
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData30
  * @run driver/timeout=720 TestShrinkAuxiliaryData30
  */
--- a/hotspot/test/gc/metaspace/TestCapacityUntilGCWrapAround.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/metaspace/TestCapacityUntilGCWrapAround.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @key gc
  * @bug 8049831
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestCapacityUntilGCWrapAround
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/survivorAlignment/TestAllocationInEden.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/survivorAlignment/TestAllocationInEden.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 8031323
  * @summary Verify that object's alignment in eden space is not affected by
  *          SurvivorAlignmentInBytes option.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestAllocationInEden SurvivorAlignmentTestMain AlignmentHelper
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -34,37 +34,43 @@
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32 -XX:-UseTLAB
- *                    -XX:OldSize=128m -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=128m -XX:MaxHeapSize=192m
+ *                   -XX:-ExplicitGCInvokesConcurrent
  *                   TestAllocationInEden 10m 9 EDEN
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32 -XX:-UseTLAB
- *                    -XX:OldSize=128m -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=128m -XX:MaxHeapSize=192m
+ *                   -XX:-ExplicitGCInvokesConcurrent
  *                   TestAllocationInEden 10m 47 EDEN
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64 -XX:-UseTLAB
- *                    -XX:OldSize=128m -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=128m  -XX:MaxHeapSize=192m
+ *                   -XX:-ExplicitGCInvokesConcurrent
  *                   TestAllocationInEden 10m 9 EDEN
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64 -XX:-UseTLAB
- *                    -XX:OldSize=128m -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=128m  -XX:MaxHeapSize=192m
+ *                   -XX:-ExplicitGCInvokesConcurrent
  *                   TestAllocationInEden 10m 87 EDEN
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128 -XX:-UseTLAB
- *                    -XX:OldSize=128m -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=128m -XX:MaxHeapSize=192m
+ *                   -XX:-ExplicitGCInvokesConcurrent
  *                   TestAllocationInEden 10m 9 EDEN
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128 -XX:-UseTLAB
- *                    -XX:OldSize=128m -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=128m -XX:MaxHeapSize=192m
+ *                   -XX:-ExplicitGCInvokesConcurrent
  *                   TestAllocationInEden 10m 147 EDEN
  */
 public class TestAllocationInEden {
--- a/hotspot/test/gc/survivorAlignment/TestPromotionFromEdenToTenured.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/survivorAlignment/TestPromotionFromEdenToTenured.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,50 +26,50 @@
  * @bug 8031323
  * @summary Verify that objects promoted from eden space to tenured space during
  *          full GC are not aligned to SurvivorAlignmentInBytes value.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestPromotionFromEdenToTenured SurvivorAlignmentTestMain
  *        AlignmentHelper
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
- *                   -XX:OldSize=32m -XX:SurvivorRatio=1
- *                    -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=32m -XX:MaxHeapSize=96m -XX:SurvivorRatio=1
+ *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32
  *                   TestPromotionFromEdenToTenured 10m 9 TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
- *                   -XX:OldSize=32m -XX:SurvivorRatio=1
- *                    -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=32m -XX:MaxHeapSize=96m -XX:SurvivorRatio=1
+ *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32
  *                   TestPromotionFromEdenToTenured 10m 47 TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
- *                   -XX:OldSize=32m -XX:SurvivorRatio=1
- *                    -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=32m  -XX:MaxHeapSize=96m
+ *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64
  *                   TestPromotionFromEdenToTenured 10m 9 TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
- *                   -XX:OldSize=32m -XX:SurvivorRatio=1
- *                    -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=32m -XX:MaxHeapSize=128m
+ *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64
  *                   TestPromotionFromEdenToTenured 10m 87 TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
- *                   -XX:OldSize=32M -XX:SurvivorRatio=1
- *                    -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=32M -XX:MaxHeapSize=96m -XX:SurvivorRatio=1
+ *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128
  *                   TestPromotionFromEdenToTenured 10m 9 TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
- *                   -XX:OldSize=32m -XX:SurvivorRatio=1
- *                    -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=32m -XX:MaxHeapSize=96m -XX:SurvivorRatio=1
+ *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128
  *                   TestPromotionFromEdenToTenured 10m 147 TENURED
--- a/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterFullGC.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterFullGC.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,44 +26,44 @@
  * @bug 8031323
  * @summary Verify that objects promoted from survivor space to tenured space
  *          during full GC are not aligned to SurvivorAlignmentInBytes value.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestPromotionFromSurvivorToTenuredAfterFullGC
  *        SurvivorAlignmentTestMain AlignmentHelper
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
- *                   -XX:OldSize=32m -XX:SurvivorRatio=1
- *                   -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=32m -XX:MaxHeapSize=160m
+ *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32
  *                   TestPromotionFromSurvivorToTenuredAfterFullGC 10m 9 TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
- *                   -XX:OldSize=32m -XX:SurvivorRatio=1
- *                   -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=32m -XX:MaxHeapSize=160m
+ *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32
  *                   TestPromotionFromSurvivorToTenuredAfterFullGC 20m 47
  *                   TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=200m -XX:MaxNewSize=200m
- *                   -XX:OldSize=32m -XX:InitialHeapSize=232m
+ *                   -XX:OldSize=32m -XX:MaxHeapSize=232m
  *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64
  *                   TestPromotionFromSurvivorToTenuredAfterFullGC 10m 9 TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
- *                   -XX:OldSize=32m -XX:SurvivorRatio=1
- *                   -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=32m -XX:MaxHeapSize=160m
+ *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64
  *                   TestPromotionFromSurvivorToTenuredAfterFullGC 20m 87
  *                   TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m
- *                   -XX:OldSize=32M -XX:InitialHeapSize=288m
+ *                   -XX:OldSize=32M -XX:MaxHeapSize=288m
  *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128
@@ -71,8 +71,8 @@
  *                    TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
- *                   -XX:OldSize=32m -XX:SurvivorRatio=1
- *                   -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=32m -XX:MaxHeapSize=160m
+ *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128
  *                   TestPromotionFromSurvivorToTenuredAfterFullGC 20m 147
--- a/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java	Wed Jul 05 20:13:05 2017 +0200
@@ -27,14 +27,14 @@
  * @summary Verify that objects promoted from survivor space to tenured space
  *          when their age exceeded tenuring threshold are not aligned to
  *          SurvivorAlignmentInBytes value.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestPromotionFromSurvivorToTenuredAfterMinorGC
  *        SurvivorAlignmentTestMain AlignmentHelper
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
- *                   -XX:OldSize=32M -XX:SurvivorRatio=1
+ *                   -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1
  *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32
@@ -42,7 +42,7 @@
  *                   TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
- *                   -XX:OldSize=32M -XX:SurvivorRatio=1
+ *                   -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1
  *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32
@@ -50,15 +50,15 @@
  *                   TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=200m -XX:MaxNewSize=200m
- *                   -XX:OldSize=32M -XX:InitialHeapSize=232m
- *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=32M -XX:MaxHeapSize=232m -XX:SurvivorRatio=1
+ *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64
  *                   TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9
  *                   TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
- *                   -XX:OldSize=32M -XX:SurvivorRatio=1
+ *                   -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1
  *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64
@@ -66,15 +66,15 @@
  *                   TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m
- *                   -XX:OldSize=32M -XX:InitialHeapSize=288m
- *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:OldSize=32M -XX:MaxHeapSize=288m -XX:SurvivorRatio=1
+ *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128
  *                    TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9
  *                    TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
- *                   -XX:OldSize=32M -XX:SurvivorRatio=1
+ *                   -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1
  *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128
--- a/hotspot/test/gc/survivorAlignment/TestPromotionToSurvivor.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/survivorAlignment/TestPromotionToSurvivor.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 8031323
  * @summary Verify that objects promoted from eden space to survivor space after
  *          minor GC are aligned to SurvivorAlignmentInBytes.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestPromotionToSurvivor
  *        SurvivorAlignmentTestMain AlignmentHelper
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
@@ -35,36 +35,37 @@
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32 -XX:OldSize=128m
- *                   -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent
  *                   TestPromotionToSurvivor 10m 9 SURVIVOR
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32 -XX:OldSize=128m
+ *                   -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent
  *                   TestPromotionToSurvivor 20m 47 SURVIVOR
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64 -XX:OldSize=128m
- *                   -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent
  *                   TestPromotionToSurvivor 8m 9 SURVIVOR
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64 -XX:OldSize=128m
- *                   -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent
  *                   TestPromotionToSurvivor 20m 87 SURVIVOR
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
- *                   -XX:SurvivorAlignmentInBytes=128 -XX:OldSize=32m
- *                   -XX:InitialHeapSize=288m  -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:SurvivorAlignmentInBytes=128 -XX:OldSize=128m
+ *                   -XX:MaxHeapSize=384m  -XX:-ExplicitGCInvokesConcurrent
  *                   TestPromotionToSurvivor 10m 9 SURVIVOR
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128 -XX:OldSize=128m
- *                   -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent
  *                   TestPromotionToSurvivor 20m 147 SURVIVOR
  */
 public class TestPromotionToSurvivor {
--- a/hotspot/test/gc/whitebox/TestConcMarkCycleWB.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/whitebox/TestConcMarkCycleWB.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test TestConMarkCycleWB
  * @bug 8065579
  * @requires vm.gc=="null" | vm.gc=="G1"
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build ClassFileInstaller com.oracle.java.testlibrary.* sun.hotspot.WhiteBox TestConcMarkCycleWB
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/whitebox/TestWBGC.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/gc/whitebox/TestWBGC.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test TestWBGC
  * @bug 8055098
  * @summary Test verify that WB methods isObjectInOldGen and youngGC works correctly.
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build TestWBGC
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  * @run driver TestWBGC
--- a/hotspot/test/runtime/ClassUnload/KeepAliveClass.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/ClassUnload/KeepAliveClass.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test KeepAliveClass
  * @summary This test case uses a java.lang.Class instance to keep a class alive.
- * @library /testlibrary /testlibrary/whitebox /runtime/testlibrary
+ * @library /testlibrary /../../test/lib /runtime/testlibrary
  * @library classes
  * @build KeepAliveClass test.Empty
  * @build ClassUnloadCommon
--- a/hotspot/test/runtime/ClassUnload/KeepAliveClassLoader.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/ClassUnload/KeepAliveClassLoader.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test KeepAliveClassLoader
  * @summary This test case uses a java.lang.ClassLoader instance to keep a class alive.
- * @library /testlibrary /testlibrary/whitebox /runtime/testlibrary
+ * @library /testlibrary /../../test/lib /runtime/testlibrary
  * @library classes
  * @build KeepAliveClassLoader test.Empty
  * @build ClassUnloadCommon
--- a/hotspot/test/runtime/ClassUnload/KeepAliveObject.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/ClassUnload/KeepAliveObject.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test KeepAliveObject
  * @summary This test case uses a class instance to keep the class alive.
- * @library /testlibrary /testlibrary/whitebox /runtime/testlibrary
+ * @library /testlibrary /../../test/lib /runtime/testlibrary
  * @library classes
  * @build KeepAliveObject test.Empty
  * @build ClassUnloadCommon
--- a/hotspot/test/runtime/ClassUnload/KeepAliveSoftReference.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/ClassUnload/KeepAliveSoftReference.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test KeepAliveSoftReference
  * @summary This test case uses a java.lang.ref.SoftReference referencing a class instance to keep a class alive.
- * @library /testlibrary /testlibrary/whitebox /runtime/testlibrary
+ * @library /testlibrary /../../test/lib /runtime/testlibrary
  * @library classes
  * @build KeepAliveSoftReference test.Empty
  * @build ClassUnloadCommon
--- a/hotspot/test/runtime/ClassUnload/UnloadTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/ClassUnload/UnloadTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test UnloadTest
- * @library /runtime/testlibrary /testlibrary /testlibrary/whitebox
+ * @library /runtime/testlibrary /testlibrary /../../test/lib
  * @library classes
  * @build ClassUnloadCommon test.Empty
  * @build UnloadTest
--- a/hotspot/test/runtime/CommandLine/TraceExceptionsTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/CommandLine/TraceExceptionsTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -33,11 +33,6 @@
 public class TraceExceptionsTest {
     public static void main(String[] args) throws Exception {
 
-        if (!Platform.isDebugBuild()) {
-          System.out.println("Skip the test on product builds since XX:+TraceExceptions is not available on product builds");
-          return;
-        }
-
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
             "-XX:+TraceExceptions", "NoClassFound");
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
--- a/hotspot/test/runtime/Metaspace/FragmentMetaspace.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/Metaspace/FragmentMetaspace.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @library /runtime/testlibrary
  * @build GeneratedClassLoader
- * @run main/othervm/timeout=200 FragmentMetaspace
+ * @run main/othervm/timeout=200 -Xmx300m FragmentMetaspace
  */
 
 import java.io.IOException;
@@ -38,25 +38,34 @@
  */
 public class FragmentMetaspace {
 
+    public static Class<?> c;
+
     public static void main(String... args) {
-        runGrowing(Long.valueOf(System.getProperty("time", "80000")));
+        runGrowing(Long.valueOf(System.getProperty("time", "80000")),
+            Integer.valueOf(System.getProperty("iterations", "200")));
         // try to clean up and unload classes to decrease
         // class verification time in debug vm
         System.gc();
     }
 
-    private static void runGrowing(long time) {
+    private static void runGrowing(long time, int iterations) {
         long startTime = System.currentTimeMillis();
-        for (int i = 0; System.currentTimeMillis() < startTime + time; ++i) {
+        for (int i = 0; System.currentTimeMillis() < startTime + time && i < iterations; ++i) {
             try {
                 GeneratedClassLoader gcl = new GeneratedClassLoader();
 
-                Class<?> c = gcl.getGeneratedClasses(i, 100)[0];
+                // getGeneratedClasses throws a RuntimeException in cases where
+                // the javac exit code is not 0. If the original reason for the exception is
+                // a "java.lang.OutOfMemoryError: Java heap space",
+                // increase the heap size in the @run tag and rerun the test.
+                // The heap can be exhausted by this test, but heap exhaustion
+                // is not a failure mode of this test and should be ignored.
+                c = gcl.getGeneratedClasses(i, 100)[0];
                 c.newInstance();
                 c = null;
 
                 gcl = null;
-            } catch (IOException|InstantiationException|IllegalAccessException ex) {
+            } catch (IOException | InstantiationException | IllegalAccessException ex) {
                 throw new RuntimeException(ex);
             }
         }
--- a/hotspot/test/runtime/NMT/ChangeTrackingLevel.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/NMT/ChangeTrackingLevel.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 8059100
  * @summary Test that you can decrease NMT tracking level but not increase it.
  * @key nmt
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build ChangeTrackingLevel
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/NMT/JcmdDetailDiff.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/NMT/JcmdDetailDiff.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary run NMT baseline, allocate memory and verify output from detail.diff
  * @key nmt jcmd
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @ignore
  * @build JcmdDetailDiff
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/runtime/NMT/JcmdSummaryDiff.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/NMT/JcmdSummaryDiff.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary run NMT baseline, allocate memory and verify output from summary.diff
  * @key nmt jcmd
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build JcmdSummaryDiff
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=summary JcmdSummaryDiff
--- a/hotspot/test/runtime/NMT/MallocRoundingReportTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/NMT/MallocRoundingReportTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary Test consistency of NMT by creating allocations of the Test type with various sizes and verifying visibility with jcmd
  * @key nmt jcmd
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build MallocRoundingReportTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocRoundingReportTest
--- a/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @summary Test corner case that overflows malloc site hashtable bucket
  * @requires sun.arch.data.model == "32"
  * @key nmt jcmd stress
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build MallocSiteHashOverflow
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocSiteHashOverflow
--- a/hotspot/test/runtime/NMT/MallocStressTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/NMT/MallocStressTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary Stress test for malloc tracking
  * @key nmt jcmd stress
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build MallocStressTest
  * @ignore - This test is disabled since it will stress NMT and timeout during normal testing
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/runtime/NMT/MallocTestType.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/NMT/MallocTestType.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary Test consistency of NMT by leaking a few select allocations of the Test type and then verify visibility with jcmd
  * @key nmt jcmd
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build MallocTestType
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/NMT/MallocTrackingVerify.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/NMT/MallocTrackingVerify.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 8054836
  * @summary Test to verify correctness of malloc tracking
  * @key nmt jcmd
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build MallocTrackingVerify
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocTrackingVerify
--- a/hotspot/test/runtime/NMT/ReleaseCommittedMemory.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/NMT/ReleaseCommittedMemory.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 8013120
  * @summary Release committed memory and make sure NMT handles it correctly
  * @key nmt regression
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build ReleaseCommittedMemory
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/NMT/ReleaseNoCommit.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/NMT/ReleaseNoCommit.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary Release uncommitted memory and make sure NMT handles it correctly
  * @key nmt regression
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build ReleaseNoCommit
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=summary ReleaseNoCommit
--- a/hotspot/test/runtime/NMT/SummarySanityCheck.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/NMT/SummarySanityCheck.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @key nmt jcmd
  * @summary Sanity check the output of NMT
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build SummarySanityCheck
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/NMT/ThreadedMallocTestType.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/NMT/ThreadedMallocTestType.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @key nmt jcmd
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build ThreadedMallocTestType
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @key nmt jcmd
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build ThreadedVirtualAllocTestType
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary Test reserve/commit/uncommit/release of virtual memory and that we track it correctly
  * @key nmt jcmd
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build VirtualAllocCommitUncommitRecommit
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail VirtualAllocCommitUncommitRecommit
--- a/hotspot/test/runtime/NMT/VirtualAllocTestType.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/NMT/VirtualAllocTestType.java	Wed Jul 05 20:13:05 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @summary Test Reserve/Commit/Uncommit/Release of virtual memory and that we track it correctly
  * @key nmt jcmd
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build VirtualAllocTestType
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Safepoint/AssertSafepointCheckConsistency1.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8047290
+ * @summary Ensure that a Monitor::lock_without_safepoint_check fires an assert when it incorrectly acquires a lock which must always have safepoint checks.
+ * @library /testlibrary /../../test/lib
+ * @build AssertSafepointCheckConsistency1
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main AssertSafepointCheckConsistency1
+ */
+
+import com.oracle.java.testlibrary.*;
+
+import sun.hotspot.WhiteBox;
+
+public class AssertSafepointCheckConsistency1 {
+    public static void main(String args[]) throws Exception {
+        if (args.length > 0) {
+            WhiteBox.getWhiteBox().assertMatchingSafepointCalls(true, true);
+        }
+        if (Platform.isDebugBuild()){
+            ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+                  "-Xbootclasspath/a:.",
+                  "-XX:+UnlockDiagnosticVMOptions",
+                  "-XX:+WhiteBoxAPI",
+                  "-XX:-TransmitErrorReport",
+                  "-Xmx32m",
+                  "AssertSafepointCheckConsistency1",
+                  "test");
+            OutputAnalyzer output = new OutputAnalyzer(pb.start());
+            output.shouldContain("assert").shouldContain("always");
+        }
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Safepoint/AssertSafepointCheckConsistency2.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8047290
+ * @summary Ensure that a Monitor::lock fires an assert when it incorrectly acquires a lock which must never have safepoint checks.
+ * @library /testlibrary /../../test/lib
+ * @build AssertSafepointCheckConsistency2
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main AssertSafepointCheckConsistency2
+ */
+
+import com.oracle.java.testlibrary.*;
+
+import sun.hotspot.WhiteBox;
+
+public class AssertSafepointCheckConsistency2 {
+    public static void main(String args[]) throws Exception {
+        if (args.length > 0) {
+            WhiteBox.getWhiteBox().assertMatchingSafepointCalls(false, false);
+        }
+        if (Platform.isDebugBuild()){
+            ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+                  "-Xbootclasspath/a:.",
+                  "-XX:+UnlockDiagnosticVMOptions",
+                  "-XX:+WhiteBoxAPI",
+                  "-XX:-TransmitErrorReport",
+                  "-Xmx32m",
+                  "AssertSafepointCheckConsistency2",
+                  "test");
+
+            OutputAnalyzer output = new OutputAnalyzer(pb.start());
+            output.shouldContain("assert").shouldContain("never");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Safepoint/AssertSafepointCheckConsistency3.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8047290
+ * @summary Ensure that Monitor::lock_without_safepoint_check does not assert when it correctly acquires a lock which must never have safepoint checks.
+ * @library /testlibrary /../../test/lib
+ * @build AssertSafepointCheckConsistency3
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main AssertSafepointCheckConsistency3
+ */
+
+import com.oracle.java.testlibrary.*;
+
+import sun.hotspot.WhiteBox;
+
+public class AssertSafepointCheckConsistency3 {
+    public static void main(String args[]) throws Exception {
+        if (args.length > 0) {
+            WhiteBox.getWhiteBox().assertMatchingSafepointCalls(false, true);
+        }
+        if (Platform.isDebugBuild()){
+            ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+                  "-Xbootclasspath/a:.",
+                  "-XX:+UnlockDiagnosticVMOptions",
+                  "-XX:+WhiteBoxAPI",
+                  "-XX:-TransmitErrorReport",
+                  "-Xmx32m",
+                  "AssertSafepointCheckConsistency3",
+                  "test");
+
+            OutputAnalyzer output = new OutputAnalyzer(pb.start());
+            output.shouldNotContain("assert");
+            output.shouldNotContain("never");
+            output.shouldNotContain("always");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Safepoint/AssertSafepointCheckConsistency4.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8047290
+ * @summary Ensure that Monitor::lock does not assert when it correctly acquires a lock which must always have safepoint checks.
+ * @library /testlibrary /../../test/lib
+ * @build AssertSafepointCheckConsistency4
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main AssertSafepointCheckConsistency4
+ */
+
+import com.oracle.java.testlibrary.*;
+
+import sun.hotspot.WhiteBox;
+
+public class AssertSafepointCheckConsistency4 {
+    public static void main(String args[]) throws Exception {
+        if (args.length > 0) {
+            WhiteBox.getWhiteBox().assertMatchingSafepointCalls(true, false);
+        }
+        if (Platform.isDebugBuild()){
+            ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+               "-Xbootclasspath/a:.",
+               "-XX:+UnlockDiagnosticVMOptions",
+               "-XX:+WhiteBoxAPI",
+               "-XX:-TransmitErrorReport",
+               "-Xmx32m",
+               "AssertSafepointCheckConsistency4",
+               "test");
+
+            OutputAnalyzer output = new OutputAnalyzer(pb.start());
+            output.shouldNotContain("assert");
+            output.shouldNotContain("never");
+            output.shouldNotContain("always");
+        }
+    }
+}
+
+
--- a/hotspot/test/runtime/interned/SanityTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/interned/SanityTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test SanityTest
  * @summary Sanity check of String.intern() & GC
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build SanityTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/memory/ReadFromNoaccessArea.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/memory/ReadFromNoaccessArea.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary Test that touching noaccess area in class ReservedHeapSpace results in SIGSEGV/ACCESS_VIOLATION
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build ReadFromNoaccessArea
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/memory/ReadVMPageSize.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/memory/ReadVMPageSize.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary Using WhiteBox to get VM page size
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build ReadVMPageSize
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm  -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI  ReadVMPageSize
--- a/hotspot/test/runtime/memory/ReserveMemory.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/memory/ReserveMemory.java	Wed Jul 05 20:13:05 2017 +0200
@@ -26,7 +26,7 @@
  * @key regression
  * @bug 8012015
  * @summary Make sure reserved (but uncommitted) memory is not accessible
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build ReserveMemory
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/memory/RunUnitTestsConcurrently.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/memory/RunUnitTestsConcurrently.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary Test launches unit tests inside vm concurrently
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build RunUnitTestsConcurrently
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/memory/StressVirtualSpaceResize.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/memory/StressVirtualSpaceResize.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary Stress test that expands/shrinks VirtualSpace
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build StressVirtualSpaceResize
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/whitebox/WBStackSize.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/runtime/whitebox/WBStackSize.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test WBStackSize
  * @summary verify that whitebox functions getThreadFullStackSize() and getThreadRemainingStackSize are working
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build WBStackSize
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/sanity/WBApi.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/sanity/WBApi.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test WBApi
  * @summary verify that whitebox functions can be linked and executed
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build WBApi
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/serviceability/ParserTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/serviceability/ParserTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary Test that the diagnostic command arguemnt parser works
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.parser.*
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary/com/oracle/java/testlibrary/Utils.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/Utils.java	Wed Jul 05 20:13:05 2017 +0200
@@ -32,13 +32,18 @@
 import java.net.InetAddress;
 import java.net.ServerSocket;
 import java.net.UnknownHostException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Random;
+import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 import sun.misc.Unsafe;
 
 /**
@@ -88,6 +93,12 @@
         TIMEOUT_FACTOR = Double.parseDouble(toFactor);
     }
 
+    /**
+    * Returns the value of JTREG default test timeout in milliseconds
+    * converted to {@code long}.
+    */
+    public static final long DEFAULT_TEST_TIMEOUT = TimeUnit.SECONDS.toMillis(120);
+
     private Utils() {
         // Private constructor to prevent class instantiation
     }
@@ -318,28 +329,15 @@
      * or null if not found.
      * @param filename name of the file to read
      * @return String contents of file, or null if file not found.
+     * @throws  IOException
+     *          if an I/O error occurs reading from the file or a malformed or
+     *          unmappable byte sequence is read
      */
-    public static String fileAsString(String filename) {
-        StringBuilder result = new StringBuilder();
-        try {
-            File file = new File(filename);
-            if (file.exists()) {
-                BufferedReader reader = new BufferedReader(new FileReader(file));
-                while (true) {
-                    String line = reader.readLine();
-                    if (line == null) {
-                        break;
-                    }
-                    result.append(line).append("\n");
-                }
-            } else {
-                // Does not exist:
-                return null;
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return result.toString();
+    public static String fileAsString(String filename) throws IOException {
+        Path filePath = Paths.get(filename);
+        return Files.exists(filePath)
+            ? Files.lines(filePath).collect(Collectors.joining(NEW_LINE))
+            : null;
     }
 
     /**
@@ -396,4 +394,14 @@
         }
         return RANDOM_GENERATOR;
     }
+
+    /**
+     * Adjusts the provided timeout value for the TIMEOUT_FACTOR
+     * @param tOut the timeout value to be adjusted
+     * @return The timeout value adjusted for the value of "test.timeout.factor"
+     *         system property
+     */
+    public static long adjustTimeout(long tOut) {
+        return Math.round(tOut * Utils.TIMEOUT_FACTOR);
+    }
 }
--- a/hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/CommandLineOptionTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/CommandLineOptionTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -49,7 +49,7 @@
     private static final String PRINT_FLAGS_FINAL_FORMAT = "%s\\s*:?=\\s*%s";
 
     /**
-     * Verifies that JVM startup behaviour matches our expectations.
+     * Verifies that JVM startup behavior matches our expectations.
      *
      * @param option an option that should be passed to JVM
      * @param expectedMessages an array of patterns that should occur
@@ -58,18 +58,24 @@
      * @param unexpectedMessages an array of patterns that should not
      *                           occur in JVM output. If {@code null} then
      *                           JVM output could be empty.
+     * @param exitErrorMessage message that will be shown if exit code is not
+     *                           as expected.
+     * @param wrongWarningMessage message that will be shown if warning
+     *                           messages are not as expected.
      * @param exitCode expected exit code.
      * @throws Throwable if verification fails or some other issues occur.
      */
     public static void verifyJVMStartup(String option,
             String expectedMessages[], String unexpectedMessages[],
+            String exitErrorMessage, String wrongWarningMessage,
             ExitCode exitCode) throws Throwable {
         CommandLineOptionTest.verifyJVMStartup(expectedMessages,
-                unexpectedMessages, exitCode, false, option);
+                unexpectedMessages, exitErrorMessage,
+                wrongWarningMessage, exitCode, false, option);
     }
 
     /**
-     * Verifies that JVM startup behaviour matches our expectations.
+     * Verifies that JVM startup behavior matches our expectations.
      *
      * @param expectedMessages an array of patterns that should occur
      *                         in JVM output. If {@code null} then
@@ -77,6 +83,10 @@
      * @param unexpectedMessages an array of patterns that should not
      *                           occur in JVM output. If {@code null} then
      *                           JVM output could be empty.
+     * @param exitErrorMessage message that will be shown if exit code is not
+     *                           as expected.
+     * @param wrongWarningMessage message that will be shown if warning
+     *                           messages are not as expected.
      * @param exitCode expected exit code.
      * @param addTestVMOptions if {@code true} then test VM options will be
      *                         passed to VM.
@@ -85,8 +95,10 @@
      * @throws Throwable if verification fails or some other issues occur.
      */
     public static void verifyJVMStartup(String expectedMessages[],
-            String unexpectedMessages[], ExitCode exitCode,
-            boolean addTestVMOptions, String... options) throws Throwable {
+            String unexpectedMessages[], String exitErrorMessage,
+            String wrongWarningMessage, ExitCode exitCode,
+            boolean addTestVMOptions, String... options)
+                    throws Throwable {
         List<String> finalOptions = new ArrayList<>();
         if (addTestVMOptions) {
             Collections.addAll(finalOptions, Utils.getTestJavaOpts());
@@ -99,23 +111,46 @@
                 new String[finalOptions.size()]));
         OutputAnalyzer outputAnalyzer
                 = new OutputAnalyzer(processBuilder.start());
-        outputAnalyzer.shouldHaveExitValue(exitCode.value);
+
+        try {
+                outputAnalyzer.shouldHaveExitValue(exitCode.value);
+        } catch (RuntimeException e) {
+            String errorMessage = String.format(
+                    "JVM process should have exit value '%d'.%n%s",
+                    exitCode.value, exitErrorMessage);
+            throw new AssertionError(errorMessage, e);
+        }
+
 
         if (expectedMessages != null) {
             for (String expectedMessage : expectedMessages) {
-                outputAnalyzer.shouldMatch(expectedMessage);
+                try {
+                    outputAnalyzer.shouldMatch(expectedMessage);
+                } catch (RuntimeException e) {
+                    String errorMessage = String.format(
+                            "Expected message not found: '%s'.%n%s",
+                            expectedMessage, wrongWarningMessage);
+                    throw new AssertionError(errorMessage, e);
+                }
             }
         }
 
         if (unexpectedMessages != null) {
             for (String unexpectedMessage : unexpectedMessages) {
-                outputAnalyzer.shouldNotMatch(unexpectedMessage);
+                try {
+                    outputAnalyzer.shouldNotMatch(unexpectedMessage);
+                } catch (RuntimeException e) {
+                    String errorMessage = String.format(
+                            "Unexpected message found: '%s'.%n%s",
+                            unexpectedMessage, wrongWarningMessage);
+                    throw new AssertionError(errorMessage, e);
+                }
             }
         }
     }
 
     /**
-     * Verifies that JVM startup behaviour matches our expectations when type
+     * Verifies that JVM startup behavior matches our expectations when type
      * of newly started VM is the same as the type of current.
      *
      * @param expectedMessages an array of patterns that should occur
@@ -124,20 +159,26 @@
      * @param unexpectedMessages an array of patterns that should not
      *                           occur in JVM output. If {@code null} then
      *                           JVM output could be empty.
+     * @param exitErrorMessage Message that will be shown if exit value is not
+     *                           as expected.
+     * @param wrongWarningMessage message that will be shown if warning
+     *                           messages are not as expected.
      * @param exitCode expected exit code.
      * @param options options that should be passed to VM in addition to mode
      *                flag.
      * @throws Throwable if verification fails or some other issues occur.
      */
     public static void verifySameJVMStartup(String expectedMessages[],
-            String unexpectedMessages[], ExitCode exitCode, String... options)
-            throws  Throwable {
+            String unexpectedMessages[], String exitErrorMessage,
+            String wrongWarningMessage, ExitCode exitCode, String... options)
+            throws Throwable {
         List<String> finalOptions = new ArrayList<>();
         finalOptions.add(CommandLineOptionTest.getVMTypeOption());
         Collections.addAll(finalOptions, options);
 
         CommandLineOptionTest.verifyJVMStartup(expectedMessages,
-                unexpectedMessages, exitCode, false,
+                unexpectedMessages, exitErrorMessage,
+                wrongWarningMessage, exitCode, false,
                 finalOptions.toArray(new String[finalOptions.size()]));
     }
 
@@ -149,13 +190,17 @@
      *
      * @param optionName a name of tested option.
      * @param expectedValue expected value of tested option.
+     * @param optionErrorString message will be shown if option value is not as
+     *                         expected.
      * @param additionalVMOpts additional options that should be
      *                         passed to JVM.
      * @throws Throwable if verification fails or some other issues occur.
      */
     public static void verifyOptionValue(String optionName,
-            String expectedValue, String... additionalVMOpts) throws Throwable {
-        verifyOptionValue(optionName, expectedValue, true, additionalVMOpts);
+            String expectedValue, String optionErrorString,
+            String... additionalVMOpts) throws Throwable {
+        verifyOptionValue(optionName, expectedValue,  optionErrorString,
+                true, additionalVMOpts);
     }
 
     /**
@@ -168,14 +213,17 @@
      * @param expectedValue expected value of tested option.
      * @param addTestVmOptions if {@code true}, then test VM options
      *                         will be used.
+     * @param optionErrorString message will be shown if option value is not as
+     *                         expected.
      * @param additionalVMOpts additional options that should be
      *                         passed to JVM.
      * @throws Throwable if verification fails or some other issues
      *                          occur.
      */
     public static void verifyOptionValue(String optionName,
-            String expectedValue, boolean addTestVmOptions,
-            String... additionalVMOpts) throws Throwable {
+            String expectedValue, String optionErrorString,
+            boolean addTestVmOptions, String... additionalVMOpts)
+                    throws Throwable {
         List<String> vmOpts = new ArrayList<>();
 
         if (addTestVmOptions) {
@@ -191,10 +239,25 @@
         OutputAnalyzer outputAnalyzer
                 = new OutputAnalyzer(processBuilder.start());
 
-        outputAnalyzer.shouldHaveExitValue(0);
+        try {
+            outputAnalyzer.shouldHaveExitValue(0);
+        } catch (RuntimeException e) {
+            String errorMessage = String.format(
+                    "JVM should start with option '%s' without errors.",
+                    optionName);
+            throw new AssertionError(errorMessage, e);
+        }
+        try {
         outputAnalyzer.shouldMatch(String.format(
                 CommandLineOptionTest.PRINT_FLAGS_FINAL_FORMAT,
                 optionName, expectedValue));
+        } catch (RuntimeException e) {
+            String errorMessage =  String.format(
+                    "Option '%s' is expected to have '%s' value%n%s",
+                    optionName, expectedValue,
+                    optionErrorString);
+            throw new AssertionError(errorMessage, e);
+        }
     }
 
     /**
@@ -207,18 +270,21 @@
      *
      * @param optionName name of tested option.
      * @param expectedValue expected value of tested option.
+     * @param optionErrorString message to show if option has another value
      * @param additionalVMOpts additional options that should be
      *                         passed to JVM.
      * @throws Throwable if verification fails or some other issues occur.
      */
     public static void verifyOptionValueForSameVM(String optionName,
-            String expectedValue, String... additionalVMOpts) throws Throwable {
+            String expectedValue, String optionErrorString,
+            String... additionalVMOpts) throws Throwable {
         List<String> finalOptions = new ArrayList<>();
         finalOptions.add(CommandLineOptionTest.getVMTypeOption());
         Collections.addAll(finalOptions, additionalVMOpts);
 
         CommandLineOptionTest.verifyOptionValue(optionName, expectedValue,
-                false, finalOptions.toArray(new String[finalOptions.size()]));
+                optionErrorString, false,
+                finalOptions.toArray(new String[finalOptions.size()]));
     }
 
     /**
--- a/hotspot/test/testlibrary/ctw/test/ClassesDirTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary/ctw/test/ClassesDirTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8012447
- * @library /testlibrary /testlibrary/whitebox /testlibrary/ctw/src
+ * @library /testlibrary /../../test/lib /testlibrary/ctw/src
  * @build ClassFileInstaller sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
  * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary/ctw/test/ClassesListTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary/ctw/test/ClassesListTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8012447
- * @library /testlibrary /testlibrary/whitebox /testlibrary/ctw/src
+ * @library /testlibrary /../../test/lib /testlibrary/ctw/src
  * @build ClassFileInstaller sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
  * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary/ctw/test/JarDirTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary/ctw/test/JarDirTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8012447
- * @library /testlibrary /testlibrary/whitebox /testlibrary/ctw/src
+ * @library /testlibrary /../../test/lib /testlibrary/ctw/src
  * @build ClassFileInstaller com.oracle.java.testlibrary.* sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
  * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary/ctw/test/JarsTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary/ctw/test/JarsTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8012447
- * @library /testlibrary /testlibrary/whitebox /testlibrary/ctw/src
+ * @library /testlibrary /../../test/lib /testlibrary/ctw/src
  * @build ClassFileInstaller com.oracle.java.testlibrary.* sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
  * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary/whitebox/Makefile	Tue Dec 30 09:44:23 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-#
-# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.	See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-
-ifneq "x$(ALT_BOOTDIR)" "x"
-	BOOTDIR := $(ALT_BOOTDIR)
-endif
-
-ifeq "x$(BOOTDIR)" "x"
-	JDK_HOME := $(shell dirname $(shell which java))/..
-else
-	JDK_HOME := $(BOOTDIR)
-endif
-
-SRC_DIR = ./
-BUILD_DIR = build
-OUTPUT_DIR = $(BUILD_DIR)/classes
-
-JAVAC = $(JDK_HOME)/bin/javac
-JAR = $(JDK_HOME)/bin/jar
-
-SRC_FILES = $(shell find $(SRC_DIR) -name '*.java')
-
-.PHONY: filelist clean cleantmp
-
-all: wb.jar cleantmp
-
-wb.jar: filelist
-	@mkdir -p $(OUTPUT_DIR)
-	$(JAVAC) -sourcepath $(SRC_DIR) -d $(OUTPUT_DIR) -cp $(OUTPUT_DIR) @filelist
-	$(JAR) cf wb.jar -C $(OUTPUT_DIR) .
-	@rm -rf $(OUTPUT_DIR)
-
-filelist: $(SRC_FILES)
-	@rm -f $@
-	@echo $(SRC_FILES) > $@
-
-clean: cleantmp
-	@rm -rf wb.jar
-
-cleantmp:
-	@rm -rf filelist
-	@rm -rf $(BUILD_DIR)
--- a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java	Tue Dec 30 09:44:23 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,251 +0,0 @@
-/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-package sun.hotspot;
-
-import java.lang.reflect.Executable;
-import java.util.Arrays;
-import java.util.List;
-import java.util.function.Function;
-import java.util.stream.Stream;
-import java.security.BasicPermission;
-
-import sun.hotspot.parser.DiagnosticCommand;
-
-public class WhiteBox {
-
-  @SuppressWarnings("serial")
-  public static class WhiteBoxPermission extends BasicPermission {
-    public WhiteBoxPermission(String s) {
-      super(s);
-    }
-  }
-
-  private WhiteBox() {}
-  private static final WhiteBox instance = new WhiteBox();
-  private static native void registerNatives();
-
-  /**
-   * Returns the singleton WhiteBox instance.
-   *
-   * The returned WhiteBox object should be carefully guarded
-   * by the caller, since it can be used to read and write data
-   * at arbitrary memory addresses. It must never be passed to
-   * untrusted code.
-   */
-  public synchronized static WhiteBox getWhiteBox() {
-    SecurityManager sm = System.getSecurityManager();
-    if (sm != null) {
-      sm.checkPermission(new WhiteBoxPermission("getInstance"));
-    }
-    return instance;
-  }
-
-  static {
-    registerNatives();
-  }
-
-  // Get the maximum heap size supporting COOPs
-  public native long getCompressedOopsMaxHeapSize();
-  // Arguments
-  public native void printHeapSizes();
-
-  // Memory
-  public native long getObjectAddress(Object o);
-  public native int  getHeapOopSize();
-  public native int  getVMPageSize();
-  public native boolean isObjectInOldGen(Object o);
-  public native long getObjectSize(Object o);
-
-  // Runtime
-  // Make sure class name is in the correct format
-  public boolean isClassAlive(String name) {
-    return isClassAlive0(name.replace('.', '/'));
-  }
-  private native boolean isClassAlive0(String name);
-
-  // JVMTI
-  public native void addToBootstrapClassLoaderSearch(String segment);
-  public native void addToSystemClassLoaderSearch(String segment);
-
-  // G1
-  public native boolean g1InConcurrentMark();
-  public native boolean g1IsHumongous(Object o);
-  public native long    g1NumFreeRegions();
-  public native int     g1RegionSize();
-  public native Object[]    parseCommandLine(String commandline, char delim, DiagnosticCommand[] args);
-
-  // NMT
-  public native long NMTMalloc(long size);
-  public native void NMTFree(long mem);
-  public native long NMTReserveMemory(long size);
-  public native void NMTCommitMemory(long addr, long size);
-  public native void NMTUncommitMemory(long addr, long size);
-  public native void NMTReleaseMemory(long addr, long size);
-  public native long NMTMallocWithPseudoStack(long size, int index);
-  public native boolean NMTIsDetailSupported();
-  public native boolean NMTChangeTrackingLevel();
-  public native int NMTGetHashSize();
-
-  // Compiler
-  public native void    deoptimizeAll();
-  public        boolean isMethodCompiled(Executable method) {
-    return isMethodCompiled(method, false /*not osr*/);
-  }
-  public native boolean isMethodCompiled(Executable method, boolean isOsr);
-  public        boolean isMethodCompilable(Executable method) {
-    return isMethodCompilable(method, -1 /*any*/);
-  }
-  public        boolean isMethodCompilable(Executable method, int compLevel) {
-    return isMethodCompilable(method, compLevel, false /*not osr*/);
-  }
-  public native boolean isMethodCompilable(Executable method, int compLevel, boolean isOsr);
-  public native boolean isMethodQueuedForCompilation(Executable method);
-  public        int     deoptimizeMethod(Executable method) {
-    return deoptimizeMethod(method, false /*not osr*/);
-  }
-  public native int     deoptimizeMethod(Executable method, boolean isOsr);
-  public        void    makeMethodNotCompilable(Executable method) {
-    makeMethodNotCompilable(method, -1 /*any*/);
-  }
-  public        void    makeMethodNotCompilable(Executable method, int compLevel) {
-    makeMethodNotCompilable(method, compLevel, false /*not osr*/);
-  }
-  public native void    makeMethodNotCompilable(Executable method, int compLevel, boolean isOsr);
-  public        int     getMethodCompilationLevel(Executable method) {
-    return getMethodCompilationLevel(method, false /*not ost*/);
-  }
-  public native int     getMethodCompilationLevel(Executable method, boolean isOsr);
-  public native boolean testSetDontInlineMethod(Executable method, boolean value);
-  public        int     getCompileQueuesSize() {
-    return getCompileQueueSize(-1 /*any*/);
-  }
-  public native int     getCompileQueueSize(int compLevel);
-  public native boolean testSetForceInlineMethod(Executable method, boolean value);
-  public        boolean enqueueMethodForCompilation(Executable method, int compLevel) {
-    return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/);
-  }
-  public native boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci);
-  public native void    clearMethodState(Executable method);
-  public native void    lockCompilation();
-  public native void    unlockCompilation();
-  public native int     getMethodEntryBci(Executable method);
-  public native Object[] getNMethod(Executable method, boolean isOsr);
-  public native long    allocateCodeBlob(int size, int type);
-  public        long    allocateCodeBlob(long size, int type) {
-      int intSize = (int) size;
-      if ((long) intSize != size || size < 0) {
-          throw new IllegalArgumentException(
-                "size argument has illegal value " + size);
-      }
-      return allocateCodeBlob( intSize, type);
-  }
-  public native void    freeCodeBlob(long addr);
-  public        void    forceNMethodSweep() {
-    try {
-        forceNMethodSweep0().join();
-    } catch (InterruptedException e) {
-        Thread.currentThread().interrupt();
-    }
-  }
-  public native Thread  forceNMethodSweep0();
-  public native Object[] getCodeHeapEntries(int type);
-  public native int     getCompilationActivityMode();
-  public native Object[] getCodeBlob(long addr);
-
-  // Intered strings
-  public native boolean isInStringTable(String str);
-
-  // Memory
-  public native void readReservedMemory();
-  public native long allocateMetaspace(ClassLoader classLoader, long size);
-  public native void freeMetaspace(ClassLoader classLoader, long addr, long size);
-  public native long incMetaspaceCapacityUntilGC(long increment);
-  public native long metaspaceCapacityUntilGC();
-
-  // Force Young GC
-  public native void youngGC();
-
-  // Force Full GC
-  public native void fullGC();
-
-  // Method tries to start concurrent mark cycle.
-  // It returns false if CM Thread is always in concurrent cycle.
-  public native boolean g1StartConcMarkCycle();
-
-  // Tests on ReservedSpace/VirtualSpace classes
-  public native int stressVirtualSpaceResize(long reservedSpaceSize, long magnitude, long iterations);
-  public native void runMemoryUnitTests();
-  public native void readFromNoaccessArea();
-  public native long getThreadStackSize();
-  public native long getThreadRemainingStackSize();
-
-  // CPU features
-  public native String getCPUFeatures();
-
-  // Native extensions
-  public native long getHeapUsageForContext(int context);
-  public native long getHeapRegionCountForContext(int context);
-  public native int getContextForObject(Object obj);
-  public native void printRegionInfo(int context);
-
-  // VM flags
-  public native boolean isConstantVMFlag(String name);
-  public native boolean isLockedVMFlag(String name);
-  public native void    setBooleanVMFlag(String name, boolean value);
-  public native void    setIntxVMFlag(String name, long value);
-  public native void    setUintxVMFlag(String name, long value);
-  public native void    setUint64VMFlag(String name, long value);
-  public native void    setSizeTVMFlag(String name, long value);
-  public native void    setStringVMFlag(String name, String value);
-  public native void    setDoubleVMFlag(String name, double value);
-  public native Boolean getBooleanVMFlag(String name);
-  public native Long    getIntxVMFlag(String name);
-  public native Long    getUintxVMFlag(String name);
-  public native Long    getUint64VMFlag(String name);
-  public native Long    getSizeTVMFlag(String name);
-  public native String  getStringVMFlag(String name);
-  public native Double  getDoubleVMFlag(String name);
-  private final List<Function<String,Object>> flagsGetters = Arrays.asList(
-    this::getBooleanVMFlag, this::getIntxVMFlag, this::getUintxVMFlag,
-    this::getUint64VMFlag, this::getSizeTVMFlag, this::getStringVMFlag,
-    this::getDoubleVMFlag);
-
-  public Object getVMFlag(String name) {
-    return flagsGetters.stream()
-                       .map(f -> f.apply(name))
-                       .filter(x -> x != null)
-                       .findAny()
-                       .orElse(null);
-  }
-  public native int getOffsetForName0(String name);
-  public int getOffsetForName(String name) throws Exception {
-    int offset = getOffsetForName0(name);
-    if (offset == -1) {
-      throw new RuntimeException(name + " not found");
-    }
-    return offset;
-  }
-
-}
--- a/hotspot/test/testlibrary/whitebox/sun/hotspot/code/BlobType.java	Tue Dec 30 09:44:23 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 sun.hotspot.code;
-
-import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryPoolMXBean;
-import java.util.EnumSet;
-
-import sun.hotspot.WhiteBox;
-
-public enum BlobType {
-    // Execution level 1 and 4 (non-profiled) nmethods (including native nmethods)
-    MethodNonProfiled(0, "CodeHeap 'non-profiled nmethods'"),
-    // Execution level 2 and 3 (profiled) nmethods
-    MethodProfiled(1, "CodeHeap 'profiled nmethods'"),
-    // Non-nmethods like Buffers, Adapters and Runtime Stubs
-    NonNMethod(2, "CodeHeap 'non-nmethods'") {
-        @Override
-        public boolean allowTypeWhenOverflow(BlobType type) {
-            return super.allowTypeWhenOverflow(type)
-                    || type == BlobType.MethodNonProfiled;
-        }
-    },
-    // All types (No code cache segmentation)
-    All(3, "CodeCache");
-
-    public final int id;
-    private final String beanName;
-
-    private BlobType(int id, String beanName) {
-        this.id = id;
-        this.beanName = beanName;
-    }
-
-    public MemoryPoolMXBean getMemoryPool() {
-        for (MemoryPoolMXBean bean : ManagementFactory.getMemoryPoolMXBeans()) {
-            String name = bean.getName();
-            if (beanName.equals(name)) {
-                return bean;
-            }
-        }
-        return null;
-    }
-
-    public boolean allowTypeWhenOverflow(BlobType type) {
-        return type == this;
-    }
-
-    public static EnumSet<BlobType> getAvailable() {
-        WhiteBox whiteBox = WhiteBox.getWhiteBox();
-        if (!whiteBox.getBooleanVMFlag("SegmentedCodeCache")) {
-            // only All for non segmented world
-            return EnumSet.of(All);
-        }
-        if (System.getProperty("java.vm.info").startsWith("interpreted ")) {
-            // only NonNMethod for -Xint
-            return EnumSet.of(NonNMethod);
-        }
-
-        EnumSet<BlobType> result = EnumSet.complementOf(EnumSet.of(All));
-        if (!whiteBox.getBooleanVMFlag("TieredCompilation")
-                || whiteBox.getIntxVMFlag("TieredStopAtLevel") <= 1) {
-            // there is no MethodProfiled in non tiered world or pure C1
-            result.remove(MethodProfiled);
-        }
-        return result;
-    }
-}
--- a/hotspot/test/testlibrary/whitebox/sun/hotspot/code/CodeBlob.java	Tue Dec 30 09:44:23 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 sun.hotspot.code;
-
-import sun.hotspot.WhiteBox;
-
-public class CodeBlob {
-  private static final WhiteBox WB = WhiteBox.getWhiteBox();
-  public static CodeBlob[] getCodeBlobs(BlobType type) {
-    Object[] obj = WB.getCodeHeapEntries(type.id);
-    if (obj == null) {
-      return null;
-    }
-    CodeBlob[] result = new CodeBlob[obj.length];
-    for (int i = 0, n = result.length; i < n; ++i) {
-      result[i] = new CodeBlob((Object[]) obj[i]);
-    }
-    return result;
-  }
-  public static CodeBlob getCodeBlob(long addr) {
-    Object[] obj = WB.getCodeBlob(addr);
-    if (obj == null) {
-      return null;
-    }
-    return new CodeBlob(obj);
-  }
-  protected CodeBlob(Object[] obj) {
-    assert obj.length == 3;
-    name = (String) obj[0];
-    size = (Integer) obj[1];
-    code_blob_type = BlobType.values()[(Integer) obj[2]];
-    assert code_blob_type.id == (Integer) obj[2];
-  }
-  public final String name;
-  public final int size;
-  public final BlobType code_blob_type;
-
-  @Override
-  public String toString() {
-    return "CodeBlob{"
-        + "name=" + name
-        + ", size=" + size
-        + ", code_blob_type=" + code_blob_type
-        + '}';
-  }
-}
--- a/hotspot/test/testlibrary/whitebox/sun/hotspot/code/NMethod.java	Tue Dec 30 09:44:23 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 sun.hotspot.code;
-
-import java.lang.reflect.Executable;
-import sun.hotspot.WhiteBox;
-
-public class NMethod extends CodeBlob {
-  private static final WhiteBox wb = WhiteBox.getWhiteBox();
-  public static NMethod get(Executable method, boolean isOsr) {
-    Object[] obj = wb.getNMethod(method, isOsr);
-    return obj == null ? null : new NMethod(obj);
-  }
-  private NMethod(Object[] obj) {
-    super((Object[])obj[0]);
-    assert obj.length == 4;
-    comp_level = (Integer) obj[1];
-    insts = (byte[]) obj[2];
-    compile_id = (Integer) obj[3];
-  }
-  public final byte[] insts;
-  public final int comp_level;
-  public final int compile_id;
-
-  @Override
-  public String toString() {
-    return "NMethod{"
-        + super.toString()
-        + ", insts=" + insts
-        + ", comp_level=" + comp_level
-        + ", compile_id=" + compile_id
-        + '}';
-  }
-}
--- a/hotspot/test/testlibrary/whitebox/sun/hotspot/cpuinfo/CPUInfo.java	Tue Dec 30 09:44:23 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 sun.hotspot.cpuinfo;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-
-import sun.hotspot.WhiteBox;
-
-/**
- * Information about CPU on test box.
- *
- * CPUInfo uses WhiteBox to gather information,
- * so WhiteBox class should be added to bootclasspath
- * and option -XX:+WhiteBoxAPI should expclicetly
- * specified on command line.
- */
-public class CPUInfo {
-
-    private static final List<String> features;
-    private static final String additionalCPUInfo;
-
-    static {
-        WhiteBox wb = WhiteBox.getWhiteBox();
-
-        Pattern additionalCPUInfoRE =
-            Pattern.compile("([^(]*\\([^)]*\\)[^,]*),\\s*");
-
-        String cpuFeaturesString = wb.getCPUFeatures();
-        Matcher matcher = additionalCPUInfoRE.matcher(cpuFeaturesString);
-        if (matcher.find()) {
-            additionalCPUInfo = matcher.group(1);
-        } else {
-            additionalCPUInfo = "";
-        }
-        String splittedFeatures[] = matcher.replaceAll("").split("(, )| ");
-
-        features = Collections.unmodifiableList(Arrays.
-                                                asList(splittedFeatures));
-    }
-
-    /**
-     * Get additional information about CPU.
-     * For example, on X86 in will be family/model/stepping
-     * and number of cores.
-     *
-     * @return additional CPU info
-     */
-    public static String getAdditionalCPUInfo() {
-        return additionalCPUInfo;
-    }
-
-    /**
-     * Get all known features supported by CPU.
-     *
-     * @return unmodifiable list with names of all known features
-     *         supported by CPU.
-     */
-    public static List<String> getFeatures() {
-        return features;
-    }
-
-    /**
-     * Check if some feature is supported by CPU.
-     *
-     * @param feature Name of feature to be tested.
-     * @return <b>true</b> if tested feature is supported by CPU.
-     */
-    public static boolean hasFeature(String feature) {
-        return features.contains(feature.toLowerCase());
-    }
-}
--- a/hotspot/test/testlibrary/whitebox/sun/hotspot/parser/DiagnosticCommand.java	Tue Dec 30 09:44:23 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.hotspot.parser;
-
-public class DiagnosticCommand {
-
-    public enum DiagnosticArgumentType {
-        JLONG, BOOLEAN, STRING, NANOTIME, STRINGARRAY, MEMORYSIZE
-    }
-
-    private String name;
-    private String desc;
-    private DiagnosticArgumentType type;
-    private boolean mandatory;
-    private String defaultValue;
-    private boolean argument;
-
-    public DiagnosticCommand(String name, String desc, DiagnosticArgumentType type,
-            boolean mandatory, String defaultValue) {
-        this(name, desc, type, false, mandatory, defaultValue);
-    }
-
-    public DiagnosticCommand(String name, String desc, DiagnosticArgumentType type,
-            boolean argument, boolean mandatory, String defaultValue) {
-        this.name = name;
-        this.desc = desc;
-        this.type = type;
-        this.mandatory = mandatory;
-        this.defaultValue = defaultValue;
-        this.argument = argument;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public String getDesc() {
-        return desc;
-    }
-
-    public DiagnosticArgumentType getType() {
-        return type;
-    }
-
-    public boolean isMandatory() {
-        return mandatory;
-    }
-
-    public boolean isArgument() {
-        return argument;
-    }
-
-    public String getDefaultValue() {
-        return defaultValue;
-    }
-}
--- a/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java	Wed Jul 05 20:13:05 2017 +0200
@@ -47,7 +47,8 @@
         BITNESS("is32bit", "is64bit"),
         OS("isLinux", "isSolaris", "isWindows", "isOSX"),
         VM_TYPE("isClient", "isServer", "isGraal", "isMinimal"),
-        IGNORED("isEmbedded", "isDebugBuild");
+        IGNORED("isEmbedded", "isDebugBuild", "shouldSAAttach",
+                "canPtraceAttachLinux", "canAttachOSX");
 
         public final List<String> methodNames;
 
--- a/hotspot/test/testlibrary_tests/ctw/ClassesDirTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary_tests/ctw/ClassesDirTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8012447
- * @library /testlibrary /testlibrary/whitebox /testlibrary/ctw/src
+ * @library /testlibrary /../../test/lib /testlibrary/ctw/src
  * @build ClassFileInstaller sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
  * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/ctw/ClassesListTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary_tests/ctw/ClassesListTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8012447
- * @library /testlibrary /testlibrary/whitebox /testlibrary/ctw/src
+ * @library /testlibrary /../../test/lib /testlibrary/ctw/src
  * @build ClassFileInstaller sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
  * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/ctw/JarDirTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary_tests/ctw/JarDirTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8012447
- * @library /testlibrary /testlibrary/whitebox /testlibrary/ctw/src
+ * @library /testlibrary /../../test/lib /testlibrary/ctw/src
  * @build ClassFileInstaller com.oracle.java.testlibrary.* sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
  * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/ctw/JarsTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary_tests/ctw/JarsTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8012447
- * @library /testlibrary /testlibrary/whitebox /testlibrary/ctw/src
+ * @library /testlibrary /../../test/lib /testlibrary/ctw/src
  * @build ClassFileInstaller com.oracle.java.testlibrary.* sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
  * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/BooleanTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/BooleanTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test BooleanTest
  * @bug 8028756
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build BooleanTest ClassFileInstaller sun.hotspot.WhiteBox com.oracle.java.testlibrary.*
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/DoubleTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/DoubleTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test DoubleTest
  * @bug 8028756
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build DoubleTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test IntxTest
  * @bug 8028756
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build IntxTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/SizeTTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/SizeTTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test SizeTTest
  * @bug 8054823
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build SizeTTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/StringTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/StringTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test StringTest
  * @bug 8028756
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build StringTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/Uint64Test.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/Uint64Test.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test Uint64Test
  * @bug 8028756
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build Uint64Test
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/UintxTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/UintxTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 /*
  * @test UintxTest
  * @bug 8028756
- * @library /testlibrary /testlibrary/whitebox
+ * @library /testlibrary /../../test/lib
  * @build UintxTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/jdk/.hgtags	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/.hgtags	Wed Jul 05 20:13:05 2017 +0200
@@ -286,3 +286,4 @@
 e336cbd8b15e959e70ed02f0f5e93fa76ebd4c07 jdk9-b41
 6b2314173433467245261364a52fb8e347fe6342 jdk9-b42
 8c6ad41974f9ab6c33d544b088648314963f2a50 jdk9-b43
+8cc4dc300041eb70a7a40e4b2431a8f4d4965ea4 jdk9-b44
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/CipherBlockChaining.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/CipherBlockChaining.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
 package com.sun.crypto.provider;
 
 import java.security.InvalidKeyException;
+import java.security.ProviderException;
+
 
 /**
  * This class represents ciphers in cipher block chaining (CBC) mode.
@@ -122,31 +124,31 @@
      *
      * <p>The input plain text <code>plain</code>, starting at
      * <code>plainOffset</code> and ending at
-     * <code>(plainOffset + len - 1)</code>, is encrypted.
+     * <code>(plainOffset + plainLen - 1)</code>, is encrypted.
      * The result is stored in <code>cipher</code>, starting at
      * <code>cipherOffset</code>.
      *
-     * <p>It is the application's responsibility to make sure that
-     * <code>plainLen</code> is a multiple of the embedded cipher's block size,
-     * as any excess bytes are ignored.
-     *
      * @param plain the buffer with the input data to be encrypted
      * @param plainOffset the offset in <code>plain</code>
      * @param plainLen the length of the input data
      * @param cipher the buffer for the result
      * @param cipherOffset the offset in <code>cipher</code>
+     * @exception ProviderException if <code>len</code> is not
+     * a multiple of the block size
      * @return the length of the encrypted data
      */
     int encrypt(byte[] plain, int plainOffset, int plainLen,
                 byte[] cipher, int cipherOffset)
     {
-        int i;
+        if ((plainLen % blockSize) != 0) {
+            throw new ProviderException("Internal error in input buffering");
+        }
         int endIndex = plainOffset + plainLen;
 
         for (; plainOffset < endIndex;
              plainOffset+=blockSize, cipherOffset += blockSize) {
-            for (i=0; i<blockSize; i++) {
-                k[i] = (byte)(plain[i+plainOffset] ^ r[i]);
+            for (int i = 0; i < blockSize; i++) {
+                k[i] = (byte)(plain[i + plainOffset] ^ r[i]);
             }
             embeddedCipher.encryptBlock(k, 0, cipher, cipherOffset);
             System.arraycopy(cipher, cipherOffset, r, 0, blockSize);
@@ -159,14 +161,10 @@
      *
      * <p>The input cipher text <code>cipher</code>, starting at
      * <code>cipherOffset</code> and ending at
-     * <code>(cipherOffset + len - 1)</code>, is decrypted.
+     * <code>(cipherOffset + cipherLen - 1)</code>, is decrypted.
      * The result is stored in <code>plain</code>, starting at
      * <code>plainOffset</code>.
      *
-     * <p>It is the application's responsibility to make sure that
-     * <code>cipherLen</code> is a multiple of the embedded cipher's block
-     * size, as any excess bytes are ignored.
-     *
      * <p>It is also the application's responsibility to make sure that
      * <code>init</code> has been called before this method is called.
      * (This check is omitted here, to avoid double checking.)
@@ -176,23 +174,23 @@
      * @param cipherLen the length of the input data
      * @param plain the buffer for the result
      * @param plainOffset the offset in <code>plain</code>
+     * @exception ProviderException if <code>len</code> is not
+     * a multiple of the block size
      * @return the length of the decrypted data
-     *
-     * @exception IllegalBlockSizeException if input data whose length does
-     * not correspond to the embedded cipher's block size is passed to the
-     * embedded cipher
      */
     int decrypt(byte[] cipher, int cipherOffset, int cipherLen,
                 byte[] plain, int plainOffset)
     {
-        int i;
+        if ((cipherLen % blockSize) != 0) {
+            throw new ProviderException("Internal error in input buffering");
+        }
         int endIndex = cipherOffset + cipherLen;
 
         for (; cipherOffset < endIndex;
              cipherOffset += blockSize, plainOffset += blockSize) {
             embeddedCipher.decryptBlock(cipher, cipherOffset, k, 0);
-            for (i = 0; i < blockSize; i++) {
-                plain[i+plainOffset] = (byte)(k[i] ^ r[i]);
+            for (int i = 0; i < blockSize; i++) {
+                plain[i + plainOffset] = (byte)(k[i] ^ r[i]);
             }
             System.arraycopy(cipher, cipherOffset, r, 0, blockSize);
         }
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/CipherCore.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/CipherCore.java	Wed Jul 05 20:13:05 2017 +0200
@@ -708,7 +708,7 @@
             len -= blockSize;
         }
         // do not count the trailing bytes which do not make up a unit
-        len = (len > 0 ? (len - (len%unitBytes)) : 0);
+        len = (len > 0 ? (len - (len % unitBytes)) : 0);
 
         // check output buffer capacity
         if ((output == null) ||
@@ -747,6 +747,9 @@
                     int bufferCapacity = buffer.length - buffered;
                     if (bufferCapacity != 0) {
                         temp = Math.min(bufferCapacity, inputConsumed);
+                        if (unitBytes != blockSize) {
+                            temp -= ((buffered + temp) % unitBytes);
+                        }
                         System.arraycopy(input, inputOffset, buffer, buffered, temp);
                         inputOffset += temp;
                         inputConsumed -= temp;
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/CipherFeedback.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/CipherFeedback.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package com.sun.crypto.provider;
 
 import java.security.InvalidKeyException;
+import java.security.ProviderException;
 
 /**
  * This class represents ciphers in cipher-feedback (CFB) mode.
@@ -133,66 +134,72 @@
      *
      * <p>The input plain text <code>plain</code>, starting at
      * <code>plainOffset</code> and ending at
-     * <code>(plainOffset + len - 1)</code>, is encrypted.
+     * <code>(plainOffset + plainLen - 1)</code>, is encrypted.
      * The result is stored in <code>cipher</code>, starting at
      * <code>cipherOffset</code>.
      *
-     * <p>It is the application's responsibility to make sure that
-     * <code>plainLen</code> is a multiple of the stream unit size
-     * <code>numBytes</code>, as any excess bytes are ignored.
-     *
-     * <p>It is also the application's responsibility to make sure that
-     * <code>init</code> has been called before this method is called.
-     * (This check is omitted here, to avoid double checking.)
-     *
      * @param plain the buffer with the input data to be encrypted
      * @param plainOffset the offset in <code>plain</code>
      * @param plainLen the length of the input data
      * @param cipher the buffer for the result
      * @param cipherOffset the offset in <code>cipher</code>
+     * @exception ProviderException if <code>plainLen</code> is not
+     * a multiple of the <code>numBytes</code>
      * @return the length of the encrypted data
      */
     int encrypt(byte[] plain, int plainOffset, int plainLen,
-                byte[] cipher, int cipherOffset)
-    {
-        int i, len;
-        len = blockSize - numBytes;
+                byte[] cipher, int cipherOffset) {
+        if ((plainLen % numBytes) != 0) {
+            throw new ProviderException("Internal error in input buffering");
+        }
+
+        int nShift = blockSize - numBytes;
         int loopCount = plainLen / numBytes;
-        int oddBytes = plainLen % numBytes;
 
-        if (len == 0) {
-            for (; loopCount > 0 ;
-                 plainOffset += numBytes, cipherOffset += numBytes,
-                 loopCount--) {
-                embeddedCipher.encryptBlock(register, 0, k, 0);
-                for (i = 0; i < blockSize; i++)
-                    register[i] = cipher[i+cipherOffset] =
-                        (byte)(k[i] ^ plain[i+plainOffset]);
+        for (; loopCount > 0 ;
+             plainOffset += numBytes, cipherOffset += numBytes,
+             loopCount--) {
+            embeddedCipher.encryptBlock(register, 0, k, 0);
+            if (nShift != 0) {
+                System.arraycopy(register, numBytes, register, 0, nShift);
+            }
+            for (int i = 0; i < numBytes; i++) {
+                register[nShift + i] = cipher[i + cipherOffset] =
+                        (byte)(k[i] ^ plain[i + plainOffset]);
             }
-            if (oddBytes > 0) {
-                embeddedCipher.encryptBlock(register, 0, k, 0);
-                for (i=0; i<oddBytes; i++)
-                    register[i] = cipher[i+cipherOffset] =
-                        (byte)(k[i] ^ plain[i+plainOffset]);
-            }
-        } else {
-            for (; loopCount > 0 ;
-                 plainOffset += numBytes, cipherOffset += numBytes,
-                 loopCount--) {
-                embeddedCipher.encryptBlock(register, 0, k, 0);
-                System.arraycopy(register, numBytes, register, 0, len);
-                for (i=0; i<numBytes; i++)
-                    register[i+len] = cipher[i+cipherOffset] =
-                        (byte)(k[i] ^ plain[i+plainOffset]);
+        }
+        return plainLen;
+    }
 
-            }
-            if (oddBytes != 0) {
-                embeddedCipher.encryptBlock(register, 0, k, 0);
-                System.arraycopy(register, numBytes, register, 0, len);
-                for (i=0; i<oddBytes; i++) {
-                    register[i+len] = cipher[i+cipherOffset] =
-                        (byte)(k[i] ^ plain[i+plainOffset]);
-                }
+    /**
+     * Performs the last encryption operation.
+     *
+     * <p>The input plain text <code>plain</code>, starting at
+     * <code>plainOffset</code> and ending at
+     * <code>(plainOffset + plainLen - 1)</code>, is encrypted.
+     * The result is stored in <code>cipher</code>, starting at
+     * <code>cipherOffset</code>.
+     *
+     * @param plain the buffer with the input data to be encrypted
+     * @param plainOffset the offset in <code>plain</code>
+     * @param plainLen the length of the input data
+     * @param cipher the buffer for the result
+     * @param cipherOffset the offset in <code>cipher</code>
+     * @return the number of bytes placed into <code>cipher</code>
+     */
+    int encryptFinal(byte[] plain, int plainOffset, int plainLen,
+                     byte[] cipher, int cipherOffset) {
+
+        int oddBytes = plainLen % numBytes;
+        int len = encrypt(plain, plainOffset, (plainLen - oddBytes),
+                          cipher, cipherOffset);
+        plainOffset += len;
+        cipherOffset += len;
+        if (oddBytes != 0) {
+            embeddedCipher.encryptBlock(register, 0, k, 0);
+            for (int i = 0; i < oddBytes; i++) {
+                 cipher[i + cipherOffset] =
+                    (byte)(k[i] ^ plain[i + plainOffset]);
             }
         }
         return plainLen;
@@ -203,17 +210,52 @@
      *
      * <p>The input cipher text <code>cipher</code>, starting at
      * <code>cipherOffset</code> and ending at
-     * <code>(cipherOffset + len - 1)</code>, is decrypted.
+     * <code>(cipherOffset + cipherLen - 1)</code>, is decrypted.
      * The result is stored in <code>plain</code>, starting at
      * <code>plainOffset</code>.
      *
-     * <p>It is the application's responsibility to make sure that
-     * <code>cipherLen</code> is a multiple of the stream unit size
-     * <code>numBytes</code>, as any excess bytes are ignored.
+     * @param cipher the buffer with the input data to be decrypted
+     * @param cipherOffset the offset in <code>cipherOffset</code>
+     * @param cipherLen the length of the input data
+     * @param plain the buffer for the result
+     * @param plainOffset the offset in <code>plain</code>
+     * @exception ProviderException if <code>cipherLen</code> is not
+     * a multiple of the <code>numBytes</code>
+     * @return the length of the decrypted data
+     */
+    int decrypt(byte[] cipher, int cipherOffset, int cipherLen,
+                byte[] plain, int plainOffset) {
+        if ((cipherLen % numBytes) != 0) {
+            throw new ProviderException("Internal error in input buffering");
+        }
+
+        int nShift = blockSize - numBytes;
+        int loopCount = cipherLen / numBytes;
+
+        for (; loopCount > 0;
+             plainOffset += numBytes, cipherOffset += numBytes,
+             loopCount--) {
+            embeddedCipher.encryptBlock(register, 0, k, 0);
+            if (nShift != 0) {
+                System.arraycopy(register, numBytes, register, 0, nShift);
+            }
+            for (int i = 0; i < numBytes; i++) {
+                register[i + nShift] = cipher[i + cipherOffset];
+                plain[i + plainOffset]
+                    = (byte)(cipher[i + cipherOffset] ^ k[i]);
+            }
+        }
+        return cipherLen;
+    }
+
+    /**
+     * Performs the last decryption operation.
      *
-     * <p>It is also the application's responsibility to make sure that
-     * <code>init</code> has been called before this method is called.
-     * (This check is omitted here, to avoid double checking.)
+     * <p>The input cipher text <code>cipher</code>, starting at
+     * <code>cipherOffset</code> and ending at
+     * <code>(cipherOffset + cipherLen - 1)</code>, is decrypted.
+     * The result is stored in <code>plain</code>, starting at
+     * <code>plainOffset</code>.
      *
      * @param cipher the buffer with the input data to be decrypted
      * @param cipherOffset the offset in <code>cipherOffset</code>
@@ -222,53 +264,19 @@
      * @param plainOffset the offset in <code>plain</code>
      * @return the length of the decrypted data
      */
-    int decrypt(byte[] cipher, int cipherOffset, int cipherLen,
-                byte[] plain, int plainOffset)
-    {
-        int i, len;
-        len = blockSize - numBytes;
-        int loopCount = cipherLen / numBytes;
-        int oddBytes = cipherLen % numBytes;
+    int decryptFinal(byte[] cipher, int cipherOffset, int cipherLen,
+                byte[] plain, int plainOffset) {
 
-        if (len == 0) {
-            for (; loopCount > 0;
-                 plainOffset += numBytes, cipherOffset += numBytes,
-                 loopCount--) {
-                embeddedCipher.encryptBlock(register, 0, k, 0);
-                for (i = 0; i < blockSize; i++) {
-                    register[i] = cipher[i+cipherOffset];
-                    plain[i+plainOffset]
-                        = (byte)(cipher[i+cipherOffset] ^ k[i]);
-                }
-            }
-            if (oddBytes > 0) {
-                embeddedCipher.encryptBlock(register, 0, k, 0);
-                for (i=0; i<oddBytes; i++) {
-                    register[i] = cipher[i+cipherOffset];
-                    plain[i+plainOffset]
-                        = (byte)(cipher[i+cipherOffset] ^ k[i]);
-                }
-            }
-        } else {
-            for (; loopCount > 0;
-                 plainOffset += numBytes, cipherOffset += numBytes,
-                 loopCount--) {
-                embeddedCipher.encryptBlock(register, 0, k, 0);
-                System.arraycopy(register, numBytes, register, 0, len);
-                for (i=0; i<numBytes; i++) {
-                    register[i+len] = cipher[i+cipherOffset];
-                    plain[i+plainOffset]
-                        = (byte)(cipher[i+cipherOffset] ^ k[i]);
-                }
-            }
-            if (oddBytes != 0) {
-                embeddedCipher.encryptBlock(register, 0, k, 0);
-                System.arraycopy(register, numBytes, register, 0, len);
-                for (i=0; i<oddBytes; i++) {
-                    register[i+len] = cipher[i+cipherOffset];
-                    plain[i+plainOffset]
-                        = (byte)(cipher[i+cipherOffset] ^ k[i]);
-                }
+        int oddBytes = cipherLen % numBytes;
+        int len = decrypt(cipher, cipherOffset, (cipherLen - oddBytes),
+                          plain, plainOffset);
+        cipherOffset += len;
+        plainOffset += len;
+        if (oddBytes != 0) {
+            embeddedCipher.encryptBlock(register, 0, k, 0);
+            for (int i = 0; i < oddBytes; i++) {
+                plain[i + plainOffset]
+                    = (byte)(cipher[i + cipherOffset] ^ k[i]);
             }
         }
         return cipherLen;
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/CounterMode.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/CounterMode.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 201313, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 
 import java.security.InvalidKeyException;
 
+
 /**
  * This class represents ciphers in counter (CTR) mode.
  *
@@ -136,14 +137,6 @@
      * The result is stored in <code>cipher</code>, starting at
      * <code>cipherOffset</code>.
      *
-     * <p>It is the application's responsibility to make sure that
-     * <code>plainLen</code> is a multiple of the embedded cipher's block size,
-     * as any excess bytes are ignored.
-     *
-     * <p>It is also the application's responsibility to make sure that
-     * <code>init</code> has been called before this method is called.
-     * (This check is omitted here, to avoid double checking.)
-     *
      * @param in the buffer with the input data to be encrypted
      * @param inOffset the offset in <code>plain</code>
      * @param len the length of the input data
@@ -155,30 +148,7 @@
         return crypt(in, inOff, len, out, outOff);
     }
 
-    /**
-     * Performs decryption operation.
-     *
-     * <p>The input cipher text <code>cipher</code>, starting at
-     * <code>cipherOffset</code> and ending at
-     * <code>(cipherOffset + len - 1)</code>, is decrypted.
-     * The result is stored in <code>plain</code>, starting at
-     * <code>plainOffset</code>.
-     *
-     * <p>It is the application's responsibility to make sure that
-     * <code>cipherLen</code> is a multiple of the embedded cipher's block
-     * size, as any excess bytes are ignored.
-     *
-     * <p>It is also the application's responsibility to make sure that
-     * <code>init</code> has been called before this method is called.
-     * (This check is omitted here, to avoid double checking.)
-     *
-     * @param in the buffer with the input data to be decrypted
-     * @param inOff the offset in <code>cipherOffset</code>
-     * @param len the length of the input data
-     * @param out the buffer for the result
-     * @param outOff the offset in <code>plain</code>
-     * @return the length of the decrypted data
-     */
+    // CTR encrypt and decrypt are identical
     int decrypt(byte[] in, int inOff, int len, byte[] out, int outOff) {
         return crypt(in, inOff, len, out, outOff);
     }
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/ElectronicCodeBook.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/ElectronicCodeBook.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package com.sun.crypto.provider;
 
 import java.security.InvalidKeyException;
+import java.security.ProviderException;
 
 /**
  * This class represents ciphers in electronic codebook (ECB) mode.
@@ -96,28 +97,24 @@
     /**
      * Performs encryption operation.
      *
-     * <p>The input plain text <code>plain</code>, starting at
-     * <code>plainOffset</code> and ending at
-     * <code>(plainOffset + len - 1)</code>, is encrypted.
-     * The result is stored in <code>cipher</code>, starting at
-     * <code>cipherOffset</code>.
-     *
-     * <p>It is the application's responsibility to make sure that
-     * <code>plainLen</code> is a multiple of the embedded cipher's block size,
-     * as any excess bytes are ignored.
-     *
-     * <p>It is also the application's responsibility to make sure that
-     * <code>init</code> has been called before this method is called.
-     * (This check is omitted here, to avoid double checking.)
+     * <p>The input plain text <code>in</code>, starting at
+     * <code>inOff</code> and ending at * <code>(inOff + len - 1)</code>,
+     * is encrypted. The result is stored in <code>out</code>, starting at
+     * <code>outOff</code>.
      *
      * @param in the buffer with the input data to be encrypted
-     * @param inOffset the offset in <code>plain</code>
+     * @param inOff the offset in <code>plain</code>
      * @param len the length of the input data
      * @param out the buffer for the result
      * @param outOff the offset in <code>cipher</code>
+     * @exception ProviderException if <code>len</code> is not
+     * a multiple of the block size
      * @return the length of the encrypted data
      */
     int encrypt(byte[] in, int inOff, int len, byte[] out, int outOff) {
+        if ((len % blockSize) != 0) {
+             throw new ProviderException("Internal error in input buffering");
+        }
         for (int i = len; i >= blockSize; i -= blockSize) {
             embeddedCipher.encryptBlock(in, inOff, out, outOff);
             inOff += blockSize;
@@ -129,28 +126,24 @@
     /**
      * Performs decryption operation.
      *
-     * <p>The input cipher text <code>cipher</code>, starting at
-     * <code>cipherOffset</code> and ending at
-     * <code>(cipherOffset + len - 1)</code>, is decrypted.
-     * The result is stored in <code>plain</code>, starting at
-     * <code>plainOffset</code>.
-     *
-     * <p>It is the application's responsibility to make sure that
-     * <code>cipherLen</code> is a multiple of the embedded cipher's block
-     * size, as any excess bytes are ignored.
-     *
-     * <p>It is also the application's responsibility to make sure that
-     * <code>init</code> has been called before this method is called.
-     * (This check is omitted here, to avoid double checking.)
+     * <p>The input cipher text <code>in</code>, starting at
+     * <code>inOff</code> and ending at * <code>(inOff + len - 1)</code>,
+     * is decrypted.The result is stored in <code>out</code>, starting at
+     * <code>outOff</code>.
      *
      * @param in the buffer with the input data to be decrypted
      * @param inOff the offset in <code>cipherOffset</code>
      * @param len the length of the input data
      * @param out the buffer for the result
      * @param outOff the offset in <code>plain</code>
+     * @exception ProviderException if <code>len</code> is not
+     * a multiple of the block size
      * @return the length of the decrypted data
      */
     int decrypt(byte[] in, int inOff, int len, byte[] out, int outOff) {
+        if ((len % blockSize) != 0) {
+             throw new ProviderException("Internal error in input buffering");
+        }
         for (int i = len; i >= blockSize; i -= blockSize) {
             embeddedCipher.decryptBlock(in, inOff, out, outOff);
             inOff += blockSize;
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -371,21 +371,19 @@
      * and ending at <code>(inOff + len - 1)</code>, is encrypted. The result
      * is stored in <code>out</code>, starting at <code>outOfs</code>.
      *
-     * <p>It is the application's responsibility to make sure that
-     * <code>len</code> is a multiple of the embedded cipher's block size,
-     * otherwise, a ProviderException will be thrown.
-     *
-     * <p>It is also the application's responsibility to make sure that
-     * <code>init</code> has been called before this method is called.
-     * (This check is omitted here, to avoid double checking.)
-     *
      * @param in the buffer with the input data to be encrypted
      * @param inOfs the offset in <code>in</code>
      * @param len the length of the input data
      * @param out the buffer for the result
      * @param outOfs the offset in <code>out</code>
+     * @exception ProviderException if <code>len</code> is not
+     * a multiple of the block size
+     * @return the number of bytes placed into the <code>out</code> buffer
      */
     int encrypt(byte[] in, int inOfs, int len, byte[] out, int outOfs) {
+        if ((len % blockSize) != 0) {
+             throw new ProviderException("Internal error in input buffering");
+        }
         processAAD();
         if (len > 0) {
             gctrPAndC.update(in, inOfs, len, out, outOfs);
@@ -398,9 +396,6 @@
     /**
      * Performs encryption operation for the last time.
      *
-     * <p>NOTE: <code>len</code> may not be multiple of the embedded
-     * cipher's block size for this call.
-     *
      * @param in the input buffer with the data to be encrypted
      * @param inOfs the offset in <code>in</code>
      * @param len the length of the input data
@@ -439,21 +434,19 @@
      * is decrypted. The result is stored in <code>out</code>, starting at
      * <code>outOfs</code>.
      *
-     * <p>It is the application's responsibility to make sure that
-     * <code>len</code> is a multiple of the embedded cipher's block
-     * size, as any excess bytes are ignored.
-     *
-     * <p>It is also the application's responsibility to make sure that
-     * <code>init</code> has been called before this method is called.
-     * (This check is omitted here, to avoid double checking.)
-     *
      * @param in the buffer with the input data to be decrypted
      * @param inOfs the offset in <code>in</code>
      * @param len the length of the input data
      * @param out the buffer for the result
      * @param outOfs the offset in <code>out</code>
+     * @exception ProviderException if <code>len</code> is not
+     * a multiple of the block size
+     * @return the number of bytes placed into the <code>out</code> buffer
      */
     int decrypt(byte[] in, int inOfs, int len, byte[] out, int outOfs) {
+        if ((len % blockSize) != 0) {
+             throw new ProviderException("Internal error in input buffering");
+        }
         processAAD();
 
         if (len > 0) {
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java	Wed Jul 05 20:13:05 2017 +0200
@@ -898,4 +898,20 @@
         md.update("Mighty Aphrodite".getBytes("UTF8"));
         return md;
     }
+
+    /**
+     * Probe the first few bytes of the keystore data stream for a valid
+     * JCEKS keystore encoding.
+     */
+    @Override
+    public boolean engineProbe(InputStream stream) throws IOException {
+        DataInputStream dataStream;
+        if (stream instanceof DataInputStream) {
+            dataStream = (DataInputStream)stream;
+        } else {
+            dataStream = new DataInputStream(stream);
+        }
+
+        return JCEKS_MAGIC == dataStream.readInt();
+    }
 }
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/OutputFeedback.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/OutputFeedback.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package com.sun.crypto.provider;
 
 import java.security.InvalidKeyException;
+import java.security.ProviderException;
 
 /**
  * This class represents ciphers in output-feedback (OFB) mode.
@@ -132,17 +133,52 @@
      *
      * <p>The input plain text <code>plain</code>, starting at
      * <code>plainOffset</code> and ending at
-     * <code>(plainOffset + len - 1)</code>, is encrypted.
+     * <code>(plainOffset + plainLen - 1)</code>, is encrypted.
      * The result is stored in <code>cipher</code>, starting at
      * <code>cipherOffset</code>.
      *
-     * <p>It is the application's responsibility to make sure that
-     * <code>plainLen</code> is a multiple of the stream unit size
-     * <code>numBytes</code>, as any excess bytes are ignored.
+     * @param plain the buffer with the input data to be encrypted
+     * @param plainOffset the offset in <code>plain</code>
+     * @param plainLen the length of the input data
+     * @param cipher the buffer for the result
+     * @param cipherOffset the offset in <code>cipher</code>
+     * @exception ProviderException if <code>plainLen</code> is not
+     * a multiple of the <code>numBytes</code>
+     * @return the length of the encrypted data
+     */
+    int encrypt(byte[] plain, int plainOffset, int plainLen,
+                byte[] cipher, int cipherOffset) {
+
+        if ((plainLen % numBytes) != 0) {
+            throw new ProviderException("Internal error in input buffering");
+        }
+        int nShift = blockSize - numBytes;
+        int loopCount = plainLen / numBytes;
+
+        for (; loopCount > 0;
+             plainOffset += numBytes, cipherOffset += numBytes,
+             loopCount--) {
+            embeddedCipher.encryptBlock(register, 0, k, 0);
+            for (int i = 0; i < numBytes; i++) {
+                cipher[i + cipherOffset] =
+                    (byte)(k[i] ^ plain[i + plainOffset]);
+                if (nShift != 0) {
+                    System.arraycopy(register, numBytes, register, 0, nShift);
+                }
+                System.arraycopy(k, 0, register, nShift, numBytes);
+            }
+        }
+        return plainLen;
+    }
+
+    /**
+     * Performs last encryption operation.
      *
-     * <p>It is also the application's responsibility to make sure that
-     * <code>init</code> has been called before this method is called.
-     * (This check is omitted here, to avoid double checking.)
+     * <p>The input plain text <code>plain</code>, starting at
+     * <code>plainOffset</code> and ending at
+     * <code>(plainOffset + plainLen - 1)</code>, is encrypted.
+     * The result is stored in <code>cipher</code>, starting at
+     * <code>cipherOffset</code>.
      *
      * @param plain the buffer with the input data to be encrypted
      * @param plainOffset the offset in <code>plain</code>
@@ -151,82 +187,34 @@
      * @param cipherOffset the offset in <code>cipher</code>
      * @return the length of the encrypted data
      */
-    int encrypt(byte[] plain, int plainOffset, int plainLen,
-                byte[] cipher, int cipherOffset)
-    {
-        int i;
-        int len = blockSize - numBytes;
-        int loopCount = plainLen / numBytes;
+    int encryptFinal(byte[] plain, int plainOffset, int plainLen,
+                     byte[] cipher, int cipherOffset) {
         int oddBytes = plainLen % numBytes;
+        int len = encrypt(plain, plainOffset, (plainLen - oddBytes),
+                          cipher, cipherOffset);
+        plainOffset += len;
+        cipherOffset += len;
 
-        if (len == 0) {
-            for (; loopCount > 0;
-                 plainOffset += numBytes, cipherOffset += numBytes,
-                 loopCount--) {
-                embeddedCipher.encryptBlock(register, 0, k, 0);
-                for (i=0; i<numBytes; i++)
-                    cipher[i+cipherOffset] =
-                        (byte)(k[i] ^ plain[i+plainOffset]);
-                System.arraycopy(k, 0, register, 0, numBytes);
-            }
-            if (oddBytes > 0) {
-                embeddedCipher.encryptBlock(register, 0, k, 0);
-                for (i=0; i<oddBytes; i++)
-                    cipher[i+cipherOffset] =
-                        (byte)(k[i] ^ plain[i+plainOffset]);
-                System.arraycopy(k, 0, register, 0, numBytes);
-            }
-        } else {
-            for (; loopCount > 0;
-                 plainOffset += numBytes, cipherOffset += numBytes,
-                 loopCount--) {
-                embeddedCipher.encryptBlock(register, 0, k, 0);
-                for (i=0; i<numBytes; i++)
-                    cipher[i+cipherOffset] =
-                        (byte)(k[i] ^ plain[i+plainOffset]);
-                System.arraycopy(register, numBytes, register, 0, len);
-                System.arraycopy(k, 0, register, len, numBytes);
-            }
-            if (oddBytes > 0) {
-                embeddedCipher.encryptBlock(register, 0, k, 0);
-                for (i=0; i<oddBytes; i++)
-                    cipher[i+cipherOffset] =
-                        (byte)(k[i] ^ plain[i+plainOffset]);
-                System.arraycopy(register, numBytes, register, 0, len);
-                System.arraycopy(k, 0, register, len, numBytes);
+        if (oddBytes != 0) {
+            embeddedCipher.encryptBlock(register, 0, k, 0);
+            for (int i = 0; i < oddBytes; i++) {
+                cipher[i + cipherOffset] =
+                    (byte)(k[i] ^ plain[ i + plainOffset]);
             }
         }
         return plainLen;
     }
 
-    /**
-     * Performs decryption operation.
-     *
-     * <p>The input cipher text <code>cipher</code>, starting at
-     * <code>cipherOffset</code> and ending at
-     * <code>(cipherOffset + len - 1)</code>, is decrypted.
-     * The result is stored in <code>plain</code>, starting at
-     * <code>plainOffset</code>.
-     *
-     * <p>It is the application's responsibility to make sure that
-     * <code>cipherLen</code> is a multiple of the stream unit size
-     * <code>numBytes</code>, as any excess bytes are ignored.
-     *
-     * <p>It is also the application's responsibility to make sure that
-     * <code>init</code> has been called before this method is called.
-     * (This check is omitted here, to avoid double checking.)
-     *
-     * @param cipher the buffer with the input data to be decrypted
-     * @param cipherOffset the offset in <code>cipherOffset</code>
-     * @param cipherLen the length of the input data
-     * @param plain the buffer for the result
-     * @param plainOffset the offset in <code>plain</code>
-     * @return the length of the decrypted data
-     */
+    // OFB encrypt and decrypt are identical
     int decrypt(byte[] cipher, int cipherOffset, int cipherLen,
-                        byte[] plain, int plainOffset)
-    {
-        // OFB encrypt and decrypt are identical
+                byte[] plain, int plainOffset) {
         return encrypt(cipher, cipherOffset, cipherLen, plain, plainOffset);
     }
+
+    // OFB encrypt and decrypt are identical
+    int decryptFinal(byte[] cipher, int cipherOffset, int cipherLen,
+                     byte[] plain, int plainOffset) {
+        // OFB encrypt and decrypt are identical
+        return encryptFinal(cipher, cipherOffset, cipherLen, plain, plainOffset);
+    }
 }
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/PCBC.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/PCBC.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
 package com.sun.crypto.provider;
 
 import java.security.InvalidKeyException;
+import java.security.ProviderException;
+
 
 /**
  * This class represents ciphers in Plaintext Cipher Block Chaining (PCBC)
@@ -118,38 +120,36 @@
      *
      * <p>The input plain text <code>plain</code>, starting at
      * <code>plainOffset</code> and ending at
-     * <code>(plainOffset + len - 1)</code>, is encrypted.
+     * <code>(plainOffset + plainLen - 1)</code>, is encrypted.
      * The result is stored in <code>cipher</code>, starting at
      * <code>cipherOffset</code>.
      *
-     * <p>It is the application's responsibility to make sure that
-     * <code>plainLen</code> is a multiple of the embedded cipher's block size,
-     * as any excess bytes are ignored.
-     *
-     * <p>It is also the application's responsibility to make sure that
-     * <code>init</code> has been called before this method is called.
-     * (This check is omitted here, to avoid double checking.)
-     *
      * @param plain the buffer with the input data to be encrypted
      * @param plainOffset the offset in <code>plain</code>
      * @param plainLen the length of the input data
      * @param cipher the buffer for the result
      * @param cipherOffset the offset in <code>cipher</code>
+     * @exception ProviderException if <code>plainLen</code> is not
+     * a multiple of the block size
+     * @return the length of the encrypted data
      */
     int encrypt(byte[] plain, int plainOffset, int plainLen,
                 byte[] cipher, int cipherOffset)
     {
+        if ((plainLen % blockSize) != 0) {
+            throw new ProviderException("Internal error in input buffering");
+        }
         int i;
         int endIndex = plainOffset + plainLen;
 
         for (; plainOffset < endIndex;
              plainOffset += blockSize, cipherOffset += blockSize) {
-            for (i=0; i<blockSize; i++) {
-                k[i] ^= plain[i+plainOffset];
+            for (i = 0; i < blockSize; i++) {
+                k[i] ^= plain[i + plainOffset];
             }
             embeddedCipher.encryptBlock(k, 0, cipher, cipherOffset);
             for (i = 0; i < blockSize; i++) {
-                k[i] = (byte)(plain[i+plainOffset] ^ cipher[i+cipherOffset]);
+                k[i] = (byte)(plain[i + plainOffset] ^ cipher[i + cipherOffset]);
             }
         }
         return plainLen;
@@ -160,27 +160,25 @@
      *
      * <p>The input cipher text <code>cipher</code>, starting at
      * <code>cipherOffset</code> and ending at
-     * <code>(cipherOffset + len - 1)</code>, is decrypted.
+     * <code>(cipherOffset + cipherLen - 1)</code>, is decrypted.
      * The result is stored in <code>plain</code>, starting at
      * <code>plainOffset</code>.
      *
-     * <p>It is the application's responsibility to make sure that
-     * <code>cipherLen</code> is a multiple of the embedded cipher's block
-     * size, as any excess bytes are ignored.
-     *
-     * <p>It is also the application's responsibility to make sure that
-     * <code>init</code> has been called before this method is called.
-     * (This check is omitted here, to avoid double checking.)
-     *
      * @param cipher the buffer with the input data to be decrypted
      * @param cipherOffset the offset in <code>cipherOffset</code>
      * @param cipherLen the length of the input data
      * @param plain the buffer for the result
      * @param plainOffset the offset in <code>plain</code>
+     * @exception ProviderException if <code>cipherLen</code> is not
+     * a multiple of the block size
+     * @return the length of the decrypted data
      */
     int decrypt(byte[] cipher, int cipherOffset, int cipherLen,
                 byte[] plain, int plainOffset)
     {
+        if ((cipherLen % blockSize) != 0) {
+             throw new ProviderException("Internal error in input buffering");
+        }
         int i;
         int endIndex = cipherOffset + cipherLen;
 
@@ -189,10 +187,10 @@
             embeddedCipher.decryptBlock(cipher, cipherOffset,
                                    plain, plainOffset);
             for (i = 0; i < blockSize; i++) {
-                plain[i+plainOffset] ^= k[i];
+                plain[i + plainOffset] ^= k[i];
             }
             for (i = 0; i < blockSize; i++) {
-                k[i] = (byte)(plain[i+plainOffset] ^ cipher[i+cipherOffset]);
+                k[i] = (byte)(plain[i + plainOffset] ^ cipher[i + cipherOffset]);
             }
         }
         return cipherLen;
--- a/jdk/src/java.base/share/classes/java/math/BigDecimal.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/math/BigDecimal.java	Wed Jul 05 20:13:05 2017 +0200
@@ -393,7 +393,7 @@
      * <p>Note that if the sequence of characters is already available
      * within a character array, using this constructor is faster than
      * converting the {@code char} array to string and using the
-     * {@code BigDecimal(String)} constructor .
+     * {@code BigDecimal(String)} constructor.
      *
      * @param  in {@code char} array that is the source of characters.
      * @param  offset first character in the array to inspect.
@@ -466,7 +466,8 @@
                     } else if (c == '.') {   // have dot
                         // have dot
                         if (dot) // two dots
-                            throw new NumberFormatException();
+                            throw new NumberFormatException("Character array"
+                                + " contains more than one decimal point.");
                         dot = true;
                     } else if (Character.isDigit(c)) { // slow path
                         int digit = Character.digit(c, 10);
@@ -488,14 +489,16 @@
                         exp = parseExp(in, offset, len);
                         // Next test is required for backwards compatibility
                         if ((int) exp != exp) // overflow
-                            throw new NumberFormatException();
+                            throw new NumberFormatException("Exponent overflow.");
                         break; // [saves a test]
                     } else {
-                        throw new NumberFormatException();
+                        throw new NumberFormatException("Character " + c
+                            + " is neither a decimal digit number, decimal point, nor"
+                            + " \"e\" notation exponential mark.");
                     }
                 }
                 if (prec == 0) // no digits found
-                    throw new NumberFormatException();
+                    throw new NumberFormatException("No digits found.");
                 // Adjust scale if exp is not zero.
                 if (exp != 0) { // had significant exponent
                     scl = adjustScale(scl, exp);
@@ -541,22 +544,24 @@
                     if (c == '.') {
                         // have dot
                         if (dot) // two dots
-                            throw new NumberFormatException();
+                            throw new NumberFormatException("Character array"
+                                + " contains more than one decimal point.");
                         dot = true;
                         continue;
                     }
                     // exponent expected
                     if ((c != 'e') && (c != 'E'))
-                        throw new NumberFormatException();
+                        throw new NumberFormatException("Character array"
+                            + " is missing \"e\" notation exponential mark.");
                     exp = parseExp(in, offset, len);
                     // Next test is required for backwards compatibility
                     if ((int) exp != exp) // overflow
-                        throw new NumberFormatException();
+                        throw new NumberFormatException("Exponent overflow.");
                     break; // [saves a test]
                 }
                 // here when no characters left
                 if (prec == 0) // no digits found
-                    throw new NumberFormatException();
+                    throw new NumberFormatException("No digits found.");
                 // Adjust scale if exp is not zero.
                 if (exp != 0) { // had significant exponent
                     scl = adjustScale(scl, exp);
@@ -592,10 +597,10 @@
                     }
                 }
             }
-        } catch (ArrayIndexOutOfBoundsException e) {
-            throw new NumberFormatException();
-        } catch (NegativeArraySizeException e) {
-            throw new NumberFormatException();
+        } catch (ArrayIndexOutOfBoundsException | NegativeArraySizeException e) {
+            NumberFormatException nfe = new NumberFormatException();
+            nfe.initCause(e);
+            throw nfe;
         }
         this.scale = scl;
         this.precision = prec;
@@ -627,7 +632,7 @@
             len--;
         }
         if (len <= 0) // no exponent digits
-            throw new NumberFormatException();
+            throw new NumberFormatException("No exponent digits.");
         // skip leading zeros in the exponent
         while (len > 10 && (c=='0' || (Character.digit(c, 10) == 0))) {
             offset++;
@@ -635,7 +640,7 @@
             len--;
         }
         if (len > 10) // too many nonzero exponent digits
-            throw new NumberFormatException();
+            throw new NumberFormatException("Too many nonzero exponent digits.");
         // c now holds first digit of exponent
         for (;; len--) {
             int v;
@@ -644,7 +649,7 @@
             } else {
                 v = Character.digit(c, 10);
                 if (v < 0) // not a digit
-                    throw new NumberFormatException();
+                    throw new NumberFormatException("Not a digit.");
             }
             exp = exp * 10 + v;
             if (len == 1)
--- a/jdk/src/java.base/share/classes/java/nio/file/Path.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/nio/file/Path.java	Wed Jul 05 20:13:05 2017 +0200
@@ -29,6 +29,7 @@
 import java.io.IOException;
 import java.net.URI;
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 /**
  * An object that may be used to locate a file in a file system. It will
@@ -246,6 +247,12 @@
      * "{@code foo/bar}" starts with "{@code foo}" and "{@code foo/bar}". It
      * does not start with "{@code f}" or "{@code fo}".
      *
+     * @implSpec
+     * The default implementation is equivalent for this path to:
+     * <pre>{@code
+     *     startsWith(getFileSystem().getPath(other));
+     * }</pre>
+     *
      * @param   other
      *          the given path string
      *
@@ -255,7 +262,9 @@
      * @throws  InvalidPathException
      *          If the path string cannot be converted to a Path.
      */
-    boolean startsWith(String other);
+    default boolean startsWith(String other) {
+        return startsWith(getFileSystem().getPath(other));
+    }
 
     /**
      * Tests if this path ends with the given path.
@@ -294,6 +303,12 @@
      * Path}"{@code foo/bar}" with the {@code String} "{@code bar/}" returns
      * {@code true}.
      *
+     * @implSpec
+     * The default implementation is equivalent for this path to:
+     * <pre>{@code
+     *     endsWith(getFileSystem().getPath(other));
+     * }</pre>
+     *
      * @param   other
      *          the given path string
      *
@@ -303,7 +318,9 @@
      * @throws  InvalidPathException
      *          If the path string cannot be converted to a Path.
      */
-    boolean endsWith(String other);
+    default boolean endsWith(String other) {
+        return endsWith(getFileSystem().getPath(other));
+    }
 
     /**
      * Returns a path that is this path with redundant name elements eliminated.
@@ -365,6 +382,12 @@
      * invoking this method with the path string "{@code gus}" will result in
      * the {@code Path} "{@code foo/bar/gus}".
      *
+     * @implSpec
+     * The default implementation is equivalent for this path to:
+     * <pre>{@code
+     *     resolve(getFileSystem().getPath(other));
+     * }</pre>
+     *
      * @param   other
      *          the path string to resolve against this path
      *
@@ -375,7 +398,9 @@
      *
      * @see FileSystem#getPath
      */
-    Path resolve(String other);
+    default Path resolve(String other) {
+        return resolve(getFileSystem().getPath(other));
+    }
 
     /**
      * Resolves the given path against this path's {@link #getParent parent}
@@ -389,6 +414,14 @@
      * returns this path's parent, or where this path doesn't have a parent, the
      * empty path.
      *
+     * @implSpec
+     * The default implementation is equivalent for this path to:
+     * <pre>{@code
+     *     (getParent() == null) ? other : getParent().resolve(other);
+     * }</pre>
+     * unless {@code other == null}, in which case a
+     * {@code NullPointerException} is thrown.
+     *
      * @param   other
      *          the path to resolve against this path's parent
      *
@@ -396,13 +429,24 @@
      *
      * @see #resolve(Path)
      */
-    Path resolveSibling(Path other);
+    default Path resolveSibling(Path other) {
+        if (other == null)
+            throw new NullPointerException();
+        Path parent = getParent();
+        return (parent == null) ? other : parent.resolve(other);
+    }
 
     /**
      * Converts a given path string to a {@code Path} and resolves it against
      * this path's {@link #getParent parent} path in exactly the manner
      * specified by the {@link #resolveSibling(Path) resolveSibling} method.
      *
+     * @implSpec
+     * The default implementation is equivalent for this path to:
+     * <pre>{@code
+     *     resolveSibling(getFileSystem().getPath(other));
+     * }</pre>
+     *
      * @param   other
      *          the path string to resolve against this path's parent
      *
@@ -413,7 +457,9 @@
      *
      * @see FileSystem#getPath
      */
-    Path resolveSibling(String other);
+    default Path resolveSibling(String other) {
+        return resolveSibling(getFileSystem().getPath(other));
+    }
 
     /**
      * Constructs a relative path between this path and a given path.
@@ -590,12 +636,28 @@
      * File} object returned by this method is {@link #equals equal} to the
      * original {@code File}.
      *
+     * @implSpec
+     * The default implementation is equivalent for this path to:
+     * <pre>{@code
+     *     new File(toString());
+     * }</pre>
+     * if the {@code FileSystem} which created this {@code Path} is the default
+     * file system; otherwise an {@code UnsupportedOperationException} is
+     * thrown.
+     *
      * @return  a {@code File} object representing this path
      *
      * @throws  UnsupportedOperationException
      *          if this {@code Path} is not associated with the default provider
      */
-    File toFile();
+    default File toFile() {
+        if (getFileSystem() == FileSystems.getDefault()) {
+            return new File(toString());
+        } else {
+            throw new UnsupportedOperationException("Path not associated with "
+                    + "default file system.");
+        }
+    }
 
     // -- watchable --
 
@@ -681,6 +743,13 @@
      *
      *     WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
      * </pre>
+     *
+     * @implSpec
+     * The default implementation is equivalent for this path to:
+     * <pre>{@code
+     *     register(watcher, events, new WatchEvent.Modifier[0]);
+     * }</pre>
+     *
      * @param   watcher
      *          The watch service to which this object is to be registered
      * @param   events
@@ -706,9 +775,10 @@
      *          method is invoked to check read access to the file.
      */
     @Override
-    WatchKey register(WatchService watcher,
-                      WatchEvent.Kind<?>... events)
-        throws IOException;
+    default WatchKey register(WatchService watcher,
+                      WatchEvent.Kind<?>... events) throws IOException {
+        return register(watcher, events, new WatchEvent.Modifier[0]);
+    }
 
     // -- Iterable --
 
@@ -721,10 +791,36 @@
      * is the name of the file or directory denoted by this path. The {@link
      * #getRoot root} component, if present, is not returned by the iterator.
      *
+     * @implSpec
+     * The default implementation returns an {@code Iterator<Path>} which, for
+     * this path, traverses the {@code Path}s returned by
+     * {@code getName(index)}, where {@code index} ranges from zero to
+     * {@code getNameCount() - 1}, inclusive.
+     *
      * @return  an iterator over the name elements of this path.
      */
     @Override
-    Iterator<Path> iterator();
+    default Iterator<Path> iterator() {
+        return new Iterator<Path>() {
+            private int i = 0;
+
+            @Override
+            public boolean hasNext() {
+                return (i < getNameCount());
+            }
+
+            @Override
+            public Path next() {
+                if (i < getNameCount()) {
+                    Path result = getName(i);
+                    i++;
+                    return result;
+                } else {
+                    throw new NoSuchElementException();
+                }
+            }
+        };
+    }
 
     // -- compareTo/equals/hashCode --
 
--- a/jdk/src/java.base/share/classes/java/security/KeyStore.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/security/KeyStore.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -92,9 +92,23 @@
  * be used (in a variety of formats).
  *
  * <p> Typical ways to request a KeyStore object include
+ * specifying an existing keystore file,
  * relying on the default type and providing a specific keystore type.
  *
  * <ul>
+ * <li>To specify an existing keystore file:
+ * <pre>
+ *    // get keystore password
+ *    char[] password = getPassword();
+ *
+ *    // probe the keystore file and load the keystore entries
+ *    KeyStore ks = KeyStore.getInstance(new File("keyStoreName"), password);
+ *</pre>
+ * The system will probe the specified file to determine its keystore type
+ * and return a keystore implementation with its entries already loaded.
+ * When this approach is used there is no need to call the keystore's
+ * {@link #load(java.io.InputStream, char[]) load} method.
+ *
  * <li>To rely on the default type:
  * <pre>
  *    KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
@@ -110,7 +124,8 @@
  * </ul>
  *
  * <p> Before a keystore can be accessed, it must be
- * {@link #load(java.io.InputStream, char[]) loaded}.
+ * {@link #load(java.io.InputStream, char[]) loaded}
+ * (unless it was already loaded during instantiation).
  * <pre>
  *    KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
  *
@@ -179,6 +194,7 @@
 
 public class KeyStore {
 
+    private static final Debug kdebug = Debug.getInstance("keystore");
     private static final Debug pdebug =
                         Debug.getInstance("provider", "Provider");
     private static final boolean skipDebug =
@@ -1594,6 +1610,188 @@
     }
 
     /**
+     * Returns a loaded keystore object of the appropriate keystore type.
+     * First the keystore type is determined by probing the specified file.
+     * Then a keystore object is instantiated and loaded using the data from
+     * that file.
+     * A password may be supplied to unlock the keystore data or perform an
+     * integrity check.
+     *
+     * <p>
+     * This method traverses the list of registered security {@link Providers},
+     * starting with the most preferred Provider.
+     * For each {@link KeyStoreSpi} implementation supported by a Provider,
+     * it invokes the {@link engineProbe} method to determine if it supports
+     * the specified keystore.
+     * A new KeyStore object is returned that encapsulates the KeyStoreSpi
+     * implementation from the first Provider that supports the specified file.
+     *
+     * <p> Note that the list of registered providers may be retrieved via
+     * the {@link Security#getProviders() Security.getProviders()} method.
+     *
+     * @param  file the keystore file
+     * @param  password the keystore password, which may be {@code null}
+     *
+     * @return a keystore object loaded with keystore data
+     *
+     * @throws KeyStoreException if no Provider supports a KeyStoreSpi
+     *             implementation for the specified keystore file.
+     * @throws IOException if there is an I/O or format problem with the
+     *             keystore data, if a password is required but not given,
+     *             or if the given password was incorrect. If the error is
+     *             due to a wrong password, the {@link Throwable#getCause cause}
+     *             of the {@code IOException} should be an
+     *             {@code UnrecoverableKeyException}.
+     * @throws NoSuchAlgorithmException if the algorithm used to check the
+     *             integrity of the keystore cannot be found.
+     * @throws CertificateException if any of the certificates in the
+     *             keystore could not be loaded.
+     * @throws IllegalArgumentException if file does not exist or does not
+     *             refer to a normal file.
+     * @throws NullPointerException if file is {@code null}.
+     * @throws SecurityException if a security manager exists and its
+     *             {@link java.lang.SecurityManager#checkRead} method denies
+     *             read access to the specified file.
+     *
+     * @see Provider
+     *
+     * @since 1.9
+     */
+    public static final KeyStore getInstance(File file, char[] password)
+        throws KeyStoreException, IOException, NoSuchAlgorithmException,
+            CertificateException {
+        return getInstance(file, password, null, true);
+    }
+
+    /**
+     * Returns a loaded keystore object of the appropriate keystore type.
+     * First the keystore type is determined by probing the specified file.
+     * Then a keystore object is instantiated and loaded using the data from
+     * that file.
+     * A {@code LoadStoreParameter} may be supplied which specifies how to
+     * unlock the keystore data or perform an integrity check.
+     *
+     * <p>
+     * This method traverses the list of registered security {@link Providers},
+     * starting with the most preferred Provider.
+     * For each {@link KeyStoreSpi} implementation supported by a Provider,
+     * it invokes the {@link engineProbe} method to determine if it supports
+     * the specified keystore.
+     * A new KeyStore object is returned that encapsulates the KeyStoreSpi
+     * implementation from the first Provider that supports the specified file.
+     *
+     * <p> Note that the list of registered providers may be retrieved via
+     * the {@link Security#getProviders() Security.getProviders()} method.
+     *
+     * @param  file the keystore file
+     * @param  param the {@code LoadStoreParameter} that specifies how to load
+     *             the keystore, which may be {@code null}
+     *
+     * @return a keystore object loaded with keystore data
+     *
+     * @throws KeyStoreException if no Provider supports a KeyStoreSpi
+     *             implementation for the specified keystore file.
+     * @throws IOException if there is an I/O or format problem with the
+     *             keystore data. If the error is due to an incorrect
+     *             {@code ProtectionParameter} (e.g. wrong password)
+     *             the {@link Throwable#getCause cause} of the
+     *             {@code IOException} should be an
+     *             {@code UnrecoverableKeyException}.
+     * @throws NoSuchAlgorithmException if the algorithm used to check the
+     *             integrity of the keystore cannot be found.
+     * @throws CertificateException if any of the certificates in the
+     *             keystore could not be loaded.
+     * @throws IllegalArgumentException if file does not exist or does not
+     *             refer to a normal file, or if param is not recognized.
+     * @throws NullPointerException if file is {@code null}.
+     * @throws SecurityException if a security manager exists and its
+     *             {@link java.lang.SecurityManager#checkRead} method denies
+     *             read access to the specified file.
+     *
+     * @see Provider
+     *
+     * @since 1.9
+     */
+    public static final KeyStore getInstance(File file,
+        LoadStoreParameter param) throws KeyStoreException, IOException,
+            NoSuchAlgorithmException, CertificateException {
+        return getInstance(file, null, param, false);
+    }
+
+    // Used by getInstance(File, char[]) & getInstance(File, LoadStoreParameter)
+    private static final KeyStore getInstance(File file, char[] password,
+        LoadStoreParameter param, boolean hasPassword)
+            throws KeyStoreException, IOException, NoSuchAlgorithmException,
+                CertificateException {
+
+        if (file == null) {
+            throw new NullPointerException();
+        }
+
+        if (file.isFile() == false) {
+            throw new IllegalArgumentException(
+                "File does not exist or it does not refer to a normal file: " +
+                    file);
+        }
+
+        KeyStore keystore = null;
+
+        try (DataInputStream dataStream =
+            new DataInputStream(
+                new BufferedInputStream(
+                    new FileInputStream(file)))) {
+
+            dataStream.mark(Integer.MAX_VALUE);
+
+            // Detect the keystore type
+            for (String type : Security.getAlgorithms("KeyStore")) {
+                Object[] objs = null;
+
+                try {
+                    objs = Security.getImpl(type, "KeyStore", (String)null);
+
+                    KeyStoreSpi impl = (KeyStoreSpi)objs[0];
+                    if (impl.engineProbe(dataStream)) {
+
+                        if (kdebug != null) {
+                            kdebug.println(type + " keystore detected: " +
+                                file);
+                        }
+
+                        keystore = new KeyStore(impl, (Provider)objs[1], type);
+                        break;
+                    }
+                } catch (NoSuchAlgorithmException | NoSuchProviderException e) {
+                    // ignore
+                    if (kdebug != null) {
+                        kdebug.println(type + " not found - " + e);
+                    }
+                } catch (IOException e) {
+                    // ignore
+                    if (kdebug != null) {
+                        kdebug.println("I/O error in " + file + " - " + e);
+                    }
+                }
+                dataStream.reset(); // prepare the stream for the next probe
+            }
+
+            // Load the keystore data
+            if (keystore != null) {
+                if (hasPassword) {
+                    dataStream.reset(); // prepare the stream for loading
+                    keystore.load(dataStream, password);
+                } else {
+                    keystore.load(param);
+                }
+                return keystore;
+            }
+        }
+
+        throw new KeyStoreException("Unrecognized keystore format: " +
+            keystore);
+    }
+
+    /**
      * A description of a to-be-instantiated KeyStore object.
      *
      * <p>An instance of this class encapsulates the information needed to
@@ -1713,7 +1911,7 @@
          * by invoking the CallbackHandler.
          *
          * <p>Subsequent calls to {@link #getKeyStore} return the same object
-         * as the initial call. If the initial call to failed with a
+         * as the initial call. If the initial call failed with a
          * KeyStoreException, subsequent calls also throw a
          * KeyStoreException.
          *
@@ -1760,6 +1958,50 @@
                 AccessController.getContext());
         }
 
+        /**
+         * Returns a new Builder object.
+         *
+         * <p>The first call to the {@link #getKeyStore} method on the returned
+         * builder will create a KeyStore using {@code file} to detect the
+         * keystore type and then call its {@link KeyStore#load load()} method.
+         * It uses the same algorithm to determine the keystore type as
+         * described in {@link KeyStore#getInstance(File, LoadStoreParameter)}.
+         * The {@code inputStream} argument is constructed from {@code file}.
+         * If {@code protection} is a {@code PasswordProtection}, the password
+         * is obtained by calling the {@code getPassword} method.
+         * Otherwise, if {@code protection} is a
+         * {@code CallbackHandlerProtection},
+         * the password is obtained by invoking the CallbackHandler.
+         *
+         * <p>Subsequent calls to {@link #getKeyStore} return the same object
+         * as the initial call. If the initial call failed with a
+         * KeyStoreException, subsequent calls also throw a KeyStoreException.
+         *
+         * <p>Calls to {@link #getProtectionParameter getProtectionParameter()}
+         * will return a {@link KeyStore.PasswordProtection PasswordProtection}
+         * object encapsulating the password that was used to invoke the
+         * {@code load} method.
+         *
+         * <p><em>Note</em> that the {@link #getKeyStore} method is executed
+         * within the {@link AccessControlContext} of the code invoking this
+         * method.
+         *
+         * @return a new Builder object
+         * @param file the File that contains the KeyStore data
+         * @param protection the ProtectionParameter securing the KeyStore data
+         * @throws NullPointerException if file or protection is null
+         * @throws IllegalArgumentException if protection is not an instance
+         *   of either PasswordProtection or CallbackHandlerProtection; or
+         *   if file does not exist or does not refer to a normal file
+         *
+         * @since 1.9
+         */
+        public static Builder newInstance(File file,
+            ProtectionParameter protection) {
+
+            return newInstance("", null, file, protection);
+        }
+
         private static final class FileBuilder extends Builder {
 
             private final String type;
@@ -1817,42 +2059,46 @@
                     }
                     public KeyStore run0() throws Exception {
                         KeyStore ks;
-                        if (provider == null) {
-                            ks = KeyStore.getInstance(type);
+                        char[] password = null;
+
+                        // Acquire keystore password
+                        if (protection instanceof PasswordProtection) {
+                            password =
+                                ((PasswordProtection)protection).getPassword();
+                            keyProtection = protection;
                         } else {
-                            ks = KeyStore.getInstance(type, provider);
-                        }
-                        InputStream in = null;
-                        char[] password = null;
-                        try {
-                            in = new FileInputStream(file);
-                            if (protection instanceof PasswordProtection) {
-                                password =
-                                ((PasswordProtection)protection).getPassword();
-                                keyProtection = protection;
-                            } else {
-                                CallbackHandler handler =
-                                    ((CallbackHandlerProtection)protection)
+                            CallbackHandler handler =
+                                ((CallbackHandlerProtection)protection)
                                     .getCallbackHandler();
-                                PasswordCallback callback = new PasswordCallback
-                                    ("Password for keystore " + file.getName(),
+                            PasswordCallback callback = new PasswordCallback
+                                ("Password for keystore " + file.getName(),
                                     false);
-                                handler.handle(new Callback[] {callback});
-                                password = callback.getPassword();
-                                if (password == null) {
-                                    throw new KeyStoreException("No password" +
-                                                                " provided");
-                                }
-                                callback.clearPassword();
-                                keyProtection = new PasswordProtection(password);
+                            handler.handle(new Callback[] {callback});
+                            password = callback.getPassword();
+                            if (password == null) {
+                                throw new KeyStoreException("No password" +
+                                                            " provided");
                             }
-                            ks.load(in, password);
-                            return ks;
-                        } finally {
-                            if (in != null) {
-                                in.close();
+                            callback.clearPassword();
+                            keyProtection = new PasswordProtection(password);
+                        }
+
+                        if (type.isEmpty()) {
+                            // Instantiate keystore and load keystore data
+                            ks = KeyStore.getInstance(file, password);
+                        } else {
+                            // Instantiate keystore
+                            if (provider == null) {
+                                ks = KeyStore.getInstance(type);
+                            } else {
+                                ks = KeyStore.getInstance(type, provider);
+                            }
+                            // Load keystore data
+                            try (InputStream in = new FileInputStream(file)) {
+                                ks.load(in, password);
                             }
                         }
+                        return ks;
                     }
                 };
                 try {
@@ -1998,5 +2244,4 @@
             return protection;
         }
     }
-
 }
--- a/jdk/src/java.base/share/classes/java/security/KeyStoreSpi.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/java/security/KeyStoreSpi.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -590,4 +590,27 @@
         }
         return false;
     }
+
+    /**
+     * Probes the specified input stream to determine whether it contains a
+     * keystore that is supported by this implementation, or not.
+     *
+     * <p>
+     * @implSpec
+     * This method returns false by default. Keystore implementations should
+     * override this method to peek at the data stream directly or to use other
+     * content detection mechanisms.
+     *
+     * @param  stream the keystore data to be probed
+     *
+     * @return true if the keystore data is supported, otherwise false
+     *
+     * @throws IOException if there is an I/O problem with the keystore data.
+     * @throws NullPointerException if stream is {@code null}.
+     *
+     * @since 1.9
+     */
+    public boolean engineProbe(InputStream stream) throws IOException {
+        return false;
+    }
 }
--- a/jdk/src/java.base/share/classes/sun/nio/fs/AbstractPath.java	Tue Dec 30 09:44:23 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  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 sun.nio.fs;
-
-import java.nio.file.*;
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-/**
- * Base implementation class of {@code Path}.
- */
-
-abstract class AbstractPath implements Path {
-    protected AbstractPath() { }
-
-    @Override
-    public final boolean startsWith(String other) {
-        return startsWith(getFileSystem().getPath(other));
-    }
-
-    @Override
-    public final boolean endsWith(String other) {
-        return endsWith(getFileSystem().getPath(other));
-    }
-
-    @Override
-    public final Path resolve(String other) {
-        return resolve(getFileSystem().getPath(other));
-    }
-
-    @Override
-    public final Path resolveSibling(Path other) {
-        if (other == null)
-            throw new NullPointerException();
-        Path parent = getParent();
-        return (parent == null) ? other : parent.resolve(other);
-    }
-
-    @Override
-    public final Path resolveSibling(String other) {
-        return resolveSibling(getFileSystem().getPath(other));
-    }
-
-    @Override
-    public final Iterator<Path> iterator() {
-        return new Iterator<Path>() {
-            private int i = 0;
-            @Override
-            public boolean hasNext() {
-                return (i < getNameCount());
-            }
-            @Override
-            public Path next() {
-                if (i < getNameCount()) {
-                    Path result = getName(i);
-                    i++;
-                    return result;
-                } else {
-                    throw new NoSuchElementException();
-                }
-            }
-            @Override
-            public void remove() {
-                throw new UnsupportedOperationException();
-            }
-        };
-    }
-
-    @Override
-    public final File toFile() {
-        return new File(toString());
-    }
-
-    @Override
-    public final WatchKey register(WatchService watcher,
-                                   WatchEvent.Kind<?>... events)
-        throws IOException
-    {
-        return register(watcher, events, new WatchEvent.Modifier[0]);
-    }
-}
--- a/jdk/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java	Wed Jul 05 20:13:05 2017 +0200
@@ -69,6 +69,8 @@
 import sun.security.pkcs.ContentInfo;
 import sun.security.x509.AlgorithmId;
 import sun.security.pkcs.EncryptedPrivateKeyInfo;
+import sun.security.provider.JavaKeyStore.JKS;
+import sun.security.util.KeyStoreDelegator;
 
 
 /**
@@ -129,6 +131,13 @@
  */
 public final class PKCS12KeyStore extends KeyStoreSpi {
 
+    // special PKCS12 keystore that supports PKCS12 and JKS file formats
+    public static final class DualFormatPKCS12 extends KeyStoreDelegator {
+        public DualFormatPKCS12() {
+            super("PKCS12", PKCS12KeyStore.class, "JKS", JKS.class);
+        }
+    }
+
     public static final int VERSION_3 = 3;
 
     private static final String[] KEY_PROTECTION_ALGORITHM = {
@@ -1053,6 +1062,39 @@
     }
 
     /**
+     * Determines if the keystore {@code Entry} for the specified
+     * {@code alias} is an instance or subclass of the specified
+     * {@code entryClass}.
+     *
+     * @param alias the alias name
+     * @param entryClass the entry class
+     *
+     * @return true if the keystore {@code Entry} for the specified
+     *          {@code alias} is an instance or subclass of the
+     *          specified {@code entryClass}, false otherwise
+     *
+     * @since 1.5
+     */
+    @Override
+    public boolean
+        engineEntryInstanceOf(String alias,
+                              Class<? extends KeyStore.Entry> entryClass)
+    {
+        if (entryClass == KeyStore.TrustedCertificateEntry.class) {
+            return engineIsCertificateEntry(alias);
+        }
+
+        Entry entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
+        if (entryClass == KeyStore.PrivateKeyEntry.class) {
+            return (entry != null && entry instanceof PrivateKeyEntry);
+        }
+        if (entryClass == KeyStore.SecretKeyEntry.class) {
+            return (entry != null && entry instanceof SecretKeyEntry);
+        }
+        return false;
+    }
+
+    /**
      * Returns the (alias) name of the first keystore entry whose certificate
      * matches the given certificate.
      *
@@ -1084,7 +1126,7 @@
             } else {
                 continue;
             }
-            if (certElem.equals(cert)) {
+            if (certElem != null && certElem.equals(cert)) {
                 return alias;
             }
         }
@@ -1923,7 +1965,12 @@
                 safeContentsData = safeContents.getData();
             } else if (contentType.equals((Object)ContentInfo.ENCRYPTED_DATA_OID)) {
                 if (password == null) {
-                   continue;
+
+                    if (debug != null) {
+                        debug.println("Warning: skipping PKCS#7 encryptedData" +
+                            " content-type - no password was supplied");
+                    }
+                    continue;
                 }
 
                 if (debug != null) {
@@ -1965,8 +2012,9 @@
                             password = new char[1];
                             continue;
                         }
-                        throw new IOException(
-                            "failed to decrypt safe contents entry: " + e, e);
+                        throw new IOException("keystore password was incorrect",
+                            new UnrecoverableKeyException(
+                                "failed to decrypt safe contents entry: " + e));
                     }
                 }
             } else {
@@ -2284,4 +2332,73 @@
         counter++;
         return (String.valueOf(counter));
     }
+
+    /*
+     * PKCS12 permitted first 24 bytes:
+     *
+     * 30 82 -- -- 02 01 03 30 82 -- -- 06 09 2A 86 48 86 F7 0D 01 07 01 A0 8-
+     * 30 -- 02 01 03 30 -- 06 09 2A 86 48 86 F7 0D 01 07 01 A0 -- 04 -- -- --
+     * 30 81 -- 02 01 03 30 81 -- 06 09 2A 86 48 86 F7 0D 01 07 01 A0 81 -- 04
+     * 30 82 -- -- 02 01 03 30 81 -- 06 09 2A 86 48 86 F7 0D 01 07 01 A0 81 --
+     * 30 83 -- -- -- 02 01 03 30 82 -- -- 06 09 2A 86 48 86 F7 0D 01 07 01 A0
+     * 30 83 -- -- -- 02 01 03 30 83 -- -- -- 06 09 2A 86 48 86 F7 0D 01 07 01
+     * 30 84 -- -- -- -- 02 01 03 30 83 -- -- -- 06 09 2A 86 48 86 F7 0D 01 07
+     * 30 84 -- -- -- -- 02 01 03 30 84 -- -- -- -- 06 09 2A 86 48 86 F7 0D 01
+     */
+
+    private static final long[][] PKCS12_HEADER_PATTERNS = {
+        { 0x3082000002010330L, 0x82000006092A8648L, 0x86F70D010701A080L },
+        { 0x3000020103300006L, 0x092A864886F70D01L, 0x0701A00004000000L },
+        { 0x3081000201033081L, 0x0006092A864886F7L, 0x0D010701A0810004L },
+        { 0x3082000002010330L, 0x810006092A864886L, 0xF70D010701A08100L },
+        { 0x3083000000020103L, 0x3082000006092A86L, 0x4886F70D010701A0L },
+        { 0x3083000000020103L, 0x308200000006092AL, 0x864886F70D010701L },
+        { 0x3084000000000201L, 0x0330820000000609L, 0x2A864886F70D0107L },
+        { 0x3084000000000201L, 0x0330820000000006L, 0x092A864886F70D01L }
+    };
+
+    private static final long[][] PKCS12_HEADER_MASKS = {
+        { 0xFFFF0000FFFFFFFFL, 0xFF0000FFFFFFFFFFL, 0xFFFFFFFFFFFFFFF0L },
+        { 0xFF00FFFFFFFF00FFL, 0xFFFFFFFFFFFFFFFFL, 0xFFFFFF00FF000000L },
+        { 0xFFFF00FFFFFFFFFFL, 0x00FFFFFFFFFFFFFFL, 0xFFFFFFFFFFFF00FFL },
+        { 0xFFFF0000FFFFFFFFL, 0xFF00FFFFFFFFFFFFL, 0xFFFFFFFFFFFFFF00L },
+        { 0xFFFF000000FFFFFFL, 0xFFFF0000FFFFFFFFL, 0xFFFFFFFFFFFFFFFFL },
+        { 0xFFFF000000FFFFFFL, 0xFFFF000000FFFFFFL, 0xFFFFFFFFFFFFFFFFL },
+        { 0xFFFF00000000FFFFL, 0xFFFFFF000000FFFFL, 0xFFFFFFFFFFFFFFFFL },
+        { 0xFFFF00000000FFFFL, 0xFFFFFF00000000FFL, 0xFFFFFFFFFFFFFFFFL }
+    };
+
+    /**
+     * Probe the first few bytes of the keystore data stream for a valid
+     * PKCS12 keystore encoding.
+     */
+    @Override
+    public boolean engineProbe(InputStream stream) throws IOException {
+
+        DataInputStream dataStream;
+        if (stream instanceof DataInputStream) {
+            dataStream = (DataInputStream)stream;
+        } else {
+            dataStream = new DataInputStream(stream);
+        }
+
+        long firstPeek = dataStream.readLong();
+        long nextPeek = dataStream.readLong();
+        long finalPeek = dataStream.readLong();
+        boolean result = false;
+
+        for (int i = 0; i < PKCS12_HEADER_PATTERNS.length; i++) {
+            if (PKCS12_HEADER_PATTERNS[i][0] ==
+                    (firstPeek & PKCS12_HEADER_MASKS[i][0]) &&
+                (PKCS12_HEADER_PATTERNS[i][1] ==
+                    (nextPeek & PKCS12_HEADER_MASKS[i][1])) &&
+                (PKCS12_HEADER_PATTERNS[i][2] ==
+                    (finalPeek & PKCS12_HEADER_MASKS[i][2]))) {
+                result = true;
+                break;
+            }
+        }
+
+        return result;
+    }
 }
--- a/jdk/src/java.base/share/classes/sun/security/provider/DSA.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/provider/DSA.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -117,7 +117,6 @@
         if (params == null) {
             throw new InvalidKeyException("DSA private key lacks parameters");
         }
-        checkKey(params);
 
         this.params = params;
         this.presetX = priv.getX();
@@ -149,7 +148,6 @@
         if (params == null) {
             throw new InvalidKeyException("DSA public key lacks parameters");
         }
-        checkKey(params);
 
         this.params = params;
         this.presetY = pub.getY();
@@ -291,16 +289,6 @@
         return null;
     }
 
-    protected void checkKey(DSAParams params) throws InvalidKeyException {
-        // FIPS186-3 states in sec4.2 that a hash function which provides
-        // a lower security strength than the (L, N) pair ordinarily should
-        // not be used.
-        int valueN = params.getQ().bitLength();
-        if (valueN > md.getDigestLength()*8) {
-            throw new InvalidKeyException("Key is too strong for this signature algorithm");
-        }
-    }
-
     private BigInteger generateR(BigInteger p, BigInteger q, BigInteger g,
                          BigInteger k) {
         BigInteger temp = g.modPow(k, p);
@@ -480,14 +468,6 @@
            }
         }
 
-        @Override
-        protected void checkKey(DSAParams params) throws InvalidKeyException {
-            int valueL = params.getP().bitLength();
-            if (valueL > 1024) {
-                throw new InvalidKeyException("Key is too long for this algorithm");
-            }
-        }
-
         /*
          * Please read bug report 4044247 for an alternative, faster,
          * NON-FIPS approved method to generate K
--- a/jdk/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,9 +31,11 @@
 import java.security.cert.CertificateFactory;
 import java.security.cert.CertificateException;
 import java.util.*;
+
 import sun.misc.IOUtils;
-
 import sun.security.pkcs.EncryptedPrivateKeyInfo;
+import sun.security.pkcs12.PKCS12KeyStore;
+import sun.security.util.KeyStoreDelegator;
 
 /**
  * This class provides the keystore implementation referred to as "JKS".
@@ -49,7 +51,7 @@
  * @since 1.2
  */
 
-abstract class JavaKeyStore extends KeyStoreSpi {
+public abstract class JavaKeyStore extends KeyStoreSpi {
 
     // regular JKS
     public static final class JKS extends JavaKeyStore {
@@ -65,6 +67,13 @@
         }
     }
 
+    // special JKS that supports JKS and PKCS12 file formats
+    public static final class DualFormatJKS extends KeyStoreDelegator {
+        public DualFormatJKS() {
+            super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class);
+        }
+    }
+
     private static final int MAGIC = 0xfeedfeed;
     private static final int VERSION_1 = 0x01;
     private static final int VERSION_2 = 0x02;
@@ -799,4 +808,20 @@
         md.update("Mighty Aphrodite".getBytes("UTF8"));
         return md;
     }
+
+    /**
+     * Probe the first few bytes of the keystore data stream for a valid
+     * JKS keystore encoding.
+     */
+    @Override
+    public boolean engineProbe(InputStream stream) throws IOException {
+        DataInputStream dataStream;
+        if (stream instanceof DataInputStream) {
+            dataStream = (DataInputStream)stream;
+        } else {
+            dataStream = new DataInputStream(stream);
+        }
+
+        return MAGIC == dataStream.readInt();
+    }
 }
--- a/jdk/src/java.base/share/classes/sun/security/provider/Sun.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/provider/Sun.java	Wed Jul 05 20:13:05 2017 +0200
@@ -40,7 +40,7 @@
 
     private static final String INFO = "SUN " +
     "(DSA key/parameter generation; DSA signing; SHA-1, MD5 digests; " +
-    "SecureRandom; X.509 certificates; JKS & DKS keystores; " +
+    "SecureRandom; X.509 certificates; PKCS12, JKS & DKS keystores; " +
     "PKIX CertPathValidator; " +
     "PKIX CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy; " +
     "JavaLoginConfig Configuration)";
--- a/jdk/src/java.base/share/classes/sun/security/provider/SunEntries.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/provider/SunEntries.java	Wed Jul 05 20:13:05 2017 +0200
@@ -228,7 +228,10 @@
         /*
          * KeyStore
          */
-        map.put("KeyStore.JKS", "sun.security.provider.JavaKeyStore$JKS");
+        map.put("KeyStore.PKCS12",
+                        "sun.security.pkcs12.PKCS12KeyStore$DualFormatPKCS12");
+        map.put("KeyStore.JKS",
+                        "sun.security.provider.JavaKeyStore$DualFormatJKS");
         map.put("KeyStore.CaseExactJKS",
                         "sun.security.provider.JavaKeyStore$CaseExactJKS");
         map.put("KeyStore.DKS", "sun.security.provider.DomainKeyStore$DKS");
--- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Wed Jul 05 20:13:05 2017 +0200
@@ -124,6 +124,7 @@
 
     private Set<Pair <String, String>> providers = null;
     private String storetype = null;
+    private boolean hasStoretypeOption = false;
     private String srcProviderName = null;
     private String providerName = null;
     private String pathlist = null;
@@ -483,11 +484,13 @@
             } else if (collator.compare(flags, "-storetype") == 0 ||
                     collator.compare(flags, "-deststoretype") == 0) {
                 storetype = args[++i];
+                hasStoretypeOption = true;
             } else if (collator.compare(flags, "-srcstorepass") == 0) {
                 srcstorePass = getPass(modifier, args[++i]);
                 passwords.add(srcstorePass);
             } else if (collator.compare(flags, "-srcstoretype") == 0) {
                 srcstoretype = args[++i];
+                hasStoretypeOption = true;
             } else if (collator.compare(flags, "-srckeypass") == 0) {
                 srckeyPass = getPass(modifier, args[++i]);
                 passwords.add(srckeyPass);
@@ -809,36 +812,42 @@
         }
 
         // Create new keystore
-        if (providerName == null) {
-            keyStore = KeyStore.getInstance(storetype);
+        // Probe for keystore type when filename is available
+        if (ksfile != null && ksStream != null && providerName == null &&
+            hasStoretypeOption == false) {
+            keyStore = KeyStore.getInstance(ksfile, storePass);
         } else {
-            keyStore = KeyStore.getInstance(storetype, providerName);
-        }
-
-        /*
-         * Load the keystore data.
-         *
-         * At this point, it's OK if no keystore password has been provided.
-         * We want to make sure that we can load the keystore data, i.e.,
-         * the keystore data has the right format. If we cannot load the
-         * keystore, why bother asking the user for his or her password?
-         * Only if we were able to load the keystore, and no keystore
-         * password has been provided, will we prompt the user for the
-         * keystore password to verify the keystore integrity.
-         * This means that the keystore is loaded twice: first load operation
-         * checks the keystore format, second load operation verifies the
-         * keystore integrity.
-         *
-         * If the keystore password has already been provided (at the
-         * command line), however, the keystore is loaded only once, and the
-         * keystore format and integrity are checked "at the same time".
-         *
-         * Null stream keystores are loaded later.
-         */
-        if (!nullStream) {
-            keyStore.load(ksStream, storePass);
-            if (ksStream != null) {
-                ksStream.close();
+            if (providerName == null) {
+                keyStore = KeyStore.getInstance(storetype);
+            } else {
+                keyStore = KeyStore.getInstance(storetype, providerName);
+            }
+
+            /*
+             * Load the keystore data.
+             *
+             * At this point, it's OK if no keystore password has been provided.
+             * We want to make sure that we can load the keystore data, i.e.,
+             * the keystore data has the right format. If we cannot load the
+             * keystore, why bother asking the user for his or her password?
+             * Only if we were able to load the keystore, and no keystore
+             * password has been provided, will we prompt the user for the
+             * keystore password to verify the keystore integrity.
+             * This means that the keystore is loaded twice: first load operation
+             * checks the keystore format, second load operation verifies the
+             * keystore integrity.
+             *
+             * If the keystore password has already been provided (at the
+             * command line), however, the keystore is loaded only once, and the
+             * keystore format and integrity are checked "at the same time".
+             *
+             * Null stream keystores are loaded later.
+             */
+            if (!nullStream) {
+                keyStore.load(ksStream, storePass);
+                if (ksStream != null) {
+                    ksStream.close();
+                }
             }
         }
 
@@ -1881,6 +1890,7 @@
         boolean isPkcs11 = false;
 
         InputStream is = null;
+        File srcksfile = null;
 
         if (P11KEYSTORE.equalsIgnoreCase(srcstoretype) ||
                 KeyStoreUtil.isWindowsKeyStore(srcstoretype)) {
@@ -1893,7 +1903,7 @@
             isPkcs11 = true;
         } else {
             if (srcksfname != null) {
-                File srcksfile = new File(srcksfname);
+                srcksfile = new File(srcksfname);
                     if (srcksfile.exists() && srcksfile.length() == 0) {
                         throw new Exception(rb.getString
                                 ("Source.keystore.file.exists.but.is.empty.") +
@@ -1908,10 +1918,16 @@
 
         KeyStore store;
         try {
-            if (srcProviderName == null) {
-                store = KeyStore.getInstance(srcstoretype);
+            // Probe for keystore type when filename is available
+            if (srcksfile != null && is != null && srcProviderName == null &&
+                hasStoretypeOption == false) {
+                store = KeyStore.getInstance(srcksfile, srcstorePass);
             } else {
-                store = KeyStore.getInstance(srcstoretype, srcProviderName);
+                if (srcProviderName == null) {
+                    store = KeyStore.getInstance(srcstoretype);
+                } else {
+                    store = KeyStore.getInstance(srcstoretype, srcProviderName);
+                }
             }
 
             if (srcstorePass == null
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/KeyStoreDelegator.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,306 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.util;
+
+import java.io.*;
+import java.security.*;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateFactory;
+import java.security.cert.CertificateException;
+import java.util.*;
+
+import sun.security.util.Debug;
+
+/**
+ * This class delegates to a primary or secondary keystore implementation.
+ *
+ * @since 1.9
+ */
+
+public class KeyStoreDelegator extends KeyStoreSpi {
+
+    private static final String KEYSTORE_TYPE_COMPAT = "keystore.type.compat";
+    private static final Debug debug = Debug.getInstance("keystore");
+
+    private String primaryType;   // the primary keystore's type
+    private String secondaryType; // the secondary keystore's type
+    private Class<? extends KeyStoreSpi> primaryKeyStore;
+                                  // the primary keystore's class
+    private Class<? extends KeyStoreSpi> secondaryKeyStore;
+                                  // the secondary keystore's class
+    private String type; // the delegate's type
+    private KeyStoreSpi keystore; // the delegate
+    private boolean compatModeEnabled = true;
+
+    public KeyStoreDelegator(
+        String primaryType,
+        Class<? extends KeyStoreSpi> primaryKeyStore,
+        String secondaryType,
+        Class<? extends KeyStoreSpi> secondaryKeyStore) {
+
+        // Check whether compatibility mode has been disabled
+        compatModeEnabled = "true".equalsIgnoreCase(
+            AccessController.doPrivileged((PrivilegedAction<String>) () ->
+                Security.getProperty(KEYSTORE_TYPE_COMPAT)));
+
+        if (compatModeEnabled) {
+            this.primaryType = primaryType;
+            this.secondaryType = secondaryType;
+            this.primaryKeyStore = primaryKeyStore;
+            this.secondaryKeyStore = secondaryKeyStore;
+        } else {
+            this.primaryType = primaryType;
+            this.secondaryType = null;
+            this.primaryKeyStore = primaryKeyStore;
+            this.secondaryKeyStore = null;
+
+            if (debug != null) {
+                debug.println("WARNING: compatibility mode disabled for " +
+                    primaryType + " and " + secondaryType + " keystore types");
+            }
+        }
+    }
+
+    @Override
+    public Key engineGetKey(String alias, char[] password)
+        throws NoSuchAlgorithmException, UnrecoverableKeyException {
+        return keystore.engineGetKey(alias, password);
+    }
+
+    @Override
+    public Certificate[] engineGetCertificateChain(String alias) {
+        return keystore.engineGetCertificateChain(alias);
+    }
+
+    @Override
+    public Certificate engineGetCertificate(String alias) {
+        return keystore.engineGetCertificate(alias);
+    }
+
+    @Override
+    public Date engineGetCreationDate(String alias) {
+        return keystore.engineGetCreationDate(alias);
+    }
+
+    @Override
+    public void engineSetKeyEntry(String alias, Key key, char[] password,
+        Certificate[] chain) throws KeyStoreException {
+        keystore.engineSetKeyEntry(alias, key, password, chain);
+    }
+
+    @Override
+    public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain)
+        throws KeyStoreException {
+        keystore.engineSetKeyEntry(alias, key, chain);
+    }
+
+    @Override
+    public void engineSetCertificateEntry(String alias, Certificate cert)
+        throws KeyStoreException {
+        keystore.engineSetCertificateEntry(alias, cert);
+    }
+
+    @Override
+    public void engineDeleteEntry(String alias) throws KeyStoreException {
+        keystore.engineDeleteEntry(alias);
+    }
+
+    @Override
+    public Enumeration<String> engineAliases() {
+        return keystore.engineAliases();
+    }
+
+    @Override
+    public boolean engineContainsAlias(String alias) {
+        return keystore.engineContainsAlias(alias);
+    }
+
+    @Override
+    public int engineSize() {
+        return keystore.engineSize();
+    }
+
+    @Override
+    public boolean engineIsKeyEntry(String alias) {
+        return keystore.engineIsKeyEntry(alias);
+    }
+
+    @Override
+    public boolean engineIsCertificateEntry(String alias) {
+        return keystore.engineIsCertificateEntry(alias);
+    }
+
+    @Override
+    public String engineGetCertificateAlias(Certificate cert) {
+        return keystore.engineGetCertificateAlias(cert);
+    }
+
+    @Override
+    public KeyStore.Entry engineGetEntry(String alias,
+        KeyStore.ProtectionParameter protParam)
+            throws KeyStoreException, NoSuchAlgorithmException,
+                UnrecoverableEntryException {
+        return keystore.engineGetEntry(alias, protParam);
+    }
+
+    @Override
+    public void engineSetEntry(String alias, KeyStore.Entry entry,
+        KeyStore.ProtectionParameter protParam)
+            throws KeyStoreException {
+        keystore.engineSetEntry(alias, entry, protParam);
+    }
+
+    @Override
+    public boolean engineEntryInstanceOf(String alias,
+        Class<? extends KeyStore.Entry> entryClass) {
+        return keystore.engineEntryInstanceOf(alias, entryClass);
+    }
+
+    @Override
+    public void engineStore(OutputStream stream, char[] password)
+        throws IOException, NoSuchAlgorithmException, CertificateException {
+
+        if (debug != null) {
+            debug.println("Storing keystore in " + type + " format");
+        }
+        keystore.engineStore(stream, password);
+    }
+
+    @Override
+    public void engineLoad(InputStream stream, char[] password)
+        throws IOException, NoSuchAlgorithmException, CertificateException {
+
+        // A new keystore is always created in the primary keystore format
+        if (stream == null) {
+            try {
+                keystore = primaryKeyStore.newInstance();
+
+            } catch (InstantiationException | IllegalAccessException e) {
+                // can safely ignore
+            }
+            type = primaryType;
+
+            if (debug != null) {
+                debug.println("Creating a new keystore in " + type + " format");
+            }
+            keystore.engineLoad(stream, password);
+
+        } else {
+            // First try the primary keystore then try the secondary keystore
+            try (InputStream bufferedStream = new BufferedInputStream(stream)) {
+                bufferedStream.mark(Integer.MAX_VALUE);
+
+                try {
+                    keystore = primaryKeyStore.newInstance();
+                    type = primaryType;
+                    keystore.engineLoad(bufferedStream, password);
+
+                } catch (Exception e) {
+
+                    // incorrect password
+                    if (e instanceof IOException &&
+                        e.getCause() instanceof UnrecoverableKeyException) {
+                        throw (IOException)e;
+                    }
+
+                    try {
+                        // Ignore secondary keystore when no compatibility mode
+                        if (!compatModeEnabled) {
+                            throw e;
+                        }
+
+                        keystore = secondaryKeyStore.newInstance();
+                        type = secondaryType;
+                        bufferedStream.reset();
+                        keystore.engineLoad(bufferedStream, password);
+
+                        if (debug != null) {
+                            debug.println("WARNING: switching from " +
+                              primaryType + " to " + secondaryType +
+                              " keystore file format has altered the " +
+                              "keystore security level");
+                        }
+
+                    } catch (InstantiationException |
+                        IllegalAccessException e2) {
+                        // can safely ignore
+
+                    } catch (IOException |
+                        NoSuchAlgorithmException |
+                        CertificateException e3) {
+
+                        // incorrect password
+                        if (e3 instanceof IOException &&
+                            e3.getCause() instanceof
+                                UnrecoverableKeyException) {
+                            throw (IOException)e3;
+                        }
+                        // rethrow the outer exception
+                        if (e instanceof IOException) {
+                            throw (IOException)e;
+                        } else if (e instanceof CertificateException) {
+                            throw (CertificateException)e;
+                        } else if (e instanceof NoSuchAlgorithmException) {
+                            throw (NoSuchAlgorithmException)e;
+                        }
+                    }
+                }
+            }
+
+            if (debug != null) {
+                debug.println("Loaded a keystore in " + type + " format");
+            }
+        }
+    }
+
+    /**
+     * Probe the first few bytes of the keystore data stream for a valid
+     * keystore encoding. Only the primary keystore implementation is probed.
+     */
+    @Override
+    public boolean engineProbe(InputStream stream) throws IOException {
+
+        boolean result = false;
+
+        try {
+            keystore = primaryKeyStore.newInstance();
+            type = primaryType;
+            result = keystore.engineProbe(stream);
+
+        } catch (Exception e) {
+            throw new IOException(e);
+
+        } finally {
+            // reset
+            if (result == false) {
+                type = null;
+                keystore = null;
+            }
+        }
+
+        return result;
+    }
+}
--- a/jdk/src/java.base/share/conf/security/java.security	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/conf/security/java.security	Wed Jul 05 20:13:05 2017 +0200
@@ -183,7 +183,17 @@
 #
 # Default keystore type.
 #
-keystore.type=jks
+keystore.type=pkcs12
+
+#
+# Controls compatibility mode for JKS and PKCS12 keystore types.
+#
+# When set to 'true', both JKS and PKCS12 keystore types support loading
+# keystore files in either JKS or PKCS12 format. When set to 'false' the
+# JKS keystore type supports loading only JKS keystore files and the PKCS12
+# keystore type supports loading only PKCS12 keystore files.
+#
+keystore.type.compat=true
 
 #
 # List of comma-separated packages that start with or equal this string
--- a/jdk/src/java.base/share/native/include/jvm.h	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/native/include/jvm.h	Wed Jul 05 20:13:05 2017 +0200
@@ -334,15 +334,6 @@
                         jobject loader, jclass caller);
 
 /*
- * Find a class from a given class loader. Throw ClassNotFoundException
- * or NoClassDefFoundError depending on the value of the last
- * argument.
- */
-JNIEXPORT jclass JNICALL
-JVM_FindClassFromClassLoader(JNIEnv *env, const char *name, jboolean init,
-                             jobject loader, jboolean throwError);
-
-/*
  * Find a class from a given class.
  */
 JNIEXPORT jclass JNICALL
--- a/jdk/src/java.base/share/native/libzip/Deflater.c	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/share/native/libzip/Deflater.c	Wed Jul 05 20:13:05 2017 +0200
@@ -76,10 +76,11 @@
         JNU_ThrowOutOfMemoryError(env, 0);
         return jlong_zero;
     } else {
-        char *msg;
-        switch (deflateInit2(strm, level, Z_DEFLATED,
-                             nowrap ? -MAX_WBITS : MAX_WBITS,
-                             DEF_MEM_LEVEL, strategy)) {
+        const char *msg;
+        int ret = deflateInit2(strm, level, Z_DEFLATED,
+                               nowrap ? -MAX_WBITS : MAX_WBITS,
+                               DEF_MEM_LEVEL, strategy);
+        switch (ret) {
           case Z_OK:
             return ptr_to_jlong(strm);
           case Z_MEM_ERROR:
@@ -91,7 +92,11 @@
             JNU_ThrowIllegalArgumentException(env, 0);
             return jlong_zero;
           default:
-            msg = strm->msg;
+            msg = ((strm->msg != NULL) ? strm->msg :
+                   (ret == Z_VERSION_ERROR) ?
+                   "zlib returned Z_VERSION_ERROR: "
+                   "compile time and runtime zlib implementations differ" :
+                   "unknown error initializing zlib library");
             free(strm);
             JNU_ThrowInternalError(env, msg);
             return jlong_zero;
--- a/jdk/src/java.base/unix/classes/sun/nio/fs/UnixPath.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixPath.java	Wed Jul 05 20:13:05 2017 +0200
@@ -40,9 +40,7 @@
  * Solaris/Linux implementation of java.nio.file.Path
  */
 
-class UnixPath
-    extends AbstractPath
-{
+class UnixPath implements Path {
     private static ThreadLocal<SoftReference<CharsetEncoder>> encoder =
         new ThreadLocal<SoftReference<CharsetEncoder>>();
 
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java	Wed Jul 05 20:13:05 2017 +0200
@@ -41,7 +41,7 @@
  * Windows implementation of Path
  */
 
-class WindowsPath extends AbstractPath {
+class WindowsPath implements Path {
 
     // The maximum path that does not require long path prefix. On Windows
     // the maximum path is 260 minus 1 (NUL) but for directories it is 260
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxButton.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxButton.java	Wed Jul 05 20:13:05 2017 +0200
@@ -70,6 +70,7 @@
         return comboBox == null ? true : comboBox.isEnabled();
     }
 
+    @SuppressWarnings("deprecation")
     public boolean isFocusTraversable() {
         return false;
     }
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameDockIconUI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameDockIconUI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -303,6 +303,7 @@
             }
         }
 
+        @SuppressWarnings("deprecation")
         public void hide() {
             final Container parent = getParent();
             final Rectangle r = this.getBounds();
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -2231,6 +2231,7 @@
             return total;
         }
 
+        @SuppressWarnings("deprecation")
         public void layoutContainer(final Container parent) {
             /* Some of the code in this method deals with changing the
              * visibility of components to hide and show the contents for the
@@ -2725,6 +2726,7 @@
             return calculateMaxTabWidth(tabPlacement);
         }
 
+        @SuppressWarnings("deprecation")
         public void layoutContainer(final Container parent) {
             /* Some of the code in this method deals with changing the
              * visibility of components to hide and show the contents for the
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenu.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenu.java	Wed Jul 05 20:13:05 2017 +0200
@@ -229,6 +229,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     public void addNotify() {
         synchronized (getTreeLock()) {
             super.addNotify();
@@ -354,6 +355,7 @@
     public void setIndeterminate(boolean indeterminate) { }
 
     @Override
+    @SuppressWarnings("deprecation")
     public void setToolTipText(final String text) {
         final MenuComponentPeer peer = getPeer();
         if (!(peer instanceof CMenuItem)) return;
@@ -363,6 +365,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     public void setIcon(final Icon i) {
         final MenuComponentPeer peer = getPeer();
         if (!(peer instanceof CMenuItem)) return;
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuBar.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuBar.java	Wed Jul 05 20:13:05 2017 +0200
@@ -246,6 +246,7 @@
             fSubmenus.remove(menu);
     }
 
+    @SuppressWarnings("deprecation")
     public Menu add(final Menu m, final int index) {
         synchronized (getTreeLock()) {
             if (m.getParent() != null) {
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuItem.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuItem.java	Wed Jul 05 20:13:05 2017 +0200
@@ -97,6 +97,7 @@
         fMenuItem.removeComponentListener(this);
     }
 
+    @SuppressWarnings("deprecation")
     static void syncLabelAndKS(MenuItem menuItem, String label, KeyStroke ks) {
         final MenuComponentPeer peer = menuItem.getPeer();
         if (!(peer instanceof CMenuItem)) {
@@ -165,6 +166,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     public void setToolTipText(final String text) {
         final MenuComponentPeer peer = getPeer();
         if (!(peer instanceof CMenuItem)) return;
@@ -173,6 +175,7 @@
         cmi.setToolTipText(text);
     }
 
+    @SuppressWarnings("deprecation")
     public void setIcon(final Icon i) {
         final MenuComponentPeer peer = getPeer();
         if (!(peer instanceof CMenuItem)) return;
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuItemCheckbox.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenuItemCheckbox.java	Wed Jul 05 20:13:05 2017 +0200
@@ -57,6 +57,7 @@
     }
 
     ScreenMenuPropertyListener fPropertyListener;
+    @SuppressWarnings("deprecation")
     public void addNotify() {
         super.addNotify();
 
@@ -154,6 +155,7 @@
         setVisible(false);
     }
 
+    @SuppressWarnings("deprecation")
     public void setToolTipText(final String text) {
         final MenuComponentPeer peer = getPeer();
         if (!(peer instanceof CMenuItem)) return;
@@ -161,6 +163,7 @@
         ((CMenuItem)peer).setToolTipText(text);
     }
 
+    @SuppressWarnings("deprecation")
     public void setIcon(final Icon i) {
         final MenuComponentPeer peer = getPeer();
         if (!(peer instanceof CMenuItem)) return;
@@ -205,6 +208,7 @@
             }
         }
 
+    @SuppressWarnings("deprecation")
     public void setIndeterminate(final boolean indeterminate) {
         final MenuComponentPeer peer = getPeer();
         if (peer instanceof CCheckboxMenuItem) {
--- a/jdk/src/java.desktop/macosx/classes/sun/awt/CGraphicsDevice.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/awt/CGraphicsDevice.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -202,6 +202,7 @@
         return true;
     }
 
+    @SuppressWarnings("deprecation")
     private static void enterFullScreenExclusive(Window w) {
         FullScreenCapable peer = (FullScreenCapable)w.getPeer();
         if (peer != null) {
@@ -209,6 +210,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     private static void exitFullScreenExclusive(Window w) {
         FullScreenCapable peer = (FullScreenCapable)w.getPeer();
         if (peer != null) {
--- a/jdk/src/java.desktop/macosx/classes/sun/java2d/OSXSurfaceData.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/java2d/OSXSurfaceData.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -125,6 +125,7 @@
         return fConfig;
     }
 
+    @SuppressWarnings("deprecation")
     protected void setBounds(int x, int y, int w, int h) {
         fBounds.reshape(x, y, w, y + h);
     }
--- a/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -74,6 +74,7 @@
      * Create a pbuffer-based SurfaceData object (or init the backbuffer
      * of an existing window if this is a double buffered GraphicsConfig)
      */
+    @SuppressWarnings("deprecation")
     protected SurfaceData initAcceleratedSurface() {
         SurfaceData sData = null;
         Component comp = vImg.getComponent();
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1243,6 +1243,7 @@
         changeFocusedWindow(activate, null);
     }
 
+    @SuppressWarnings("deprecation")
     private boolean isOneOfOwnersOf(LWWindowPeer peer) {
         Window owner = (peer != null ? peer.getTarget().getOwner() : null);
         while (owner != null) {
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -88,6 +88,7 @@
         super.startDrag(dsc, cursor, dragImage, dragImageOffset);
     }
 
+    @SuppressWarnings("deprecation")
     protected void startDrag(Transferable transferable, long[] formats, Map<Long, DataFlavor> formatMap) {
         DragGestureEvent trigger = getTrigger();
         InputEvent         triggerEvent = trigger.getTriggerEvent();
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Wed Jul 05 20:13:05 2017 +0200
@@ -46,6 +46,7 @@
         show();
     }
 
+    @SuppressWarnings("deprecation")
     public void addNotify() {
         if (getPeer() == null) {
             LWCToolkit toolkit = (LWCToolkit)Toolkit.getDefaultToolkit();
@@ -60,6 +61,7 @@
 
     public void unregisterAccelerator(AWTKeyStroke stroke) {}
 
+    @SuppressWarnings("deprecation")
     protected long getLayerPtr() {
         LWWindowPeer peer = (LWWindowPeer)getPeer();
         return peer.getLayerPtr();
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethod.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethod.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -385,6 +385,7 @@
 
     // java.awt.Toolkit#getNativeContainer() is not available
     //    from this package
+    @SuppressWarnings("deprecation")
     private LWComponentPeer<?, ?> getNearestNativePeer(Component comp) {
         if (comp==null)
             return null;
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuBar.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CMenuBar.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     public void addHelpMenu(Menu m) {
         CMenu cMenu = (CMenu)m.getPeer();
         nativeSetHelpMenu(getModel(), cMenu.getModel());
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Wed Jul 05 20:13:05 2017 +0200
@@ -190,6 +190,7 @@
             nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), filename);
         }}
     }) {
+        @SuppressWarnings("deprecation")
         public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
             Component root = SwingUtilities.getRoot(p);
             if (root == null || (LWWindowPeer)root.getPeer() == null) return null;
@@ -519,6 +520,7 @@
     }
 
     @Override // PlatformWindow
+    @SuppressWarnings("deprecation")
     public void setVisible(boolean visible) {
         final long nsWindowPtr = getNSWindowPtr();
 
@@ -674,6 +676,7 @@
     }
 
     @Override  // PlatformWindow
+    @SuppressWarnings("deprecation")
     public void toFront() {
         final long nsWindowPtr = getNSWindowPtr();
         LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java	Wed Jul 05 20:13:05 2017 +0200
@@ -68,6 +68,7 @@
         updateImage();
     }
 
+    @SuppressWarnings("deprecation")
     private CPopupMenu checkAndCreatePopupPeer() {
         CPopupMenu menuPeer = null;
         if (popup != null) {
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java	Wed Jul 05 20:13:05 2017 +0200
@@ -78,6 +78,7 @@
      * Synthetic event delivery for focus management
      */
     @Override
+    @SuppressWarnings("deprecation")
     public void synthesizeWindowActivation(boolean activated) {
         if (isActive != activated) {
             isActive = activated;
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Wed Jul 05 20:13:05 2017 +0200
@@ -104,6 +104,67 @@
 
 @implementation AWTWindow_Normal
 AWT_NS_WINDOW_IMPLEMENTATION
+
+// Gesture support
+- (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b {
+    AWT_ASSERT_APPKIT_THREAD;
+
+    JNIEnv *env = [ThreadUtilities getJNIEnv];
+    jobject platformWindow = [((AWTWindow *)self.delegate).javaPlatformWindow jObjectWithEnv:env];
+    if (platformWindow != NULL) {
+        // extract the target AWT Window object out of the CPlatformWindow
+        static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;");
+        jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target);
+        if (awtWindow != NULL) {
+            // translate the point into Java coordinates
+            NSPoint loc = [event locationInWindow];
+            loc.y = [self frame].size.height - loc.y;
+
+            // send up to the GestureHandler to recursively dispatch on the AWT event thread
+            static JNF_CLASS_CACHE(jc_GestureHandler, "com/apple/eawt/event/GestureHandler");
+            static JNF_STATIC_MEMBER_CACHE(sjm_handleGestureFromNative, jc_GestureHandler, "handleGestureFromNative", "(Ljava/awt/Window;IDDDD)V");
+            JNFCallStaticVoidMethod(env, sjm_handleGestureFromNative, awtWindow, type, (jdouble)loc.x, (jdouble)loc.y, (jdouble)a, (jdouble)b);
+            (*env)->DeleteLocalRef(env, awtWindow);
+        }
+        (*env)->DeleteLocalRef(env, platformWindow);
+    }
+}
+
+- (void)beginGestureWithEvent:(NSEvent *)event {
+    [self postGesture:event
+                   as:com_apple_eawt_event_GestureHandler_PHASE
+                    a:-1.0
+                    b:0.0];
+}
+
+- (void)endGestureWithEvent:(NSEvent *)event {
+    [self postGesture:event
+                   as:com_apple_eawt_event_GestureHandler_PHASE
+                    a:1.0
+                    b:0.0];
+}
+
+- (void)magnifyWithEvent:(NSEvent *)event {
+    [self postGesture:event
+                   as:com_apple_eawt_event_GestureHandler_MAGNIFY
+                    a:[event magnification]
+                    b:0.0];
+}
+
+- (void)rotateWithEvent:(NSEvent *)event {
+    [self postGesture:event
+                   as:com_apple_eawt_event_GestureHandler_ROTATE
+                    a:[event rotation]
+                    b:0.0];
+}
+
+- (void)swipeWithEvent:(NSEvent *)event {
+    [self postGesture:event
+                   as:com_apple_eawt_event_GestureHandler_SWIPE
+                    a:[event deltaX]
+                    b:[event deltaY]];
+}
+
 @end
 @implementation AWTWindow_Panel
 AWT_NS_WINDOW_IMPLEMENTATION
@@ -399,67 +460,6 @@
 }
 
 
-// Gesture support
-- (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b {
-AWT_ASSERT_APPKIT_THREAD;
-
-    JNIEnv *env = [ThreadUtilities getJNIEnv];
-    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
-    if (platformWindow != NULL) {
-        // extract the target AWT Window object out of the CPlatformWindow
-        static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;");
-        jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target);
-        if (awtWindow != NULL) {
-            // translate the point into Java coordinates
-            NSPoint loc = [event locationInWindow];
-            loc.y = [self.nsWindow frame].size.height - loc.y;
-
-            // send up to the GestureHandler to recursively dispatch on the AWT event thread
-            static JNF_CLASS_CACHE(jc_GestureHandler, "com/apple/eawt/event/GestureHandler");
-            static JNF_STATIC_MEMBER_CACHE(sjm_handleGestureFromNative, jc_GestureHandler, "handleGestureFromNative", "(Ljava/awt/Window;IDDDD)V");
-            JNFCallStaticVoidMethod(env, sjm_handleGestureFromNative, awtWindow, type, (jdouble)loc.x, (jdouble)loc.y, (jdouble)a, (jdouble)b);
-            (*env)->DeleteLocalRef(env, awtWindow);
-        }
-        (*env)->DeleteLocalRef(env, platformWindow);
-    }
-}
-
-- (void)beginGestureWithEvent:(NSEvent *)event {
-    [self postGesture:event
-                   as:com_apple_eawt_event_GestureHandler_PHASE
-                    a:-1.0
-                    b:0.0];
-}
-
-- (void)endGestureWithEvent:(NSEvent *)event {
-    [self postGesture:event
-                   as:com_apple_eawt_event_GestureHandler_PHASE
-                    a:1.0
-                    b:0.0];
-}
-
-- (void)magnifyWithEvent:(NSEvent *)event {
-    [self postGesture:event
-                   as:com_apple_eawt_event_GestureHandler_MAGNIFY
-                    a:[event magnification]
-                    b:0.0];
-}
-
-- (void)rotateWithEvent:(NSEvent *)event {
-    [self postGesture:event
-                   as:com_apple_eawt_event_GestureHandler_ROTATE
-                    a:[event rotation]
-                    b:0.0];
-}
-
-- (void)swipeWithEvent:(NSEvent *)event {
-    [self postGesture:event
-                   as:com_apple_eawt_event_GestureHandler_SWIPE
-                    a:[event deltaX]
-                    b:[event deltaY]];
-}
-
-
 // NSWindowDelegate methods
 
 - (void) _deliverMoveResizeEvent {
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/AWTStrike.m	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/AWTStrike.m	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,14 +25,11 @@
 
 #import <JavaNativeFoundation/JavaNativeFoundation.h>
 #import "java_awt_geom_PathIterator.h"
-#import "sun_awt_SunHints.h"
 #import "sun_font_CStrike.h"
 #import "sun_font_CStrikeDisposer.h"
 #import "CGGlyphImages.h"
 #import "CGGlyphOutlines.h"
-#import "AWTStrike.h"
 #import "CoreTextSupport.h"
-//#import "jni_util.h"
 #include "fontscalerdefs.h"
 
 /* Use THIS_FILE when it is available. */
@@ -65,10 +62,10 @@
         invDevTx.b *= -1;
         invDevTx.c *= -1;
         fFontTx = CGAffineTransformConcat(CGAffineTransformConcat(tx, invDevTx), sInverseTX);
-        fDevTx = CGAffineTransformInvert(invDevTx);
+        fDevTx = CGAffineTransformInvert(CGAffineTransformConcat(invDevTx, sInverseTX));
 
         // the "font size" is the square root of the determinant of the matrix
-        fSize = sqrt(abs(fFontTx.a * fFontTx.d - fFontTx.b * fFontTx.c));
+        fSize = sqrt(fabs(fFontTx.a * fFontTx.d - fFontTx.b * fFontTx.c));
     }
     return self;
 }
--- a/jdk/src/java.desktop/share/classes/com/sun/beans/editors/ColorEditor.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/beans/editors/ColorEditor.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 public class ColorEditor extends Panel implements PropertyEditor {
     private static final long serialVersionUID = 1781257185164716054L;
 
+    @SuppressWarnings("deprecation")
     public ColorEditor() {
         setLayout(null);
 
@@ -69,10 +70,12 @@
         changeColor(c);
     }
 
+    @SuppressWarnings("deprecation")
     public Dimension preferredSize() {
         return new Dimension(ourWidth, 40);
     }
 
+    @SuppressWarnings("deprecation")
     public boolean keyUp(Event e, int key) {
         if (e.target == text) {
             try {
@@ -107,6 +110,7 @@
 
     }
 
+    @SuppressWarnings("deprecation")
     public boolean action(Event e, Object arg) {
         if (e.target == choser) {
             changeColor(colors[choser.getSelectedIndex()]);
--- a/jdk/src/java.desktop/share/classes/com/sun/beans/editors/FontEditor.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/beans/editors/FontEditor.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 public class FontEditor extends Panel implements java.beans.PropertyEditor {
     private static final long serialVersionUID = 6732704486002715933L;
 
+    @SuppressWarnings("deprecation")
     public FontEditor() {
         setLayout(null);
 
@@ -62,6 +63,7 @@
     }
 
 
+    @SuppressWarnings("deprecation")
     public Dimension preferredSize() {
         return new Dimension(300, 40);
     }
@@ -93,6 +95,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     private void changeFont(Font f) {
         font = f;
         if (sample != null) {
@@ -124,6 +127,7 @@
                    font.getStyle() + ", " + font.getSize() + ")";
     }
 
+    @SuppressWarnings("deprecation")
     public boolean action(Event e, Object arg) {
         String family = familyChoser.getSelectedItem();
         int style = styles[styleChoser.getSelectedIndex()];
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -143,6 +143,7 @@
         return map;
     }
 
+    @SuppressWarnings("deprecation")
     public String getFileName() {
         JFileChooser fc = getFileChooser();
         String typedInName = fileNameTextField != null ?
@@ -419,6 +420,7 @@
 
 
 
+    @SuppressWarnings("deprecation")
     protected class SelectionListener implements ListSelectionListener {
         public void valueChanged(ListSelectionEvent e) {
             if (!e.getValueIsAdjusting()) {
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifDesktopIconUI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifDesktopIconUI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -245,6 +245,7 @@
                 e.isPopupTrigger(), MouseEvent.NOBUTTON));
         }
 
+        @SuppressWarnings("deprecation")
         public boolean isFocusTraversable() {
             return false;
         }
@@ -336,6 +337,7 @@
                 e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON ));
         }
 
+        @SuppressWarnings("deprecation")
         public boolean isFocusTraversable() {
             return false;
         }
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifInternalFrameTitlePane.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifInternalFrameTitlePane.java	Wed Jul 05 20:13:05 2017 +0200
@@ -242,6 +242,7 @@
             setBorderPainted(false);
         }
 
+        @SuppressWarnings("deprecation")
         public boolean isFocusTraversable() {
             return false;
         }
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopPaneUI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopPaneUI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,6 +60,7 @@
         super.installDefaults();
     }
 
+    @SuppressWarnings("deprecation")
     protected void installKeyboardActions() {
         super.installKeyboardActions();
 
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Wed Jul 05 20:13:05 2017 +0200
@@ -2487,6 +2487,7 @@
     /**
      * Calculates the dialog unit mapping.
      */
+    @SuppressWarnings("deprecation")
     private void calculateBaseUnits() {
         // This calculation comes from:
         // http://support.microsoft.com/default.aspx?scid=kb;EN-US;125681
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupWindow.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupWindow.java	Wed Jul 05 20:13:05 2017 +0200
@@ -78,6 +78,7 @@
         paint(g);
     }
 
+    @SuppressWarnings("deprecation")
     public void hide() {
         super.hide();
         /** We need to call removeNotify() here because hide() does
@@ -89,6 +90,7 @@
         removeNotify();
     }
 
+    @SuppressWarnings("deprecation")
     public void show() {
         super.show();
         this.pack();
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java	Wed Jul 05 20:13:05 2017 +0200
@@ -700,6 +700,7 @@
             setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
         }
 
+        @SuppressWarnings("deprecation")
         public boolean isFocusTraversable() {
             return false;
         }
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java	Wed Jul 05 20:13:05 2017 +0200
@@ -167,9 +167,9 @@
         for (int i = 0; i < allchannelnames.length; i++) {
             if ((channelmask & m) != 0L) {
                 if (i < channelnames.length) {
-                    sb.append(channelnames[i] + " ");
+                    sb.append(channelnames[i]).append(' ');
                 } else {
-                    sb.append(allchannelnames[i] + " ");
+                    sb.append(allchannelnames[i]).append(' ');
                 }
             }
             m *= 2L;
--- a/jdk/src/java.desktop/share/classes/java/awt/Canvas.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/Canvas.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,6 +70,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     void setGraphicsConfiguration(GraphicsConfiguration gc) {
         synchronized(getTreeLock()) {
             CanvasPeer peer = (CanvasPeer)getPeer();
--- a/jdk/src/java.desktop/share/classes/java/awt/Container.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/Container.java	Wed Jul 05 20:13:05 2017 +0200
@@ -805,6 +805,7 @@
      * to new heavyweight parent.
      * @since 1.5
      */
+    @SuppressWarnings("deprecation")
     private void reparentTraverse(ContainerPeer parentPeer, Container child) {
         checkTreeLock();
 
@@ -828,6 +829,7 @@
      * Container must be heavyweight.
      * @since 1.5
      */
+    @SuppressWarnings("deprecation")
     private void reparentChild(Component comp) {
         checkTreeLock();
         if (comp == null) {
@@ -4189,6 +4191,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     private void recursiveShowHeavyweightChildren() {
         if (!hasHeavyweightDescendants() || !isVisible()) {
             return;
@@ -4210,6 +4213,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     private void recursiveHideHeavyweightChildren() {
         if (!hasHeavyweightDescendants()) {
             return;
@@ -4231,6 +4235,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     private void recursiveRelocateHeavyweightChildren(Point origin) {
         for (int index = 0; index < getComponentCount(); index++) {
             Component comp = getComponent(index);
--- a/jdk/src/java.desktop/share/classes/java/awt/DefaultFocusTraversalPolicy.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/DefaultFocusTraversalPolicy.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -93,6 +93,7 @@
      * @return <code>true</code> if aComponent meets the above requirements;
      *         <code>false</code> otherwise
      */
+    @SuppressWarnings("deprecation")
     protected boolean accept(Component aComponent) {
         if (!(aComponent.isVisible() && aComponent.isDisplayable() &&
               aComponent.isEnabled()))
--- a/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java	Wed Jul 05 20:13:05 2017 +0200
@@ -796,6 +796,7 @@
      * @return <code>true</code>
      * @see Component#dispatchEvent
      */
+    @SuppressWarnings("deprecation")
     public boolean dispatchKeyEvent(KeyEvent e) {
         Component focusOwner = (((AWTEvent)e).isPosted) ? getFocusOwner() : e.getComponent();
 
@@ -1021,6 +1022,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     private boolean preDispatchKeyEvent(KeyEvent ke) {
         if (((AWTEvent) ke).isPosted) {
             Component focusOwner = getFocusOwner();
--- a/jdk/src/java.desktop/share/classes/java/awt/Dialog.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/Dialog.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -749,6 +749,7 @@
      * @see Component#isDisplayable
      * @see #removeNotify
      */
+    @SuppressWarnings("deprecation")
     public void addNotify() {
         synchronized (getTreeLock()) {
             if (parent != null && parent.getPeer() == null) {
@@ -897,6 +898,7 @@
     /**
      * @return true if we actually showed, false if we just called toFront()
      */
+    @SuppressWarnings("deprecation")
     private boolean conditionalShow(Component toFocus, AtomicLong time) {
         boolean retval;
 
--- a/jdk/src/java.desktop/share/classes/java/awt/FileDialog.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/FileDialog.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -314,6 +314,7 @@
      * Creates the file dialog's peer.  The peer allows us to change the look
      * of the file dialog without changing its functionality.
      */
+    @SuppressWarnings("deprecation")
     public void addNotify() {
         synchronized(getTreeLock()) {
             if (parent != null && parent.getPeer() == null) {
--- a/jdk/src/java.desktop/share/classes/java/awt/FontMetrics.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/FontMetrics.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -409,6 +409,7 @@
      * @see       #charsWidth(char[], int, int)
      * @see       #stringWidth(String)
      */
+    @SuppressWarnings("deprecation")
     public int bytesWidth(byte data[], int off, int len) {
         return stringWidth(new String(data, 0, off, len));
     }
--- a/jdk/src/java.desktop/share/classes/java/awt/Graphics.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/Graphics.java	Wed Jul 05 20:13:05 2017 +0200
@@ -843,6 +843,7 @@
      * @see         java.awt.Graphics#drawChars
      * @see         java.awt.Graphics#drawString
      */
+    @SuppressWarnings("deprecation")
     public void drawBytes(byte data[], int offset, int length, int x, int y) {
         drawString(new String(data, 0, offset, length), x, y);
     }
--- a/jdk/src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java	Wed Jul 05 20:13:05 2017 +0200
@@ -28,6 +28,7 @@
 
 import java.awt.image.BufferedImage;
 import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Locale;
 
 import sun.font.FontManager;
@@ -161,43 +162,38 @@
      */
     private static boolean getHeadlessProperty() {
         if (headless == null) {
-            java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction<Object>() {
-                public Object run() {
-                    String nm = System.getProperty("java.awt.headless");
+            AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+                String nm = System.getProperty("java.awt.headless");
 
-                    if (nm == null) {
-                        /* No need to ask for DISPLAY when run in a browser */
-                        if (System.getProperty("javaplugin.version") != null) {
-                            headless = defaultHeadless = Boolean.FALSE;
+                if (nm == null) {
+                    /* No need to ask for DISPLAY when run in a browser */
+                    if (System.getProperty("javaplugin.version") != null) {
+                        headless = defaultHeadless = Boolean.FALSE;
+                    } else {
+                        String osName = System.getProperty("os.name");
+                        if (osName.contains("OS X") && "sun.awt.HToolkit".equals(
+                                System.getProperty("awt.toolkit")))
+                        {
+                            headless = defaultHeadless = Boolean.TRUE;
                         } else {
-                            String osName = System.getProperty("os.name");
-                            if (osName.contains("OS X") && "sun.awt.HToolkit".equals(
-                                    System.getProperty("awt.toolkit")))
-                            {
-                                headless = defaultHeadless = Boolean.TRUE;
-                            } else {
-                                headless = defaultHeadless =
-                                    Boolean.valueOf(("Linux".equals(osName) ||
-                                                     "SunOS".equals(osName) ||
-                                                     "FreeBSD".equals(osName) ||
-                                                     "NetBSD".equals(osName) ||
-                                                     "OpenBSD".equals(osName) ||
-                                                     "AIX".equals(osName)) &&
-                                                     (System.getenv("DISPLAY") == null));
-                            }
+                            final String display = System.getenv("DISPLAY");
+                            headless = defaultHeadless =
+                                ("Linux".equals(osName) ||
+                                 "SunOS".equals(osName) ||
+                                 "FreeBSD".equals(osName) ||
+                                 "NetBSD".equals(osName) ||
+                                 "OpenBSD".equals(osName) ||
+                                 "AIX".equals(osName)) &&
+                                 (display == null || display.trim().isEmpty());
                         }
-                    } else if (nm.equals("true")) {
-                        headless = Boolean.TRUE;
-                    } else {
-                        headless = Boolean.FALSE;
                     }
-                    return null;
-                }
+                } else {
+                    headless = Boolean.valueOf(nm);
                 }
-            );
+                return null;
+            });
         }
-        return headless.booleanValue();
+        return headless;
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java	Wed Jul 05 20:13:05 2017 +0200
@@ -3054,6 +3054,7 @@
         return (wto != wfrom);
     }
 
+    @SuppressWarnings("deprecation")
     static Component getHeavyweight(Component comp) {
         if (comp == null || comp.getPeer() == null) {
             return null;
--- a/jdk/src/java.desktop/share/classes/java/awt/PopupMenu.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/PopupMenu.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -153,6 +153,7 @@
      *                parent's hierarchy
      * @exception RuntimeException if the parent is not showing on screen
      */
+    @SuppressWarnings("deprecation")
     public void show(Component origin, int x, int y) {
         // Use localParent for thread safety.
         MenuContainer localParent = parent;
--- a/jdk/src/java.desktop/share/classes/java/awt/ScrollPane.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/ScrollPane.java	Wed Jul 05 20:13:05 2017 +0200
@@ -732,6 +732,7 @@
         /**
          * Invoked when the value of the adjustable has changed.
          */
+        @SuppressWarnings("deprecation")
         public void adjustmentValueChanged(AdjustmentEvent e) {
             Adjustable adj = e.getAdjustable();
             int value = e.getValue();
@@ -831,6 +832,7 @@
     /**
      * Invoked when the value of the adjustable has changed.
      */
+    @SuppressWarnings("deprecation")
     public void adjustmentValueChanged(AdjustmentEvent e) {
         Adjustable adj = e.getAdjustable();
         int value = e.getValue();
--- a/jdk/src/java.desktop/share/classes/java/awt/SplashScreen.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/SplashScreen.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -203,6 +203,7 @@
      * @return URL for the current splash screen image file
      * @throws IllegalStateException if the splash screen has already been closed
      */
+    @SuppressWarnings("deprecation")
     public URL getImageURL() throws IllegalStateException {
         synchronized (SplashScreen.class) {
             checkVisible();
--- a/jdk/src/java.desktop/share/classes/java/awt/Window.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/Window.java	Wed Jul 05 20:13:05 2017 +0200
@@ -755,6 +755,7 @@
      * @see Container#removeNotify
      * @since 1.0
      */
+    @SuppressWarnings("deprecation")
     public void addNotify() {
         synchronized (getTreeLock()) {
             Container parent = this.parent;
@@ -798,6 +799,7 @@
      * @see Component#isDisplayable
      * @see #setMinimumSize
      */
+    @SuppressWarnings("deprecation")
     public void pack() {
         Container parent = this.parent;
         if (parent != null && parent.getPeer() == null) {
@@ -1070,6 +1072,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     static void updateChildFocusableWindowState(Window w) {
         if (w.getPeer() != null && w.isShowing()) {
             ((WindowPeer)w.getPeer()).updateFocusableWindowState();
@@ -1157,6 +1160,7 @@
      * as reported in javadoc. So we need to implement this functionality even if a
      * child overrides dispose() in a wrong way without calling super.dispose().
      */
+    @SuppressWarnings("deprecation")
     void disposeImpl() {
         dispose();
         if (getPeer() != null) {
@@ -3623,6 +3627,7 @@
      *
      * @since 1.7
      */
+    @SuppressWarnings("deprecation")
     public void setOpacity(float opacity) {
         synchronized (getTreeLock()) {
             if (opacity < 0.0f || opacity > 1.0f) {
@@ -3721,6 +3726,7 @@
      *
      * @since 1.7
      */
+    @SuppressWarnings("deprecation")
     public void setShape(Shape shape) {
         synchronized (getTreeLock()) {
             if (shape != null) {
@@ -3838,6 +3844,7 @@
      * @see GraphicsConfiguration#isTranslucencyCapable()
      */
     @Override
+    @SuppressWarnings("deprecation")
     public void setBackground(Color bgColor) {
         Color oldBg = getBackground();
         super.setBackground(bgColor);
@@ -3890,6 +3897,7 @@
         return bg != null ? bg.getAlpha() == 255 : true;
     }
 
+    @SuppressWarnings("deprecation")
     private void updateWindow() {
         synchronized (getTreeLock()) {
             WindowPeer peer = (WindowPeer)getPeer();
@@ -4080,6 +4088,7 @@
                 window.securityWarningHeight = height;
             }
 
+            @SuppressWarnings("deprecation")
             public void setSecurityWarningPosition(Window window,
                     Point2D point, float alignmentX, float alignmentY)
             {
--- a/jdk/src/java.desktop/share/classes/java/awt/datatransfer/StringSelection.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/datatransfer/StringSelection.java	Wed Jul 05 20:13:05 2017 +0200
@@ -47,6 +47,7 @@
     private static final int STRING = 0;
     private static final int PLAIN_TEXT = 1;
 
+    @SuppressWarnings("deprecation")
     private static final DataFlavor[] flavors = {
         DataFlavor.stringFlavor,
         DataFlavor.plainTextFlavor // deprecated
--- a/jdk/src/java.desktop/share/classes/java/awt/datatransfer/SystemFlavorMap.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/datatransfer/SystemFlavorMap.java	Wed Jul 05 20:13:05 2017 +0200
@@ -624,6 +624,7 @@
         return new ArrayList<>(returnValue);
     }
 
+    @SuppressWarnings("deprecation")
     private static Set<DataFlavor> convertMimeTypeToDataFlavors(
         final String baseType) {
 
--- a/jdk/src/java.desktop/share/classes/java/awt/dnd/DropTarget.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/java/awt/dnd/DropTarget.java	Wed Jul 05 20:13:05 2017 +0200
@@ -499,6 +499,7 @@
      *
      */
 
+    @SuppressWarnings("deprecation")
     public void addNotify(ComponentPeer peer) {
         if (peer == componentPeer) return;
 
@@ -690,6 +691,7 @@
          * update the geometry of the autoscroll region
          */
 
+        @SuppressWarnings("deprecation")
         private void updateRegion() {
            Insets    i    = autoScroll.getAutoscrollInsets();
            Dimension size = component.getSize();
--- a/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -149,6 +149,7 @@
      * or attributes is null, or the initial PrintService is not in the
      * list of browsable services.
      */
+    @SuppressWarnings("deprecation")
     public static PrintService printDialog(GraphicsConfiguration gc,
                                            int x, int y,
                                            PrintService[] services,
--- a/jdk/src/java.desktop/share/classes/javax/swing/DebugGraphics.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/DebugGraphics.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1453,6 +1453,7 @@
 
     /** Returns a DebugGraphics for use in buffering window.
       */
+    @SuppressWarnings("deprecation")
     private Graphics debugGraphics() {
         DebugGraphics        debugGraphics;
         DebugGraphicsInfo    info = info();
--- a/jdk/src/java.desktop/share/classes/javax/swing/GroupLayout.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/GroupLayout.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1213,15 +1213,15 @@
             registerComponents(horizontalGroup, HORIZONTAL);
             registerComponents(verticalGroup, VERTICAL);
         }
-        StringBuffer buffer = new StringBuffer();
-        buffer.append("HORIZONTAL\n");
-        createSpringDescription(buffer, horizontalGroup, "  ", HORIZONTAL);
-        buffer.append("\nVERTICAL\n");
-        createSpringDescription(buffer, verticalGroup, "  ", VERTICAL);
-        return buffer.toString();
+        StringBuilder sb = new StringBuilder();
+        sb.append("HORIZONTAL\n");
+        createSpringDescription(sb, horizontalGroup, "  ", HORIZONTAL);
+        sb.append("\nVERTICAL\n");
+        createSpringDescription(sb, verticalGroup, "  ", VERTICAL);
+        return sb.toString();
     }
 
-    private void createSpringDescription(StringBuffer buffer, Spring spring,
+    private void createSpringDescription(StringBuilder sb, Spring spring,
             String indent, int axis) {
         String origin = "";
         String padding = "";
@@ -1239,20 +1239,19 @@
             padding = ", userCreated=" + paddingSpring.getUserCreated() +
                     ", matches=" + paddingSpring.getMatchDescription();
         }
-        buffer.append(indent + spring.getClass().getName() + " " +
-                Integer.toHexString(spring.hashCode()) + " " +
-                origin +
-                ", size=" + spring.getSize() +
-                ", alignment=" + spring.getAlignment() +
-                " prefs=[" + spring.getMinimumSize(axis) +
-                " " + spring.getPreferredSize(axis) +
-                " " + spring.getMaximumSize(axis) +
-                padding + "]\n");
+        sb.append(indent).append(spring.getClass().getName()).append(' ')
+                .append(Integer.toHexString(spring.hashCode())).append(' ')
+                .append(origin).append(", size=").append(spring.getSize())
+                .append(", alignment=").append(spring.getAlignment())
+                .append(" prefs=[").append(spring.getMinimumSize(axis))
+                .append(' ').append(spring.getPreferredSize(axis)).append(' ')
+                .append(spring.getMaximumSize(axis)).append(padding)
+                .append("]\n");
         if (spring instanceof Group) {
             List<Spring> springs = ((Group)spring).springs;
             indent += "  ";
             for (int counter = 0; counter < springs.size(); counter++) {
-                createSpringDescription(buffer, springs.get(counter), indent,
+                createSpringDescription(sb, springs.get(counter), indent,
                         axis);
             }
         }
--- a/jdk/src/java.desktop/share/classes/javax/swing/JApplet.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JApplet.java	Wed Jul 05 20:13:05 2017 +0200
@@ -243,6 +243,7 @@
     *      hidden: true
     * description: The menubar for accessing pulldown menus from this applet.
     */
+    @SuppressWarnings("deprecation")
     public void setJMenuBar(JMenuBar menuBar) {
         getRootPane().setMenuBar(menuBar);
     }
@@ -253,6 +254,7 @@
     * @return the menubar set on this applet
     * @see #setJMenuBar
     */
+    @SuppressWarnings("deprecation")
     public JMenuBar getJMenuBar() {
         return getRootPane().getMenuBar();
     }
--- a/jdk/src/java.desktop/share/classes/javax/swing/JColorChooser.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JColorChooser.java	Wed Jul 05 20:13:05 2017 +0200
@@ -133,6 +133,7 @@
      * returns true.
      * @see java.awt.GraphicsEnvironment#isHeadless
      */
+    @SuppressWarnings("deprecation")
     public static Color showDialog(Component component,
         String title, Color initialColor) throws HeadlessException {
 
@@ -543,17 +544,17 @@
      * @return  a string representation of this <code>JColorChooser</code>
      */
     protected String paramString() {
-        StringBuilder chooserPanelsString = new StringBuilder("");
-        for (int i=0; i<chooserPanels.length; i++) {
-            chooserPanelsString.append("[" + chooserPanels[i].toString()
-                                       + "]");
+        StringBuilder chooserPanelsString = new StringBuilder();
+        for (AbstractColorChooserPanel panel : chooserPanels) {
+            chooserPanelsString.append('[').append(panel)
+                               .append(']');
         }
-        String previewPanelString = (previewPanel != null ?
-                                     previewPanel.toString() : "");
+        String previewPanelString = (previewPanel != null ? previewPanel
+                .toString() : "");
 
-        return super.paramString() +
-        ",chooserPanels=" + chooserPanelsString.toString() +
-        ",previewPanel=" + previewPanelString;
+        return super.paramString() + ",chooserPanels="
+                + chooserPanelsString.toString() + ",previewPanel="
+                + previewPanelString;
     }
 
 /////////////////
@@ -654,6 +655,7 @@
         okButton.getAccessibleContext().setAccessibleDescription(okString);
         okButton.setActionCommand("OK");
         okButton.addActionListener(new ActionListener() {
+            @SuppressWarnings("deprecation")
             public void actionPerformed(ActionEvent e) {
                 hide();
             }
@@ -685,6 +687,7 @@
 
         cancelButton.setActionCommand("cancel");
         cancelButton.addActionListener(new ActionListener() {
+            @SuppressWarnings("deprecation")
             public void actionPerformed(ActionEvent e) {
                 hide();
             }
@@ -723,6 +726,7 @@
         this.addWindowListener(new Closer());
     }
 
+    @SuppressWarnings("deprecation")
     public void show() {
         initialColor = chooserPane.getColor();
         super.show();
@@ -734,6 +738,7 @@
 
     @SuppressWarnings("serial") // JDK-implementation class
     class Closer extends WindowAdapter implements Serializable{
+        @SuppressWarnings("deprecation")
         public void windowClosing(WindowEvent e) {
             cancelButton.doClick(0);
             Window w = e.getWindow();
--- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java	Wed Jul 05 20:13:05 2017 +0200
@@ -5049,6 +5049,7 @@
         this.paintingChild = paintingChild;
     }
 
+    @SuppressWarnings("deprecation")
     void _paintImmediately(int x, int y, int w, int h) {
         Graphics g;
         Container c;
--- a/jdk/src/java.desktop/share/classes/javax/swing/JDialog.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JDialog.java	Wed Jul 05 20:13:05 2017 +0200
@@ -849,6 +849,7 @@
     *      hidden: true
     * description: The menubar for accessing pulldown menus from this dialog.
     */
+    @SuppressWarnings("deprecation")
     public void setJMenuBar(JMenuBar menu) {
         getRootPane().setMenuBar(menu);
     }
@@ -859,6 +860,7 @@
     * @return the menubar set on this dialog
     * @see #setJMenuBar
     */
+    @SuppressWarnings("deprecation")
     public JMenuBar getJMenuBar() {
         return getRootPane().getMenuBar();
     }
--- a/jdk/src/java.desktop/share/classes/javax/swing/JFileChooser.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JFileChooser.java	Wed Jul 05 20:13:05 2017 +0200
@@ -757,6 +757,7 @@
      * returns true.
      * @see java.awt.GraphicsEnvironment#isHeadless
      */
+    @SuppressWarnings("deprecation")
     public int showDialog(Component parent, String approveButtonText)
         throws HeadlessException {
         if (dialog != null) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/JFrame.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JFrame.java	Wed Jul 05 20:13:05 2017 +0200
@@ -494,6 +494,7 @@
     *      hidden: true
     * description: The menubar for accessing pulldown menus from this frame.
     */
+    @SuppressWarnings("deprecation")
     public void setJMenuBar(JMenuBar menubar) {
         getRootPane().setMenuBar(menubar);
     }
@@ -504,6 +505,7 @@
     *
     * @see #setJMenuBar
     */
+    @SuppressWarnings("deprecation")
     public JMenuBar getJMenuBar() {
         return getRootPane().getMenuBar();
     }
--- a/jdk/src/java.desktop/share/classes/javax/swing/JInternalFrame.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JInternalFrame.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1494,6 +1494,7 @@
      * @param width  an integer giving the component's new width in pixels
      * @param height an integer giving the component's new height in pixels
      */
+    @SuppressWarnings("deprecation")
     public void reshape(int x, int y, int width, int height) {
         super.reshape(x, y, width, height);
         validate();
@@ -1735,6 +1736,7 @@
      * @see InternalFrameEvent#INTERNAL_FRAME_OPENED
      * @see #setVisible
      */
+    @SuppressWarnings("deprecation")
     public void show() {
         // bug 4312922
         if (isVisible()) {
@@ -1766,6 +1768,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     public void hide() {
         if (isIcon()) {
             getDesktopIcon().setVisible(false);
--- a/jdk/src/java.desktop/share/classes/javax/swing/JList.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JList.java	Wed Jul 05 20:13:05 2017 +0200
@@ -3663,6 +3663,7 @@
                 }
             }
 
+            @SuppressWarnings("deprecation")
             public boolean isFocusTraversable() {
                 AccessibleContext ac = getCurrentAccessibleContext();
                 if (ac instanceof AccessibleComponent) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/JOptionPane.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JOptionPane.java	Wed Jul 05 20:13:05 2017 +0200
@@ -566,6 +566,7 @@
      *   <code>true</code>
      * @see java.awt.GraphicsEnvironment#isHeadless
      */
+    @SuppressWarnings("deprecation")
     public static Object showInputDialog(Component parentComponent,
         Object message, String title, int messageType, Icon icon,
         Object[] selectionValues, Object initialSelectionValue)
@@ -855,6 +856,7 @@
      *   <code>true</code>
      * @see java.awt.GraphicsEnvironment#isHeadless
      */
+    @SuppressWarnings("deprecation")
     public static int showOptionDialog(Component parentComponent,
         Object message, String title, int optionType, int messageType,
         Icon icon, Object[] options, Object initialValue)
--- a/jdk/src/java.desktop/share/classes/javax/swing/JTabbedPane.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JTabbedPane.java	Wed Jul 05 20:13:05 2017 +0200
@@ -333,6 +333,7 @@
      * @see #addChangeListener
      * @see EventListenerList
      */
+    @SuppressWarnings("deprecation")
     protected void fireStateChanged() {
         /* --- Begin code to deal with visibility --- */
 
@@ -949,6 +950,7 @@
      * @see #addTab
      * @see #insertTab
      */
+    @SuppressWarnings("deprecation")
     public void removeTabAt(int index) {
         checkIndex(index);
 
@@ -1557,6 +1559,7 @@
      *    attribute: visualUpdate true
      *  description: The component at the specified tab index.
      */
+    @SuppressWarnings("deprecation")
     public void setComponentAt(int index, Component component) {
         Page page = pages.get(index);
         if (component != page.component) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/JTable.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JTable.java	Wed Jul 05 20:13:05 2017 +0200
@@ -5810,6 +5810,7 @@
      *                where 0 is the first column
      * @return the <code>Component</code> being edited
      */
+    @SuppressWarnings("deprecation")
     public Component prepareEditor(TableCellEditor editor, int row, int column) {
         Object value = getValueAt(row, column);
         boolean isSelected = isCellSelected(row, column);
@@ -8788,6 +8789,7 @@
                 }
             }
 
+            @SuppressWarnings("deprecation")
             public boolean isFocusTraversable() {
                 AccessibleContext ac = getCurrentAccessibleContext();
                 if (ac instanceof AccessibleComponent) {
@@ -9640,6 +9642,7 @@
              * @see AccessibleState#FOCUSED
              * @see AccessibleStateSet
              */
+            @SuppressWarnings("deprecation")
             public boolean isFocusTraversable() {
                 AccessibleContext ac = getCurrentAccessibleContext();
                 if (ac instanceof AccessibleComponent) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/JViewport.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JViewport.java	Wed Jul 05 20:13:05 2017 +0200
@@ -829,6 +829,7 @@
      *
      * @see JComponent#reshape(int, int, int, int)
      */
+    @SuppressWarnings("deprecation")
     public void reshape(int x, int y, int w, int h) {
         boolean sizeChanged = (getWidth() != w) || (getHeight() != h);
         if (sizeChanged) {
@@ -1447,6 +1448,7 @@
      * Returns true if the component needs to be completely repainted after
      * a blit and a paint is received.
      */
+    @SuppressWarnings("deprecation")
     private boolean needsRepaintAfterBlit() {
         // Find the first heavy weight ancestor. isObscured and
         // canDetermineObscurity are only appropriate for heavy weights.
--- a/jdk/src/java.desktop/share/classes/javax/swing/Popup.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/Popup.java	Wed Jul 05 20:13:05 2017 +0200
@@ -253,6 +253,7 @@
             paint(g);
         }
 
+        @SuppressWarnings("deprecation")
         public void show() {
             this.pack();
             if (getWidth() > 0 && getHeight() > 0) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/ProgressMonitor.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/ProgressMonitor.java	Wed Jul 05 20:13:05 2017 +0200
@@ -260,6 +260,7 @@
      * @see #setMaximum
      * @see #close
      */
+    @SuppressWarnings("deprecation")
     public void setProgress(int nv) {
         if (nv >= max) {
             close();
--- a/jdk/src/java.desktop/share/classes/javax/swing/RepaintManager.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/RepaintManager.java	Wed Jul 05 20:13:05 2017 +0200
@@ -401,6 +401,7 @@
      *
      * @see JComponent#repaint
      */
+    @SuppressWarnings("deprecation")
     private void addDirtyRegion0(Container c, int x, int y, int w, int h) {
         /* Special cases we don't have to bother with.
          */
--- a/jdk/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java	Wed Jul 05 20:13:05 2017 +0200
@@ -195,6 +195,7 @@
         return true;
     }
 
+    @SuppressWarnings("deprecation")
     private void enumerateCycle(Container container, List<Component> cycle) {
         if (!(container.isVisible() && container.isDisplayable())) {
             return;
--- a/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1929,6 +1929,7 @@
         public void windowDeactivated(WindowEvent e) {
         }
 
+        @SuppressWarnings("deprecation")
         public void show() {
             // This frame can never be shown
         }
--- a/jdk/src/java.desktop/share/classes/javax/swing/UIManager.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/UIManager.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1436,6 +1436,7 @@
     /*
      * Sets default swing focus traversal policy.
      */
+    @SuppressWarnings("deprecation")
     private static void maybeInitializeFocusPolicy(JComponent comp) {
         // Check for JRootPane which indicates that a swing toplevel
         // is coming, in which case a swing default focus policy
--- a/jdk/src/java.desktop/share/classes/javax/swing/package.html	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/package.html	Wed Jul 05 20:13:05 2017 +0200
@@ -3,7 +3,7 @@
 
 <HEAD>
 <!--
-Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
 This code is free software; you can redistribute it and/or modify it
@@ -68,6 +68,8 @@
 the event dispatching thread. The following two examples work equally
 well for transferring control and starting up a Swing application:
 <pre>
+import javax.swing.SwingUtilities;
+
 public class MyApp implements Runnable {
     public void run() {
         // Invoked on the event dispatching thread.
@@ -75,16 +77,18 @@
     }
 
     public static void main(String[] args) {
-        SwingUtilities.invokeLater(new MyApp(args));
+        SwingUtilities.invokeLater(new MyApp());
     }
 }
 </pre>
 Or:
 <pre>
+import javax.swing.SwingUtilities;
+
 public class MyApp {
     MyApp(String[] args) {
-        // Invoked on the event dispatching thread. Do any initialization
-        // here.
+        // Invoked on the event dispatching thread.
+        // Do any initialization here.
     }
 
     public void show() {
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicArrowButton.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicArrowButton.java	Wed Jul 05 20:13:05 2017 +0200
@@ -216,6 +216,7 @@
          *
          * @return {@code false}
          */
+        @SuppressWarnings("deprecation")
         public boolean isFocusTraversable() {
           return false;
         }
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java	Wed Jul 05 20:13:05 2017 +0200
@@ -223,6 +223,7 @@
     /**
      * Implementation of ComboPopup.show().
      */
+    @SuppressWarnings("deprecation")
     public void show() {
         comboBox.firePopupMenuWillBecomeVisible();
         setListSelection(comboBox.getSelectedIndex());
@@ -234,6 +235,7 @@
     /**
      * Implementation of ComboPopup.hide().
      */
+    @SuppressWarnings("deprecation")
     public void hide() {
         MenuSelectionManager manager = MenuSelectionManager.defaultManager();
         MenuElement [] selection = manager.getSelectedPath();
@@ -1032,6 +1034,7 @@
     /**
      * Overridden to unconditionally return false.
      */
+    @SuppressWarnings("deprecation")
     public boolean isFocusTraversable() {
         return false;
     }
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -502,6 +502,7 @@
         public void mouseReleased(MouseEvent evt) {
         }
 
+        @SuppressWarnings("deprecation")
         public void valueChanged(ListSelectionEvent evt) {
             if(!evt.getValueIsAdjusting()) {
                 JFileChooser chooser = getFileChooser();
@@ -1305,6 +1306,7 @@
          * @return  The representation of the data to be transfered.
          *
          */
+        @SuppressWarnings("deprecation")
         protected Transferable createTransferable(JComponent c) {
             Object[] values = null;
             if (c instanceof JList) {
@@ -1330,8 +1332,8 @@
 
             for (Object obj : values) {
                 String val = ((obj == null) ? "" : obj.toString());
-                plainBuf.append(val + "\n");
-                htmlBuf.append("  <li>" + val + "\n");
+                plainBuf.append(val).append('\n');
+                htmlBuf.append("  <li>").append(val).append('\n');
             }
 
             // remove the last newline
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java	Wed Jul 05 20:13:05 2017 +0200
@@ -926,6 +926,7 @@
      * This class should be treated as a &quot;protected&quot; inner class.
      * Instantiate it only within subclasses of <code>Foo</code>.
      */
+    @SuppressWarnings("deprecation")
     public class SystemMenuBar extends JMenuBar {
         public boolean isFocusTraversable() { return false; }
         public void requestFocus() {}
@@ -963,6 +964,7 @@
                 setOpaque(((Boolean)opacity).booleanValue());
             }
         }
+        @SuppressWarnings("deprecation")
         public boolean isFocusTraversable() { return false; }
         public void requestFocus() {}
         public AccessibleContext getAccessibleContext() {
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicListUI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicListUI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -2931,6 +2931,7 @@
          * @return  The representation of the data to be transfered.
          *
          */
+        @SuppressWarnings("deprecation")
         protected Transferable createTransferable(JComponent c) {
             if (c instanceof JList) {
                 JList<?> list = (JList) c;
@@ -2948,8 +2949,8 @@
                 for (int i = 0; i < values.length; i++) {
                     Object obj = values[i];
                     String val = ((obj == null) ? "" : obj.toString());
-                    plainStr.append(val + "\n");
-                    htmlStr.append("  <li>" + val + "\n");
+                    plainStr.append(val).append('\n');
+                    htmlStr.append("  <li>").append(val).append('\n');
                 }
 
                 // remove the last newline
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneDivider.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneDivider.java	Wed Jul 05 20:13:05 2017 +0200
@@ -441,6 +441,7 @@
                 }
             }
             // Don't want the button to participate in focus traversable.
+            @SuppressWarnings("deprecation")
             public boolean isFocusTraversable() {
                 return false;
             }
@@ -497,6 +498,7 @@
                 }
             }
             // Don't want the button to participate in focus traversable.
+            @SuppressWarnings("deprecation")
             public boolean isFocusTraversable() {
                 return false;
             }
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1191,6 +1191,7 @@
      * Should be messaged before the dragging session starts, resets
      * lastDragLocation and dividerSize.
      */
+    @SuppressWarnings("deprecation")
     protected void startDragging() {
         Component       leftC = splitPane.getLeftComponent();
         Component       rightC = splitPane.getRightComponent();
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -2395,6 +2395,7 @@
             return total;
         }
 
+        @SuppressWarnings("deprecation")
         public void layoutContainer(Container parent) {
             /* Some of the code in this method deals with changing the
             * visibility of components to hide and show the contents for the
@@ -2903,6 +2904,7 @@
             return calculateMaxTabWidth(tabPlacement);
         }
 
+        @SuppressWarnings("deprecation")
         public void layoutContainer(Container parent) {
             /* Some of the code in this method deals with changing the
              * visibility of components to hide and show the contents for the
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -2230,11 +2230,11 @@
                     for (int col = 0; col < cols.length; col++) {
                         Object obj = table.getValueAt(rows[row], cols[col]);
                         String val = ((obj == null) ? "" : obj.toString());
-                        plainStr.append(val + "\t");
-                        htmlStr.append("  <td>" + val + "</td>\n");
+                        plainStr.append(val).append('\t');
+                        htmlStr.append("  <td>").append(val).append("</td>\n");
                     }
                     // we want a newline at the end of each line and not a tab
-                    plainStr.deleteCharAt(plainStr.length() - 1).append("\n");
+                    plainStr.deleteCharAt(plainStr.length() - 1).append('\n');
                     htmlStr.append("</tr>\n");
                 }
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -2644,6 +2644,7 @@
             /**
              * The only richer format supported is the file list flavor
              */
+            @SuppressWarnings("deprecation")
             protected Object getRicherData(DataFlavor flavor) throws UnsupportedFlavorException {
                 if (richText == null) {
                     return null;
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -421,6 +421,7 @@
      *
      * @param direction a direction
      */
+    @SuppressWarnings("deprecation")
     protected void navigateFocusedComp(int direction)
     {
         int nComp = toolBar.getComponentCount();
@@ -886,6 +887,7 @@
      * @param b {@code true} if the {@code JToolBar} is floating
      * @param p the position
      */
+    @SuppressWarnings("deprecation")
     public void setFloating(boolean b, Point p) {
         if (toolBar.isFloatable()) {
             boolean visible = false;
@@ -1080,6 +1082,7 @@
      * @param position the relative to the {@code JTollBar} position
      * @param origin the screen position of {@code JToolBar} before dragging
      */
+    @SuppressWarnings("deprecation")
     protected void dragTo(Point position, Point origin)
     {
         if (toolBar.isFloatable())
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTreeUI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTreeUI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -2363,6 +2363,7 @@
      * @param messageCancel message to cancel editing
      * @param messageTree message to tree
      */
+    @SuppressWarnings("deprecation")
     protected void completeEditing(boolean messageStop,
                                    boolean messageCancel,
                                    boolean messageTree) {
@@ -3618,8 +3619,8 @@
                     boolean leaf = model.isLeaf(node);
                     String label = getDisplayString(path, true, leaf);
 
-                    plainStr.append(label + "\n");
-                    htmlStr.append("  <li>" + label + "\n");
+                    plainStr.append(label).append('\n');
+                    htmlStr.append("  <li>").append(label).append('\n');
                 }
 
                 // remove the last newline
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalComboBoxButton.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalComboBoxButton.java	Wed Jul 05 20:13:05 2017 +0200
@@ -161,6 +161,7 @@
         iconOnly = onlyIcon;
     }
 
+    @SuppressWarnings("deprecation")
     public boolean isFocusTraversable() {
         return false;
     }
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalRootPaneUI.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalRootPaneUI.java	Wed Jul 05 20:13:05 2017 +0200
@@ -441,6 +441,7 @@
          * @param the Container for which this layout manager is being used
          * @return a Dimension object containing the layout's preferred size
          */
+        @SuppressWarnings("deprecation")
         public Dimension preferredLayoutSize(Container parent) {
             Dimension cpd, mbd, tpd;
             int cpWidth = 0;
@@ -493,6 +494,7 @@
          * @param the Container for which this layout manager is being used
          * @return a Dimension object containing the layout's minimum size
          */
+        @SuppressWarnings("deprecation")
         public Dimension minimumLayoutSize(Container parent) {
             Dimension cpd, mbd, tpd;
             int cpWidth = 0;
@@ -544,6 +546,7 @@
          * @param the Container for which this layout manager is being used
          * @return a Dimension object containing the layout's maximum size
          */
+        @SuppressWarnings("deprecation")
         public Dimension maximumLayoutSize(Container target) {
             Dimension cpd, mbd, tpd;
             int cpWidth = Integer.MAX_VALUE;
@@ -607,6 +610,7 @@
          *
          * @param the Container for which this layout manager is being used
          */
+        @SuppressWarnings("deprecation")
         public void layoutContainer(Container parent) {
             JRootPane root = (JRootPane) parent;
             Rectangle b = root.getBounds();
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSplitPaneDivider.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSplitPaneDivider.java	Wed Jul 05 20:13:05 2017 +0200
@@ -185,6 +185,7 @@
             }
 
             // Don't want the button to participate in focus traversable.
+            @SuppressWarnings("deprecation")
             public boolean isFocusTraversable() {
                 return false;
             }
@@ -294,6 +295,7 @@
             }
 
             // Don't want the button to participate in focus traversable.
+            @SuppressWarnings("deprecation")
             public boolean isFocusTraversable() {
                 return false;
             }
--- a/jdk/src/java.desktop/share/classes/javax/swing/table/JTableHeader.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/table/JTableHeader.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1427,6 +1427,7 @@
                 }
             }
 
+            @SuppressWarnings("deprecation")
             public boolean isFocusTraversable() {
                 AccessibleContext ac = getCurrentAccessibleContext();
                 if (ac instanceof AccessibleComponent) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphPainter1.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphPainter1.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -218,6 +218,7 @@
         return p1;
     }
 
+    @SuppressWarnings("deprecation")
     void sync(GlyphView v) {
         Font f = v.getFont();
         if ((metrics == null) || (! f.equals(metrics.getFont()))) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/StyleContext.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/StyleContext.java	Wed Jul 05 20:13:05 2017 +0200
@@ -279,6 +279,7 @@
      * @param f the font
      * @return the metrics
      */
+    @SuppressWarnings("deprecation")
     public FontMetrics getFontMetrics(Font f) {
         // The Toolkit implementations cache, so we just forward
         // to the default toolkit.
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/AccessibleHTML.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/AccessibleHTML.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -916,6 +916,7 @@
              * @return the zero-based index of the character under Point p; if
              * Point is invalid returns -1.
              */
+            @SuppressWarnings("deprecation")
             public int getIndexAtPoint(Point p) {
                 View v = getView();
                 if (v != null) {
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/FormView.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/FormView.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -599,6 +599,7 @@
      * @param point associated with the mouse click.
      * @return the image data.
      */
+    @SuppressWarnings("deprecation")
     private String getImageData(Point point) {
 
         String mouseCoords = point.x + ":" + point.y;
@@ -816,6 +817,7 @@
      * URLEncoder.encode() method before being added to the
      * buffer.
      */
+    @SuppressWarnings("deprecation")
     private void appendBuffer(StringBuilder buffer, String name, String value) {
         if (buffer.length() > 0) {
             buffer.append('&');
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/FrameView.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/FrameView.java	Wed Jul 05 20:13:05 2017 +0200
@@ -218,6 +218,7 @@
      * the scrolling attribute.  If not defined, the default is "auto" which
      * maps to the scrollbar's being displayed as needed.
      */
+    @SuppressWarnings("deprecation")
     private void createScrollPane() {
         AttributeSet attributes = getElement().getAttributes();
         String scrolling = (String)attributes.getAttribute(HTML.Attribute.SCROLLING);
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/HiddenTagView.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/HiddenTagView.java	Wed Jul 05 20:13:05 2017 +0200
@@ -129,6 +129,7 @@
 
     // local methods
 
+    @SuppressWarnings("deprecation")
     void updateYAlign(Font font) {
         Container c = getContainer();
         FontMetrics fm = (c != null) ? c.getFontMetrics(font) :
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/IsindexView.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/IsindexView.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -88,6 +88,7 @@
      * contents of the JTextField.  The search
      * contents are URLEncoded.
      */
+    @SuppressWarnings("deprecation")
     public void actionPerformed(ActionEvent evt) {
 
         String data = textField.getText();
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/LineView.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/LineView.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -161,6 +161,7 @@
     /**
      * Returns the location for the tab.
      */
+    @SuppressWarnings("deprecation")
     protected float getPreTab(float x, int tabOffset) {
         Document d = getDocument();
         View v = getViewAtPosition(tabOffset, null);
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java	Wed Jul 05 20:13:05 2017 +0200
@@ -2562,6 +2562,7 @@
             }
         }
 
+        @SuppressWarnings("deprecation")
         void paint(Graphics g, float x, float y, float w, float h, View v) {
             Rectangle clip = g.getClipRect();
             if (clip != null) {
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java	Wed Jul 05 20:13:05 2017 +0200
@@ -234,6 +234,7 @@
      * Minimum size
      */
     @Override
+    @SuppressWarnings("deprecation")
     public Dimension minimumSize() {
         return new Dimension(defaultAppletSize.width,
                              defaultAppletSize.height);
@@ -243,6 +244,7 @@
      * Preferred size
      */
     @Override
+    @SuppressWarnings("deprecation")
     public Dimension preferredSize() {
         return new Dimension(currentAppletSize.width,
                              currentAppletSize.height);
@@ -700,6 +702,7 @@
      * applet event processing so that it can be gracefully interrupted from
      * things like HotJava.
      */
+    @SuppressWarnings("deprecation")
     private void runLoader() {
         if (status != APPLET_DISPOSE) {
             showAppletStatus("notdisposed");
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletProps.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletProps.java	Wed Jul 05 20:13:05 2017 +0200
@@ -44,6 +44,7 @@
     TextField proxyPort;
     Choice accessMode;
 
+    @SuppressWarnings("deprecation")
     AppletProps() {
         setTitle(amh.getMessage("title"));
         Panel p = new Panel();
@@ -100,6 +101,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     void apply() {
         String proxyHostValue = proxyHost.getText().trim();
         String proxyPortValue = proxyPort.getText().trim();
@@ -172,6 +174,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     public boolean action(Event evt, Object obj) {
         if (amh.getMessage("button.apply").equals(obj)) {
             apply();
@@ -197,6 +200,7 @@
 /* Dialog class to display property-related errors to user */
 @SuppressWarnings("serial") // JDK implementation class
 class AppletPropsErrorDialog extends Dialog {
+    @SuppressWarnings("deprecation")
     public AppletPropsErrorDialog(Frame parent, String title, String message,
                 String buttonText) {
         super(parent, title, true);
@@ -212,6 +216,7 @@
              fRect.y + ((fRect.height - dDim.height) / 2));
     }
 
+    @SuppressWarnings("deprecation")
     public boolean action(Event event, Object object) {
         hide();
         dispose();
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletSecurity.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletSecurity.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -121,6 +121,7 @@
     /**
      * get the current (first) instance of an AppletClassLoader on the stack.
      */
+    @SuppressWarnings("deprecation")
     private AppletClassLoader currentAppletClassLoader()
     {
         // try currentClassLoader first
@@ -308,6 +309,7 @@
      * @exception  SecurityException  if the caller does not have
      *             permission to access the AWT event queue.
      */
+    @SuppressWarnings("deprecation")
     public void checkAwtEventQueueAccess() {
         AppContext appContext = AppContext.getAppContext();
         AppletClassLoader appletClassLoader = currentAppletClassLoader();
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletViewer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletViewer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -48,6 +48,7 @@
     /**
      * Create the tag frame.
      */
+    @SuppressWarnings("deprecation")
     TextFrame(int x, int y, String title, String text) {
         setTitle(title);
         TextArea txt = new TextArea(20, 60);
@@ -156,6 +157,7 @@
     /**
      * Create the applet viewer.
      */
+    @SuppressWarnings("deprecation")
     public AppletViewer(int x, int y, URL doc, Hashtable<String, String> atts,
                         PrintStream statusMsgStream, AppletViewerFactory factory) {
         this.factory = factory;
@@ -228,6 +230,7 @@
             }
 
             @Override
+            @SuppressWarnings("deprecation")
             public void appletStateChanged(AppletEvent evt)
             {
                 AppletPanel src = (AppletPanel)evt.getSource();
@@ -594,6 +597,7 @@
     /**
      * Make sure the atrributes are uptodate.
      */
+    @SuppressWarnings("deprecation")
     public void updateAtts() {
         Dimension d = panel.size();
         Insets in = panel.insets();
@@ -648,6 +652,7 @@
     /**
      * Save the applet to a well known file (for now) as a serialized object
      */
+    @SuppressWarnings("deprecation")
     void appletSave() {
         AccessController.doPrivileged(new PrivilegedAction<Object>() {
 
@@ -699,6 +704,7 @@
     /**
      * Clone the viewer and the applet.
      */
+    @SuppressWarnings("deprecation")
     void appletClone() {
         Point p = location();
         updateAtts();
@@ -711,6 +717,7 @@
     /**
      * Show the applet tag.
      */
+    @SuppressWarnings("deprecation")
     void appletTag() {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         updateAtts();
@@ -724,6 +731,7 @@
     /**
      * Show the applet info.
      */
+    @SuppressWarnings("deprecation")
     void appletInfo() {
         String str = panel.applet.getAppletInfo();
         if (str == null) {
--- a/jdk/src/java.desktop/share/classes/sun/awt/AppContext.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/AppContext.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -413,6 +413,7 @@
      *                                    contained within this AppContext
      * @since      1.2
      */
+    @SuppressWarnings("deprecation")
     public void dispose() throws IllegalThreadStateException {
         // Check to be sure that the current Thread isn't in this AppContext
         if (this.threadGroup.parentOf(Thread.currentThread().getThreadGroup())) {
--- a/jdk/src/java.desktop/share/classes/sun/awt/DebugSettings.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/DebugSettings.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -146,6 +146,7 @@
     /*
      * Sets up default property values
      */
+    @SuppressWarnings("deprecation")
     private void loadDefaultProperties() {
         // is there a more inefficient way to setup default properties?
         // maybe, but this has got to be close to 100% non-optimal
--- a/jdk/src/java.desktop/share/classes/sun/awt/LightweightFrame.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/LightweightFrame.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -88,6 +88,7 @@
     @Override public final void toFront() {}
     @Override public final void toBack() {}
 
+    @SuppressWarnings("deprecation")
     @Override public void addNotify() {
         synchronized (getTreeLock()) {
             if (getPeer() == null) {
@@ -114,6 +115,7 @@
      * @param activate if <code>true</code>, activates the frame;
      *                 otherwise, deactivates the frame
      */
+    @SuppressWarnings("deprecation")
     public void emulateActivation(boolean activate) {
         ((FramePeer)getPeer()).emulateActivation(activate);
     }
--- a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java	Wed Jul 05 20:13:05 2017 +0200
@@ -713,6 +713,7 @@
     }
 
 
+    @SuppressWarnings("deprecation")
     static final SoftCache imgCache = new SoftCache();
 
     static Image getImageFromHash(Toolkit tk, URL url) {
--- a/jdk/src/java.desktop/share/classes/sun/awt/datatransfer/DataTransferer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/datatransfer/DataTransferer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -717,6 +717,7 @@
      * Primary translation function for translating a Transferable into
      * a byte array, given a source DataFlavor and target format.
      */
+    @SuppressWarnings("deprecation")
     public byte[] translateTransferable(Transferable contents,
                                         DataFlavor flavor,
                                         long format) throws IOException
@@ -1287,6 +1288,7 @@
      * an InputStream into an Object, given a source format and a target
      * DataFlavor.
      */
+    @SuppressWarnings("deprecation")
     public Object translateStream(InputStream str, DataFlavor flavor,
                                   long format, Transferable localeTransferable)
         throws IOException
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/GifImageDecoder.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/GifImageDecoder.java	Wed Jul 05 20:13:05 2017 +0200
@@ -114,7 +114,7 @@
     /**
      * produce an image from the stream.
      */
-    @SuppressWarnings("fallthrough")
+    @SuppressWarnings({"fallthrough", "deprecation"})
     public void produceImage() throws IOException, ImageFormatException {
         try {
             readHeader();
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,6 +59,7 @@
 
     private static class ObserverCache {
 
+        @SuppressWarnings("deprecation")
         static final SoftCache INSTANCE = new SoftCache();
     }
 
@@ -80,7 +81,7 @@
         }
 
         synchronized (ObserverCache.INSTANCE) {
-            ImageObserver o = (ImageObserver) ObserverCache.INSTANCE.get(image);
+            ImageObserver o = (ImageObserver) ObserverCache.INSTANCE.get(observer);
 
             if (o == null) {
 
@@ -109,7 +110,7 @@
                                     image, flags, x, y, width, height);
                         };
 
-                ObserverCache.INSTANCE.put(image, o);
+                ObserverCache.INSTANCE.put(observer, o);
             }
             return o;
         }
--- a/jdk/src/java.desktop/share/classes/sun/font/StandardGlyphVector.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/font/StandardGlyphVector.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1894,9 +1894,9 @@
             }
         }
         catch(Exception e) {
-            buf.append(" " + e.getMessage());
+            buf.append(' ').append(e.getMessage());
         }
-        buf.append("}");
+        buf.append('}');
 
         return buf;
     }
--- a/jdk/src/java.desktop/share/classes/sun/print/PSPrinterJob.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/print/PSPrinterJob.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1214,6 +1214,7 @@
      * of distinct PS fonts needed to draw this text. This saves us
      * doing this processing one extra time.
      */
+    @SuppressWarnings("deprecation")
     protected int platformFontCount(Font font, String str) {
         if (mFontProps == null) {
             return 0;
@@ -1228,6 +1229,7 @@
         return (psFonts == null) ? 0 : psFonts.length;
     }
 
+    @SuppressWarnings("deprecation")
      protected boolean textOut(Graphics g, String str, float x, float y,
                                Font mLastFont, FontRenderContext frc,
                                float width) {
@@ -2123,6 +2125,7 @@
          * @param w the width of the applet panel in the browser window
          * @param h the width of the applet panel in the browser window
          */
+        @SuppressWarnings("deprecation")
         public PluginPrinter(Component applet,
                              PrintStream stream,
                              int x, int y, int w, int h) {
--- a/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java	Wed Jul 05 20:13:05 2017 +0200
@@ -745,6 +745,7 @@
      * return a PageFormat corresponding to the updated attributes,
      * or null if the user cancelled the dialog.
      */
+    @SuppressWarnings("deprecation")
     public PageFormat pageDialog(final PrintRequestAttributeSet attributes)
         throws HeadlessException {
         if (GraphicsEnvironment.isHeadless()) {
--- a/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java	Wed Jul 05 20:13:05 2017 +0200
@@ -792,6 +792,7 @@
             return label;
         }
 
+        @SuppressWarnings("deprecation")
         public void actionPerformed(ActionEvent e) {
             Object source = e.getSource();
 
--- a/jdk/src/java.desktop/share/classes/sun/swing/FilePane.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/swing/FilePane.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1355,6 +1355,7 @@
     /**
      * @param index visual index of the file to be edited
      */
+    @SuppressWarnings("deprecation")
     private void editFileName(int index) {
         JFileChooser chooser = getFileChooser();
         File currentDirectory = chooser.getCurrentDirectory();
@@ -1521,6 +1522,7 @@
     }
 
 
+    @SuppressWarnings("deprecation")
     void setFileSelected() {
         if (getFileChooser().isMultiSelectionEnabled() && !isDirectorySelected()) {
             File[] files = getFileChooser().getSelectedFiles(); // Should be selected
--- a/jdk/src/java.desktop/share/classes/sun/swing/JLightweightFrame.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/swing/JLightweightFrame.java	Wed Jul 05 20:13:05 2017 +0200
@@ -241,6 +241,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     public void notifyDisplayChanged(final int scaleFactor) {
         if (scaleFactor != this.scaleFactor) {
             if (!copyBufferEnabled) content.paintLock();
@@ -260,6 +261,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     public void addNotify() {
         super.addNotify();
         if (getPeer() instanceof DisplayChangedListener) {
--- a/jdk/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java	Wed Jul 05 20:13:05 2017 +0200
@@ -358,6 +358,7 @@
      * @param c Graphics Graphics
      * @param font Font to get FontMetrics for
      */
+    @SuppressWarnings("deprecation")
     public static FontMetrics getFontMetrics(JComponent c, Graphics g,
                                              Font font) {
         if (c != null) {
@@ -1706,6 +1707,7 @@
      * This is not a general-purpose method and is here only to permit
      * sharing code.
      */
+    @SuppressWarnings("deprecation")
     public static boolean tabbedPaneChangeFocusTo(Component comp) {
         if (comp != null) {
             if (comp.isFocusTraversable()) {
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/InfoWindow.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/InfoWindow.java	Wed Jul 05 20:13:05 2017 +0200
@@ -71,6 +71,7 @@
     }
 
     // Must be executed on EDT.
+    @SuppressWarnings("deprecation")
     protected void show(Point corner, int indent) {
         assert SunToolkit.isDispatchThreadForAppContext(this);
 
@@ -98,6 +99,7 @@
         closer.schedule();
     }
 
+    @SuppressWarnings("deprecation")
     public void hide() {
         closer.close();
     }
@@ -125,6 +127,7 @@
         }
 
         // WARNING: this method may be executed on Toolkit thread.
+        @SuppressWarnings("deprecation")
         private void doClose() {
             SunToolkit.executeOnEventHandlerThread(InfoWindow.this, new Runnable() {
                 public void run() {
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/ListHelper.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/ListHelper.java	Wed Jul 05 20:13:05 2017 +0200
@@ -225,6 +225,7 @@
         return index == focusedIndex;
     }
 
+    @SuppressWarnings("deprecation")
     void setFont(Font newFont) {
         if (newFont != font) {
             font = newFont;
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XBaseMenuWindow.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XBaseMenuWindow.java	Wed Jul 05 20:13:05 2017 +0200
@@ -326,6 +326,7 @@
      * check for adding duplicate items
      * @param item item to add
      */
+    @SuppressWarnings("deprecation")
     public void addItem(MenuItem item) {
         XMenuItemPeer mp = (XMenuItemPeer)item.getPeer();
         if (mp != null) {
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XChoicePeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XChoicePeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -499,6 +499,7 @@
     }
 
     // Stolen from TinyChoicePeer
+    @SuppressWarnings("deprecation")
     public Dimension getMinimumSize() {
         // TODO: move this impl into ListHelper?
         FontMetrics fm = getFontMetrics(target.getFont());
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XClipboard.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XClipboard.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -281,6 +281,11 @@
             }
         }
 
-        checkChange(formats);
+        XToolkit.awtUnlock();
+        try {
+            checkChange(formats);
+        } finally {
+            XToolkit.awtLock();
+        }
     }
 }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -167,6 +167,7 @@
         return System.getProperty("sun.awt.X11.XComponentPeer.reparentNotSupported", "false").equals("false");
     }
 
+    @SuppressWarnings("deprecation")
     public boolean isObscured() {
         Container container  = (target instanceof Container) ?
             (Container)target : target.getParent();
@@ -279,6 +280,7 @@
     }
 
     // TODO: consider moving it to KeyboardFocusManagerPeerImpl
+    @SuppressWarnings("deprecation")
     final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                       boolean focusedWindowChangeAllowed, long time,
                                       CausedFocusEvent.Cause cause)
@@ -388,6 +390,7 @@
     /**
      * @see java.awt.peer.ComponentPeer
      */
+    @SuppressWarnings("deprecation")
     public void setEnabled(final boolean value) {
         if (enableLog.isLoggable(PlatformLogger.Level.FINE)) {
             enableLog.fine("{0}ing {1}", (value ? "Enabl" : "Disabl"), this);
@@ -1324,6 +1327,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     private void addTree(Collection<Long> order, Set<Long> set, Container cont) {
         for (int i = 0; i < cont.getComponentCount(); i++) {
             Component comp = cont.getComponent(i);
@@ -1344,6 +1348,7 @@
 
     /****** DropTargetPeer implementation ********************/
 
+    @SuppressWarnings("deprecation")
     public void addDropTarget(DropTarget dt) {
         Component comp = target;
         while(!(comp == null || comp instanceof Window)) {
@@ -1358,6 +1363,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     public void removeDropTarget(DropTarget dt) {
         Component comp = target;
         while(!(comp == null || comp instanceof Window)) {
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDragSourceContextPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDragSourceContextPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -110,6 +110,7 @@
         return theInstance;
     }
 
+    @SuppressWarnings("deprecation")
     protected void startDrag(Transferable transferable,
                              long[] formats, Map<Long, DataFlavor> formatMap) {
         Component component = getTrigger().getComponent();
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDropTargetContextPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDropTargetContextPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -188,6 +188,7 @@
     // If source is an XEmbedCanvasPeer, passes the event to it for processing and
     // return true if the event is forwarded to the XEmbed child.
     // Otherwise, does nothing and return false.
+    @SuppressWarnings("deprecation")
     private boolean processSunDropTargetEvent(SunDropTargetEvent event) {
         Object source = event.getSource();
 
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedChildProxyPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedChildProxyPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -166,6 +166,7 @@
         XToolkit.postEvent(XToolkit.targetToAppContext(proxy), event);
     }
 
+    @SuppressWarnings("deprecation")
     boolean simulateMotifRequestFocus(Component lightweightChild, boolean temporary,
                                       boolean focusedWindowChangeAllowed, long time)
     {
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbeddedFrame.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbeddedFrame.java	Wed Jul 05 20:13:05 2017 +0200
@@ -61,6 +61,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     public void addNotify()
     {
         if (getPeer() == null) {
@@ -77,6 +78,7 @@
     /*
      * The method shouldn't be called in case of active XEmbed.
      */
+    @SuppressWarnings("deprecation")
     public boolean traverseIn(boolean direction) {
         XEmbeddedFramePeer peer = (XEmbeddedFramePeer)getPeer();
         if (peer != null) {
@@ -89,6 +91,7 @@
         return false;
     }
 
+    @SuppressWarnings("deprecation")
     protected boolean traverseOut(boolean direction) {
         XEmbeddedFramePeer xefp = (XEmbeddedFramePeer) getPeer();
         if (direction == FORWARD) {
@@ -103,6 +106,7 @@
     /*
      * The method shouldn't be called in case of active XEmbed.
      */
+    @SuppressWarnings("deprecation")
     public void synthesizeWindowActivation(boolean doActivate) {
         XEmbeddedFramePeer peer = (XEmbeddedFramePeer)getPeer();
         if (peer != null) {
@@ -114,12 +118,14 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     public void registerAccelerator(AWTKeyStroke stroke) {
         XEmbeddedFramePeer xefp = (XEmbeddedFramePeer) getPeer();
         if (xefp != null) {
             xefp.registerAccelerator(stroke);
         }
     }
+    @SuppressWarnings("deprecation")
     public void unregisterAccelerator(AWTKeyStroke stroke) {
         XEmbeddedFramePeer xefp = (XEmbeddedFramePeer) getPeer();
         if (xefp != null) {
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbeddingContainer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbeddingContainer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,6 +46,7 @@
         XToolkit.removeEventDispatcher(embedder.getWindow(), this);
     }
 
+    @SuppressWarnings("deprecation")
     void add(long child) {
         if (checkXEmbed(child)) {
             Component proxy = createChildProxy(child);
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XFileDialogPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XFileDialogPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -135,6 +135,7 @@
         this.target = target;
     }
 
+    @SuppressWarnings("deprecation")
     private void init(FileDialog target) {
         fileDialog = target; //new Dialog(target, target.getTitle(), false);
         this.title = target.getTitle();
@@ -414,6 +415,7 @@
     /**
      * handle the cancel event
      */
+    @SuppressWarnings("deprecation")
     void handleCancel() {
         KeyboardFocusManager.getCurrentKeyboardFocusManager()
             .removeKeyEventDispatcher(this);
@@ -435,6 +437,7 @@
     /**
      * handle the quit event
      */
+    @SuppressWarnings("deprecation")
     void handleQuitButton() {
         dir = null;
         file = null;
@@ -444,6 +447,7 @@
     /**
      * set the entry of the new dir with f
      */
+    @SuppressWarnings("deprecation")
     void setFilterEntry(String d, String f) {
         File fe = new File(d);
 
@@ -638,6 +642,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     public boolean dispatchKeyEvent(KeyEvent keyEvent) {
         int id = keyEvent.getID();
         int keyCode = keyEvent.getKeyCode();
@@ -774,6 +779,7 @@
     }
 
     // 03/02/2005 b5097243 Pressing 'ESC' on a file dlg does not dispose the dlg on Xtoolkit
+    @SuppressWarnings("deprecation")
     public void setVisible(boolean b){
         if (fileDialog == null) {
             init(target);
@@ -852,6 +858,7 @@
     public final static int VERTICAL = 1;
     int orientation;
 
+    @SuppressWarnings("deprecation")
     public Separator(int length, int thickness, int orient) {
         super();
         orientation = orient;
@@ -863,6 +870,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     public void paint(Graphics g) {
         int x1, y1, x2, y2;
         Rectangle bbox = bounds();
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XFramePeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XFramePeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -108,6 +108,7 @@
         setExtendedState(state);
     }
 
+    @SuppressWarnings("deprecation")
     public void setMenuBar(MenuBar mb) {
         // state_lock should always be the second after awt_lock
         XToolkit.awtLock();
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XInputMethod.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XInputMethod.java	Wed Jul 05 20:13:05 2017 +0200
@@ -137,6 +137,7 @@
         XToolkit.awtUnlock();
     }
 
+    @SuppressWarnings("deprecation")
     long getCurrentParentWindow() {
         return ((XWindow)clientComponentWindow.getPeer()).getContentWindow();
     }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMenuBarPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMenuBarPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -163,6 +163,7 @@
         postPaintEvent();
     }
 
+    @SuppressWarnings("deprecation")
     public void addHelpMenu(Menu m) {
         XMenuPeer mp = (XMenuPeer)m.getPeer();
         synchronized(getMenuTreeLock()) {
@@ -179,6 +180,7 @@
     /**
      * called from XFramePeer.setMenuBar
      */
+    @SuppressWarnings("deprecation")
     public void init(Frame frame) {
         this.target = frame;
         this.framePeer = (XFramePeer)frame.getPeer();
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseInfoPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseInfoPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -75,6 +75,7 @@
         return 0;
     }
 
+    @SuppressWarnings("deprecation")
     public boolean isWindowUnderMouse(Window w) {
 
         long display = XToolkit.getDisplay();
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XPanelPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XPanelPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -76,6 +76,7 @@
 
     }
 
+    @SuppressWarnings("deprecation")
     public void setBackground(Color c) {
         Component comp;
         int i;
@@ -101,6 +102,7 @@
         setForegroundForHierarchy((Container) target, c);
     }
 
+    @SuppressWarnings("deprecation")
     private void setForegroundForHierarchy(Container cont, Color c) {
         synchronized(target.getTreeLock()) {
             int n = cont.getComponentCount();
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRepaintArea.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRepaintArea.java	Wed Jul 05 20:13:05 2017 +0200
@@ -55,6 +55,7 @@
     /**
      * Calls <code>Component.paint(Graphics)</code> with given Graphics.
      */
+    @SuppressWarnings("deprecation")
     protected void paintComponent(Component comp, Graphics g) {
         if (comp != null) {
             final XComponentPeer peer = (XComponentPeer) comp.getPeer();
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XScrollPanePeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XScrollPanePeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -141,6 +141,7 @@
         repaint();
     }
 
+    @SuppressWarnings("deprecation")
     Dimension getChildSize() {
         ScrollPane sp = (ScrollPane)target;
         if (sp.countComponents() > 0) {
@@ -151,6 +152,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     boolean setScrollbarSpace() {
         ScrollPane sp = (ScrollPane)target;
         boolean changed = false;
@@ -268,6 +270,7 @@
     /**
      * Scroll the contents to position x, y
      */
+    @SuppressWarnings("deprecation")
     void scroll(int x, int y, int flag, int type) {
         checkSecurity();
         ScrollPane sp = (ScrollPane)target;
@@ -569,6 +572,7 @@
      * ToDo(aim): needs to query native motif for more accurate size and
      * color information.
      */
+    @SuppressWarnings("deprecation")
     public void print(Graphics g) {
         ScrollPane sp = (ScrollPane)target;
         Dimension d = sp.size();
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XScrollbarPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XScrollbarPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,7 @@
         DEFAULT_WIDTH_LINUX = XToolkit.getUIDefaults().getInt("ScrollBar.defaultWidth");
     }
 
+    @SuppressWarnings("deprecation")
     public void preInit(XCreateWindowParams params) {
         super.preInit(params);
         Scrollbar target = (Scrollbar) this.target;
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextAreaPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextAreaPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1164,6 +1164,7 @@
         }
 
         @Override
+        @SuppressWarnings("deprecation")
         public ComponentPeer getPeer() {
             return (ComponentPeer) (xwin);
         }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextFieldPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextFieldPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -208,6 +208,7 @@
      * @see java.awt.peer.TextComponentPeer
      */
     @Override
+    @SuppressWarnings("deprecation")
     public String getText() {
         return xtext.getText();
     }
@@ -564,6 +565,7 @@
         }
 
         @Override
+        @SuppressWarnings("deprecation")
         public void actionPerformed( ActionEvent actionEvent ) {
             peer.postEvent(new ActionEvent(peer.target,
                                            ActionEvent.ACTION_PERFORMED,
@@ -598,6 +600,7 @@
         }
 
         @Override
+        @SuppressWarnings("deprecation")
         public ComponentPeer getPeer() {
             return (ComponentPeer) peer;
         }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java	Wed Jul 05 20:13:05 2017 +0200
@@ -2438,12 +2438,14 @@
             awtUnlock();
         }
     }
+    @SuppressWarnings("deprecation")
     public void grab(Window w) {
         if (w.getPeer() != null) {
             ((XWindowPeer)w.getPeer()).setGrab(true);
         }
     }
 
+    @SuppressWarnings("deprecation")
     public void ungrab(Window w) {
         if (w.getPeer() != null) {
            ((XWindowPeer)w.getPeer()).setGrab(false);
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -347,6 +347,7 @@
     }
 
     // It's synchronized with disposal by EDT.
+    @SuppressWarnings("deprecation")
     public void showPopupMenu(int x, int y) {
         if (isDisposed())
             return;
@@ -415,6 +416,7 @@
         canvas.addMouseMotionListener(eventProxy);
     }
 
+    @SuppressWarnings("deprecation")
     long getWindow() {
         return ((XEmbeddedFramePeer)eframe.getPeer()).getWindow();
     }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java	Wed Jul 05 20:13:05 2017 +0200
@@ -282,6 +282,7 @@
         return reparented;
     }
 
+    @SuppressWarnings("deprecation")
     static long getParentWindowID(Component target) {
 
         ComponentPeer peer = target.getParent().getPeer();
@@ -298,6 +299,7 @@
     }
 
 
+    @SuppressWarnings("deprecation")
     static XWindow getParentXWindowObject(Component target) {
         if (target == null) return null;
         Component temp = target.getParent();
@@ -374,6 +376,7 @@
                            target.getFont());
     }
 
+    @SuppressWarnings("deprecation")
     public FontMetrics getFontMetrics(Font font) {
         return Toolkit.getDefaultToolkit().getFontMetrics(font);
     }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -210,6 +210,7 @@
     private static native String getLocalHostname();
     private static native int getJvmPID();
 
+    @SuppressWarnings("deprecation")
     void postInit(XCreateWindowParams params) {
         super.postInit(params);
 
@@ -400,6 +401,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     public void recursivelySetIcon(java.util.List<IconInfo> icons) {
         dumpIcons(winAttr.icons);
         setIconHints(icons);
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -325,6 +325,7 @@
         return (isFullScreenSupported() && (getFullScreenWindow() != null));
     }
 
+    @SuppressWarnings("deprecation")
     private static void enterFullScreenExclusive(Window w) {
         X11ComponentPeer peer = (X11ComponentPeer)w.getPeer();
         if (peer != null) {
@@ -333,6 +334,7 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
     private static void exitFullScreenExclusive(Window w) {
         X11ComponentPeer peer = (X11ComponentPeer)w.getPeer();
         if (peer != null) {
--- a/jdk/src/java.desktop/unix/classes/sun/java2d/opengl/GLXVolatileSurfaceManager.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/unix/classes/sun/java2d/opengl/GLXVolatileSurfaceManager.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -73,6 +73,7 @@
      * Create a pbuffer-based SurfaceData object (or init the backbuffer
      * of an existing window if this is a double buffered GraphicsConfig)
      */
+    @SuppressWarnings("deprecation")
     protected SurfaceData initAcceleratedSurface() {
         SurfaceData sData;
         Component comp = vImg.getComponent();
--- a/jdk/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java	Wed Jul 05 20:13:05 2017 +0200
@@ -329,6 +329,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     public synchronized void setFullScreenWindow(Window w) {
         Window old = getFullScreenWindow();
         if (w == old) {
@@ -404,6 +405,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     public synchronized void setDisplayMode(DisplayMode dm) {
         if (!isDisplayChangeSupported()) {
             super.setDisplayMode(dm);
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java	Wed Jul 05 20:13:05 2017 +0200
@@ -606,6 +606,7 @@
 
     // java.awt.Toolkit#getNativeContainer() is not available
     //  from this package
+    @SuppressWarnings("deprecation")
     private WComponentPeer getNearestNativePeer(Component comp)
     {
         if (comp==null)     return null;
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WKeyboardFocusManagerPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WKeyboardFocusManagerPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -46,6 +46,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     public void setCurrentFocusOwner(Component comp) {
         setNativeFocusOwner(comp != null ? comp.getPeer() : null);
     }
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WListPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WListPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -39,6 +39,7 @@
     // ListPeer implementation
 
     @Override
+    @SuppressWarnings("deprecation")
     public int[] getSelectedIndexes() {
         List l = (List)target;
         int len = l.countItems();
@@ -92,6 +93,7 @@
 
     @Override
     public native void delItems(int start, int end);
+    @SuppressWarnings("deprecation")
     public void clear() {
         List l = (List)target;
         delItems(0, l.countItems());
@@ -129,6 +131,7 @@
     native void create(WComponentPeer parent);
 
     @Override
+    @SuppressWarnings("deprecation")
     void initialize() {
         List li = (List)target;
 
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WScrollPanePeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WScrollPanePeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -199,6 +199,7 @@
         }
 
         @Override
+        @SuppressWarnings("deprecation")
         public void run() {
             if (getScrollChild() == null) {
                 return;
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WTrayIconPeer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WTrayIconPeer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -82,6 +82,7 @@
 
         SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
                 @Override
+                @SuppressWarnings("deprecation")
                 public void run() {
                     PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                     if (popup != newPopup) {
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,6 +61,7 @@
     private BufferCapabilities bufferCaps;
     private D3DGraphicsDevice device;
 
+    @SuppressWarnings("deprecation")
     protected D3DGraphicsConfig(D3DGraphicsDevice device) {
         super(device, 0);
         this.device = device;
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java	Wed Jul 05 20:13:05 2017 +0200
@@ -176,6 +176,7 @@
                                                                  long hwnd);
 
     @Override
+    @SuppressWarnings("deprecation")
     protected void enterFullScreenExclusive(final int screen, WindowPeer wp)
     {
         final WWindowPeer wpeer = (WWindowPeer)realFSWindow.getPeer();
@@ -246,6 +247,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     protected void addFSWindowListener(Window w) {
         // if the window is not a toplevel (has an owner) we have to use the
         // real toplevel to enter the full-screen mode with (4933099).
@@ -273,6 +275,7 @@
     }
 
     @Override
+    @SuppressWarnings("deprecation")
     protected void removeFSWindowListener(Window w) {
         realFSWindow.removeWindowListener(fsWindowListener);
         fsWindowListener = null;
@@ -337,6 +340,7 @@
                                                        int bitDepth,
                                                        int refreshRate);
     @Override
+    @SuppressWarnings("deprecation")
     protected void configDisplayMode(final int screen, final WindowPeer w,
                                      final int width, final int height,
                                      final int bitDepth, final int refreshRate)
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java	Wed Jul 05 20:13:05 2017 +0200
@@ -523,6 +523,7 @@
      * @param comp component to check for hw children
      * @return true if Component has heavyweight children
      */
+    @SuppressWarnings("deprecation")
     private static boolean hasHWChildren(Component comp) {
         if (comp instanceof Container) {
             for (Component c : ((Container)comp).getComponents()) {
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DVolatileSurfaceManager.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DVolatileSurfaceManager.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -79,6 +79,7 @@
      * Create a pbuffer-based SurfaceData object (or init the backbuffer
      * of an existing window if this is a double buffered GraphicsConfig).
      */
+    @SuppressWarnings("deprecation")
     protected SurfaceData initAcceleratedSurface() {
         SurfaceData sData;
         Component comp = vImg.getComponent();
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -81,6 +81,7 @@
         wglAvailable = initWGL();
     }
 
+    @SuppressWarnings("deprecation")
     protected WGLGraphicsConfig(Win32GraphicsDevice device, int visualnum,
                                 long configInfo, ContextCapabilities oglCaps)
     {
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/opengl/WGLVolatileSurfaceManager.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/opengl/WGLVolatileSurfaceManager.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -73,6 +73,7 @@
      * Create a pbuffer-based SurfaceData object (or init the backbuffer
      * of an existing window if this is a double buffered GraphicsConfig).
      */
+    @SuppressWarnings("deprecation")
     protected SurfaceData initAcceleratedSurface() {
         SurfaceData sData;
         Component comp = vImg.getComponent();
--- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoMech.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoMech.java	Wed Jul 05 20:13:05 2017 +0200
@@ -37,6 +37,7 @@
     CRYPTO_AES_ECB(1, new String[]
         { "Cipher.AES/ECB/NoPadding;com.oracle.security.ucrypto.NativeCipher$AesEcbNoPadding",
           "Cipher.AES/ECB/PKCS5Padding;com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesEcbPKCS5",
+          "Alg.Alias.Cipher.AES;AES/ECB/PKCS5Padding",
           "Cipher.AES_128/ECB/NoPadding;com.oracle.security.ucrypto.NativeCipher$Aes128EcbNoPadding",
           "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.1;AES_128/ECB/NoPadding",
           "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.1;AES_128/ECB/NoPadding",
@@ -81,7 +82,8 @@
         { "Cipher.AES/CFB128/NoPadding;com.oracle.security.ucrypto.NativeCipher$AesCfb128NoPadding",
           "Cipher.AES/CFB128/PKCS5Padding;com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesCfb128PKCS5" }),
     CRYPTO_RSA_PKCS(31, new String[]
-        { "Cipher.RSA/ECB/PKCS1Padding;com.oracle.security.ucrypto.NativeRSACipher$PKCS1Padding" }),
+        { "Cipher.RSA/ECB/PKCS1Padding;com.oracle.security.ucrypto.NativeRSACipher$PKCS1Padding",
+          "Alg.Alias.Cipher.RSA;RSA/ECB/PKCS1Padding" }),
     CRYPTO_RSA_X_509(32, new String[]
         { "Cipher.RSA/ECB/NoPadding;com.oracle.security.ucrypto.NativeRSACipher$NoPadding" }),
     CRYPTO_MD5_RSA_PKCS(33, new String[]
--- a/jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/Main.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/jdk.dev/share/classes/sun/tools/native2ascii/Main.java	Wed Jul 05 20:13:05 2017 +0200
@@ -71,11 +71,8 @@
 import java.nio.charset.CharsetEncoder;
 import java.nio.charset.Charset;
 import java.nio.charset.IllegalCharsetNameException;
-import java.nio.file.Files;
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.UnsupportedCharsetException;
-import sun.tools.native2ascii.A2NFilter;
-import sun.tools.native2ascii.N2AFilter;
 
 /**
  * Main program of the native2ascii
@@ -94,7 +91,7 @@
     /**
      * Run the converter
      */
-    public synchronized boolean convert(String argv[]){
+    public synchronized boolean convert(String argv[]) {
         List<String> v = new ArrayList<>(2);
         File outputFile = null;
         boolean createOutputFile = false;
@@ -102,14 +99,14 @@
         // Parse arguments
         for (int i = 0; i < argv.length; i++) {
             if (argv[i].equals("-encoding")) {
-                if ((i + 1) < argv.length){
+                if ((i + 1) < argv.length) {
                     encodingString = argv[++i];
                 } else {
                     error(getMsg("err.bad.arg"));
                     usage();
                     return false;
                 }
-            } else if (argv[i].equals("-reverse")){
+            } else if (argv[i].equals("-reverse")) {
                 reverse = true;
             } else {
                 if (v.size() > 1) {
@@ -119,15 +116,18 @@
                 v.add(argv[i]);
             }
         }
-        if (encodingString == null)
-           defaultEncoding = Charset.defaultCharset().name();
 
+        if (encodingString == null) {
+            defaultEncoding = Charset.defaultCharset().name();
+        }
         char[] lineBreak = System.getProperty("line.separator").toCharArray();
+
         try {
             initializeConverter();
 
-            if (v.size() == 1)
+            if (v.size() == 1) {
                 inputFileName = v.get(0);
+            }
 
             if (v.size() == 2) {
                 inputFileName = v.get(0);
@@ -137,40 +137,38 @@
 
             if (createOutputFile) {
                 outputFile = new File(outputFileName);
-                    if (outputFile.exists() && !outputFile.canWrite()) {
-                        throw new Exception(formatMsg("err.cannot.write", outputFileName));
-                    }
+                if (outputFile.exists() && !outputFile.canWrite()) {
+                    throw new Exception(formatMsg("err.cannot.write", outputFileName));
+                }
             }
 
-            if (reverse){
-                BufferedReader reader = getA2NInput(inputFileName);
-                Writer osw = getA2NOutput(outputFileName);
-                String line;
-
-                while ((line = reader.readLine()) != null) {
-                    osw.write(line.toCharArray());
-                    osw.write(lineBreak);
-                    if (outputFileName == null) { // flush stdout
-                        osw.flush();
+            if (reverse) {
+                try (BufferedReader reader = getA2NInput(inputFileName);
+                        Writer osw = getA2NOutput(outputFileName);) {
+                    String line;
+                    while ((line = reader.readLine()) != null) {
+                        osw.write(line.toCharArray());
+                        osw.write(lineBreak);
+                        if (outputFileName == null) { // flush stdout
+                            osw.flush();
+                        }
                     }
                 }
-                reader.close();  // Close the stream.
-                osw.close();
             } else {
-             //N2A
-                String inLine;
-                BufferedReader in = getN2AInput(inputFileName);
-                BufferedWriter out = getN2AOutput(outputFileName);
-
-                while ((inLine = in.readLine()) != null) {
-                    out.write(inLine.toCharArray());
-                    out.write(lineBreak);
-                    if (outputFileName == null) { // flush stdout
-                        out.flush();
+                // N2A
+                try (BufferedReader in = getN2AInput(inputFileName);
+                        BufferedWriter out = getN2AOutput(outputFileName);) {
+                    String inLine;
+                    while ((inLine = in.readLine()) != null) {
+                        out.write(inLine.toCharArray());
+                        out.write(lineBreak);
+                        if (outputFileName == null) { // flush stdout
+                            out.flush();
+                        }
                     }
                 }
-                out.close();
             }
+
             // Since we are done rename temporary file to desired output file
             if (createOutputFile) {
                 if (outputFile.exists()) {
@@ -182,8 +180,7 @@
                 }
                 tempFile.renameTo(outputFile);
             }
-
-        } catch(Exception e){
+        } catch (Exception e) {
             error(e.toString());
             return false;
         }
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AliasFileParser.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/AliasFileParser.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
  */
 public class AliasFileParser {
     private static final String ALIAS = "alias";
-    private static final boolean DEBUG = false;
+    // 8028357 removed old, inefficient debug logging
 
     // other variables
     private URL inputfile;
@@ -64,21 +64,12 @@
         }
     }
 
-    private void logln(String s) {
-        if (DEBUG) {
-            System.err.println(s);
-        }
-    }
-
     /**
      * method to get the next token as a Token type
      */
     private void nextToken() throws IOException {
         st.nextToken();
         currentToken = new Token(st.ttype, st.sval);
-
-        logln("Read token: type = " + currentToken.ttype
-              + " string = " + currentToken.sval);
     }
 
     /**
@@ -90,8 +81,6 @@
 
         if ((currentToken.ttype == ttype)
                 && (currentToken.sval.compareTo(token) == 0)) {
-            logln("matched type: " + ttype + " and token = "
-                  + currentToken.sval);
             nextToken();
         } else {
             throw new SyntaxException(st.lineno());
@@ -105,7 +94,6 @@
      */
     private void match(int ttype) throws IOException, SyntaxException {
         if (currentToken.ttype == ttype) {
-            logln("matched type: " + ttype + ", token = " + currentToken.sval);
             nextToken();
         } else {
             throw new SyntaxException(st.lineno());
@@ -157,8 +145,6 @@
             } while ((currentToken.ttype != StreamTokenizer.TT_EOF)
                      && (currentToken.sval.compareTo(ALIAS) != 0));
 
-            logln("adding map entry for " + name + " values = " + aliases);
-
             map.put(name, aliases);
         }
     }
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/CountedTimerTaskUtils.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/CountedTimerTaskUtils.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
  */
 public class CountedTimerTaskUtils {
 
-    private static final boolean DEBUG = false;
+    // 8028357 removed old, inefficient debug logging
 
     /**
      * Reschedule a CountedTimeTask at a different interval. Probably not
@@ -58,14 +58,6 @@
         long lastRun = oldTask.scheduledExecutionTime();
         long expired = now - lastRun;
 
-        if (DEBUG) {
-            System.err.println("computing timer delay: "
-                               + " oldInterval = " + oldInterval
-                               + " newInterval = " + newInterval
-                               + " samples = " + oldTask.executionCount()
-                               + " expired = " + expired);
-        }
-
         /*
          * check if original task ever ran - if not, then lastRun is
          * undefined and we simply set the delay to 0.
@@ -76,12 +68,6 @@
             delay = remainder >= 0 ? remainder : 0;
         }
 
-        if (DEBUG) {
-            System.err.println("rescheduling sampler task: interval = "
-                               + newInterval
-                               + " delay = " + delay);
-        }
-
         timer.schedule(newTask, delay, newInterval);
     }
 }
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -44,7 +44,8 @@
  */
 public class PerfDataBuffer extends PerfDataBufferImpl {
 
-    private static final boolean DEBUG = false;
+    // 8028357 removed old, inefficient debug logging
+
     private static final int syncWaitMs =
             Integer.getInteger("sun.jvmstat.perdata.syncWaitMs", 5000);
     private static final ArrayList<Monitor> EMPTY_LIST = new ArrayList<Monitor>(0);
@@ -268,18 +269,13 @@
          * loop waiting for the ticks counter to be non zero. This is
          * an indication that the jvm is initialized.
          */
-        log("synchWithTarget: " + lvmid + " ");
         while (ticks.longValue() == 0) {
-            log(".");
-
             try { Thread.sleep(20); } catch (InterruptedException e) { }
 
             if (System.currentTimeMillis() > timeLimit) {
-                lognl("failed: " + lvmid);
                 throw new MonitorException("Could Not Synchronize with target");
             }
         }
-        lognl("success: " + lvmid);
     }
 
     /**
@@ -291,24 +287,18 @@
                       throws MonitorException {
         Monitor monitor = null;
 
-        log("polling for: " + lvmid + "," + name + " ");
-
         pollForEntry = nextEntry;
         while ((monitor = map.get(name)) == null) {
-            log(".");
 
             try { Thread.sleep(20); } catch (InterruptedException e) { }
 
             long t = System.currentTimeMillis();
             if ((t > timeLimit) || (overflow.intValue() > 0)) {
-                lognl("failed: " + lvmid + "," + name);
-                dumpAll(map, lvmid);
                 throw new MonitorException("Could not find expected counter");
             }
 
             getNewMonitors(map);
         }
-        lognl("success: " + lvmid + "," + name);
         return monitor;
     }
 
@@ -481,8 +471,6 @@
 
         // check for the end of the buffer
         if (nextEntry == buffer.limit()) {
-            lognl("getNextMonitorEntry():"
-                  + " nextEntry == buffer.limit(): returning");
             return null;
         }
 
@@ -614,37 +602,4 @@
         nextEntry = entryStart + entryLength;
         return monitor;
     }
-
-    /**
-     * Method to dump debugging information
-     */
-    private void dumpAll(Map<String, Monitor> map, int lvmid) {
-        if (DEBUG) {
-            Set<String> keys = map.keySet();
-
-            System.err.println("Dump for " + lvmid);
-            int j = 0;
-            for (Iterator<String> i = keys.iterator(); i.hasNext(); j++) {
-                Monitor monitor = map.get(i.next());
-                System.err.println(j + "\t" + monitor.getName()
-                                   + "=" + monitor.getValue());
-            }
-            System.err.println("nextEntry = " + nextEntry
-                               + " pollForEntry = " + pollForEntry);
-            System.err.println("Buffer info:");
-            System.err.println("buffer = " + buffer);
-        }
-    }
-
-    private void lognl(String s) {
-        if (DEBUG) {
-            System.err.println(s);
-        }
-    }
-
-    private void log(String s) {
-        if (DEBUG) {
-            System.err.print(s);
-        }
-    }
 }
--- a/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java	Wed Jul 05 20:13:05 2017 +0200
@@ -62,7 +62,8 @@
  */
 public class PerfDataBuffer extends PerfDataBufferImpl {
 
-    private static final boolean DEBUG = false;
+    // 8028357 removed old, inefficient debug logging
+
     private static final int syncWaitMs =
             Integer.getInteger("sun.jvmstat.perdata.syncWaitMs", 5000);
     private static final ArrayList<Monitor> EMPTY_LIST = new ArrayList<>(0);
@@ -264,20 +265,15 @@
         long timeLimit = System.currentTimeMillis() + syncWaitMs;
 
         // loop waiting for the accessible indicater to be non-zero
-        log("synchWithTarget: " + lvmid + " ");
         while (!prologue.isAccessible()) {
 
-            log(".");
-
             // give the target jvm a chance to complete initializatoin
             try { Thread.sleep(20); } catch (InterruptedException e) { }
 
             if (System.currentTimeMillis() > timeLimit) {
-                logln("failed: " + lvmid);
                 throw new MonitorException("Could not synchronize with target");
             }
         }
-        logln("success: " + lvmid);
     }
 
     /**
@@ -306,8 +302,6 @@
 
         // check for end of the buffer
         if (nextEntry == buffer.limit()) {
-            logln("getNextMonitorEntry():"
-                  + " nextEntry == buffer.limit(): returning");
             return null;
         }
 
@@ -346,9 +340,6 @@
         byte varByte = buffer.get();
         int dataOffset = buffer.getInt();
 
-        dump_entry_fixed(entryStart, nameOffset, vectorLength, typeCodeByte,
-                         flags, unitsByte, varByte, dataOffset);
-
         // convert common attributes to their object types
         Units units = Units.toUnits(unitsByte);
         Variability variability = Variability.toVariability(varByte);
@@ -439,8 +430,6 @@
         // set the position to the start of the data item
         buffer.position(entryStart + dataOffset);
 
-        dump_entry_variable(name, buffer, dataSize);
-
         if (vectorLength == 0) {
             // create a scalar Monitor object
             if (typeCode == TypeCode.LONG) {
@@ -514,103 +503,4 @@
         nextEntry = entryStart + entryLength;
         return monitor;
     }
-
-    /**
-     * Method to dump debugging information
-     */
-    private void dumpAll(Map<String, Monitor> map, int lvmid) {
-        if (DEBUG) {
-            Set<String> keys = map.keySet();
-
-            System.err.println("Dump for " + lvmid);
-            int j = 0;
-            for (Iterator<String> i = keys.iterator(); i.hasNext(); j++) {
-                Monitor monitor = map.get(i.next());
-                System.err.println(j + "\t" + monitor.getName()
-                                   + "=" + monitor.getValue());
-            }
-            System.err.println("nextEntry = " + nextEntry);
-            System.err.println("Buffer info:");
-            System.err.println("buffer = " + buffer);
-        }
-    }
-
-    /**
-     * Method to dump the fixed portion of an entry.
-     */
-    private void dump_entry_fixed(int entry_start, int nameOffset,
-                                  int vectorLength, byte typeCodeByte,
-                                  byte flags, byte unitsByte, byte varByte,
-                                  int dataOffset) {
-        if (DEBUG) {
-            System.err.println("Entry at offset: 0x"
-                               + Integer.toHexString(entry_start));
-            System.err.println("\tname_offset = 0x"
-                               + Integer.toHexString(nameOffset));
-            System.err.println("\tvector_length = 0x"
-                               + Integer.toHexString(vectorLength));
-            System.err.println("\tdata_type = 0x"
-                               + Integer.toHexString(typeCodeByte));
-            System.err.println("\tflags = 0x"
-                               + Integer.toHexString(flags));
-            System.err.println("\tdata_units = 0x"
-                               + Integer.toHexString(unitsByte));
-            System.err.println("\tdata_variability = 0x"
-                               + Integer.toHexString(varByte));
-            System.err.println("\tdata_offset = 0x"
-                               + Integer.toHexString(dataOffset));
-        }
-    }
-
-    private void dump_entry_variable(String name, ByteBuffer bb, int size) {
-        if (DEBUG) {
-            char[] toHex = new char[] { '0', '1', '2', '3',
-                                        '4', '5', '6', '7',
-                                        '8', '9', 'a', 'b',
-                                        'c', 'd', 'e', 'f' };
-
-            ByteBuffer data = bb.slice();
-            data.limit(size);
-
-            System.err.println("\tname = " + name);
-            System.err.println("\tdata = ");
-
-            int count=0;
-            while (data.hasRemaining()) {
-                byte b = data.get();
-                byte high = (byte)((b >> 8) & 0x0f);
-                byte low = (byte)(b & 0x0f);
-
-                if (count % 16 == 0) {
-                    System.err.print("\t\t" + Integer.toHexString(count / 16)
-                                     + ": ");
-                }
-
-                System.err.print(String.valueOf(toHex[high])
-                                 + String.valueOf(toHex[low]));
-
-                count++;
-                if (count % 16 == 0) {
-                    System.err.println();
-                } else {
-                    System.err.print(" ");
-                }
-            }
-            if (count % 16 != 0) {
-                System.err.println();
-            }
-        }
-    }
-
-    private void logln(String s) {
-        if (DEBUG) {
-            System.err.println(s);
-        }
-    }
-
-    private void log(String s) {
-        if (DEBUG) {
-            System.err.print(s);
-        }
-    }
 }
--- a/jdk/test/ProblemList.txt	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/ProblemList.txt	Wed Jul 05 20:13:05 2017 +0200
@@ -120,6 +120,10 @@
 
 # jdk_lang
 
+# 8029891
+java/lang/ClassLoader/deadlock/GetResource.java                 generic-all
+
+
 ############################################################################
 
 # jdk_instrument
@@ -239,9 +243,6 @@
 java/security/KeyPairGenerator/SolarisShortDSA.java             solaris-all
 sun/security/tools/keytool/standard.sh                          solaris-all
 
-# 8049312
-com/sun/crypto/provider/Cipher/AES/CICO.java			generic-all
-
 # 8062758
 java/security/Security/ClassLoaderDeadlock/Deadlock2.sh         generic-all
 
@@ -267,7 +268,7 @@
 
 # Tests take too long, on sparcs see 7143279
 # also see 8059906
-tools/pack200/CommandLineTests.java
+tools/pack200/CommandLineTests.java                             generic-all
 tools/pack200/Pack200Test.java                                  solaris-all,macosx-all
 
 # 8007410
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/oracle/security/ucrypto/TestAlias.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8043349
+ * @summary Ensure the cipher aliases of AES and RSA works correctly
+ */
+import java.io.*;
+import java.security.*;
+import java.security.spec.*;
+import java.util.*;
+import javax.crypto.*;
+import javax.crypto.spec.*;
+
+public class TestAlias extends UcryptoTest {
+
+    private static final String[] CIPHER_ALGOS = {
+        "AES/ECB/PKCS5Padding",
+        "AES",
+        "RSA/ECB/PKCS1Padding",
+        "RSA",
+    };
+
+    public static void main(String[] args) throws Exception {
+        main(new TestAlias(), null);
+    }
+
+    public void doTest(Provider prov) throws Exception {
+        Cipher c;
+        for (int i = 0; i < (CIPHER_ALGOS.length - 1); i+=2) {
+            String fullTransformation = CIPHER_ALGOS[i];
+            try {
+                c = Cipher.getInstance(fullTransformation, prov);
+            } catch (NoSuchAlgorithmException nsae) {
+                System.out.println("Skip unsupported algo: " + fullTransformation);
+                continue;
+            }
+            c = Cipher.getInstance(CIPHER_ALGOS[i+1], prov);
+        }
+
+        System.out.println("Test Passed");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Graphics2D/DrawString/DrawRotatedStringUsingRotatedFont.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+
+import static java.awt.image.BufferedImage.TYPE_INT_RGB;
+import static java.lang.Math.toRadians;
+
+/**
+ * @test
+ * @bug 8065373
+ * @summary Verifies that we get correct direction, when draw rotated string.
+ * @author Sergey Bylokhov
+ * @run main DrawRotatedStringUsingRotatedFont
+ */
+public final class DrawRotatedStringUsingRotatedFont {
+
+    private static final int SIZE = 500;
+    private static final String STR = "MMMMMMMMMMMMMMMM";
+
+    private static AffineTransform[] txs = {
+                            AffineTransform.getRotateInstance(toRadians(00)),
+                            AffineTransform.getRotateInstance(toRadians(45)),
+                            AffineTransform.getRotateInstance(toRadians(-45)),
+                            AffineTransform.getRotateInstance(toRadians(90)),
+                            AffineTransform.getRotateInstance(toRadians(-90)),
+                            AffineTransform.getRotateInstance(toRadians(135)),
+                            AffineTransform.getRotateInstance(toRadians(-135)),
+                            AffineTransform.getRotateInstance(toRadians(180)),
+                            AffineTransform.getRotateInstance(toRadians(-180)),
+                            AffineTransform.getRotateInstance(toRadians(225)),
+                            AffineTransform.getRotateInstance(toRadians(-225)),
+                            AffineTransform.getRotateInstance(toRadians(270)),
+                            AffineTransform.getRotateInstance(toRadians(-270)),
+                            AffineTransform.getRotateInstance(toRadians(315)),
+                            AffineTransform.getRotateInstance(toRadians(-315)),
+                            AffineTransform.getRotateInstance(toRadians(360)),
+                            AffineTransform.getRotateInstance(toRadians(-360))
+    };
+
+    public static void main(final String[] args) throws IOException {
+        for (final AffineTransform tx2 : txs) {
+            for (final AffineTransform tx1 : txs) {
+                for (final boolean aa : new boolean[]{true, false}) {
+                    final BufferedImage bi1 = createImage(aa, tx1, tx2);
+                    final BufferedImage bi2 = createImage(aa, tx2, tx1);
+                    compareImage(bi1, bi2);
+                    fillTextArea(bi1, tx1, tx2);
+                    fillTextArea(bi2, tx2, tx1);
+                    checkColors(bi1, bi2);
+                }
+            }
+        }
+        System.out.println("Passed");
+    }
+
+    /**
+     * Compares two images.
+     */
+    private static void compareImage(final BufferedImage bi1,
+                                     final BufferedImage bi2)
+            throws IOException {
+        for (int i = 0; i < SIZE; ++i) {
+            for (int j = 0; j < SIZE; ++j) {
+                if (bi1.getRGB(i, j) != bi2.getRGB(i, j)) {
+                    ImageIO.write(bi1, "png", new File("image1.png"));
+                    ImageIO.write(bi2, "png", new File("image2.png"));
+                    throw new RuntimeException("Failed: wrong text location");
+                }
+            }
+        }
+    }
+
+    /**
+     * Checks an image color. RED and GREEN are allowed only.
+     */
+    private static void checkColors(final BufferedImage bi1,
+                                    final BufferedImage bi2)
+            throws IOException {
+        for (int i = 0; i < SIZE; ++i) {
+            for (int j = 0; j < SIZE; ++j) {
+                final int rgb1 = bi1.getRGB(i, j);
+                final int rgb2 = bi2.getRGB(i, j);
+                if (rgb1 != rgb2 || rgb1 != 0xFFFF0000 && rgb1 != 0xFF00FF00) {
+                    ImageIO.write(bi1, "png", new File("image1.png"));
+                    ImageIO.write(bi2, "png", new File("image2.png"));
+                    throw new RuntimeException("Failed: wrong text location");
+                }
+            }
+        }
+    }
+
+    /**
+     * Creates an BufferedImage and draws a text, using two transformations,
+     * one for graphics and one for font.
+     */
+    private static BufferedImage createImage(final boolean aa,
+                                             final AffineTransform gtx,
+                                             final AffineTransform ftx) {
+        final BufferedImage bi = new BufferedImage(SIZE, SIZE, TYPE_INT_RGB);
+        final Graphics2D bg = bi.createGraphics();
+        bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+                            aa ? RenderingHints.VALUE_ANTIALIAS_ON
+                               : RenderingHints.VALUE_ANTIALIAS_OFF);
+        bg.setColor(Color.RED);
+        bg.fillRect(0, 0, SIZE, SIZE);
+        bg.translate(100, 100);
+        bg.transform(gtx);
+        bg.setColor(Color.BLACK);
+        bg.setFont(bg.getFont().deriveFont(20.0f).deriveFont(ftx));
+        bg.drawString(STR, 0, 0);
+        bg.dispose();
+        return bi;
+    }
+
+    /**
+     * Fills the area of text using green solid color.
+     */
+    private static void fillTextArea(final BufferedImage bi,
+                                     final AffineTransform tx1,
+                                     final AffineTransform tx2) {
+        final Graphics2D bg = bi.createGraphics();
+        bg.translate(100, 100);
+        bg.transform(tx1);
+        bg.transform(tx2);
+        bg.setColor(Color.GREEN);
+        final Font font = bg.getFont().deriveFont(20.0f);
+        bg.setFont(font);
+        bg.fill(font.getStringBounds(STR, bg.getFontRenderContext()));
+        bg.dispose();
+    }
+}
+
--- a/jdk/test/java/awt/GraphicsEnvironment/TestDetectHeadless/TestDetectHeadless.sh	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/java/awt/GraphicsEnvironment/TestDetectHeadless/TestDetectHeadless.sh	Wed Jul 05 20:13:05 2017 +0200
@@ -28,7 +28,7 @@
 #
 
 # @test
-# @bug 8058930
+# @bug 8058930 7077826
 # @summary java.awt.GraphicsEnvironment.getHeadlessProperty() does not work for AIX
 #
 # @build TestDetectHeadless
@@ -36,7 +36,7 @@
 
 OS=`uname -s`
 case "$OS" in
-    Windows* | CYGWIN* )
+    Windows* | CYGWIN* | Darwin)
         echo "Passed"; exit 0 ;;
     * ) unset DISPLAY ;;
 esac
@@ -44,4 +44,14 @@
 ${TESTJAVA}/bin/java ${TESTVMOPTS} \
     -cp ${TESTCLASSES} TestDetectHeadless
 
+if [ $? -ne 0 ]; then
+	exit 1;
+fi
+
+DISPLAY=
+export DISPLAY
+
+${TESTJAVA}/bin/java ${TESTVMOPTS} \
+    -cp ${TESTCLASSES} TestDetectHeadless
+
 exit $?
--- a/jdk/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.sh	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.sh	Wed Jul 05 20:13:05 2017 +0200
@@ -1,4 +1,4 @@
-# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -21,23 +21,15 @@
 
 ${TESTJAVA}/bin/javac -cp ${TESTSRC} -d . ${TESTSRC}/BadDisplayTest.java
 
-
-DISPLAY=
-export DISPLAY
-
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    ${TESTJAVA}/bin/java ${TESTVMOPTS} BadDisplayTest
-    ;;
-  Linux )
-    ${TESTJAVA}/bin/java ${TESTVMOPTS} BadDisplayTest
-     ;;
-  * )
-    echo "Unsupported System: ${OS}"
-    exit 0;
-    ;;
+    Windows* | CYGWIN* | Darwin)
+        echo "Passed"; exit 0 ;;
 esac
 
+DISPLAY=SomeBadDisplay
+export DISPLAY
+
+${TESTJAVA}/bin/java ${TESTVMOPTS} BadDisplayTest
+
 exit $?
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/MultiResolutionImage/MultiResolutionImageObserverTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.awt.image.BufferedImage;
+import java.awt.image.ImageObserver;
+import static java.awt.image.ImageObserver.*;
+import java.io.File;
+import javax.imageio.ImageIO;
+/*
+ * @test
+ * @bug 8065627
+ * @summary Animated GIFs fail to display on a HiDPI display
+ * @author Alexander Scherbatiy
+ * @run main MultiResolutionImageObserverTest
+ */
+
+public class MultiResolutionImageObserverTest {
+
+    private static final int TIMEOUT = 500;
+
+    public static void main(String[] args) throws Exception {
+
+        generateImages();
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
+        Image image = Toolkit.getDefaultToolkit().getImage(IMAGE_NAME_1X);
+
+        LoadImageObserver sizeObserver
+                = new LoadImageObserver(WIDTH | HEIGHT);
+        toolkit.prepareImage(image, -1, -1, sizeObserver);
+        waitForImageLoading(sizeObserver, "The first observer is not called");
+
+        LoadImageObserver bitsObserver
+                = new LoadImageObserver(SOMEBITS | FRAMEBITS | ALLBITS);
+
+        BufferedImage buffImage = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
+        Graphics2D g2d = (Graphics2D) buffImage.createGraphics();
+        g2d.scale(2, 2);
+        g2d.drawImage(image, 0, 0, bitsObserver);
+        waitForImageLoading(bitsObserver, "The second observer is not called!");
+        g2d.dispose();
+    }
+
+    private static void waitForImageLoading(LoadImageObserver observer,
+            String errorMessage) throws Exception {
+
+        long endTime = System.currentTimeMillis() + TIMEOUT;
+
+        while (!observer.loaded && System.currentTimeMillis() < endTime) {
+            Thread.sleep(TIMEOUT / 10);
+        }
+
+        if (!observer.loaded) {
+            throw new RuntimeException(errorMessage);
+        }
+    }
+
+    private static final String IMAGE_NAME_1X = "image.png";
+    private static final String IMAGE_NAME_2X = "image@2x.png";
+
+    private static void generateImages() throws Exception {
+        generateImage(1);
+        generateImage(2);
+    }
+
+    private static void generateImage(int scale) throws Exception {
+        BufferedImage image = new BufferedImage(
+                scale * 200, scale * 300,
+                BufferedImage.TYPE_INT_RGB);
+        Graphics g = image.createGraphics();
+        g.setColor(scale == 1 ? Color.GREEN : Color.BLUE);
+        g.fillRect(0, 0, scale * 200, scale * 300);
+        File file = new File(scale == 1 ? IMAGE_NAME_1X : IMAGE_NAME_2X);
+        ImageIO.write(image, "png", file);
+        g.dispose();
+    }
+
+    private static class LoadImageObserver implements ImageObserver {
+
+        private final int infoflags;
+        private boolean loaded;
+
+        public LoadImageObserver(int flags) {
+            this.infoflags = flags;
+        }
+
+        @Override
+        public boolean imageUpdate(Image img, int flags, int x, int y, int width, int height) {
+
+            if ((flags & infoflags) != 0) {
+                loaded = true;
+            }
+
+            return !loaded;
+        }
+    }
+}
--- a/jdk/test/java/lang/ClassLoader/EndorsedDirs.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/java/lang/ClassLoader/EndorsedDirs.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,25 +23,48 @@
 
 /*
  * @test
- * @bug 8060206
+ * @bug 8060206 8067366
  * @summary Endorsed standards and override mechanism is removed
  */
 
 import java.io.*;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 public class EndorsedDirs {
-    public static void main(String arg[]) throws Exception {
+    private static String[] VALUES = new String[] {
+            null,
+            "",
+            "\"\""
+    };
+    public static void main(String... args) throws Exception {
         String value = System.getProperty("java.endorsed.dirs");
+        System.out.format("java.endorsed.dirs = '%s'%n", value);
+        if (args.length > 0) {
+            int index = Integer.valueOf(args[0]);
+            String expectedValue = VALUES[index];
+            if (!(expectedValue == value ||
+                    (value != null && value.isEmpty()) ||
+                    (expectedValue != null & expectedValue.equals(value)))) {
+                throw new RuntimeException("java.endorsed.dirs (" +
+                        value + ") != " + expectedValue);
+            }
+            // launched by subprocess.
+            return;
+        }
+
         if (value != null) {
             throw new RuntimeException("java.endorsed.dirs not removed: " + value);
         }
 
-        fatalError("-Djava.endorsed.dirs=foo");
+        fatalError(0, "-Djava.endorsed.dirs=foo");
+        start(0);
+        start(1, "-Djava.endorsed.dirs=");
+        start(2, "-Djava.endorsed.dirs=\"\"");
     }
 
-    static void fatalError(String... args) throws Exception {
+    static ProcessBuilder newProcessBuilder(int testParam, String... args) throws Exception {
         List<String> commands = new ArrayList<>();
         String java = System.getProperty("java.home") + "/bin/java";
         commands.add(java);
@@ -52,9 +75,22 @@
         commands.add("-cp");
         commands.add(cpath);
         commands.add("EndorsedDirs");
+        commands.add(String.valueOf(testParam));
 
-        ProcessBuilder processBuilder = new ProcessBuilder(commands);
-        final Process process = processBuilder.start();
+        System.out.println("Testing " + commands.stream().collect(Collectors.joining(" ")));
+        return new ProcessBuilder(commands);
+    }
+
+    static void start(int testParam, String... args) throws Exception {
+        start(newProcessBuilder(testParam, args), false);
+    }
+
+    static void fatalError(int testParam, String... args) throws Exception {
+        start(newProcessBuilder(testParam, args), true);
+    }
+
+    static void start(ProcessBuilder pb, boolean fatalError) throws Exception {
+        final Process process = pb.start();
         BufferedReader errorStream = new BufferedReader(
                 new InputStreamReader(process.getErrorStream()));
         BufferedReader outStream = new BufferedReader(
@@ -72,11 +108,15 @@
         System.err.println(errorLine);
         process.waitFor(1000, TimeUnit.MILLISECONDS);
         int exitStatus = process.exitValue();
-        if (exitStatus == 0) {
-            throw new RuntimeException("Expect fatal error");
-        }
-        if (!errorLine.contains("Could not create the Java Virtual Machine")) {
-            throw new RuntimeException(errorLine);
+        if (fatalError) {
+            if (exitStatus == 0) {
+                throw new RuntimeException("Expected fatal error");
+            }
+            if (!errorLine.contains("Could not create the Java Virtual Machine")) {
+                throw new RuntimeException(errorLine);
+            }
+        } else if (exitStatus != 0) {
+            throw new RuntimeException("Failed: " + errorLine);
         }
     }
 }
--- a/jdk/test/java/lang/ClassLoader/ExtDirs.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/java/lang/ClassLoader/ExtDirs.java	Wed Jul 05 20:13:05 2017 +0200
@@ -23,25 +23,49 @@
 
 /*
  * @test
- * @bug 8060206
+ * @bug 8060206 8067366
  * @summary Extension mechanism is removed
  */
 
 import java.io.*;
+import java.lang.Integer;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 public class ExtDirs {
-    public static void main(String arg[]) throws Exception {
+    private static String[] VALUES = new String[] {
+            null,
+            "",
+            "\"\""
+    };
+    public static void main(String... args) throws Exception {
         String value = System.getProperty("java.ext.dirs");
+        System.out.format("java.ext.dirs = '%s'%n", value);
+        if (args.length > 0) {
+            int index = Integer.valueOf(args[0]);
+            String expectedValue = VALUES[index];
+            if (!(expectedValue == value ||
+                    (value != null && value.isEmpty()) ||
+                    (expectedValue != null & expectedValue.equals(value)))) {
+                throw new RuntimeException("java.ext.dirs (" +
+                        value + ") != " + expectedValue);
+            }
+            // launched by subprocess.
+            return;
+        }
+
         if (value != null) {
             throw new RuntimeException("java.ext.dirs not removed: " + value);
         }
 
-        fatalError("-Djava.ext.dirs=foo");
+        fatalError(0, "-Djava.ext.dirs=foo");
+        start(0);
+        start(1, "-Djava.ext.dirs=");
+        start(2, "-Djava.ext.dirs=\"\"");
     }
 
-    static void fatalError(String... args) throws Exception {
+    static ProcessBuilder newProcessBuilder(int testParam, String... args) throws Exception {
         List<String> commands = new ArrayList<>();
         String java = System.getProperty("java.home") + "/bin/java";
         commands.add(java);
@@ -52,9 +76,22 @@
         commands.add("-cp");
         commands.add(cpath);
         commands.add("ExtDirs");
+        commands.add(String.valueOf(testParam));
 
-        ProcessBuilder processBuilder = new ProcessBuilder(commands);
-        final Process process = processBuilder.start();
+        System.out.println("Testing " + commands.stream().collect(Collectors.joining(" ")));
+        return new ProcessBuilder(commands);
+    }
+
+    static void start(int testParam, String... args) throws Exception {
+        start(newProcessBuilder(testParam, args), false);
+    }
+
+    static void fatalError(int testParam, String... args) throws Exception {
+        start(newProcessBuilder(testParam, args), true);
+    }
+
+    static void start(ProcessBuilder pb, boolean fatalError) throws Exception {
+        final Process process = pb.start();
         BufferedReader errorStream = new BufferedReader(
                 new InputStreamReader(process.getErrorStream()));
         BufferedReader outStream = new BufferedReader(
@@ -72,11 +109,15 @@
         System.err.println(errorLine);
         process.waitFor(1000, TimeUnit.MILLISECONDS);
         int exitStatus = process.exitValue();
-        if (exitStatus == 0) {
-            throw new RuntimeException("Expect fatal error");
-        }
-        if (!errorLine.contains("Could not create the Java Virtual Machine")) {
-            throw new RuntimeException(errorLine);
+        if (fatalError) {
+            if (exitStatus == 0) {
+                throw new RuntimeException("Expected fatal error");
+            }
+            if (!errorLine.contains("Could not create the Java Virtual Machine")) {
+                throw new RuntimeException(errorLine);
+            }
+        } else if (exitStatus != 0) {
+            throw new RuntimeException("Failed: " + errorLine);
         }
     }
 }
--- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,11 +35,13 @@
  * @run main/timeout=600 LowMemoryTest
  */
 
+import com.sun.management.DiagnosticCommandMBean;
 import java.lang.management.*;
 import java.util.*;
 import java.util.concurrent.Phaser;
 import javax.management.*;
 import javax.management.openmbean.CompositeData;
+import sun.management.ManagementFactoryHelper;
 
 public class LowMemoryTest {
     private static final MemoryMXBean mm = ManagementFactory.getMemoryMXBean();
@@ -94,9 +96,15 @@
     }
 
     static class TestListener implements NotificationListener {
+        private boolean isRelaxed = false;
         private int triggers = 0;
         private final long[] count = new long[NUM_TRIGGERS * 2];
         private final long[] usedMemory = new long[NUM_TRIGGERS * 2];
+
+        public TestListener() {
+            isRelaxed = ManagementFactory.getRuntimeMXBean().getInputArguments().contains("-XX:+UseConcMarkSweepGC");
+        }
+
         @Override
         public void handleNotification(Notification notif, Object handback) {
             MemoryNotificationInfo minfo = MemoryNotificationInfo.
@@ -106,7 +114,8 @@
             triggers++;
         }
         public void checkResult() throws Exception {
-            if (triggers != NUM_TRIGGERS) {
+            if ((!isRelaxed && triggers != NUM_TRIGGERS) ||
+                (isRelaxed && triggers < NUM_TRIGGERS)) {
                 throw new RuntimeException("Unexpected number of triggers = " +
                     triggers + " but expected to be " + NUM_TRIGGERS);
             }
--- a/jdk/test/java/net/ResponseCache/ResponseCacheTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/java/net/ResponseCache/ResponseCacheTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
 import java.net.*;
 import java.util.*;
 import java.io.*;
-import sun.net.www.ParseUtil;
 import javax.net.ssl.*;
 
 /**
@@ -178,11 +177,16 @@
     }
 
     static class MyResponseCache extends ResponseCache {
-        public CacheResponse
-        get(URI uri, String rqstMethod, Map<String,List<String>> rqstHeaders)
-            throws IOException {
-            if (uri.equals(ParseUtil.toURI(url1))) {
-                return new MyCacheResponse(FNPrefix+"file1.cache");
+        public CacheResponse get(URI uri, String rqstMethod,
+                                 Map<String,List<String>> rqstHeaders)
+            throws IOException
+        {
+            try {
+                if (uri.equals(url1.toURI())) {
+                    return new MyCacheResponse(FNPrefix+"file1.cache");
+                }
+            } catch (URISyntaxException ex) {
+                throw new RuntimeException (ex);
             }
             return null;
         }
--- a/jdk/test/java/security/KeyStore/PKCS12/ReadP12Test.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/java/security/KeyStore/PKCS12/ReadP12Test.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003,2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,8 +65,7 @@
 
 public class ReadP12Test {
 
-    private final static String IN_KETYSTORE_TYPE = "pkcs12";
-    private final static String IN_KEYSTORE_PRV = "SunJSSE";
+    private final static String IN_KEYSTORE_TYPE = "pkcs12";
     private final static String IN_STORE_PASS = "pass";
 
     public static void main(String args[]) throws Exception {
@@ -124,8 +123,7 @@
         String dir = System.getProperty("test.src", ".");
         String keystorePath = dir + File.separator + "certs" + File.separator
                 + "readP12";
-        inputKeyStore = KeyStore
-                .getInstance(IN_KETYSTORE_TYPE, IN_KEYSTORE_PRV);
+        inputKeyStore = KeyStore.getInstance(IN_KEYSTORE_TYPE);
         // KeyStore have encoded by Base64.getMimeEncoder().encode(),need decode
         // first.
         byte[] input = Files.readAllBytes(Paths.get(keystorePath, inKeyStore));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/KeyStore/ProbeKeystores.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8044445
+ * @summary test new methods from JEP-229: Create PKCS12 Keystores by Default
+ */
+
+import java.io.*;
+import java.security.*;
+import java.security.KeyStore.*;
+import java.security.cert.*;
+import javax.crypto.*;
+import javax.security.auth.callback.*;
+
+public class ProbeKeystores {
+    private static final char[] PASSWORD = "changeit".toCharArray();
+    private static final char[] BAD_PASSWORD = "badpasword".toCharArray();
+    private static final String DIR = System.getProperty("test.src", ".");
+    private static final String CERT_FILE = "trusted.pem";
+
+    public static final void main(String[] args) throws Exception {
+        try {
+            test();
+        } finally {
+            cleanup();
+        }
+    }
+
+    private static final void test() throws Exception {
+        cleanup();
+
+        // Testing empty keystores
+
+        init("empty.jks", "JKS");
+        init("empty.jceks", "JCEKS");
+        init("empty.p12", "PKCS12");
+
+        load("empty.jks", "JKS");
+        load("empty.jceks", "JCEKS");
+        load("empty.p12", "PKCS12");
+        load("empty.jks", "PKCS12"); // test compatibility mode
+        load("empty.p12", "JKS"); // test compatibility mode
+        load("empty.jks", "PKCS12", true); // test without compatibility mode
+        load("empty.jks", "JKS", false); // test without compatibility mode
+        load("empty.p12", "JKS", true); // test without compatibility mode
+        load("empty.p12", "PKCS12", false); // test without compatibility mode
+
+        probe("empty.jks", "JKS");
+        probe("empty.jceks", "JCEKS");
+        probe("empty.p12", "PKCS12");
+
+        build("empty.jks", "JKS", true);
+        build("empty.jks", "JKS", false);
+        build("empty.jceks", "JCEKS", true);
+        build("empty.jceks", "JCEKS", false);
+        build("empty.p12", "PKCS12", true);
+        build("empty.p12", "PKCS12", false);
+
+        // Testing keystores containing an X.509 certificate
+
+        X509Certificate cert = loadCertificate(CERT_FILE);
+        init("onecert.jks", "JKS", cert);
+        init("onecert.jceks", "JCEKS", cert);
+        init("onecert.p12", "PKCS12", cert);
+
+        load("onecert.jks", "JKS");
+        load("onecert.jceks", "JCEKS");
+        load("onecert.p12", "PKCS12");
+        load("onecert.jks", "PKCS12"); // test compatibility mode
+        load("onecert.p12", "JKS"); // test compatibility mode
+        load("onecert.jks", "PKCS12", true); // test without compatibility mode
+        load("onecert.jks", "JKS", false); // test without compatibility mode
+        load("onecert.p12", "JKS", true); // test without compatibility mode
+        load("onecert.p12", "PKCS12", false); // test without compatibility mode
+
+        probe("onecert.jks", "JKS");
+        probe("onecert.jceks", "JCEKS");
+        probe("onecert.p12", "PKCS12");
+
+        build("onecert.jks", "JKS", true);
+        build("onecert.jks", "JKS", false);
+        build("onecert.jceks", "JCEKS", true);
+        build("onecert.jceks", "JCEKS", false);
+        build("onecert.p12", "PKCS12", true);
+        build("onecert.p12", "PKCS12", false);
+
+        // Testing keystores containing a secret key
+
+        SecretKey key = generateSecretKey("AES", 128);
+        init("onekey.jceks", "JCEKS", key);
+        init("onekey.p12", "PKCS12", key);
+
+        load("onekey.jceks", "JCEKS");
+        load("onekey.p12", "PKCS12");
+        load("onekey.p12", "JKS"); // test compatibility mode
+        load("onekey.p12", "JKS", true); // test without compatibility mode
+        load("onekey.p12", "PKCS12", false); // test without compatibility mode
+
+        probe("onekey.jceks", "JCEKS");
+        probe("onekey.p12", "PKCS12");
+
+        build("onekey.jceks", "JCEKS", true);
+        build("onekey.jceks", "JCEKS", false);
+        build("onekey.p12", "PKCS12", true);
+        build("onekey.p12", "PKCS12", false);
+
+        System.out.println("OK.");
+    }
+
+    private static void cleanup() {
+        new File("empty.jks").delete();
+        new File("empty.jceks").delete();
+        new File("empty.p12").delete();
+        new File("onecert.jks").delete();
+        new File("onecert.jceks").delete();
+        new File("onecert.p12").delete();
+        new File("onekey.jceks").delete();
+        new File("onekey.p12").delete();
+    }
+
+    // Instantiate an empty keystore using the supplied keystore type
+    private static void init(String file, String type) throws Exception {
+        KeyStore ks = KeyStore.getInstance(type);
+        ks.load(null, null);
+        try (OutputStream stream = new FileOutputStream(DIR + "/" + file)) {
+            ks.store(stream, PASSWORD);
+        }
+        System.out.println("Created a " + type + " keystore named '" + file + "'");
+    }
+
+    // Instantiate a keystore using the supplied keystore type & create an entry
+    private static void init(String file, String type, X509Certificate cert)
+        throws Exception {
+        KeyStore ks = KeyStore.getInstance(type);
+        ks.load(null, null);
+        ks.setEntry("mycert", new KeyStore.TrustedCertificateEntry(cert), null);
+        try (OutputStream stream = new FileOutputStream(DIR + "/" + file)) {
+            ks.store(stream, PASSWORD);
+        }
+        System.out.println("Created a " + type + " keystore named '" + file + "'");
+    }
+
+    // Instantiate a keystore using the supplied keystore type & create an entry
+    private static void init(String file, String type, SecretKey key)
+        throws Exception {
+        KeyStore ks = KeyStore.getInstance(type);
+        ks.load(null, null);
+        ks.setEntry("mykey", new KeyStore.SecretKeyEntry(key),
+            new PasswordProtection(PASSWORD));
+        try (OutputStream stream = new FileOutputStream(DIR + "/" + file)) {
+            ks.store(stream, PASSWORD);
+        }
+        System.out.println("Created a " + type + " keystore named '" + file + "'");
+    }
+
+    // Instantiate a keystore by probing the supplied file for the keystore type
+    private static void probe(String file, String type) throws Exception {
+        // First try with the correct password
+        KeyStore ks = KeyStore.getInstance(new File(DIR, file), PASSWORD);
+        if (!type.equalsIgnoreCase(ks.getType())) {
+            throw new Exception("ERROR: expected a " + type + " keystore, " +
+                "got a " + ks.getType() + " keystore instead");
+        } else {
+            System.out.println("Probed a " + type + " keystore named '" + file + "'");
+        }
+
+        // Next try with an incorrect password
+        try {
+            ks = KeyStore.getInstance(new File(DIR, file), BAD_PASSWORD);
+            throw new Exception("ERROR: expected an exception but got success");
+        } catch (IOException e) {
+            System.out.println("Failed to load a " + type + " keystore named '" + file + "' (as expected)");
+        }
+    }
+
+    // Instantiate a keystore by probing the supplied file for the keystore type
+    private static void build(String file, String type, boolean usePassword)
+        throws Exception {
+
+        Builder builder;
+        if (usePassword) {
+            builder = Builder.newInstance(new File(DIR, file),
+                new PasswordProtection(PASSWORD));
+        } else {
+            builder = Builder.newInstance(new File(DIR, file),
+                new CallbackHandlerProtection(new DummyHandler()));
+        }
+        KeyStore ks = builder.getKeyStore();
+        if (!type.equalsIgnoreCase(ks.getType())) {
+            throw new Exception("ERROR: expected a " + type + " keystore, " +
+                "got a " + ks.getType() + " keystore instead");
+        } else {
+            System.out.println("Built a " + type + " keystore named '" + file + "'");
+        }
+    }
+
+    // Load the keystore entries
+    private static void load(String file, String type) throws Exception {
+        KeyStore ks = KeyStore.getInstance(type);
+        try (InputStream stream = new FileInputStream(DIR + "/" + file)) {
+            ks.load(stream, PASSWORD);
+        }
+        if (!type.equalsIgnoreCase(ks.getType())) {
+            throw new Exception("ERROR: expected a " + type + " keystore, " +
+                "got a " + ks.getType() + " keystore instead");
+        } else {
+            System.out.println("Loaded a " + type + " keystore named '" + file + "'");
+        }
+    }
+
+    // Load the keystore entries (with compatibility mode disabled)
+    private static void load(String file, String type, boolean expectFailure)
+        throws Exception {
+        Security.setProperty("keystore.type.compat", "false");
+        try {
+            load(file, type);
+            if (expectFailure) {
+                throw new Exception("ERROR: expected load to fail but it didn't");
+            }
+        } catch (IOException e) {
+            if (expectFailure) {
+                System.out.println("Failed to load a " + type + " keystore named '" + file + "' (as expected)");
+            } else {
+                throw e;
+            }
+        } finally {
+            Security.setProperty("keystore.type.compat", "true");
+        }
+    }
+
+    // Read an X.509 certificate from the supplied file
+    private static X509Certificate loadCertificate(String certFile)
+        throws Exception {
+        X509Certificate cert = null;
+        try (FileInputStream certStream =
+            new FileInputStream(DIR + "/" + certFile)) {
+            CertificateFactory factory =
+                CertificateFactory.getInstance("X.509");
+            return (X509Certificate) factory.generateCertificate(certStream);
+        }
+    }
+
+    // Generate a secret key using the supplied algorithm name and key size
+    private static SecretKey generateSecretKey(String algorithm, int size)
+        throws NoSuchAlgorithmException {
+        KeyGenerator generator = KeyGenerator.getInstance(algorithm);
+        generator.init(size);
+        return generator.generateKey();
+    }
+
+    private static class DummyHandler implements CallbackHandler {
+        public void handle(Callback[] callbacks)
+            throws IOException, UnsupportedCallbackException {
+            System.out.println("** Callbackhandler invoked");
+            for (int i = 0; i < callbacks.length; i++) {
+                Callback cb = callbacks[i];
+                if (cb instanceof PasswordCallback) {
+                    PasswordCallback pcb = (PasswordCallback)cb;
+                    pcb.setPassword(PASSWORD);
+                    break;
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/KeyStore/trusted.pem	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,29 @@
+-----BEGIN CERTIFICATE-----
+MIIF5DCCBMygAwIBAgIQGVCD3zqdD1ZMZZ/zLAPnQzANBgkqhkiG9w0BAQUFADCBvDELMAkGA1UE
+BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
+ZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2UgYXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29t
+L3JwYSAoYykxMDE2MDQGA1UEAxMtVmVyaVNpZ24gQ2xhc3MgMyBJbnRlcm5hdGlvbmFsIFNlcnZl
+ciBDQSAtIEczMB4XDTEyMDcxMDAwMDAwMFoXDTEzMDczMTIzNTk1OVowgbgxCzAJBgNVBAYTAlVT
+MRMwEQYDVQQIEwpDYWxpZm9ybmlhMRcwFQYDVQQHFA5SZWR3b29kIFNob3JlczEbMBkGA1UEChQS
+T3JhY2xlIENvcnBvcmF0aW9uMRIwEAYDVQQLFAlHbG9iYWwgSVQxMzAxBgNVBAsUKlRlcm1zIG9m
+IHVzZSBhdCB3d3cudmVyaXNpZ24uY29tL3JwYSAoYykwNTEVMBMGA1UEAxQMKi5vcmFjbGUuY29t
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz/dOCGrWzPj62q0ZkF59Oj9Fli4wHAuX
+U4/S0yBXF8j6K7TKWFTQkGZt3+08KUhmLm1CE1DbbyRJT292YNXYXunNaKdABob8kaBO/NESUOEJ
+0SZh7fd0xCSJAAPiwOMrM5jLeb/dEpU6nP74Afrhu5ffvKdcvTRGguj9H2oVsisTK8Z1HsiiwcJG
+JXcrjvdCZoPU4FHvK03XZPAqPHKNSaJOrux6kRIWYjQMlmL+qDOb0nNHa6gBdi+VqqJHJHeAM677
+dcUd0jn2m2OWtUnrM3MJZQof7/z27RTdX5J8np0ChkUgm63biDgRZO7uZP0DARQ0I6lZMlrarT8/
+sct3twIDAQABo4IB4jCCAd4wFwYDVR0RBBAwDoIMKi5vcmFjbGUuY29tMAkGA1UdEwQCMAAwCwYD
+VR0PBAQDAgWgMEQGA1UdIAQ9MDswOQYLYIZIAYb4RQEHFwMwKjAoBggrBgEFBQcCARYcaHR0cHM6
+Ly93d3cudmVyaXNpZ24uY29tL3JwYTAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwbgYI
+KwYBBQUHAQwEYjBgoV6gXDBaMFgwVhYJaW1hZ2UvZ2lmMCEwHzAHBgUrDgMCGgQUS2u5KJYGDLvQ
+UjibKaxLB4shBRgwJhYkaHR0cDovL2xvZ28udmVyaXNpZ24uY29tL3ZzbG9nbzEuZ2lmMHIGCCsG
+AQUFBwEBBGYwZDAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AudmVyaXNpZ24uY29tMDwGCCsGAQUF
+BzAChjBodHRwOi8vc3ZyaW50bC1nMy1haWEudmVyaXNpZ24uY29tL1NWUkludGxHMy5jZXIwQQYD
+VR0fBDowODA2oDSgMoYwaHR0cDovL3N2cmludGwtZzMtY3JsLnZlcmlzaWduLmNvbS9TVlJJbnRs
+RzMuY3JsMB8GA1UdIwQYMBaAFNebfNgioBX33a1fzimbWMO8RgC1MA0GCSqGSIb3DQEBBQUAA4IB
+AQAITRBlEo+qXLwCL53Db2BGnhDgnSomjne8aCmU7Yt4Kp91tzJdhNuaC/wwDuzD2dPJqzemae3s
+wKiOXrmDQZDj9NNTdkrXHnCvDR4TpOynWe3zBa0bwKnV2cIRKcv482yV53u0kALyFZbagYPwOOz3
+YJA/2SqdcDn9Ztc/ABQ1SkyXyA5j4LJdf2g7BtYrFxjy0RG6We2iM781WSB/9MCNKyHgiwd3KpLf
+urdSKLzy1elNAyt1P3UHwBIIvZ6sJIr/eeELc54Lxt6PtQCXx8qwxYTYXWPXbLgKBHdebgrmAbPK
+TfD69wysvjk6vwSHjmvaqB4R4WRcgkuT+1gxx+ve
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/smartcardio/CommandAPDUTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8049021
+ * @summary Test different constructors for CommandAPDU and check CLA,INS,NC,NE,
+ * P1,and P2
+ * @run testng CommandAPDUTest
+ */
+import java.nio.ByteBuffer;
+import javax.smartcardio.CommandAPDU;
+import static org.testng.Assert.*;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+public class CommandAPDUTest {
+
+    static final byte[] C1 = {(byte) 0x00, (byte) 0xA4, (byte) 0x04,
+        (byte) 0x00, (byte) 0x07, (byte) 0xA0, (byte) 0x00, (byte) 0x00,
+        (byte) 0x00, (byte) 0x62, (byte) 0x81, (byte) 0x01, (byte) 0x00};
+    static int cla, ins, nc, ne, p1, p2;
+    static byte[] apdu, data;
+    static CommandAPDU cm1, cm2, cm3, cm4, cm5, cm6, cm7, cm8, cm9;
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+        //expected values of apdu, data, headers, nc, ne
+        CommandAPDU capdu = new CommandAPDU(C1);
+        apdu = capdu.getBytes();
+        data = capdu.getData();
+
+        cla = capdu.getCLA();
+        if (cla != (C1[0] & 0xff)) {
+            throw new RuntimeException("Failure: cla is not right");
+        }
+
+        ins = capdu.getINS();
+        if (ins != (C1[1] & 0xff)) {
+            throw new RuntimeException("Failure: ins is not right");
+        }
+
+        p1 = capdu.getP1();
+        if (p1 != (C1[2] & 0xff)) {
+            throw new RuntimeException("Failure: p1 is not right");
+        }
+
+        p2 = capdu.getP2();
+        if (p2 != (C1[3] & 0xff)) {
+            throw new RuntimeException("Failure: p2 is not right");
+        }
+
+        nc = capdu.getNc();
+        ne = capdu.getNe();
+
+        //Test on following constructors
+        cm1 = new CommandAPDU(apdu);
+        cm2 = new CommandAPDU(cla, ins, p1, p2);
+        cm3 = new CommandAPDU(cla, ins, p1, p2, data);
+        cm4 = new CommandAPDU(cla, ins, p1, p2, data, ne);
+        cm5 = new CommandAPDU(cla, ins, p1, p2, ne);
+        cm6 = new CommandAPDU(ByteBuffer.wrap(apdu));
+        cm7 = new CommandAPDU(apdu, 0, apdu.length);
+        cm8 = new CommandAPDU(cla, ins, p1, p2, data, 0, nc);
+        cm9 = new CommandAPDU(cla, ins, p1, p2, data, 0, nc, ne);
+    }
+
+    @Test(dataProvider = "provider1")
+    public static void testHeaders(CommandAPDU cm) {
+        assertEquals(cla, cm.getCLA());
+        assertEquals(ins, cm.getINS());
+        assertEquals(p1, cm.getP1());
+        assertEquals(p2, cm.getP2());
+    }
+
+    @Test(dataProvider = "provider2")
+    public static void testAPDU(CommandAPDU cm) {
+        assertEquals(apdu, cm.getBytes());
+    }
+
+    @Test(dataProvider = "provider3")
+    public static void testData(CommandAPDU cm) {
+        assertEquals(data, cm.getData());
+    }
+
+    @Test(dataProvider = "provider3")
+    public static void testNC(CommandAPDU cm) {
+        assertEquals(nc, cm.getNc());
+    }
+
+    @Test(dataProvider = "provider4")
+    public static void testNE(CommandAPDU cm) {
+        assertEquals(ne, cm.getNe());
+    }
+
+    @DataProvider
+    public Object[][] provider1() {
+        return new Object[][]{{cm1}, {cm2}, {cm3}, {cm4}, {cm5}, {cm6}, {cm7},
+        {cm8}, {cm9}};
+    }
+
+    @DataProvider
+    public Object[][] provider2() {
+        return new Object[][]{{cm1}, {cm6}, {cm7}};
+    }
+
+    @DataProvider
+    public Object[][] provider3() {
+        return new Object[][]{{cm1}, {cm3}, {cm4}, {cm6}, {cm7}, {cm8}, {cm9}};
+    }
+
+    @DataProvider
+    public Object[][] provider4() {
+        return new Object[][]{{cm1}, {cm4}, {cm5}, {cm6}, {cm7}, {cm9}};
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/smartcardio/ResponseAPDUTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8049021
+ * @summary Construct ResponseAPDU from byte array and check NR< SW, SW1 and SW2
+ * @run testng ResponseAPDUTest
+ */
+import javax.smartcardio.ResponseAPDU;
+import static org.testng.Assert.*;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class ResponseAPDUTest {
+
+    static final byte[] R1 = {(byte) 0x07, (byte) 0xA0, (byte) 0x00,
+        (byte) 0x00, (byte) 0x00, (byte) 0x62, (byte) 0x81, (byte) 0x01,
+        (byte) 0x04, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x24,
+        (byte) 0x05, (byte) 0x00, (byte) 0x0B, (byte) 0x04, (byte) 0xB0,
+        (byte) 0x25, (byte) 0x90, (byte) 0x00};
+    static final ResponseAPDU RAPDU = new ResponseAPDU(R1);
+    static byte[] expectedData;
+    static int expectedNr, expectedSw1, expectedSw2, expectedSw;
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+        //expected values for data,nr,sw1,sw2 and sw
+
+        int apduLen = R1.length;
+        expectedData = new byte[apduLen - 2];
+        for (int i = 0; i < (apduLen - 2); i++) {
+            expectedData[i] = R1[i];
+        }
+
+        expectedNr = expectedData.length;
+        expectedSw1 = R1[apduLen - 2] & 0xff;
+        expectedSw2 = R1[apduLen - 1] & 0xff;
+        expectedSw = (expectedSw1 << 8) | expectedSw2;
+    }
+
+    @Test
+    public static void test() {
+        assertEquals(RAPDU.getBytes(), R1);
+        assertEquals(RAPDU.getData(), expectedData);
+        assertEquals(RAPDU.getNr(), expectedNr);
+        assertEquals(RAPDU.getSW(), expectedSw);
+        assertEquals(RAPDU.getSW1(), expectedSw1);
+        assertEquals(RAPDU.getSW2(), expectedSw2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/smartcardio/TerminalFactorySpiTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8049021
+ * @summary Test if we can write new provider for smart card
+ * @run main/othervm/policy=policy TerminalFactorySpiTest
+ */
+import java.security.Provider;
+import java.security.Security;
+import java.util.Arrays;
+import javax.smartcardio.CardTerminals;
+import javax.smartcardio.TerminalFactory;
+import javax.smartcardio.TerminalFactorySpi;
+
+public class TerminalFactorySpiTest {
+
+    static boolean callMethod = false;
+
+    public static void main(String[] args) throws Exception {
+        Provider myProvider = new MyProvider();
+        Security.addProvider(myProvider);
+        System.out.println(Arrays.asList(Security.getProviders()));
+
+        TerminalFactory.getInstance("MyType", new Object()).terminals();
+        if (!callMethod) {
+            throw new RuntimeException("Expected engineTerminals() not called");
+        }
+    }
+
+    public static class MyProvider extends Provider {
+
+        MyProvider() {
+            super("MyProvider", 1.0d, "smart Card Example");
+            put("TerminalFactory.MyType", "TerminalFactorySpiTest$MyTerminalFactorySpi");
+        }
+    }
+
+    public static class MyTerminalFactorySpi extends TerminalFactorySpi {
+
+        public MyTerminalFactorySpi(Object ob) {
+        }
+
+        protected CardTerminals engineTerminals() {
+            System.out.println("MyTerminalFactory.engineTerminals()");
+            callMethod = true;
+            return null;
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/smartcardio/policy	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,4 @@
+grant {
+        permission java.security.SecurityPermission "insertProvider.MyProvider";
+        permission java.security.SecurityPermission "putProviderProperty.MyProvider";
+};
--- a/jdk/test/javax/swing/regtesthelpers/Util.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/javax/swing/regtesthelpers/Util.java	Wed Jul 05 20:13:05 2017 +0200
@@ -253,4 +253,18 @@
         }
         return result;
     }
+
+    /**
+     * Gets key codes from system mnemonic key mask
+     * @return key codes list
+     */
+    public static ArrayList<Integer> getSystemMnemonicKeyCodes() {
+        String osName = System.getProperty("os.name");
+        ArrayList<Integer> result = new ArrayList<>();
+        if (osName.contains("OS X")) {
+            result.add(KeyEvent.VK_CONTROL);
+        }
+        result.add(KeyEvent.ALT_MASK);
+        return result;
+    }
 }
--- a/jdk/test/sun/awt/dnd/8024061/bug8024061.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/sun/awt/dnd/8024061/bug8024061.java	Wed Jul 05 20:13:05 2017 +0200
@@ -277,9 +277,6 @@
                     try {
                         Transferable t = dtde.getTransferable();
                         Object data = t.getTransferData(DropObjectFlavor);
-                        if (data != null) {
-                            throw new Exception("getTransferData returned non-null");
-                        }
                     } catch (Exception e) {
                         dragEnterException = e;
                         e.printStackTrace();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/rmi/rmic/iiopCompilation/IIOPCompilation.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8065957
+ * @library ../../../../java/rmi/testlibrary
+ * @build TestLibrary
+ * @summary Compiles a PortableRemoteObject with rmic -iiop and ensures that stub and tie classes are generated.
+ * @run main IIOPCompilation
+ * @author Felix Yang
+ *
+ */
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.rmi.RemoteException;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.rmi.PortableRemoteObject;
+
+public class IIOPCompilation {
+
+    public static void main(String args[]) throws IOException, InterruptedException {
+        IIOPCompilation test = new IIOPCompilation();
+        test.doTest();
+    }
+
+    private void doTest() throws IOException, InterruptedException {
+        String className = DummyImpl.class.getName();
+        int exitCode = runRmic(className);
+        if (exitCode != 0) {
+            throw new RuntimeException("Rmic failed. The exit code is " + exitCode);
+        }
+
+        // Check the stub class generated correctly
+        String stubFile = "_" + Dummy.class.getName() + "_Stub.class";
+        assertFileExists(stubFile);
+
+        // Check the tie class generated correctly
+        String tieFile = "_" + className + "_Tie.class";
+        assertFileExists(tieFile);
+    }
+
+    private void assertFileExists(String fileName) throws FileNotFoundException {
+        if (!new File(fileName).exists()) {
+            throw new FileNotFoundException(fileName + " doesn't exist!");
+        }
+    }
+
+    private int runRmic(String classname) throws IOException, InterruptedException {
+        String rmicProgramStr = TestLibrary.getProperty("java.home", "") + File.separator + "bin" + File.separator + "rmic";
+        String testClasses = TestLibrary.getProperty("test.classes", "");
+        List<String> command = Arrays.asList(rmicProgramStr, "-iiop", "-classpath", testClasses, classname);
+        System.out.println("Running command: " + command);
+
+        Process p = null;
+        try {
+            p = new ProcessBuilder(command).inheritIO().start();
+            p.waitFor();
+            return p.exitValue();
+        } finally {
+            if (p != null && p.isAlive()) {
+                p.destroy();
+            }
+        }
+    }
+}
+
+interface Dummy extends java.rmi.Remote {
+}
+
+class DummyImpl extends PortableRemoteObject implements Dummy {
+    public DummyImpl() throws RemoteException {
+    }
+}
--- a/jdk/test/sun/security/provider/DSA/TestDSA2.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/sun/security/provider/DSA/TestDSA2.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,7 @@
     public static void main(String[] args) throws Exception {
         boolean[] expectedToPass = { true, true, true };
         test(1024, expectedToPass);
-        boolean[] expectedToPass2 = { false, true, true };
+        boolean[] expectedToPass2 = { true, true, true };
         test(2048, expectedToPass2);
     }
 
--- a/jdk/test/sun/security/tools/jarsigner/DefaultSigalg.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/sun/security/tools/jarsigner/DefaultSigalg.java	Wed Jul 05 20:13:05 2017 +0200
@@ -74,7 +74,7 @@
         KeyStore ks = KeyStore.getInstance("JKS");
         try (FileInputStream jks = new FileInputStream("jks");
                 JarFile jf = new JarFile("a.jar")) {
-            ks.load(jks, null);
+            ks.load(jks, "changeit".toCharArray());
             for (int i = 0; i<keyalgs.length; i++) {
                 String keyalg = keyalgs[i];
                 // keytool
--- a/jdk/test/sun/security/tools/jarsigner/concise_jarsigner.sh	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/sun/security/tools/jarsigner/concise_jarsigner.sh	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -47,12 +47,13 @@
 # Choose 1024-bit RSA to make sure it runs fine and fast on all platforms. In
 # fact, every keyalg/keysize combination is OK for this test.
 
-KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore js.jks -keyalg rsa -keysize 1024"
+KS=js.ks
+KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS -keyalg rsa -keysize 1024"
 JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
 JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
 JAVAC="$TESTJAVA${FS}bin${FS}javac ${TESTTOOLVMOPTS} ${TESTJAVACOPTS}"
 
-rm js.jks
+rm $KS
 
 echo class A1 {} > A1.java
 echo class A2 {} > A2.java
@@ -73,9 +74,9 @@
 
 # a.jar includes 8 unsigned, 2 signed by a1 and a2, 2 signed by a3
 $JAR cvf a.jar A1.class A2.class
-$JARSIGNER -keystore js.jks -storepass changeit a.jar a1
+$JARSIGNER -keystore $KS -storepass changeit a.jar a1
 $JAR uvf a.jar A3.class A4.class
-$JARSIGNER -keystore js.jks -storepass changeit a.jar a2
+$JARSIGNER -keystore $KS -storepass changeit a.jar a2
 $JAR uvf a.jar A5.class A6.class
 
 # Verify OK
@@ -87,15 +88,15 @@
 [ $? = 20 ] || exit $LINENO
 
 # 16(hasUnsignedEntry)
-$JARSIGNER -verify a.jar -strict -keystore js.jks
+$JARSIGNER -verify a.jar -strict -keystore $KS -storepass changeit
 [ $? = 16 ] || exit $LINENO
 
 # 16(hasUnsignedEntry)+32(notSignedByAlias)
-$JARSIGNER -verify a.jar a1 -strict -keystore js.jks
+$JARSIGNER -verify a.jar a1 -strict -keystore $KS -storepass changeit
 [ $? = 48 ] || exit $LINENO
 
 # 16(hasUnsignedEntry)
-$JARSIGNER -verify a.jar a1 a2 -strict -keystore js.jks
+$JARSIGNER -verify a.jar a1 a2 -strict -keystore $KS -storepass changeit
 [ $? = 16 ] || exit $LINENO
 
 # 12 entries all together
@@ -153,25 +154,25 @@
         $KT -importcert -alias badchain
 $KT -delete -alias ca
 
-$JARSIGNER -strict -keystore js.jks -storepass changeit a.jar expired
+$JARSIGNER -strict -keystore $KS -storepass changeit a.jar expired
 [ $? = 4 ] || exit $LINENO
 
-$JARSIGNER -strict -keystore js.jks -storepass changeit a.jar notyetvalid
+$JARSIGNER -strict -keystore $KS -storepass changeit a.jar notyetvalid
 [ $? = 4 ] || exit $LINENO
 
-$JARSIGNER -strict -keystore js.jks -storepass changeit a.jar badku
+$JARSIGNER -strict -keystore $KS -storepass changeit a.jar badku
 [ $? = 8 ] || exit $LINENO
 
-$JARSIGNER -strict -keystore js.jks -storepass changeit a.jar badeku
+$JARSIGNER -strict -keystore $KS -storepass changeit a.jar badeku
 [ $? = 8 ] || exit $LINENO
 
-$JARSIGNER -strict -keystore js.jks -storepass changeit a.jar goodku
+$JARSIGNER -strict -keystore $KS -storepass changeit a.jar goodku
 [ $? = 0 ] || exit $LINENO
 
-$JARSIGNER -strict -keystore js.jks -storepass changeit a.jar goodeku
+$JARSIGNER -strict -keystore $KS -storepass changeit a.jar goodeku
 [ $? = 0 ] || exit $LINENO
 
-$JARSIGNER -strict -keystore js.jks -storepass changeit a.jar badchain
+$JARSIGNER -strict -keystore $KS -storepass changeit a.jar badchain
 [ $? = 4 ] || exit $LINENO
 
 $JARSIGNER -verify a.jar
@@ -189,11 +190,11 @@
 $KT -delete -alias ca2
 
 # Now altchain is still self-signed
-$JARSIGNER -strict -keystore js.jks -storepass changeit a.jar altchain
+$JARSIGNER -strict -keystore $KS -storepass changeit a.jar altchain
 [ $? = 0 ] || exit $LINENO
 
 # If -certchain is used, then it's bad
-$JARSIGNER -strict -keystore js.jks -storepass changeit -certchain certchain a.jar altchain
+$JARSIGNER -strict -keystore $KS -storepass changeit -certchain certchain a.jar altchain
 [ $? = 4 ] || exit $LINENO
 
 $JARSIGNER -verify a.jar
--- a/jdk/test/sun/security/tools/jarsigner/emptymanifest.sh	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/sun/security/tools/jarsigner/emptymanifest.sh	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -44,14 +44,14 @@
     ;;
 esac
 
-KS=emptymanifest.jks
+KS=emptymanifest.ks
 JFILE=em.jar
 
 KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS"
 JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
 JAVA="$TESTJAVA${FS}bin${FS}java ${TESTVMOPTS}"
 JAVAC="$TESTJAVA${FS}bin${FS}javac ${TESTTOOLVMOPTS} ${TESTJAVACOPTS}"
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
+JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -keystore $KS -storepass changeit"
 
 rm $KS $JFILE
 echo A > A
@@ -70,7 +70,7 @@
 
 $KT -alias a -dname CN=a -keyalg rsa -genkey -validity 300
 
-$JARSIGNER -keystore $KS -storepass changeit $JFILE a || exit 1
-$JARSIGNER -keystore $KS -verify -debug -strict $JFILE || exit 2
+$JARSIGNER $JFILE a || exit 1
+$JARSIGNER -verify -debug -strict $JFILE || exit 2
 
 exit 0
--- a/jdk/test/sun/security/tools/jarsigner/nameclash.sh	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/sun/security/tools/jarsigner/nameclash.sh	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2014 Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -42,12 +42,12 @@
     ;;
 esac
 
-KS=nc.jks
+KS=nc.ks
 JFILE=nc.jar
 
 KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS"
 JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
+JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -keystore $KS -storepass changeit"
 
 rm $KS $JFILE
 
@@ -57,10 +57,10 @@
 echo A > A
 $JAR cvf $JFILE A
 
-$JARSIGNER -keystore $KS -storepass changeit $JFILE a -digestalg SHA1 || exit 1
-$JARSIGNER -keystore $KS -storepass changeit $JFILE b -digestalg SHA-1 || exit 2
+$JARSIGNER $JFILE a -digestalg SHA1 || exit 1
+$JARSIGNER $JFILE b -digestalg SHA-1 || exit 2
 
-$JARSIGNER -keystore $KS -verify -debug -strict $JFILE || exit 3
+$JARSIGNER -verify -debug -strict $JFILE || exit 3
 
 exit 0
 
--- a/jdk/test/sun/security/tools/jarsigner/passtype.sh	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/sun/security/tools/jarsigner/passtype.sh	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
     ;;
 esac
 
-KS=pt.jks
+KS=pt.ks
 JFILE=pt.jar
 
 KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -keystore $KS -validity 300 -keyalg rsa"
@@ -62,11 +62,15 @@
 echo A > A
 $JAR cvf $JFILE A
 
+# Sign
 $JARSIGNER -keystore $KS -storepass test12 $JFILE a || exit 4
 PASSENV=test12 $JARSIGNER -keystore $KS -storepass:env PASSENV $JFILE b || exit 5
 $JARSIGNER -keystore $KS -storepass:file passfile $JFILE b || exit 6
 
-$JARSIGNER -keystore $KS -verify -debug -strict $JFILE || exit 7
+# Verify
+$JARSIGNER -keystore $KS -storepass test12 -verify -debug -strict $JFILE || exit 7
+PASSENV=test12 $JARSIGNER -keystore $KS -storepass:env PASSENV -verify -debug -strict $JFILE || exit 8
+$JARSIGNER -keystore $KS -storepass:file passfile -verify -debug -strict $JFILE || exit 9
 
 exit 0
 
--- a/jdk/test/sun/security/tools/keytool/KeyToolTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/sun/security/tools/keytool/KeyToolTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -328,15 +328,15 @@
         // name changes: genkeypair, importcert, exportcert
         remove("x.jks");
         remove("x.jks.p1.cert");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -alias p1 -dname CN=olala");
-        testOK("", "-keystore x.jks -storepass changeit -exportcert -alias p1 -file x.jks.p1.cert");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -alias p1 -dname CN=olala");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -exportcert -alias p1 -file x.jks.p1.cert");
         ks = loadStore("x.jks", "changeit", "JKS");
         assertTrue(ks.getKey("p1", "changeit".toCharArray()) != null,
             "key not DSA");
         assertTrue(new File("x.jks.p1.cert").exists(), "p1 export err");
-        testOK("", "-keystore x.jks -storepass changeit -delete -alias p1");
-        testOK("y\n", "-keystore x.jks -storepass changeit -importcert -alias c1 -file x.jks.p1.cert");  // importcert, prompt for Yes/No
-        testOK("", "-keystore x.jks -storepass changeit -importcert -alias c2 -file x.jks.p1.cert -noprompt"); // importcert, -noprompt
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -delete -alias p1");
+        testOK("y\n", "-keystore x.jks -storetype JKS -storepass changeit -importcert -alias c1 -file x.jks.p1.cert");  // importcert, prompt for Yes/No
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -importcert -alias c2 -file x.jks.p1.cert -noprompt"); // importcert, -noprompt
         ks = loadStore("x.jks", "changeit", "JKS");
         assertTrue(ks.getCertificate("c1") != null, "import c1 err");
 
@@ -346,10 +346,10 @@
         assertTrue(certImpl.getVersion() == 3, "Version is not 3");
 
         // changealias and keyclone
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -alias p1 -dname CN=olala");
-        testOK("changeit\n", "-keystore x.jks -changealias -alias p1 -destalias p11");
-        testOK("changeit\n", "-keystore x.jks -changealias -alias c1 -destalias c11");
-        testOK("changeit\n\n", "-keystore x.jks -keyclone -alias p11 -destalias p111"); // press ENTER when prompt for p111's keypass
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -alias p1 -dname CN=olala");
+        testOK("changeit\n", "-keystore x.jks -storetype JKS -changealias -alias p1 -destalias p11");
+        testOK("changeit\n", "-keystore x.jks -storetype JKS -changealias -alias c1 -destalias c11");
+        testOK("changeit\n\n", "-keystore x.jks -storetype JKS -keyclone -alias p11 -destalias p111"); // press ENTER when prompt for p111's keypass
         ks = loadStore("x.jks", "changeit", "JKS");
         assertTrue(!ks.containsAlias("p1"), "there is no p1");
         assertTrue(!ks.containsAlias("c1"), "there is no c1");
@@ -382,7 +382,7 @@
         assertTrue(!ks.containsAlias("s7"), "s7 not created");
 
         // maybe we needn't test this, one day JKS will support SecretKey
-        //testFail("changeit\nchangeit\n", "-keystore x.jks -genseckey -keyalg AES -alias s3 -keysize 128");
+        //testFail("changeit\nchangeit\n", "-keystore x.jks -storetype JKS -genseckey -keyalg AES -alias s3 -keysize 128");
 
         // importKeyStore
         remove("x.jks");
@@ -479,9 +479,9 @@
 
         // pkcs12
         remove("x.jks");
-        testFail("changeit\nchangeit\n", "-keystore x.jks -genkeypair -alias p1 -dname CN=olala"); // JKS prompt for keypass
+        testFail("changeit\nchangeit\n", "-keystore x.jks -storetype JKS -genkeypair -alias p1 -dname CN=olala"); // JKS prompt for keypass
         remove("x.jks");
-        testOK("changeit\nchangeit\n\n", "-keystore x.jks -genkeypair -alias p1 -dname CN=olala"); // just type ENTER means keypass=storepass
+        testOK("changeit\nchangeit\n\n", "-keystore x.jks -storetype JKS -genkeypair -alias p1 -dname CN=olala"); // just type ENTER means keypass=storepass
         remove("x.p12");
         testOK("", "-keystore x.p12 -storetype PKCS12 -storepass changeit -genkeypair -alias p0 -dname CN=olala"); // PKCS12 only need storepass
         testOK("changeit\n", "-keystore x.p12 -storetype PKCS12 -genkeypair -alias p1 -dname CN=olala");
@@ -616,84 +616,84 @@
     void sqeImportTest() throws Exception {
         KeyStore ks;
         remove("x.jks");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
-        testOK("", "-keystore x.jks -storepass changeit -exportcert -file x.jks.p1.cert");
-        /* deleted */ testOK("", "-keystore x.jks -storepass changeit -delete -alias mykey");
-        testOK("", "-keystore x.jks -storepass changeit -importcert -file x.jks.p1.cert -noprompt");
-        /* deleted */ testOK("", "-keystore x.jks -storepass changeit -delete -alias mykey");
-        testOK("yes\n", "-keystore x.jks -storepass changeit -importcert -file x.jks.p1.cert");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -exportcert -file x.jks.p1.cert");
+        /* deleted */ testOK("", "-keystore x.jks -storetype JKS -storepass changeit -delete -alias mykey");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -importcert -file x.jks.p1.cert -noprompt");
+        /* deleted */ testOK("", "-keystore x.jks -storetype JKS -storepass changeit -delete -alias mykey");
+        testOK("yes\n", "-keystore x.jks -storetype JKS -storepass changeit -importcert -file x.jks.p1.cert");
         ks = loadStore("x.jks", "changeit", "JKS");
         assertTrue(ks.containsAlias("mykey"), "imported");
-        /* deleted */ testOK("", "-keystore x.jks -storepass changeit -delete -alias mykey");
-        testOK("\n", "-keystore x.jks -storepass changeit -importcert -file x.jks.p1.cert");
+        /* deleted */ testOK("", "-keystore x.jks -storetype JKS -storepass changeit -delete -alias mykey");
+        testOK("\n", "-keystore x.jks -storetype JKS -storepass changeit -importcert -file x.jks.p1.cert");
         ks = loadStore("x.jks", "changeit", "JKS");
         assertTrue(!ks.containsAlias("mykey"), "imported");
-        testOK("no\n", "-keystore x.jks -storepass changeit -importcert -file x.jks.p1.cert");
+        testOK("no\n", "-keystore x.jks -storetype JKS -storepass changeit -importcert -file x.jks.p1.cert");
         ks = loadStore("x.jks", "changeit", "JKS");
         assertTrue(!ks.containsAlias("mykey"), "imported");
-        testFail("no\n", "-keystore x.jks -storepass changeit -importcert -file nonexist");
-        testFail("no\n", "-keystore x.jks -storepass changeit -importcert -file x.jks");
+        testFail("no\n", "-keystore x.jks -storetype JKS -storepass changeit -importcert -file nonexist");
+        testFail("no\n", "-keystore x.jks -storetype JKS -storepass changeit -importcert -file x.jks");
         remove("x.jks");
     }
     // keyclone: exist. nonexist err, cert err, dest exist, misc
     void sqeKeyclonetest() throws Exception {
         remove("x.jks");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -new newpass -keyclone -dest p0"); // new pass
-        testOK("\n", "-keystore x.jks -storepass changeit -keypass changeit -keyclone -dest p1"); // new pass
-        testOK("\n", "-keystore x.jks -storepass changeit -keyclone -dest p2");
-        testFail("\n", "-keystore x.jks -storepass changeit -keyclone -dest p2");
-        testFail("\n", "-keystore x.jks -storepass changeit -keyclone -dest p3 -alias noexist");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -new newpass -keyclone -dest p0"); // new pass
+        testOK("\n", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -keyclone -dest p1"); // new pass
+        testOK("\n", "-keystore x.jks -storetype JKS -storepass changeit -keyclone -dest p2");
+        testFail("\n", "-keystore x.jks -storetype JKS -storepass changeit -keyclone -dest p2");
+        testFail("\n", "-keystore x.jks -storetype JKS -storepass changeit -keyclone -dest p3 -alias noexist");
         // no cert
-        testOK("", "-keystore x.jks -storepass changeit -exportcert -file x.jks.p1.cert");
-        testOK("", "-keystore x.jks -storepass changeit -delete -alias mykey");
-        testOK("", "-keystore x.jks -storepass changeit -importcert -file x.jks.p1.cert -noprompt");
-        testFail("", "-keystore x.jks -storepass changeit -keypass changeit -new newpass -keyclone -dest p0"); // new pass
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -exportcert -file x.jks.p1.cert");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -delete -alias mykey");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -importcert -file x.jks.p1.cert -noprompt");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -new newpass -keyclone -dest p0"); // new pass
         remove("x.jks");
     }
     // keypasswd: exist, short, nonexist err, cert err, misc
     void sqeKeypasswdTest() throws Exception {
         remove("x.jks");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -keypasswd -new newpass");
-        /*change back*/ testOK("", "-keystore x.jks -storepass changeit -keypass newpass -keypasswd -new changeit");
-        testOK("newpass\nnewpass\n", "-keystore x.jks -storepass changeit -keypass changeit -keypasswd");
-        /*change back*/ testOK("", "-keystore x.jks -storepass changeit -keypass newpass -keypasswd -new changeit");
-        testOK("new\nnew\nnewpass\nnewpass\n", "-keystore x.jks -storepass changeit -keypass changeit -keypasswd");
-        /*change back*/ testOK("", "-keystore x.jks -storepass changeit -keypass newpass -keypasswd -new changeit");
-        testOK("", "-keystore x.jks -storepass changeit -keypasswd -new newpass");
-        /*change back*/ testOK("", "-keystore x.jks -storepass changeit -keypass newpass -keypasswd -new changeit");
-        testOK("changeit\n", "-keystore x.jks -keypasswd -new newpass");
-        /*change back*/ testOK("", "-keystore x.jks -storepass changeit -keypass newpass -keypasswd -new changeit");
-        testFail("", "-keystore x.jks -storepass badpass -keypass changeit -keypasswd -new newpass");
-        testFail("", "-keystore x.jks -storepass changeit -keypass bad -keypasswd -new newpass");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -keypasswd -new newpass");
+        /*change back*/ testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass newpass -keypasswd -new changeit");
+        testOK("newpass\nnewpass\n", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -keypasswd");
+        /*change back*/ testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass newpass -keypasswd -new changeit");
+        testOK("new\nnew\nnewpass\nnewpass\n", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -keypasswd");
+        /*change back*/ testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass newpass -keypasswd -new changeit");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypasswd -new newpass");
+        /*change back*/ testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass newpass -keypasswd -new changeit");
+        testOK("changeit\n", "-keystore x.jks -storetype JKS -keypasswd -new newpass");
+        /*change back*/ testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass newpass -keypasswd -new changeit");
+        testFail("", "-keystore x.jks -storetype JKS -storepass badpass -keypass changeit -keypasswd -new newpass");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -keypass bad -keypasswd -new newpass");
         // no cert
-        testOK("", "-keystore x.jks -storepass changeit -exportcert -file x.jks.p1.cert");
-        testOK("", "-keystore x.jks -storepass changeit -delete -alias mykey");
-        testOK("", "-keystore x.jks -storepass changeit -importcert -file x.jks.p1.cert -noprompt");
-        testFail("", "-keystore x.jks -storepass changeit -keypass changeit -keypasswd -new newpass");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -exportcert -file x.jks.p1.cert");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -delete -alias mykey");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -importcert -file x.jks.p1.cert -noprompt");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -keypasswd -new newpass");
         // diff pass
-        testOK("", "-keystore x.jks -storepass changeit -delete -alias mykey");
-        testOK("", "-keystore x.jks -storepass changeit -keypass keypass -genkeypair -dname CN=olala");
-        testFail("", "-keystore x.jks -storepass changeit -keypasswd -new newpass");
-        testOK("keypass\n", "-keystore x.jks -storepass changeit -keypasswd -new newpass");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -delete -alias mykey");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass keypass -genkeypair -dname CN=olala");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -keypasswd -new newpass");
+        testOK("keypass\n", "-keystore x.jks -storetype JKS -storepass changeit -keypasswd -new newpass");
         // i hate those misc test
         remove("x.jks");
     }
     // list: -f -alias, exist, nonexist err; otherwise, check all shows, -rfc shows more, and misc
     void sqeListTest() throws Exception {
         remove("x.jks");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
-        testOK("", "-keystore x.jks -storepass changeit -list");
-        testOK("", "-keystore x.jks -storepass changeit -list -alias mykey");
-        testFail("", "-keystore x.jks -storepass changeit -list -alias notexist");
-        testFail("", "-keystore x.jks -storepass badpass -list -alias mykey");
-        testOK("", "-keystore x.jks -storepass changeit -keypass badpass -list -alias mykey");  // keypass ignore
-        testOK("\n", "-keystore x.jks -list");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -list");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -list -alias mykey");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -list -alias notexist");
+        testFail("", "-keystore x.jks -storetype JKS -storepass badpass -list -alias mykey");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass badpass -list -alias mykey");  // keypass ignore
+        testOK("\n", "-keystore x.jks -storetype JKS -list");
         assertTrue(err.indexOf("WARNING") != -1, "no storepass");
-        testOK("changeit\n", "-keystore x.jks -list");
+        testOK("changeit\n", "-keystore x.jks -storetype JKS -list");
         assertTrue(err.indexOf("WARNING") == -1, "has storepass");
-        testFail("badpass\n", "-keystore x.jks -list");
+        testFail("badpass\n", "-keystore x.jks -storetype JKS -list");
         // misc
         testFail("", "-keystore aa\\bb//cc -storepass changeit -list");
         testFail("", "-keystore nonexisting -storepass changeit -list");
@@ -703,45 +703,45 @@
     // selfcert: exist, non-exist err, cert err, sig..., dname, wrong keypass, misc
     void sqeSelfCertTest() throws Exception {
         remove("x.jks");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
-        testOK("", "-keystore x.jks -storepass changeit -selfcert");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -selfcert");
-        testFail("", "-keystore x.jks -storepass changeit -keypass changeit -selfcert -alias nonexisting"); // not exist
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -selfcert -dname CN=NewName");
-        testFail("", "-keystore x.jks -storepass changeit -keypass changeit -selfcert -sigalg MD5withRSA"); // sig not compatible
-        testFail("", "-keystore x.jks -storepass wrong -keypass changeit -selfcert"); // bad pass
-        testFail("", "-keystore x.jks -storepass changeit -keypass wrong -selfcert"); // bad pass
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -selfcert");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -selfcert");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -selfcert -alias nonexisting"); // not exist
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -selfcert -dname CN=NewName");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -selfcert -sigalg MD5withRSA"); // sig not compatible
+        testFail("", "-keystore x.jks -storetype JKS -storepass wrong -keypass changeit -selfcert"); // bad pass
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -keypass wrong -selfcert"); // bad pass
         //misc
         testFail("", "-keystore nonexist -storepass changeit -keypass changeit -selfcert");
         testFail("", "-keystore aa//dd\\gg -storepass changeit -keypass changeit -selfcert");
         // diff pass
         remove("x.jks");
-        testOK("", "-keystore x.jks -storepass changeit -keypass keypass -genkeypair -dname CN=olala");
-        testFail("", "-keystore x.jks -storepass changeit -selfcert");
-        testOK("keypass\n", "-keystore x.jks -storepass changeit -selfcert");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass keypass -genkeypair -dname CN=olala");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -selfcert");
+        testOK("keypass\n", "-keystore x.jks -storetype JKS -storepass changeit -selfcert");
 
-        testOK("", "-keystore x.jks -storepass changeit -exportcert -file x.jks.p1.cert");
-        testOK("", "-keystore x.jks -storepass changeit -delete -alias mykey");
-        testOK("", "-keystore x.jks -storepass changeit -importcert -file x.jks.p1.cert -noprompt");
-        testFail("", "-keystore x.jks -storepass changeit -selfcert");  // certentry cannot do selfcert
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -exportcert -file x.jks.p1.cert");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -delete -alias mykey");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -importcert -file x.jks.p1.cert -noprompt");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -selfcert");  // certentry cannot do selfcert
         remove("x.jks");
     }
     // storepass: bad old, short new, misc
     void sqeStorepassTest() throws Exception {
         remove("x.jks");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
-        testOK("", "-storepasswd -keystore x.jks -storepass changeit -new newstore"); // all in arg
-        /* Change back */ testOK("", "-storepasswd -keystore x.jks -storepass newstore -new changeit");
-        testOK("changeit\nnewstore\nnewstore\n", "-storepasswd -keystore x.jks"); // all not in arg, new twice
-        /* Change back */ testOK("", "-storepasswd -keystore x.jks -storepass newstore -new changeit");
-        testOK("changeit\n", "-storepasswd -keystore x.jks -new newstore"); // new in arg
-        /* Change back */ testOK("", "-storepasswd -keystore x.jks -storepass newstore -new changeit");
-        testOK("newstore\nnewstore\n", "-storepasswd -keystore x.jks -storepass changeit"); // old in arg
-        /* Change back */ testOK("", "-storepasswd -keystore x.jks -storepass newstore -new changeit");
-        testOK("new\nnew\nnewstore\nnewstore\n", "-storepasswd -keystore x.jks -storepass changeit"); // old in arg
-        /* Change back */ testOK("", "-storepasswd -keystore x.jks -storepass newstore -new changeit");
-        testFail("", "-storepasswd -keystore x.jks -storepass badold -new newstore"); // bad old
-        testFail("", "-storepasswd -keystore x.jks -storepass changeit -new new"); // short new
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
+        testOK("", "-storepasswd -keystore x.jks -storetype JKS -storepass changeit -new newstore"); // all in arg
+        /* Change back */ testOK("", "-storepasswd -keystore x.jks -storetype JKS -storepass newstore -new changeit");
+        testOK("changeit\nnewstore\nnewstore\n", "-storepasswd -keystore x.jks -storetype JKS"); // all not in arg, new twice
+        /* Change back */ testOK("", "-storepasswd -keystore x.jks -storetype JKS -storepass newstore -new changeit");
+        testOK("changeit\n", "-storepasswd -keystore x.jks -storetype JKS -new newstore"); // new in arg
+        /* Change back */ testOK("", "-storepasswd -keystore x.jks -storetype JKS -storepass newstore -new changeit");
+        testOK("newstore\nnewstore\n", "-storepasswd -keystore x.jks -storetype JKS -storepass changeit"); // old in arg
+        /* Change back */ testOK("", "-storepasswd -keystore x.jks -storetype JKS -storepass newstore -new changeit");
+        testOK("new\nnew\nnewstore\nnewstore\n", "-storepasswd -keystore x.jks -storetype JKS -storepass changeit"); // old in arg
+        /* Change back */ testOK("", "-storepasswd -keystore x.jks -storetype JKS -storepass newstore -new changeit");
+        testFail("", "-storepasswd -keystore x.jks -storetype JKS -storepass badold -new newstore"); // bad old
+        testFail("", "-storepasswd -keystore x.jks -storetype JKS -storepass changeit -new new"); // short new
         // misc
         testFail("", "-storepasswd -keystore nonexist -storepass changeit -new newstore"); // non exist
         testFail("", "-storepasswd -keystore badkeystore -storepass changeit -new newstore"); // bad file
@@ -752,40 +752,40 @@
     void sqeGenkeyTest() throws Exception {
 
         remove("x.jks");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
-        testFail("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -alias newentry");
-        testFail("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -alias newentry");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keyalg DSA -alias n1");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keyalg RSA -alias n2");
-        testFail("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keyalg NoSuchAlg -alias n3");
-        testFail("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keysize 56 -alias n4");
-        testFail("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keysize 999 -alias n5");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keysize 512 -alias n6");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keysize 1024 -alias n7");
-        testFail("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -sigalg NoSuchAlg -alias n8");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keyalg RSA -sigalg MD2withRSA -alias n9");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keyalg RSA -sigalg MD5withRSA -alias n10");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keyalg RSA -sigalg SHA1withRSA -alias n11");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala -alias newentry");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala -alias newentry");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keyalg DSA -alias n1");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keyalg RSA -alias n2");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keyalg NoSuchAlg -alias n3");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keysize 56 -alias n4");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keysize 999 -alias n5");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keysize 512 -alias n6");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keysize 1024 -alias n7");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala -sigalg NoSuchAlg -alias n8");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keyalg RSA -sigalg MD2withRSA -alias n9");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keyalg RSA -sigalg MD5withRSA -alias n10");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keyalg RSA -sigalg SHA1withRSA -alias n11");
         testFail("", "-keystore aa\\bb//cc\\dd -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keyalg RSA -sigalg NoSuchAlg -alias n12");
         testFail("", "-keystore badkeystore -storepass changeit -keypass changeit -genkeypair -dname CN=olala -alias n14");
-        testFail("", "-keystore x.jks -storepass badpass -keypass changeit -genkeypair -dname CN=olala -alias n16");
-        testFail("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CNN=olala -alias n17");
+        testFail("", "-keystore x.jks -storetype JKS -storepass badpass -keypass changeit -genkeypair -dname CN=olala -alias n16");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CNN=olala -alias n17");
         remove("x.jks");
     }
 
     void sqeExportTest() throws Exception {
         remove("x.jks");
-        testFail("", "-keystore x.jks -storepass changeit -export -file mykey.cert -alias mykey"); // nonexist
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
-        testOK("", "-keystore x.jks -storepass changeit -export -file mykey.cert -alias mykey");
-        testOK("", "-keystore x.jks -storepass changeit -delete -alias mykey");
-        testOK("", "-keystore x.jks -storepass changeit -import -file mykey.cert -noprompt -alias c1");
-        testOK("", "-keystore x.jks -storepass changeit -export -file mykey.cert2 -alias c1");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -export -file mykey.cert -alias mykey"); // nonexist
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -export -file mykey.cert -alias mykey");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -delete -alias mykey");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -import -file mykey.cert -noprompt -alias c1");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -export -file mykey.cert2 -alias c1");
         testFail("", "-keystore aa\\bb//cc\\dd -storepass changeit -export -file mykey.cert2 -alias c1");
         testFail("", "-keystore nonexistkeystore -storepass changeit -export -file mykey.cert2 -alias c1");
         testFail("", "-keystore badkeystore -storepass changeit -export -file mykey.cert2 -alias c1");
-        testFail("", "-keystore x.jks -storepass badpass -export -file mykey.cert2 -alias c1");
+        testFail("", "-keystore x.jks -storetype JKS -storepass badpass -export -file mykey.cert2 -alias c1");
         remove("mykey.cert");
         remove("mykey.cert2");
         remove("x.jks");
@@ -793,14 +793,14 @@
 
     void sqeDeleteTest() throws Exception {
         remove("x.jks");
-        testFail("", "-keystore x.jks -storepass changeit -delete -alias mykey"); // nonexist
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
-        testOK("", "-keystore x.jks -storepass changeit -delete -alias mykey");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -delete -alias mykey"); // nonexist
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -delete -alias mykey");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
         testFail("", "-keystore aa\\bb//cc\\dd -storepass changeit -delete -alias mykey"); // keystore name illegal
         testFail("", "-keystore nonexistkeystore -storepass changeit -delete -alias mykey"); // keystore not exist
         testFail("", "-keystore badkeystore -storepass changeit -delete -alias mykey"); // keystore invalid
-        testFail("", "-keystore x.jks -storepass xxxxxxxx -delete -alias mykey"); // wrong pass
+        testFail("", "-keystore x.jks -storetype JKS -storepass xxxxxxxx -delete -alias mykey"); // wrong pass
         remove("x.jks");
     }
 
@@ -809,31 +809,31 @@
         remove("x.jks.p1.cert");
         remove("csr1");
         // PrivateKeyEntry can do certreq
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keysize 1024");
-        testOK("", "-keystore x.jks -storepass changeit -certreq -file csr1 -alias mykey");
-        testOK("", "-keystore x.jks -storepass changeit -certreq -file csr1");
-        testOK("", "-keystore x.jks -storepass changeit -certreq -file csr1 -sigalg SHA1withDSA");
-        testFail("", "-keystore x.jks -storepass changeit -certreq -file csr1 -sigalg MD5withRSA"); // unmatched sigalg
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keysize 1024");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -certreq -file csr1 -alias mykey");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -certreq -file csr1");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -certreq -file csr1 -sigalg SHA1withDSA");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -certreq -file csr1 -sigalg MD5withRSA"); // unmatched sigalg
         // misc test
-        testFail("", "-keystore x.jks -storepass badstorepass -certreq -file csr1"); // bad storepass
-        testOK("changeit\n", "-keystore x.jks -certreq -file csr1"); // storepass from terminal
-        testFail("\n", "-keystore x.jks -certreq -file csr1"); // must provide storepass
-        testFail("", "-keystore x.jks -storepass changeit -keypass badkeypass -certreq -file csr1"); // bad keypass
-        testFail("", "-keystore x.jks -storepass changeit -certreq -file aa\\bb//cc\\dd");  // bad filepath
+        testFail("", "-keystore x.jks -storetype JKS -storepass badstorepass -certreq -file csr1"); // bad storepass
+        testOK("changeit\n", "-keystore x.jks -storetype JKS -certreq -file csr1"); // storepass from terminal
+        testFail("\n", "-keystore x.jks -storetype JKS -certreq -file csr1"); // must provide storepass
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -keypass badkeypass -certreq -file csr1"); // bad keypass
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -certreq -file aa\\bb//cc\\dd");  // bad filepath
         testFail("", "-keystore noexistks -storepass changeit -certreq -file csr1"); // non-existing keystore
         // Try the RSA private key
-        testOK("", "-keystore x.jks -storepass changeit -delete -alias mykey");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keyalg RSA");
-        testOK("", "-keystore x.jks -storepass changeit -certreq -file csr1 -alias mykey");
-        testOK("", "-keystore x.jks -storepass changeit -certreq -file csr1");
-        testFail("", "-keystore x.jks -storepass changeit -certreq -file csr1 -sigalg SHA1withDSA"); // unmatched sigalg
-        testOK("", "-keystore x.jks -storepass changeit -certreq -file csr1 -sigalg MD5withRSA");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -delete -alias mykey");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keyalg RSA");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -certreq -file csr1 -alias mykey");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -certreq -file csr1");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -certreq -file csr1 -sigalg SHA1withDSA"); // unmatched sigalg
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -certreq -file csr1 -sigalg MD5withRSA");
         // TrustedCertificateEntry cannot do certreq
-        testOK("", "-keystore x.jks -storepass changeit -exportcert -file x.jks.p1.cert");
-        testOK("", "-keystore x.jks -storepass changeit -delete -alias mykey");
-        testOK("", "-keystore x.jks -storepass changeit -importcert -file x.jks.p1.cert -noprompt");
-        testFail("", "-keystore x.jks -storepass changeit -certreq -file csr1 -alias mykey");
-        testFail("", "-keystore x.jks -storepass changeit -certreq -file csr1");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -exportcert -file x.jks.p1.cert");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -delete -alias mykey");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -importcert -file x.jks.p1.cert -noprompt");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -certreq -file csr1 -alias mykey");
+        testFail("", "-keystore x.jks -storetype JKS -storepass changeit -certreq -file csr1");
         remove("x.jks");
         remove("x.jks.p1.cert");
         remove("csr1");
@@ -842,8 +842,8 @@
     void sqePrintcertTest() throws Exception {
         remove("x.jks");
         remove("mykey.cert");
-        testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
-        testOK("", "-keystore x.jks -storepass changeit -export -file mykey.cert -alias mykey");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
+        testOK("", "-keystore x.jks -storetype JKS -storepass changeit -export -file mykey.cert -alias mykey");
         testFail("", "-printcert -file badkeystore");
         testFail("", "-printcert -file a/b/c/d");
         testOK("", "-printcert -file mykey.cert");
@@ -857,7 +857,7 @@
     void v3extTest(String keyAlg) throws Exception {
         KeyStore ks;
         remove("x.jks");
-        String simple = "-keystore x.jks -storepass changeit -keypass changeit -noprompt -keyalg " + keyAlg + " ";
+        String simple = "-keystore x.jks -storetype JKS -storepass changeit -keypass changeit -noprompt -keyalg " + keyAlg + " ";
         String pre = simple + "-genkeypair -dname CN=Olala -alias ";
 
         // Version and SKID
@@ -1195,39 +1195,39 @@
         testOK("", "-help");
 
         //   2. keytool -genkey -v -keysize 512 Enter "a" for the keystore password. Check error (password too short). Enter "password" for the keystore password. Hit 'return' for "first and last name", "organizational unit", "City", "State", and "Country Code". Type "yes" when they ask you if everything is correct. Type 'return' for new key password.
-        testOK("a\npassword\npassword\nMe\nHere\nNow\nPlace\nPlace\nUS\nyes\n\n", "-genkey -v -keysize 512 -keystore x.jks");
+        testOK("a\npassword\npassword\nMe\nHere\nNow\nPlace\nPlace\nUS\nyes\n\n", "-genkey -v -keysize 512 -keystore x.jks -storetype JKS");
         //   3. keytool -list -v -storepass password
-        testOK("", "-list -v -storepass password -keystore x.jks");
+        testOK("", "-list -v -storepass password -keystore x.jks -storetype JKS");
         //   4. keytool -list -v Type "a" for the keystore password. Check error (wrong keystore password).
-        testFail("a\n", "-list -v -keystore x.jks");
+        testFail("a\n", "-list -v -keystore x.jks -storetype JKS");
         assertTrue(ex.indexOf("password was incorrect") != -1);
         //   5. keytool -genkey -v -keysize 512 Enter "password" as the password. Check error (alias 'mykey' already exists).
-        testFail("password\n", "-genkey -v -keysize 512 -keystore x.jks");
+        testFail("password\n", "-genkey -v -keysize 512 -keystore x.jks -storetype JKS");
         assertTrue(ex.indexOf("alias <mykey> already exists") != -1);
         //   6. keytool -genkey -v -keysize 512 -alias mykey2 -storepass password Hit 'return' for "first and last name", "organizational unit", "City", "State", and "Country Code". Type "yes" when they ask you if everything is correct. Type 'return' for new key password.
-        testOK("\n\n\n\n\n\nyes\n\n", "-genkey -v -keysize 512 -alias mykey2 -storepass password -keystore x.jks");
+        testOK("\n\n\n\n\n\nyes\n\n", "-genkey -v -keysize 512 -alias mykey2 -storepass password -keystore x.jks -storetype JKS");
         //   7. keytool -list -v Type 'password' for the store password.
-        testOK("password\n", "-list -v -keystore x.jks");
+        testOK("password\n", "-list -v -keystore x.jks -storetype JKS");
         //   8. keytool -keypasswd -v -alias mykey2 -storepass password Type "a" for the new key password. Type "aaaaaa" for the new key password. Type "bbbbbb" when re-entering the new key password. Type "a" for the new key password. Check Error (too many failures).
-        testFail("a\naaaaaa\nbbbbbb\na\n", "-keypasswd -v -alias mykey2 -storepass password -keystore x.jks");
+        testFail("a\naaaaaa\nbbbbbb\na\n", "-keypasswd -v -alias mykey2 -storepass password -keystore x.jks -storetype JKS");
         assertTrue(ex.indexOf("Too many failures - try later") != -1);
         //   9. keytool -keypasswd -v -alias mykey2 -storepass password Type "aaaaaa" for the new key password. Type "aaaaaa" when re-entering the new key password.
-        testOK("aaaaaa\naaaaaa\n", "-keypasswd -v -alias mykey2 -storepass password -keystore x.jks");
+        testOK("aaaaaa\naaaaaa\n", "-keypasswd -v -alias mykey2 -storepass password -keystore x.jks -storetype JKS");
         //  10. keytool -selfcert -v -alias mykey -storepass password
-        testOK("", "-selfcert -v -alias mykey -storepass password -keystore x.jks");
+        testOK("", "-selfcert -v -alias mykey -storepass password -keystore x.jks -storetype JKS");
         //  11. keytool -list -v -storepass password
-        testOK("", "-list -v -storepass password -keystore x.jks");
+        testOK("", "-list -v -storepass password -keystore x.jks -storetype JKS");
         //  12. keytool -export -v -alias mykey -file cert -storepass password
         remove("cert");
-        testOK("", "-export -v -alias mykey -file cert -storepass password -keystore x.jks");
+        testOK("", "-export -v -alias mykey -file cert -storepass password -keystore x.jks -storetype JKS");
         //  13. keytool -import -v -file cert -storepass password Check error (Certificate reply and cert are the same)
-        testFail("", "-import -v -file cert -storepass password -keystore x.jks");
+        testFail("", "-import -v -file cert -storepass password -keystore x.jks -storetype JKS");
         assertTrue(ex.indexOf("Certificate reply and certificate in keystore are identical") != -1);
         //  14. keytool -printcert -file cert
-        testOK("", "-printcert -file cert -keystore x.jks");
+        testOK("", "-printcert -file cert -keystore x.jks -storetype JKS");
         remove("cert");
         //  15. keytool -list -storepass password -provider sun.security.provider.Sun
-        testOK("", "-list -storepass password -provider sun.security.provider.Sun -keystore x.jks");
+        testOK("", "-list -storepass password -provider sun.security.provider.Sun -keystore x.jks -storetype JKS");
 
         //Error tests
 
@@ -1245,13 +1245,13 @@
         testFail("", "-keypasswd -storetype PKCS11 -keystore NONE");
         assertTrue(ex.indexOf("UnsupportedOperationException") != -1);
         //   5. keytool -list -protected -storepass password Check error (password can not be specified with -protected)
-        testFail("", "-list -protected -storepass password -keystore x.jks");
+        testFail("", "-list -protected -storepass password -keystore x.jks -storetype JKS");
         assertTrue(ex.indexOf("if -protected is specified, then") != -1);
         //   6. keytool -keypasswd -protected -keypass password Check error (password can not be specified with -protected)
-        testFail("", "-keypasswd -protected -keypass password -keystore x.jks");
+        testFail("", "-keypasswd -protected -keypass password -keystore x.jks -storetype JKS");
         assertTrue(ex.indexOf("if -protected is specified, then") != -1);
         //   7. keytool -keypasswd -protected -new password Check error (password can not be specified with -protected)
-        testFail("", "-keypasswd -protected -new password -keystore x.jks");
+        testFail("", "-keypasswd -protected -new password -keystore x.jks -storetype JKS");
         assertTrue(ex.indexOf("if -protected is specified, then") != -1);
         remove("x.jks");
     }
--- a/jdk/test/sun/security/tools/keytool/NewSize7.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/sun/security/tools/keytool/NewSize7.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
                 " -keypass changeit -keyalg rsa").split(" "));
         KeyStore ks = KeyStore.getInstance("JKS");
         try (FileInputStream fin = new FileInputStream(FILE)) {
-            ks.load(fin, null);
+            ks.load(fin, "changeit".toCharArray());
         }
         Files.delete(Paths.get(FILE));
         RSAPublicKey r = (RSAPublicKey)ks.getCertificate("a").getPublicKey();
--- a/jdk/test/sun/security/tools/keytool/selfissued.sh	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/sun/security/tools/keytool/selfissued.sh	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -44,14 +44,14 @@
     ;;
 esac
 
-KS=selfsigned.jks
+KS=selfsigned.ks
 KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS -keyalg rsa"
 
 rm $KS
 
 $KT -alias ca -dname CN=CA -genkeypair
-$KT -alias ca1 -dname CN=CA -genkeypair
-$KT -alias ca2 -dname CN=CA -genkeypair
+$KT -alias ca1 -dname CN=CA1 -genkeypair
+$KT -alias ca2 -dname CN=CA2 -genkeypair
 $KT -alias e1 -dname CN=E1 -genkeypair
 
 # ca signs ca1, ca1 signs ca2, all self-issued
--- a/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh	Wed Jul 05 20:13:05 2017 +0200
@@ -24,7 +24,7 @@
 #
 
 # @test
-# @bug 4630463 4630971 4636448 4701617 4721296 4710890 6247817 7021987
+# @bug 4630463 4630971 4636448 4701617 4721296 4710890 6247817 7021987 8067964
 # @summary Tests miscellaneous native2ascii bugfixes and regressions
 
 
--- a/jdk/test/tools/pack200/Pack200Test.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/tools/pack200/Pack200Test.java	Wed Jul 05 20:13:05 2017 +0200
@@ -127,7 +127,7 @@
         // select the jars carefully, adding more jars will increase the
         // testing time, especially for jprt.
         jarList.add(Utils.createRtJar());
-        jarList.add(Utils.locateJar("golden.jar"));
+        jarList.add(Utils.getGoldenJar());
         System.out.println(jarList);
         doPackUnpack();
     }
--- a/jdk/test/tools/pack200/PackTestZip64.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/tools/pack200/PackTestZip64.java	Wed Jul 05 20:13:05 2017 +0200
@@ -52,7 +52,7 @@
         // make a copy of the test specimen to local directory
         File testFile = new File("tools_java.jar");
         // Add a large number of small files to the golden jar
-        generateLargeJar(testFile, Utils.locateJar("golden.jar"));
+        generateLargeJar(testFile, Utils.getGoldenJar());
 
         List<String> cmdsList = new ArrayList<>();
 
--- a/jdk/test/tools/pack200/RepackTest.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/tools/pack200/RepackTest.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,7 @@
 
         // make a copy of the test specimen to local directory
         File testFile = new File("src_tools.jar");
-        Utils.copyFile(Utils.locateJar("golden.jar"), testFile);
+        Utils.copyFile(Utils.getGoldenJar(), testFile);
         List<String> cmdsList = new ArrayList<>();
 
         // case 1:
--- a/jdk/test/tools/pack200/TimeStamp.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/tools/pack200/TimeStamp.java	Wed Jul 05 20:13:05 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,7 +54,7 @@
     public static void main(String... args) throws IOException {
 
         // make a local copy of our test file
-        File srcFile = Utils.locateJar("golden.jar");
+        File srcFile = Utils.getGoldenJar();
         File goldenFile = new File("golden.jar");
         Utils.copyFile(srcFile, goldenFile);
 
--- a/jdk/test/tools/pack200/Utils.java	Tue Dec 30 09:44:23 2014 -0800
+++ b/jdk/test/tools/pack200/Utils.java	Wed Jul 05 20:13:05 2017 +0200
@@ -63,7 +63,7 @@
             System.getProperty("os.name").startsWith("Windows");
     static final boolean Is64Bit =
             System.getProperty("sun.arch.data.model", "32").equals("64");
-    static final File   JavaSDK =  new File(JavaHome).getParentFile();
+    static final File   JavaSDK =  new File(JavaHome);
 
     static final String PACK_FILE_EXT   = ".pack";
     static final String JAVA_FILE_EXT   = ".java";
@@ -82,11 +82,7 @@
         if (VerifierJar.exists()) {
             return;
         }
-        File srcDir = new File(TEST_SRC_DIR, VERIFIER_DIR_NAME);
-        if (!srcDir.exists()) {
-            // if not available try one level above
-            srcDir = new File(TEST_SRC_DIR.getParentFile(), VERIFIER_DIR_NAME);
-        }
+        File srcDir = new File(getVerifierDir(), "src");
         List<File> javaFileList = findFiles(srcDir, createFilter(JAVA_FILE_EXT));
         File tmpFile = File.createTempFile("javac", ".tmp");
         XCLASSES.mkdirs();
@@ -115,6 +111,18 @@
             ".");
     }
 
+    private static File getVerifierDir() {
+        File srcDir = new File(TEST_SRC_DIR, VERIFIER_DIR_NAME);
+        if (!srcDir.exists()) {
+            // if not available try one level above
+            srcDir = new File(TEST_SRC_DIR.getParentFile(), VERIFIER_DIR_NAME);
+        }
+        return srcDir;
+    }
+
+    static File getGoldenJar() {
+        return new File(new File(getVerifierDir(), "data"), "golden.jar");
+    }
     static void dirlist(File dir) {
         File[] files = dir.listFiles();
         System.out.println("--listing " + dir.getAbsolutePath() + "---");
@@ -564,7 +572,8 @@
         File rtJar = new File("rt.jar");
         cmdList.clear();
         cmdList.add(getJarCmd());
-        cmdList.add("cvf");
+        // cmdList.add("cvf"); too noisy
+        cmdList.add("cf");
         cmdList.add(rtJar.getName());
         cmdList.add("-C");
         cmdList.add("out");
@@ -574,24 +583,4 @@
         recursiveDelete(new File("out"));
         return rtJar;
     }
-    private static List<File> locaterCache = null;
-    // search the source dir and jdk dir for requested file and returns
-    // the first location it finds.
-    static File locateJar(String name) {
-        try {
-            if (locaterCache == null) {
-                locaterCache = new ArrayList<File>();
-                locaterCache.addAll(findFiles(TEST_SRC_DIR, createFilter(JAR_FILE_EXT)));
-                locaterCache.addAll(findFiles(JavaSDK, createFilter(JAR_FILE_EXT)));
-            }
-            for (File f : locaterCache) {
-                if (f.getName().equals(name)) {
-                    return f;
-                }
-            }
-            throw new IOException("file not found: " + name);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/Makefile	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,65 @@
+#
+# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.	See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# Utility Makefile that creates wb.jar, which is used to simplify using 
+# the Whitebox API outside the jtreg-testbase.
+
+ifneq "x$(ALT_BOOTDIR)" "x"
+	BOOTDIR := $(ALT_BOOTDIR)
+endif
+
+ifeq "x$(BOOTDIR)" "x"
+	JDK_HOME := $(shell dirname $(shell which java))/..
+else
+	JDK_HOME := $(BOOTDIR)
+endif
+
+SRC_DIR = ./
+BUILD_DIR = build
+OUTPUT_DIR = $(BUILD_DIR)/classes
+
+JAVAC = $(JDK_HOME)/bin/javac
+JAR = $(JDK_HOME)/bin/jar
+
+SRC_FILES = $(shell find $(SRC_DIR) -name '*.java')
+
+.PHONY: filelist clean cleantmp
+
+all: wb.jar cleantmp
+
+wb.jar: filelist
+	@mkdir -p $(OUTPUT_DIR)
+	$(JAVAC) -sourcepath $(SRC_DIR) -d $(OUTPUT_DIR) -cp $(OUTPUT_DIR) @filelist
+	$(JAR) cf wb.jar -C $(OUTPUT_DIR) .
+	@rm -rf $(OUTPUT_DIR)
+
+filelist: $(SRC_FILES)
+	@rm -f $@
+	@echo $(SRC_FILES) > $@
+
+clean: cleantmp
+	@rm -rf wb.jar
+
+cleantmp:
+	@rm -rf filelist
+	@rm -rf $(BUILD_DIR)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/sun/hotspot/WhiteBox.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,254 @@
+/*
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.hotspot;
+
+import java.lang.reflect.Executable;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Function;
+import java.util.stream.Stream;
+import java.security.BasicPermission;
+
+import sun.hotspot.parser.DiagnosticCommand;
+
+public class WhiteBox {
+
+  @SuppressWarnings("serial")
+  public static class WhiteBoxPermission extends BasicPermission {
+    public WhiteBoxPermission(String s) {
+      super(s);
+    }
+  }
+
+  private WhiteBox() {}
+  private static final WhiteBox instance = new WhiteBox();
+  private static native void registerNatives();
+
+  /**
+   * Returns the singleton WhiteBox instance.
+   *
+   * The returned WhiteBox object should be carefully guarded
+   * by the caller, since it can be used to read and write data
+   * at arbitrary memory addresses. It must never be passed to
+   * untrusted code.
+   */
+  public synchronized static WhiteBox getWhiteBox() {
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null) {
+      sm.checkPermission(new WhiteBoxPermission("getInstance"));
+    }
+    return instance;
+  }
+
+  static {
+    registerNatives();
+  }
+
+  // Get the maximum heap size supporting COOPs
+  public native long getCompressedOopsMaxHeapSize();
+  // Arguments
+  public native void printHeapSizes();
+
+  // Memory
+  public native long getObjectAddress(Object o);
+  public native int  getHeapOopSize();
+  public native int  getVMPageSize();
+  public native boolean isObjectInOldGen(Object o);
+  public native long getObjectSize(Object o);
+
+  // Runtime
+  // Make sure class name is in the correct format
+  public boolean isClassAlive(String name) {
+    return isClassAlive0(name.replace('.', '/'));
+  }
+  private native boolean isClassAlive0(String name);
+
+  // JVMTI
+  public native void addToBootstrapClassLoaderSearch(String segment);
+  public native void addToSystemClassLoaderSearch(String segment);
+
+  // G1
+  public native boolean g1InConcurrentMark();
+  public native boolean g1IsHumongous(Object o);
+  public native long    g1NumFreeRegions();
+  public native int     g1RegionSize();
+  public native Object[]    parseCommandLine(String commandline, char delim, DiagnosticCommand[] args);
+
+  // NMT
+  public native long NMTMalloc(long size);
+  public native void NMTFree(long mem);
+  public native long NMTReserveMemory(long size);
+  public native void NMTCommitMemory(long addr, long size);
+  public native void NMTUncommitMemory(long addr, long size);
+  public native void NMTReleaseMemory(long addr, long size);
+  public native long NMTMallocWithPseudoStack(long size, int index);
+  public native boolean NMTIsDetailSupported();
+  public native boolean NMTChangeTrackingLevel();
+  public native int NMTGetHashSize();
+
+  // Compiler
+  public native int     deoptimizeFrames(boolean makeNotEntrant);
+  public native void    deoptimizeAll();
+  public        boolean isMethodCompiled(Executable method) {
+    return isMethodCompiled(method, false /*not osr*/);
+  }
+  public native boolean isMethodCompiled(Executable method, boolean isOsr);
+  public        boolean isMethodCompilable(Executable method) {
+    return isMethodCompilable(method, -1 /*any*/);
+  }
+  public        boolean isMethodCompilable(Executable method, int compLevel) {
+    return isMethodCompilable(method, compLevel, false /*not osr*/);
+  }
+  public native boolean isMethodCompilable(Executable method, int compLevel, boolean isOsr);
+  public native boolean isMethodQueuedForCompilation(Executable method);
+  public        int     deoptimizeMethod(Executable method) {
+    return deoptimizeMethod(method, false /*not osr*/);
+  }
+  public native int     deoptimizeMethod(Executable method, boolean isOsr);
+  public        void    makeMethodNotCompilable(Executable method) {
+    makeMethodNotCompilable(method, -1 /*any*/);
+  }
+  public        void    makeMethodNotCompilable(Executable method, int compLevel) {
+    makeMethodNotCompilable(method, compLevel, false /*not osr*/);
+  }
+  public native void    makeMethodNotCompilable(Executable method, int compLevel, boolean isOsr);
+  public        int     getMethodCompilationLevel(Executable method) {
+    return getMethodCompilationLevel(method, false /*not ost*/);
+  }
+  public native int     getMethodCompilationLevel(Executable method, boolean isOsr);
+  public native boolean testSetDontInlineMethod(Executable method, boolean value);
+  public        int     getCompileQueuesSize() {
+    return getCompileQueueSize(-1 /*any*/);
+  }
+  public native int     getCompileQueueSize(int compLevel);
+  public native boolean testSetForceInlineMethod(Executable method, boolean value);
+  public        boolean enqueueMethodForCompilation(Executable method, int compLevel) {
+    return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/);
+  }
+  public native boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci);
+  public native void    clearMethodState(Executable method);
+  public native void    lockCompilation();
+  public native void    unlockCompilation();
+  public native int     getMethodEntryBci(Executable method);
+  public native Object[] getNMethod(Executable method, boolean isOsr);
+  public native long    allocateCodeBlob(int size, int type);
+  public        long    allocateCodeBlob(long size, int type) {
+      int intSize = (int) size;
+      if ((long) intSize != size || size < 0) {
+          throw new IllegalArgumentException(
+                "size argument has illegal value " + size);
+      }
+      return allocateCodeBlob( intSize, type);
+  }
+  public native void    freeCodeBlob(long addr);
+  public        void    forceNMethodSweep() {
+    try {
+        forceNMethodSweep0().join();
+    } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+    }
+  }
+  public native Thread  forceNMethodSweep0();
+  public native Object[] getCodeHeapEntries(int type);
+  public native int     getCompilationActivityMode();
+  public native Object[] getCodeBlob(long addr);
+
+  // Intered strings
+  public native boolean isInStringTable(String str);
+
+  // Memory
+  public native void readReservedMemory();
+  public native long allocateMetaspace(ClassLoader classLoader, long size);
+  public native void freeMetaspace(ClassLoader classLoader, long addr, long size);
+  public native long incMetaspaceCapacityUntilGC(long increment);
+  public native long metaspaceCapacityUntilGC();
+
+  // Force Young GC
+  public native void youngGC();
+
+  // Force Full GC
+  public native void fullGC();
+
+  // Method tries to start concurrent mark cycle.
+  // It returns false if CM Thread is always in concurrent cycle.
+  public native boolean g1StartConcMarkCycle();
+
+  // Tests on ReservedSpace/VirtualSpace classes
+  public native int stressVirtualSpaceResize(long reservedSpaceSize, long magnitude, long iterations);
+  public native void runMemoryUnitTests();
+  public native void readFromNoaccessArea();
+  public native long getThreadStackSize();
+  public native long getThreadRemainingStackSize();
+
+  // CPU features
+  public native String getCPUFeatures();
+
+  // Native extensions
+  public native long getHeapUsageForContext(int context);
+  public native long getHeapRegionCountForContext(int context);
+  public native int getContextForObject(Object obj);
+  public native void printRegionInfo(int context);
+
+  // VM flags
+  public native boolean isConstantVMFlag(String name);
+  public native boolean isLockedVMFlag(String name);
+  public native void    setBooleanVMFlag(String name, boolean value);
+  public native void    setIntxVMFlag(String name, long value);
+  public native void    setUintxVMFlag(String name, long value);
+  public native void    setUint64VMFlag(String name, long value);
+  public native void    setSizeTVMFlag(String name, long value);
+  public native void    setStringVMFlag(String name, String value);
+  public native void    setDoubleVMFlag(String name, double value);
+  public native Boolean getBooleanVMFlag(String name);
+  public native Long    getIntxVMFlag(String name);
+  public native Long    getUintxVMFlag(String name);
+  public native Long    getUint64VMFlag(String name);
+  public native Long    getSizeTVMFlag(String name);
+  public native String  getStringVMFlag(String name);
+  public native Double  getDoubleVMFlag(String name);
+  private final List<Function<String,Object>> flagsGetters = Arrays.asList(
+    this::getBooleanVMFlag, this::getIntxVMFlag, this::getUintxVMFlag,
+    this::getUint64VMFlag, this::getSizeTVMFlag, this::getStringVMFlag,
+    this::getDoubleVMFlag);
+
+  public Object getVMFlag(String name) {
+    return flagsGetters.stream()
+                       .map(f -> f.apply(name))
+                       .filter(x -> x != null)
+                       .findAny()
+                       .orElse(null);
+  }
+  public native int getOffsetForName0(String name);
+  public int getOffsetForName(String name) throws Exception {
+    int offset = getOffsetForName0(name);
+    if (offset == -1) {
+      throw new RuntimeException(name + " not found");
+    }
+    return offset;
+  }
+
+  // Safepoint Checking
+  public native void assertMatchingSafepointCalls(boolean mutexSafepointValue, boolean attemptedNoSafepointValue);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/sun/hotspot/code/BlobType.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.hotspot.code;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryPoolMXBean;
+import java.util.EnumSet;
+
+import sun.hotspot.WhiteBox;
+
+public enum BlobType {
+    // Execution level 1 and 4 (non-profiled) nmethods (including native nmethods)
+    MethodNonProfiled(0, "CodeHeap 'non-profiled nmethods'"),
+    // Execution level 2 and 3 (profiled) nmethods
+    MethodProfiled(1, "CodeHeap 'profiled nmethods'"),
+    // Non-nmethods like Buffers, Adapters and Runtime Stubs
+    NonNMethod(2, "CodeHeap 'non-nmethods'") {
+        @Override
+        public boolean allowTypeWhenOverflow(BlobType type) {
+            return super.allowTypeWhenOverflow(type)
+                    || type == BlobType.MethodNonProfiled;
+        }
+    },
+    // All types (No code cache segmentation)
+    All(3, "CodeCache");
+
+    public final int id;
+    private final String beanName;
+
+    private BlobType(int id, String beanName) {
+        this.id = id;
+        this.beanName = beanName;
+    }
+
+    public MemoryPoolMXBean getMemoryPool() {
+        for (MemoryPoolMXBean bean : ManagementFactory.getMemoryPoolMXBeans()) {
+            String name = bean.getName();
+            if (beanName.equals(name)) {
+                return bean;
+            }
+        }
+        return null;
+    }
+
+    public boolean allowTypeWhenOverflow(BlobType type) {
+        return type == this;
+    }
+
+    public static EnumSet<BlobType> getAvailable() {
+        WhiteBox whiteBox = WhiteBox.getWhiteBox();
+        if (!whiteBox.getBooleanVMFlag("SegmentedCodeCache")) {
+            // only All for non segmented world
+            return EnumSet.of(All);
+        }
+        if (System.getProperty("java.vm.info").startsWith("interpreted ")) {
+            // only NonNMethod for -Xint
+            return EnumSet.of(NonNMethod);
+        }
+
+        EnumSet<BlobType> result = EnumSet.complementOf(EnumSet.of(All));
+        if (!whiteBox.getBooleanVMFlag("TieredCompilation")
+                || whiteBox.getIntxVMFlag("TieredStopAtLevel") <= 1) {
+            // there is no MethodProfiled in non tiered world or pure C1
+            result.remove(MethodProfiled);
+        }
+        return result;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/sun/hotspot/code/CodeBlob.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.hotspot.code;
+
+import sun.hotspot.WhiteBox;
+
+public class CodeBlob {
+  private static final WhiteBox WB = WhiteBox.getWhiteBox();
+  public static CodeBlob[] getCodeBlobs(BlobType type) {
+    Object[] obj = WB.getCodeHeapEntries(type.id);
+    if (obj == null) {
+      return null;
+    }
+    CodeBlob[] result = new CodeBlob[obj.length];
+    for (int i = 0, n = result.length; i < n; ++i) {
+      result[i] = new CodeBlob((Object[]) obj[i]);
+    }
+    return result;
+  }
+  public static CodeBlob getCodeBlob(long addr) {
+    Object[] obj = WB.getCodeBlob(addr);
+    if (obj == null) {
+      return null;
+    }
+    return new CodeBlob(obj);
+  }
+  protected CodeBlob(Object[] obj) {
+    assert obj.length == 3;
+    name = (String) obj[0];
+    size = (Integer) obj[1];
+    code_blob_type = BlobType.values()[(Integer) obj[2]];
+    assert code_blob_type.id == (Integer) obj[2];
+  }
+  public final String name;
+  public final int size;
+  public final BlobType code_blob_type;
+
+  @Override
+  public String toString() {
+    return "CodeBlob{"
+        + "name=" + name
+        + ", size=" + size
+        + ", code_blob_type=" + code_blob_type
+        + '}';
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/sun/hotspot/code/NMethod.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.hotspot.code;
+
+import java.lang.reflect.Executable;
+import sun.hotspot.WhiteBox;
+
+public class NMethod extends CodeBlob {
+  private static final WhiteBox wb = WhiteBox.getWhiteBox();
+  public static NMethod get(Executable method, boolean isOsr) {
+    Object[] obj = wb.getNMethod(method, isOsr);
+    return obj == null ? null : new NMethod(obj);
+  }
+  private NMethod(Object[] obj) {
+    super((Object[])obj[0]);
+    assert obj.length == 4;
+    comp_level = (Integer) obj[1];
+    insts = (byte[]) obj[2];
+    compile_id = (Integer) obj[3];
+  }
+  public final byte[] insts;
+  public final int comp_level;
+  public final int compile_id;
+
+  @Override
+  public String toString() {
+    return "NMethod{"
+        + super.toString()
+        + ", insts=" + insts
+        + ", comp_level=" + comp_level
+        + ", compile_id=" + compile_id
+        + '}';
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/sun/hotspot/cpuinfo/CPUInfo.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.hotspot.cpuinfo;
+
+import java.util.List;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
+import sun.hotspot.WhiteBox;
+
+/**
+ * Information about CPU on test box.
+ *
+ * CPUInfo uses WhiteBox to gather information,
+ * so WhiteBox class should be added to bootclasspath
+ * and option -XX:+WhiteBoxAPI should expclicetly
+ * specified on command line.
+ */
+public class CPUInfo {
+
+    private static final List<String> features;
+    private static final String additionalCPUInfo;
+
+    static {
+        WhiteBox wb = WhiteBox.getWhiteBox();
+
+        Pattern additionalCPUInfoRE =
+            Pattern.compile("([^(]*\\([^)]*\\)[^,]*),\\s*");
+
+        String cpuFeaturesString = wb.getCPUFeatures();
+        Matcher matcher = additionalCPUInfoRE.matcher(cpuFeaturesString);
+        if (matcher.find()) {
+            additionalCPUInfo = matcher.group(1);
+        } else {
+            additionalCPUInfo = "";
+        }
+        String splittedFeatures[] = matcher.replaceAll("").split("(, )| ");
+
+        features = Collections.unmodifiableList(Arrays.
+                                                asList(splittedFeatures));
+    }
+
+    /**
+     * Get additional information about CPU.
+     * For example, on X86 in will be family/model/stepping
+     * and number of cores.
+     *
+     * @return additional CPU info
+     */
+    public static String getAdditionalCPUInfo() {
+        return additionalCPUInfo;
+    }
+
+    /**
+     * Get all known features supported by CPU.
+     *
+     * @return unmodifiable list with names of all known features
+     *         supported by CPU.
+     */
+    public static List<String> getFeatures() {
+        return features;
+    }
+
+    /**
+     * Check if some feature is supported by CPU.
+     *
+     * @param feature Name of feature to be tested.
+     * @return <b>true</b> if tested feature is supported by CPU.
+     */
+    public static boolean hasFeature(String feature) {
+        return features.contains(feature.toLowerCase());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/sun/hotspot/parser/DiagnosticCommand.java	Wed Jul 05 20:13:05 2017 +0200
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.hotspot.parser;
+
+public class DiagnosticCommand {
+
+    public enum DiagnosticArgumentType {
+        JLONG, BOOLEAN, STRING, NANOTIME, STRINGARRAY, MEMORYSIZE
+    }
+
+    private String name;
+    private String desc;
+    private DiagnosticArgumentType type;
+    private boolean mandatory;
+    private String defaultValue;
+    private boolean argument;
+
+    public DiagnosticCommand(String name, String desc, DiagnosticArgumentType type,
+            boolean mandatory, String defaultValue) {
+        this(name, desc, type, false, mandatory, defaultValue);
+    }
+
+    public DiagnosticCommand(String name, String desc, DiagnosticArgumentType type,
+            boolean argument, boolean mandatory, String defaultValue) {
+        this.name = name;
+        this.desc = desc;
+        this.type = type;
+        this.mandatory = mandatory;
+        this.defaultValue = defaultValue;
+        this.argument = argument;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public DiagnosticArgumentType getType() {
+        return type;
+    }
+
+    public boolean isMandatory() {
+        return mandatory;
+    }
+
+    public boolean isArgument() {
+        return argument;
+    }
+
+    public String getDefaultValue() {
+        return defaultValue;
+    }
+}