changeset 15735:f61c40b324c5

Merge
author amurillo
date Tue, 27 Sep 2016 09:04:49 -0700
parents a041a4759597 665096863382
children d16e09effe10
files
diffstat 65 files changed, 883 insertions(+), 464 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Fri Sep 23 13:32:21 2016 -0700
+++ b/.hgtags	Tue Sep 27 09:04:49 2016 -0700
@@ -379,3 +379,4 @@
 803adcd526d74ae0b64948d1f8260c2dbe514779 jdk-9+134
 021369229cfd0b5feb76834b2ea498f47f43c0f3 jdk-9+135
 54c5931849a33a363e03fdffa141503f5cc4779d jdk-9+136
+e72df94364e3686e7d62059ce0d6b187b82da713 jdk-9+137
--- a/make/launcher/Launcher-java.desktop.gmk	Fri Sep 23 13:32:21 2016 -0700
+++ b/make/launcher/Launcher-java.desktop.gmk	Tue Sep 27 09:04:49 2016 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,7 @@
 # Hook to include the corresponding custom file, if present.
 $(eval $(call IncludeCustomExtension, jdk, launcher/Launcher-java.desktop.gmk))
 
-ifndef BUILD_HEADLESS_ONLY
+ifeq ($(ENABLE_HEADLESS_ONLY), false)
   $(eval $(call SetupBuildLauncher, appletviewer, \
       MAIN_CLASS := sun.applet.Main, \
       JAVA_ARGS := --add-modules ALL-DEFAULT, \
--- a/make/launcher/Launcher-jdk.policytool.gmk	Fri Sep 23 13:32:21 2016 -0700
+++ b/make/launcher/Launcher-jdk.policytool.gmk	Tue Sep 27 09:04:49 2016 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 
 include LauncherCommon.gmk
 
-ifndef BUILD_HEADLESS_ONLY
+ifeq ($(ENABLE_HEADLESS_ONLY), false)
   $(eval $(call SetupBuildLauncher, policytool, \
       MAIN_CLASS := sun.security.tools.policytool.PolicyTool, \
       LIBS_unix := $(X_LIBS), \
--- a/make/lib/Awt2dLibraries.gmk	Fri Sep 23 13:32:21 2016 -0700
+++ b/make/lib/Awt2dLibraries.gmk	Tue Sep 27 09:04:49 2016 -0700
@@ -280,7 +280,7 @@
 ################################################################################
 
 ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),)
-  ifndef BUILD_HEADLESS_ONLY
+  ifeq ($(ENABLE_HEADLESS_ONLY), false)
 
     LIBAWT_XAWT_DIRS := \
         $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt_xawt \
@@ -511,77 +511,75 @@
 
 ################################################################################
 
-ifeq ($(BUILD_HEADLESS), true)
-  # Mac and Windows only use the native AWT lib, do not build libawt_headless
-  ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx),)
+# Mac and Windows only use the native AWT lib, do not build libawt_headless
+ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx),)
 
-    LIBAWT_HEADLESS_DIRS := $(JDK_TOPDIR)/src/java.desktop/unix/native/libawt_headless/awt \
-        $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \
-        $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/opengl \
-        $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/x11 \
-        $(JDK_TOPDIR)/src/java.desktop/share/native/common/java2d/opengl \
-        $(JDK_TOPDIR)/src/java.desktop/share/native/common/font \
-        #
+  LIBAWT_HEADLESS_DIRS := $(JDK_TOPDIR)/src/java.desktop/unix/native/libawt_headless/awt \
+      $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \
+      $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/opengl \
+      $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/x11 \
+      $(JDK_TOPDIR)/src/java.desktop/share/native/common/java2d/opengl \
+      $(JDK_TOPDIR)/src/java.desktop/share/native/common/font \
+      #
 
-    LIBAWT_HEADLESS_EXCLUDES := medialib
-    LIBAWT_HEADLESS_CFLAGS := -I$(SUPPORT_OUTPUTDIR)/headers/java.desktop \
-        $(addprefix -I, $(LIBAWT_HEADLESS_DIRS)) \
-        -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d \
-        -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d/loops \
-        -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image/cvutils \
-        -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d/pipe \
-        -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image \
-        -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt/java2d \
-        -I$(JDK_TOPDIR)/src/java.desktop/share/native/common/font \
-        -I$(JDK_TOPDIR)/src/java.desktop/share/native/common/awt/debug \
-        -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/font \
-        -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libsunwjdga/ \
-        $(LIBJAVA_HEADER_FLAGS) \
-        #
+  LIBAWT_HEADLESS_EXCLUDES := medialib
+  LIBAWT_HEADLESS_CFLAGS := -I$(SUPPORT_OUTPUTDIR)/headers/java.desktop \
+      $(addprefix -I, $(LIBAWT_HEADLESS_DIRS)) \
+      -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d \
+      -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d/loops \
+      -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image/cvutils \
+      -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d/pipe \
+      -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image \
+      -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt/java2d \
+      -I$(JDK_TOPDIR)/src/java.desktop/share/native/common/font \
+      -I$(JDK_TOPDIR)/src/java.desktop/share/native/common/awt/debug \
+      -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/font \
+      -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libsunwjdga/ \
+      $(LIBJAVA_HEADER_FLAGS) \
+      #
 
-    LIBAWT_HEADLESS_REORDER :=
-    ifeq ($(OPENJDK_TARGET_OS), solaris)
-      ifneq ($(OPENJDK_TARGET_CPU), x86_64)
-        LIBAWT_HEADLESS_REORDER := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/reorder-$(OPENJDK_TARGET_CPU)
-      endif
+  LIBAWT_HEADLESS_REORDER :=
+  ifeq ($(OPENJDK_TARGET_OS), solaris)
+    ifneq ($(OPENJDK_TARGET_CPU), x86_64)
+      LIBAWT_HEADLESS_REORDER := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/reorder-$(OPENJDK_TARGET_CPU)
     endif
+  endif
 
-    $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_HEADLESS, \
-        LIBRARY := awt_headless, \
-        OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
-        SRC := $(LIBAWT_HEADLESS_DIRS), \
-        EXCLUDES := $(LIBAWT_HEADLESS_EXCLUDES), \
-        OPTIMIZATION := LOW, \
-        CFLAGS := $(CFLAGS_JDKLIB) \
-            -DHEADLESS=true \
-            -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \
-            $(CUPS_CFLAGS) \
-            $(X_CFLAGS) \
-            $(LIBAWT_HEADLESS_CFLAGS), \
-        DISABLED_WARNINGS_xlc := 1506-356, \
-        DISABLED_WARNINGS_solstudio := E_EMPTY_TRANSLATION_UNIT, \
-        MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/mapfile-vers, \
-        LDFLAGS := $(LDFLAGS_JDKLIB) \
-            $(call SET_SHARED_LIBRARY_ORIGIN), \
-        LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
-        LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
-        LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
-        REORDER := $(LIBAWT_HEADLESS_REORDER), \
-        LIBS_unix := -lawt -ljvm -ljava, \
-        LIBS_linux := $(LIBM) $(LIBDL), \
-        LIBS_solaris := $(LIBM) $(LIBDL) $(LIBCXX) -lc, \
-        OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt_headless, \
-    ))
+  $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_HEADLESS, \
+      LIBRARY := awt_headless, \
+      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
+      SRC := $(LIBAWT_HEADLESS_DIRS), \
+      EXCLUDES := $(LIBAWT_HEADLESS_EXCLUDES), \
+      OPTIMIZATION := LOW, \
+      CFLAGS := $(CFLAGS_JDKLIB) \
+          -DHEADLESS=true \
+          -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \
+          $(CUPS_CFLAGS) \
+          $(X_CFLAGS) \
+          $(LIBAWT_HEADLESS_CFLAGS), \
+      DISABLED_WARNINGS_xlc := 1506-356, \
+      DISABLED_WARNINGS_solstudio := E_EMPTY_TRANSLATION_UNIT, \
+      MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/mapfile-vers, \
+      LDFLAGS := $(LDFLAGS_JDKLIB) \
+          $(call SET_SHARED_LIBRARY_ORIGIN), \
+      LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
+      LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
+      LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
+      REORDER := $(LIBAWT_HEADLESS_REORDER), \
+      LIBS_unix := -lawt -ljvm -ljava, \
+      LIBS_linux := $(LIBM) $(LIBDL), \
+      LIBS_solaris := $(LIBM) $(LIBDL) $(LIBCXX) -lc, \
+      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt_headless, \
+  ))
 
-    # AIX warning explanation:
-    # 1506-356 : (W) Compilation unit is empty.
-    #            This happens during the headless build
+  # AIX warning explanation:
+  # 1506-356 : (W) Compilation unit is empty.
+  #            This happens during the headless build
 
-    $(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT)
+  $(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT)
 
-    TARGETS += $(BUILD_LIBAWT_HEADLESS)
+  TARGETS += $(BUILD_LIBAWT_HEADLESS)
 
-  endif
 endif
 
 ################################################################################
@@ -780,7 +778,7 @@
     ifneq ($(OPENJDK_TARGET_OS), solaris)
       JAWT_LIBS += -lawt
     endif
-    ifndef BUILD_HEADLESS_ONLY
+    ifeq ($(ENABLE_HEADLESS_ONLY), false)
       JAWT_LIBS += -lawt_xawt
     else
       JAWT_LIBS += -lawt_headless
@@ -809,7 +807,7 @@
       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjawt, \
   ))
 
-  ifndef BUILD_HEADLESS_ONLY
+  ifeq ($(ENABLE_HEADLESS_ONLY), false)
     $(BUILD_LIBJAWT): $(BUILD_LIBAWT_XAWT)
   else
     $(BUILD_LIBJAWT): $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt_headless$(SHARED_LIBRARY_SUFFIX)
@@ -825,7 +823,7 @@
 
 ################################################################################
 
-ifndef BUILD_HEADLESS_ONLY
+ifeq ($(ENABLE_HEADLESS_ONLY), false)
 
   LIBSPLASHSCREEN_DIRS := \
       $(JDK_TOPDIR)/src/java.desktop/share/native/libjavajpeg \
--- a/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java	Tue Sep 27 09:04:49 2016 -0700
@@ -869,5 +869,4 @@
     static SpeciesData speciesData_LLL()    { return checkCache(3, "LLL"); }
     static SpeciesData speciesData_LLLL()   { return checkCache(4, "LLLL"); }
     static SpeciesData speciesData_LLLLL()  { return checkCache(5, "LLLLL"); }
-    static SpeciesData speciesData_LLLLLL() { return checkCache(6, "LLLLLL"); }
 }
--- a/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Tue Sep 27 09:04:49 2016 -0700
@@ -39,14 +39,14 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.lang.reflect.Modifier;
+import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.stream.Stream;
 
+import static java.lang.invoke.LambdaForm.BasicType;
+import static java.lang.invoke.LambdaForm.BasicType.*;
 import static java.lang.invoke.LambdaForm.*;
-import static java.lang.invoke.LambdaForm.BasicType.*;
-import static java.lang.invoke.LambdaForm.Kind.*;
 import static java.lang.invoke.MethodHandleNatives.Constants.*;
 import static java.lang.invoke.MethodHandleStatics.*;
 
@@ -65,6 +65,9 @@
     private static final String OBJ     = "java/lang/Object";
     private static final String OBJARY  = "[Ljava/lang/Object;";
 
+    private static final String LOOP_CLAUSES = MHI + "$LoopClauses";
+    private static final String MHARY2       = "[[L" + MH + ";";
+
     private static final String LF_SIG  = "L" + LF + ";";
     private static final String LFN_SIG = "L" + LFN + ";";
     private static final String LL_SIG  = "(L" + OBJ + ";)L" + OBJ + ";";
@@ -1319,38 +1322,43 @@
      * The pattern looks like (Cf. MethodHandleImpl.loop):
      * <blockquote><pre>{@code
      * // a0: BMH
-     * // a1: inits, a2: steps, a3: preds, a4: finis
-     * // a5: box, a6: unbox
-     * // a7 (and following): arguments
-     * loop=Lambda(a0:L,a1:L,a2:L,a3:L,a4:L,a5:L,a6:L,a7:L)=>{
-     *   t8:L=MethodHandle.invokeBasic(a5:L,a7:L);                  // box the arguments into an Object[]
-     *   t9:L=MethodHandleImpl.loop(bt:L,a1:L,a2:L,a3:L,a4:L,t8:L); // call the loop executor (with supplied types in bt)
-     *   t10:L=MethodHandle.invokeBasic(a6:L,t9:L);t10:L}           // unbox the result; return the result
+     * // a1: LoopClauses (containing an array of arrays: inits, steps, preds, finis)
+     * // a2: box, a3: unbox
+     * // a4 (and following): arguments
+     * loop=Lambda(a0:L,a1:L,a2:L,a3:L,a4:L)=>{
+     *   t5:L=MethodHandle.invokeBasic(a2:L,a4:L);          // box the arguments into an Object[]
+     *   t6:L=MethodHandleImpl.loop(bt:L,a1:L,t5:L);        // call the loop executor (with supplied types in bt)
+     *   t7:L=MethodHandle.invokeBasic(a3:L,t6:L);t7:L}     // unbox the result; return the result
      * }</pre></blockquote>
      * <p>
      * It is compiled into bytecode equivalent to the code seen in {@link MethodHandleImpl#loop(BasicType[],
-     * MethodHandle[], MethodHandle[], MethodHandle[], MethodHandle[], Object...)}, with the difference that no arrays
+     * MethodHandleImpl.LoopClauses, Object...)}, with the difference that no arrays
      * will be used for local state storage. Instead, the local state will be mapped to actual stack slots.
      * <p>
      * Bytecode generation applies an unrolling scheme to enable better bytecode generation regarding local state type
      * handling. The generated bytecode will have the following form ({@code void} types are ignored for convenience).
      * Assume there are {@code C} clauses in the loop.
      * <blockquote><pre>{@code
-     * INIT: (INIT_SEQ for clause 1)
-     *       ...
-     *       (INIT_SEQ for clause C)
-     * LOOP: (LOOP_SEQ for clause 1)
-     *       ...
-     *       (LOOP_SEQ for clause C)
-     *       GOTO LOOP
-     * DONE: ...
+     * PREINIT: ALOAD_1
+     *          CHECKCAST LoopClauses
+     *          GETFIELD LoopClauses.clauses
+     *          ASTORE clauseDataIndex          // place the clauses 2-dimensional array on the stack
+     * INIT:    (INIT_SEQ for clause 1)
+     *          ...
+     *          (INIT_SEQ for clause C)
+     * LOOP:    (LOOP_SEQ for clause 1)
+     *          ...
+     *          (LOOP_SEQ for clause C)
+     *          GOTO LOOP
+     * DONE:    ...
      * }</pre></blockquote>
      * <p>
      * The {@code INIT_SEQ_x} sequence for clause {@code x} (with {@code x} ranging from {@code 0} to {@code C-1}) has
      * the following shape. Assume slot {@code vx} is used to hold the state for clause {@code x}.
      * <blockquote><pre>{@code
-     * INIT_SEQ_x:  ALOAD inits
-     *              CHECKCAST MethodHandle[]
+     * INIT_SEQ_x:  ALOAD clauseDataIndex
+     *              ICONST_0
+     *              AALOAD      // load the inits array
      *              ICONST x
      *              AALOAD      // load the init handle for clause x
      *              load args
@@ -1361,24 +1369,27 @@
      * The {@code LOOP_SEQ_x} sequence for clause {@code x} (with {@code x} ranging from {@code 0} to {@code C-1}) has
      * the following shape. Again, assume slot {@code vx} is used to hold the state for clause {@code x}.
      * <blockquote><pre>{@code
-     * LOOP_SEQ_x:  ALOAD steps
-     *              CHECKCAST MethodHandle[]
+     * LOOP_SEQ_x:  ALOAD clauseDataIndex
+     *              ICONST_1
+     *              AALOAD              // load the steps array
      *              ICONST x
      *              AALOAD              // load the step handle for clause x
      *              load locals
      *              load args
      *              INVOKEVIRTUAL MethodHandle.invokeBasic
      *              store vx
-     *              ALOAD preds
-     *              CHECKCAST MethodHandle[]
+     *              ALOAD clauseDataIndex
+     *              ICONST_2
+     *              AALOAD              // load the preds array
      *              ICONST x
      *              AALOAD              // load the pred handle for clause x
      *              load locals
      *              load args
      *              INVOKEVIRTUAL MethodHandle.invokeBasic
      *              IFNE LOOP_SEQ_x+1   // predicate returned false -> jump to next clause
-     *              ALOAD finis
-     *              CHECKCAST MethodHandle[]
+     *              ALOAD clauseDataIndex
+     *              ICONST_3
+     *              AALOAD              // load the finis array
      *              ICONST x
      *              AALOAD              // load the fini handle for clause x
      *              load locals
@@ -1397,8 +1408,12 @@
         BasicType[] loopClauseTypes = (BasicType[]) invoker.arguments[0];
         Class<?>[] loopLocalStateTypes = Stream.of(loopClauseTypes).
                 filter(bt -> bt != BasicType.V_TYPE).map(BasicType::basicTypeClass).toArray(Class<?>[]::new);
+        Class<?>[] localTypes = new Class<?>[loopLocalStateTypes.length + 1];
+        localTypes[0] = MethodHandleImpl.LoopClauses.class;
+        System.arraycopy(loopLocalStateTypes, 0, localTypes, 1, loopLocalStateTypes.length);
 
-        final int firstLoopStateIndex = extendLocalsMap(loopLocalStateTypes);
+        final int clauseDataIndex = extendLocalsMap(localTypes);
+        final int firstLoopStateIndex = clauseDataIndex + 1;
 
         Class<?> returnType = result.function.resolvedHandle().type().returnType();
         MethodType loopType = args.function.resolvedHandle().type()
@@ -1420,10 +1435,16 @@
         Label lDone = new Label();
         Label lNext;
 
+        // PREINIT:
+        emitPushArgument(MethodHandleImpl.LoopClauses.class, invoker.arguments[1]);
+        mv.visitFieldInsn(Opcodes.GETFIELD, LOOP_CLAUSES, "clauses", MHARY2);
+        emitAstoreInsn(clauseDataIndex);
+
         // INIT:
         for (int c = 0, state = 0; c < nClauses; ++c) {
             MethodType cInitType = loopType.changeReturnType(loopClauseTypes[c].basicTypeClass());
-            emitLoopHandleInvoke(invoker, inits, c, args, false, cInitType, loopLocalStateTypes, firstLoopStateIndex);
+            emitLoopHandleInvoke(invoker, inits, c, args, false, cInitType, loopLocalStateTypes, clauseDataIndex,
+                    firstLoopStateIndex);
             if (cInitType.returnType() != void.class) {
                 emitStoreInsn(BasicType.basicType(cInitType.returnType()), firstLoopStateIndex + state);
                 ++state;
@@ -1440,18 +1461,21 @@
             boolean isVoid = stepType.returnType() == void.class;
 
             // invoke loop step
-            emitLoopHandleInvoke(invoker, steps, c, args, true, stepType, loopLocalStateTypes, firstLoopStateIndex);
+            emitLoopHandleInvoke(invoker, steps, c, args, true, stepType, loopLocalStateTypes, clauseDataIndex,
+                    firstLoopStateIndex);
             if (!isVoid) {
                 emitStoreInsn(BasicType.basicType(stepType.returnType()), firstLoopStateIndex + state);
                 ++state;
             }
 
             // invoke loop predicate
-            emitLoopHandleInvoke(invoker, preds, c, args, true, predType, loopLocalStateTypes, firstLoopStateIndex);
+            emitLoopHandleInvoke(invoker, preds, c, args, true, predType, loopLocalStateTypes, clauseDataIndex,
+                    firstLoopStateIndex);
             mv.visitJumpInsn(Opcodes.IFNE, lNext);
 
             // invoke fini
-            emitLoopHandleInvoke(invoker, finis, c, args, true, finiType, loopLocalStateTypes, firstLoopStateIndex);
+            emitLoopHandleInvoke(invoker, finis, c, args, true, finiType, loopLocalStateTypes, clauseDataIndex,
+                    firstLoopStateIndex);
             mv.visitJumpInsn(Opcodes.GOTO, lDone);
 
             // this is the beginning of the next loop clause
@@ -1483,9 +1507,10 @@
     }
 
     private void emitLoopHandleInvoke(Name holder, int handles, int clause, Name args, boolean pushLocalState,
-                                      MethodType type, Class<?>[] loopLocalStateTypes, int firstLoopStateSlot) {
+                                      MethodType type, Class<?>[] loopLocalStateTypes, int clauseDataSlot,
+                                      int firstLoopStateSlot) {
         // load handle for clause
-        emitPushArgument(holder, handles);
+        emitPushClauseArray(clauseDataSlot, handles);
         emitIconstInsn(clause);
         mv.visitInsn(Opcodes.AALOAD);
         // load loop state (preceding the other arguments)
@@ -1499,6 +1524,12 @@
         mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, MH, "invokeBasic", type.toMethodDescriptorString(), false);
     }
 
+    private void emitPushClauseArray(int clauseDataSlot, int which) {
+        emitAloadInsn(clauseDataSlot);
+        emitIconstInsn(which - 1);
+        mv.visitInsn(Opcodes.AALOAD);
+    }
+
     private void emitZero(BasicType type) {
         switch (type) {
             case I_TYPE: mv.visitInsn(Opcodes.ICONST_0); break;
--- a/src/java.base/share/classes/java/lang/invoke/LambdaForm.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/LambdaForm.java	Tue Sep 27 09:04:49 2016 -0700
@@ -41,7 +41,6 @@
 import static java.lang.invoke.LambdaForm.BasicType.*;
 import static java.lang.invoke.MethodHandleNatives.Constants.REF_invokeStatic;
 import static java.lang.invoke.MethodHandleStatics.*;
-import java.util.Objects;
 
 /**
  * The symbolic, non-executable form of a method handle's invocation semantics.
@@ -732,9 +731,9 @@
     boolean isLoop(int pos) {
         // loop idiom:
         //   t_{n}:L=MethodHandle.invokeBasic(...)
-        //   t_{n+1}:L=MethodHandleImpl.loop(types, *, *, *, *, t_{n})
+        //   t_{n+1}:L=MethodHandleImpl.loop(types, *, t_{n})
         //   t_{n+2}:?=MethodHandle.invokeBasic(*, t_{n+1})
-        return isMatchingIdiom(pos, "loop", 5);
+        return isMatchingIdiom(pos, "loop", 2);
     }
 
     /*
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Tue Sep 27 09:04:49 2016 -0700
@@ -1689,8 +1689,7 @@
             NF_tryFinally = new NamedFunction(MethodHandleImpl.class
                     .getDeclaredMethod("tryFinally", MethodHandle.class, MethodHandle.class, Object[].class));
             NF_loop = new NamedFunction(MethodHandleImpl.class
-                    .getDeclaredMethod("loop", BasicType[].class, MethodHandle[].class, MethodHandle[].class,
-                            MethodHandle[].class, MethodHandle[].class, Object[].class));
+                    .getDeclaredMethod("loop", BasicType[].class, LoopClauses.class, Object[].class));
             NF_throwException = new NamedFunction(MethodHandleImpl.class
                     .getDeclaredMethod("throwException", Throwable.class));
             NF_profileBoolean = new NamedFunction(MethodHandleImpl.class
@@ -1794,12 +1793,13 @@
         MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
         MethodHandle unboxResult = unboxResultHandle(tloop);
 
-        BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLLL();
+        LoopClauses clauseData =
+                new LoopClauses(new MethodHandle[][]{toArray(init), toArray(step), toArray(pred), toArray(fini)});
+        BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLL();
         BoundMethodHandle mh;
         try {
-            mh = (BoundMethodHandle) data.constructor().invokeBasic(type, form, (Object) toArray(init),
-                    (Object) toArray(step), (Object) toArray(pred), (Object) toArray(fini), (Object) collectArgs,
-                    (Object) unboxResult);
+            mh = (BoundMethodHandle) data.constructor().invokeBasic(type, form, (Object) clauseData,
+                    (Object) collectArgs, (Object) unboxResult);
         } catch (Throwable ex) {
             throw uncaughtException(ex);
         }
@@ -1818,23 +1818,20 @@
      * {@code t12}):
      * <blockquote><pre>{@code
      *  loop=Lambda(a0:L,a1:L)=>{
-     *    t2:L=BoundMethodHandle$Species_L6.argL0(a0:L);             // array of init method handles
-     *    t3:L=BoundMethodHandle$Species_L6.argL1(a0:L);             // array of step method handles
-     *    t4:L=BoundMethodHandle$Species_L6.argL2(a0:L);             // array of pred method handles
-     *    t5:L=BoundMethodHandle$Species_L6.argL3(a0:L);             // array of fini method handles
-     *    t6:L=BoundMethodHandle$Species_L6.argL4(a0:L);             // helper handle to box the arguments into an Object[]
-     *    t7:L=BoundMethodHandle$Species_L6.argL5(a0:L);             // helper handle to unbox the result
-     *    t8:L=MethodHandle.invokeBasic(t6:L,a1:L);                  // box the arguments into an Object[]
-     *    t9:L=MethodHandleImpl.loop(null,t2:L,t3:L,t4:L,t5:L,t6:L); // call the loop executor
-     *    t10:L=MethodHandle.invokeBasic(t7:L,t9:L);t10:L}           // unbox the result; return the result
+     *    t2:L=BoundMethodHandle$Species_L3.argL0(a0:L);    // LoopClauses holding init, step, pred, fini handles
+     *    t3:L=BoundMethodHandle$Species_L3.argL1(a0:L);    // helper handle to box the arguments into an Object[]
+     *    t4:L=BoundMethodHandle$Species_L3.argL2(a0:L);    // helper handle to unbox the result
+     *    t5:L=MethodHandle.invokeBasic(t3:L,a1:L);         // box the arguments into an Object[]
+     *    t6:L=MethodHandleImpl.loop(null,t2:L,t3:L);       // call the loop executor
+     *    t7:L=MethodHandle.invokeBasic(t4:L,t6:L);t7:L}    // unbox the result; return the result
      * }</pre></blockquote>
      * <p>
-     * {@code argL0} through {@code argL3} are the arrays of init, step, pred, and fini method handles.
-     * {@code argL4} and {@code argL5} are auxiliary method handles: {@code argL2} boxes arguments and wraps them into
-     * {@code Object[]} ({@code ValueConversions.array()}), and {@code argL3} unboxes the result if necessary
+     * {@code argL0} is a LoopClauses instance holding, in a 2-dimensional array, the init, step, pred, and fini method
+     * handles. {@code argL1} and {@code argL2} are auxiliary method handles: {@code argL1} boxes arguments and wraps
+     * them into {@code Object[]} ({@code ValueConversions.array()}), and {@code argL2} unboxes the result if necessary
      * ({@code ValueConversions.unbox()}).
      * <p>
-     * Having {@code t6} and {@code t7} passed in via a BMH and not hardcoded in the lambda form allows to share lambda
+     * Having {@code t3} and {@code t4} passed in via a BMH and not hardcoded in the lambda form allows to share lambda
      * forms among loop combinators with the same basic type.
      * <p>
      * The above template is instantiated by using the {@link LambdaFormEditor} to replace the {@code null} argument to
@@ -1845,15 +1842,12 @@
     private static LambdaForm makeLoopForm(MethodType basicType, BasicType[] localVarTypes) {
         MethodType lambdaType = basicType.invokerType();
 
-        final int THIS_MH = 0;  // the BMH_LLLLLL
+        final int THIS_MH = 0;  // the BMH_LLL
         final int ARG_BASE = 1; // start of incoming arguments
         final int ARG_LIMIT = ARG_BASE + basicType.parameterCount();
 
         int nameCursor = ARG_LIMIT;
-        final int GET_INITS = nameCursor++;
-        final int GET_STEPS = nameCursor++;
-        final int GET_PREDS = nameCursor++;
-        final int GET_FINIS = nameCursor++;
+        final int GET_CLAUSE_DATA = nameCursor++;
         final int GET_COLLECT_ARGS = nameCursor++;
         final int GET_UNBOX_RESULT = nameCursor++;
         final int BOXED_ARGS = nameCursor++;
@@ -1864,14 +1858,11 @@
         if (lform == null) {
             Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType);
 
-            BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLLL();
+            BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLL();
             names[THIS_MH] = names[THIS_MH].withConstraint(data);
-            names[GET_INITS] = new Name(data.getterFunction(0), names[THIS_MH]);
-            names[GET_STEPS] = new Name(data.getterFunction(1), names[THIS_MH]);
-            names[GET_PREDS] = new Name(data.getterFunction(2), names[THIS_MH]);
-            names[GET_FINIS] = new Name(data.getterFunction(3), names[THIS_MH]);
-            names[GET_COLLECT_ARGS] = new Name(data.getterFunction(4), names[THIS_MH]);
-            names[GET_UNBOX_RESULT] = new Name(data.getterFunction(5), names[THIS_MH]);
+            names[GET_CLAUSE_DATA] = new Name(data.getterFunction(0), names[THIS_MH]);
+            names[GET_COLLECT_ARGS] = new Name(data.getterFunction(1), names[THIS_MH]);
+            names[GET_UNBOX_RESULT] = new Name(data.getterFunction(2), names[THIS_MH]);
 
             // t_{i}:L=MethodHandle.invokeBasic(collectArgs:L,a1:L,...);
             MethodType collectArgsType = basicType.changeReturnType(Object.class);
@@ -1881,10 +1872,10 @@
             System.arraycopy(names, ARG_BASE, args, 1, ARG_LIMIT - ARG_BASE);
             names[BOXED_ARGS] = new Name(makeIntrinsic(invokeBasic, Intrinsic.LOOP), args);
 
-            // t_{i+1}:L=MethodHandleImpl.loop(localTypes:L,inits:L,steps:L,preds:L,finis:L,t_{i}:L);
+            // t_{i+1}:L=MethodHandleImpl.loop(localTypes:L,clauses:L,t_{i}:L);
             Object[] lArgs =
                     new Object[]{null, // placeholder for BasicType[] localTypes - will be added by LambdaFormEditor
-                            names[GET_INITS], names[GET_STEPS], names[GET_PREDS], names[GET_FINIS], names[BOXED_ARGS]};
+                            names[GET_CLAUSE_DATA], names[BOXED_ARGS]};
             names[LOOP] = new Name(NF_loop, lArgs);
 
             // t_{i+2}:I=MethodHandle.invokeBasic(unbox:L,t_{i+1}:L);
@@ -1900,22 +1891,52 @@
         return lform.editor().noteLoopLocalTypesForm(BOXED_ARGS, localVarTypes);
     }
 
+    static class LoopClauses {
+        @Stable final MethodHandle[][] clauses;
+        LoopClauses(MethodHandle[][] clauses) {
+            assert clauses.length == 4;
+            this.clauses = clauses;
+        }
+        @Override
+        public String toString() {
+            StringBuffer sb = new StringBuffer("LoopClauses -- ");
+            for (int i = 0; i < 4; ++i) {
+                if (i > 0) {
+                    sb.append("       ");
+                }
+                sb.append('<').append(i).append(">: ");
+                MethodHandle[] hs = clauses[i];
+                for (int j = 0; j < hs.length; ++j) {
+                    if (j > 0) {
+                        sb.append("          ");
+                    }
+                    sb.append('*').append(j).append(": ").append(hs[j]).append('\n');
+                }
+            }
+            sb.append(" --\n");
+            return sb.toString();
+        }
+    }
 
     /**
      * Intrinsified during LambdaForm compilation
      * (see {@link InvokerBytecodeGenerator#emitLoop(int)}).
      */
     @LambdaForm.Hidden
-    static Object loop(BasicType[] localTypes, MethodHandle[] init, MethodHandle[] step, MethodHandle[] pred,
-                       MethodHandle[] fini, Object... av) throws Throwable {
+    static Object loop(BasicType[] localTypes, LoopClauses clauseData, Object... av) throws Throwable {
+        final MethodHandle[] init = clauseData.clauses[0];
+        final MethodHandle[] step = clauseData.clauses[1];
+        final MethodHandle[] pred = clauseData.clauses[2];
+        final MethodHandle[] fini = clauseData.clauses[3];
         int varSize = (int) Stream.of(init).filter(h -> h.type().returnType() != void.class).count();
         int nArgs = init[0].type().parameterCount();
         Object[] varsAndArgs = new Object[varSize + nArgs];
         for (int i = 0, v = 0; i < init.length; ++i) {
-            if (init[i].type().returnType() == void.class) {
-                init[i].asFixedArity().invokeWithArguments(av);
+            MethodHandle ih = init[i];
+            if (ih.type().returnType() == void.class) {
+                ih.invokeWithArguments(av);
             } else {
-                varsAndArgs[v++] = init[i].asFixedArity().invokeWithArguments(av);
+                varsAndArgs[v++] = ih.invokeWithArguments(av);
             }
         }
         System.arraycopy(av, 0, varsAndArgs, varSize, nArgs);
@@ -1926,12 +1947,12 @@
                 MethodHandle s = step[i];
                 MethodHandle f = fini[i];
                 if (s.type().returnType() == void.class) {
-                    s.asFixedArity().invokeWithArguments(varsAndArgs);
+                    s.invokeWithArguments(varsAndArgs);
                 } else {
-                    varsAndArgs[v++] = s.asFixedArity().invokeWithArguments(varsAndArgs);
+                    varsAndArgs[v++] = s.invokeWithArguments(varsAndArgs);
                 }
-                if (!(boolean) p.asFixedArity().invokeWithArguments(varsAndArgs)) {
-                    return f.asFixedArity().invokeWithArguments(varsAndArgs);
+                if (!(boolean) p.invokeWithArguments(varsAndArgs)) {
+                    return f.invokeWithArguments(varsAndArgs);
                 }
             }
         }
@@ -2122,14 +2143,13 @@
         Throwable t = null;
         Object r = null;
         try {
-            // Use asFixedArity() to avoid unnecessary boxing of last argument for VarargsCollector case.
-            r = target.asFixedArity().invokeWithArguments(av);
+            r = target.invokeWithArguments(av);
         } catch (Throwable thrown) {
             t = thrown;
             throw t;
         } finally {
             Object[] args = target.type().returnType() == void.class ? prepend(av, t) : prepend(av, t, r);
-            r = cleanup.asFixedArity().invokeWithArguments(args);
+            r = cleanup.invokeWithArguments(args);
         }
         return r;
     }
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Tue Sep 27 09:04:49 2016 -0700
@@ -4368,10 +4368,11 @@
         }
 
         // Step 4: fill in missing parameter types.
-        List<MethodHandle> finit = fillParameterTypes(init, commonSuffix);
-        List<MethodHandle> fstep = fillParameterTypes(step, commonParameterSequence);
-        List<MethodHandle> fpred = fillParameterTypes(pred, commonParameterSequence);
-        List<MethodHandle> ffini = fillParameterTypes(fini, commonParameterSequence);
+        // Also convert all handles to fixed-arity handles.
+        List<MethodHandle> finit = fixArities(fillParameterTypes(init, commonSuffix));
+        List<MethodHandle> fstep = fixArities(fillParameterTypes(step, commonParameterSequence));
+        List<MethodHandle> fpred = fixArities(fillParameterTypes(pred, commonParameterSequence));
+        List<MethodHandle> ffini = fixArities(fillParameterTypes(fini, commonParameterSequence));
 
         assert finit.stream().map(MethodHandle::type).map(MethodType::parameterList).
                 allMatch(pl -> pl.equals(commonSuffix));
@@ -4389,6 +4390,10 @@
         }).collect(Collectors.toList());
     }
 
+    private static List<MethodHandle> fixArities(List<MethodHandle> hs) {
+        return hs.stream().map(MethodHandle::asFixedArity).collect(Collectors.toList());
+    }
+
     /**
      * Constructs a {@code while} loop from an initializer, a body, and a predicate. This is a convenience wrapper for
      * the {@linkplain #loop(MethodHandle[][]) generic loop combinator}.
@@ -4887,7 +4892,8 @@
         // target parameter list.
         cleanup = dropArgumentsToMatch(cleanup, (rtype == void.class ? 1 : 2), targetParamTypes, 0);
 
-        return MethodHandleImpl.makeTryFinally(target, cleanup, rtype, targetParamTypes);
+        // Use asFixedArity() to avoid unnecessary boxing of last argument for VarargsCollector case.
+        return MethodHandleImpl.makeTryFinally(target.asFixedArity(), cleanup.asFixedArity(), rtype, targetParamTypes);
     }
 
     /**
--- a/src/java.base/share/classes/java/lang/module/ModuleInfo.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/java/lang/module/ModuleInfo.java	Tue Sep 27 09:04:49 2016 -0700
@@ -664,7 +664,7 @@
             try {
                 bb.get(b, off, len);
             } catch (BufferUnderflowException e) {
-                throw new EOFException();
+                throw new EOFException(e.getMessage());
             }
         }
 
@@ -681,7 +681,7 @@
                 int ch = bb.get();
                 return (ch != 0);
             } catch (BufferUnderflowException e) {
-                throw new EOFException();
+                throw new EOFException(e.getMessage());
             }
         }
 
@@ -690,7 +690,7 @@
             try {
                 return bb.get();
             } catch (BufferUnderflowException e) {
-                throw new EOFException();
+                throw new EOFException(e.getMessage());
             }
         }
 
@@ -699,7 +699,7 @@
             try {
                 return ((int) bb.get()) & 0xff;
             } catch (BufferUnderflowException e) {
-                throw new EOFException();
+                throw new EOFException(e.getMessage());
             }
         }
 
@@ -708,7 +708,7 @@
             try {
                 return bb.getShort();
             } catch (BufferUnderflowException e) {
-                throw new EOFException();
+                throw new EOFException(e.getMessage());
             }
         }
 
@@ -717,7 +717,7 @@
             try {
                 return ((int) bb.getShort()) & 0xffff;
             } catch (BufferUnderflowException e) {
-                throw new EOFException();
+                throw new EOFException(e.getMessage());
             }
         }
 
@@ -726,7 +726,7 @@
             try {
                 return bb.getChar();
             } catch (BufferUnderflowException e) {
-                throw new EOFException();
+                throw new EOFException(e.getMessage());
             }
         }
 
@@ -735,7 +735,7 @@
             try {
                 return bb.getInt();
             } catch (BufferUnderflowException e) {
-                throw new EOFException();
+                throw new EOFException(e.getMessage());
             }
         }
 
@@ -744,7 +744,7 @@
             try {
                 return bb.getLong();
             } catch (BufferUnderflowException e) {
-                throw new EOFException();
+                throw new EOFException(e.getMessage());
             }
         }
 
@@ -753,7 +753,7 @@
             try {
                 return bb.getFloat();
             } catch (BufferUnderflowException e) {
-                throw new EOFException();
+                throw new EOFException(e.getMessage());
             }
         }
 
@@ -762,7 +762,7 @@
             try {
                 return bb.getDouble();
             } catch (BufferUnderflowException e) {
-                throw new EOFException();
+                throw new EOFException(e.getMessage());
             }
         }
 
--- a/src/java.base/share/classes/java/lang/reflect/Proxy.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/java/lang/reflect/Proxy.java	Tue Sep 27 09:04:49 2016 -0700
@@ -597,10 +597,10 @@
         private final Module module;
         ProxyBuilder(ClassLoader loader, List<Class<?>> interfaces) {
             if (!VM.isModuleSystemInited()) {
-                throw new InternalError("Proxy is not supported until module system is fully initialzed");
+                throw new InternalError("Proxy is not supported until module system is fully initialized");
             }
             if (interfaces.size() > 65535) {
-                throw new IllegalArgumentException("interface limit exceeded");
+                throw new IllegalArgumentException("interface limit exceeded: " + interfaces.size());
             }
 
             Set<Class<?>> refTypes = referencedTypes(loader, interfaces);
--- a/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java	Tue Sep 27 09:04:49 2016 -0700
@@ -2559,6 +2559,13 @@
      * exceptionally with a CompletionException with this exception as
      * cause.
      *
+     * <p>Unless overridden by a subclass, a new non-minimal
+     * CompletableFuture with all methods available can be obtained from
+     * a minimal CompletionStage via {@link #toCompletableFuture()}.
+     * For example, completion of a minimal stage can be awaited by
+     *
+     * <pre> {@code minimalStage.toCompletableFuture().join(); }</pre>
+     *
      * @return the new CompletionStage
      * @since 9
      */
@@ -2853,6 +2860,16 @@
         @Override public CompletableFuture<T> completeOnTimeout
             (T value, long timeout, TimeUnit unit) {
             throw new UnsupportedOperationException(); }
+        @Override public CompletableFuture<T> toCompletableFuture() {
+            Object r;
+            if ((r = result) != null)
+                return new CompletableFuture<T>(encodeRelay(r));
+            else {
+                CompletableFuture<T> d = new CompletableFuture<>();
+                unipush(new UniRelay<T,T>(d, this));
+                return d;
+            }
+        }
     }
 
     // VarHandle mechanics
--- a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java	Tue Sep 27 09:04:49 2016 -0700
@@ -1191,7 +1191,7 @@
      * Default idle timeout value (in milliseconds) for the thread
      * triggering quiescence to park waiting for new work
      */
-    private static final long DEFAULT_KEEPALIVE = 60000L;
+    private static final long DEFAULT_KEEPALIVE = 60_000L;
 
     /**
      * Undershoot tolerance for idle timeouts
@@ -2303,7 +2303,6 @@
             throw new NullPointerException();
         long ms = Math.max(unit.toMillis(keepAliveTime), TIMEOUT_SLOP);
 
-        String prefix = "ForkJoinPool-" + nextPoolId() + "-worker-";
         int corep = Math.min(Math.max(corePoolSize, parallelism), MAX_CAP);
         long c = ((((long)(-corep)       << TC_SHIFT) & TC_MASK) |
                   (((long)(-parallelism) << RC_SHIFT) & RC_MASK));
@@ -2315,8 +2314,8 @@
         n |= n >>> 1; n |= n >>> 2; n |= n >>> 4; n |= n >>> 8; n |= n >>> 16;
         n = (n + 1) << 1; // power of two, including space for submission queues
 
+        this.workerNamePrefix = "ForkJoinPool-" + nextPoolId() + "-worker-";
         this.workQueues = new WorkQueue[n];
-        this.workerNamePrefix = prefix;
         this.factory = factory;
         this.ueh = handler;
         this.saturate = saturate;
@@ -2327,11 +2326,19 @@
         checkPermission();
     }
 
+    private Object newInstanceFromSystemProperty(String property)
+        throws ReflectiveOperationException {
+        String className = System.getProperty(property);
+        return (className == null)
+            ? null
+            : ClassLoader.getSystemClassLoader().loadClass(className)
+            .getConstructor().newInstance();
+    }
+
     /**
      * Constructor for common pool using parameters possibly
      * overridden by system properties
      */
-    @SuppressWarnings("deprecation") // Class.newInstance
     private ForkJoinPool(byte forCommonPoolOnly) {
         int parallelism = -1;
         ForkJoinWorkerThreadFactory fac = null;
@@ -2339,18 +2346,12 @@
         try {  // ignore exceptions in accessing/parsing properties
             String pp = System.getProperty
                 ("java.util.concurrent.ForkJoinPool.common.parallelism");
-            String fp = System.getProperty
-                ("java.util.concurrent.ForkJoinPool.common.threadFactory");
-            String hp = System.getProperty
-                ("java.util.concurrent.ForkJoinPool.common.exceptionHandler");
             if (pp != null)
                 parallelism = Integer.parseInt(pp);
-            if (fp != null)
-                fac = ((ForkJoinWorkerThreadFactory)ClassLoader.
-                           getSystemClassLoader().loadClass(fp).newInstance());
-            if (hp != null)
-                handler = ((UncaughtExceptionHandler)ClassLoader.
-                           getSystemClassLoader().loadClass(hp).newInstance());
+            fac = (ForkJoinWorkerThreadFactory) newInstanceFromSystemProperty(
+                "java.util.concurrent.ForkJoinPool.common.threadFactory");
+            handler = (UncaughtExceptionHandler) newInstanceFromSystemProperty(
+                "java.util.concurrent.ForkJoinPool.common.exceptionHandler");
         } catch (Exception ignore) {
         }
 
@@ -2373,8 +2374,8 @@
         n |= n >>> 1; n |= n >>> 2; n |= n >>> 4; n |= n >>> 8; n |= n >>> 16;
         n = (n + 1) << 1;
 
+        this.workerNamePrefix = "ForkJoinPool.commonPool-worker-";
         this.workQueues = new WorkQueue[n];
-        this.workerNamePrefix = "ForkJoinPool.commonPool-worker-";
         this.factory = fac;
         this.ueh = handler;
         this.saturate = null;
--- a/src/java.base/share/classes/java/util/concurrent/atomic/DoubleAccumulator.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/DoubleAccumulator.java	Tue Sep 27 09:04:49 2016 -0700
@@ -35,6 +35,9 @@
 
 package java.util.concurrent.atomic;
 
+import static java.lang.Double.doubleToRawLongBits;
+import static java.lang.Double.longBitsToDouble;
+
 import java.io.Serializable;
 import java.util.function.DoubleBinaryOperator;
 
@@ -91,7 +94,7 @@
     public DoubleAccumulator(DoubleBinaryOperator accumulatorFunction,
                              double identity) {
         this.function = accumulatorFunction;
-        base = this.identity = Double.doubleToRawLongBits(identity);
+        base = this.identity = doubleToRawLongBits(identity);
     }
 
     /**
@@ -101,18 +104,19 @@
      */
     public void accumulate(double x) {
         Cell[] as; long b, v, r; int m; Cell a;
-        if ((as = cells) != null ||
-            (r = Double.doubleToRawLongBits
-             (function.applyAsDouble
-              (Double.longBitsToDouble(b = base), x))) != b  && !casBase(b, r)) {
+        if ((as = cells) != null
+            || ((r = doubleToRawLongBits
+                (function.applyAsDouble(longBitsToDouble(b = base), x))) != b
+                && !casBase(b, r))) {
             boolean uncontended = true;
-            if (as == null || (m = as.length - 1) < 0 ||
-                (a = as[getProbe() & m]) == null ||
-                !(uncontended =
-                  (r = Double.doubleToRawLongBits
-                   (function.applyAsDouble
-                    (Double.longBitsToDouble(v = a.value), x))) == v ||
-                  a.cas(v, r)))
+            if (as == null
+                || (m = as.length - 1) < 0
+                || (a = as[getProbe() & m]) == null
+                || !(uncontended =
+                     ((r = doubleToRawLongBits
+                       (function.applyAsDouble
+                        (longBitsToDouble(v = a.value), x))) == v)
+                     || a.cas(v, r)))
                 doubleAccumulate(x, function, uncontended);
         }
     }
@@ -128,12 +132,12 @@
      */
     public double get() {
         Cell[] as = cells;
-        double result = Double.longBitsToDouble(base);
+        double result = longBitsToDouble(base);
         if (as != null) {
             for (Cell a : as)
                 if (a != null)
                     result = function.applyAsDouble
-                        (result, Double.longBitsToDouble(a.value));
+                        (result, longBitsToDouble(a.value));
         }
         return result;
     }
@@ -168,12 +172,12 @@
      */
     public double getThenReset() {
         Cell[] as = cells;
-        double result = Double.longBitsToDouble(base);
+        double result = longBitsToDouble(base);
         base = identity;
         if (as != null) {
             for (Cell a : as) {
                 if (a != null) {
-                    double v = Double.longBitsToDouble(a.value);
+                    double v = longBitsToDouble(a.value);
                     a.reset(identity);
                     result = function.applyAsDouble(result, v);
                 }
@@ -267,9 +271,9 @@
          * held by this proxy
          */
         private Object readResolve() {
-            double d = Double.longBitsToDouble(identity);
+            double d = longBitsToDouble(identity);
             DoubleAccumulator a = new DoubleAccumulator(function, d);
-            a.base = Double.doubleToRawLongBits(value);
+            a.base = doubleToRawLongBits(value);
             return a;
         }
     }
--- a/src/java.base/share/classes/java/util/concurrent/atomic/LongAccumulator.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/LongAccumulator.java	Tue Sep 27 09:04:49 2016 -0700
@@ -103,14 +103,16 @@
      */
     public void accumulate(long x) {
         Cell[] as; long b, v, r; int m; Cell a;
-        if ((as = cells) != null ||
-            (r = function.applyAsLong(b = base, x)) != b && !casBase(b, r)) {
+        if ((as = cells) != null
+            || ((r = function.applyAsLong(b = base, x)) != b
+                && !casBase(b, r))) {
             boolean uncontended = true;
-            if (as == null || (m = as.length - 1) < 0 ||
-                (a = as[getProbe() & m]) == null ||
-                !(uncontended =
-                  (r = function.applyAsLong(v = a.value, x)) == v ||
-                  a.cas(v, r)))
+            if (as == null
+                || (m = as.length - 1) < 0
+                || (a = as[getProbe() & m]) == null
+                || !(uncontended =
+                     (r = function.applyAsLong(v = a.value, x)) == v
+                     || a.cas(v, r)))
                 longAccumulate(x, function, uncontended);
         }
     }
--- a/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java	Tue Sep 27 09:04:49 2016 -0700
@@ -186,7 +186,9 @@
 
         if (result.getMajorVersion() != ImageHeader.MAJOR_VERSION ||
             result.getMinorVersion() != ImageHeader.MINOR_VERSION) {
-            throw new IOException("The image file \"" + name + "\" is not the correct version");
+            throw new IOException("The image file \"" + name + "\" is not " +
+                "the correct version. Major: " + result.getMajorVersion() +
+                ". Minor: " + result.getMinorVersion());
         }
 
         return result;
@@ -318,11 +320,11 @@
 
     private ByteBuffer readBuffer(long offset, long size) {
         if (offset < 0 || Integer.MAX_VALUE <= offset) {
-            throw new IndexOutOfBoundsException("offset");
+            throw new IndexOutOfBoundsException("Bad offset: " + offset);
         }
 
         if (size < 0 || Integer.MAX_VALUE <= size) {
-            throw new IndexOutOfBoundsException("size");
+            throw new IndexOutOfBoundsException("Bad size: " + size);
         }
 
         if (MAP_ALL) {
@@ -382,11 +384,13 @@
         long uncompressedSize = loc.getUncompressedSize();
 
         if (compressedSize < 0 || Integer.MAX_VALUE < compressedSize) {
-            throw new IndexOutOfBoundsException("Compressed size");
+            throw new IndexOutOfBoundsException(
+                "Bad compressed size: " + compressedSize);
         }
 
         if (uncompressedSize < 0 || Integer.MAX_VALUE < uncompressedSize) {
-            throw new IndexOutOfBoundsException("Uncompressed size");
+            throw new IndexOutOfBoundsException(
+                "Bad uncompressed size: " + uncompressedSize);
         }
 
         if (compressedSize == 0) {
--- a/src/java.base/share/classes/jdk/internal/jimage/ImageHeader.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/jdk/internal/jimage/ImageHeader.java	Tue Sep 27 09:04:49 2016 -0700
@@ -79,7 +79,8 @@
         Objects.requireNonNull(buffer);
 
         if (buffer.capacity() != HEADER_SLOTS) {
-            throw new InternalError("jimage header not the correct size");
+            throw new InternalError(
+                "jimage header not the correct size: " + buffer.capacity());
         }
 
         int magic = buffer.get(0);
--- a/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java	Tue Sep 27 09:04:49 2016 -0700
@@ -81,7 +81,8 @@
                 }
 
                 if (kind < ATTRIBUTE_END || ATTRIBUTE_COUNT <= kind) {
-                    throw new InternalError("Invalid jimage attribute kind");
+                    throw new InternalError(
+                        "Invalid jimage attribute kind: " + kind);
                 }
 
                 int length = attributeLength(data);
@@ -91,7 +92,7 @@
                     value <<= 8;
 
                     if (!bytes.hasRemaining()) {
-                        throw new InternalError("\"Missing jimage attribute datad");
+                        throw new InternalError("Missing jimage attribute data");
                     }
 
                     value |= bytes.get() & 0xFF;
@@ -134,7 +135,8 @@
 
     long getAttribute(int kind) {
         if (kind < ATTRIBUTE_END || ATTRIBUTE_COUNT <= kind) {
-            throw new InternalError("Invalid jimage attribute kind");
+            throw new InternalError(
+                "Invalid jimage attribute kind: " + kind);
         }
 
         return attributes[kind];
@@ -142,7 +144,8 @@
 
     String getAttributeString(int kind) {
         if (kind < ATTRIBUTE_END || ATTRIBUTE_COUNT <= kind) {
-            throw new InternalError("Invalid jimage attribute kind");
+            throw new InternalError(
+                "Invalid jimage attribute kind: " + kind);
         }
 
         return getStrings().get((int)attributes[kind]);
--- a/src/java.base/share/classes/jdk/internal/jimage/ImageStream.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/jdk/internal/jimage/ImageStream.java	Tue Sep 27 09:04:49 2016 -0700
@@ -82,7 +82,7 @@
 
     public void ensure(int needs) {
         if (needs < 0) {
-            throw new IndexOutOfBoundsException("needs");
+            throw new IndexOutOfBoundsException("Bad value: " + needs);
         }
 
         if (needs > buffer.remaining()) {
@@ -106,7 +106,7 @@
 
     public void skip(int n) {
         if (n < 0) {
-            throw new IndexOutOfBoundsException("n");
+            throw new IndexOutOfBoundsException("skip value = " + n);
         }
 
         buffer.position(buffer.position() + n);
--- a/src/java.base/share/classes/jdk/internal/jimage/ImageStringsReader.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/jdk/internal/jimage/ImageStringsReader.java	Tue Sep 27 09:04:49 2016 -0700
@@ -151,7 +151,7 @@
         try {
             charsFromMUTF8(chars, bytes, offset, count);
         } catch (UTFDataFormatException ex) {
-            throw new InternalError("Attempt to convert non modified UTF-8 byte sequence");
+            throw new InternalError("Attempt to convert non modified UTF-8 byte sequence", ex);
         }
 
         return new String(chars);
@@ -199,7 +199,8 @@
                     ch = buffer.get();
 
                     if ((ch & 0xC0) != 0x80) {
-                        throw new InternalError("Bad continuation in modified UTF-8 byte sequence");
+                        throw new InternalError("Bad continuation in " +
+                            "modified UTF-8 byte sequence: " + ch);
                     }
 
                     uch = ((uch & ~mask) << 6) | (ch & 0x3F);
@@ -208,7 +209,8 @@
             }
 
             if ((uch & 0xFFFF) != uch) {
-                throw new InternalError("UTF-32 char in modified UTF-8 byte sequence");
+                throw new InternalError("UTF-32 char in modified UTF-8 " +
+                    "byte sequence: " + uch);
             }
 
             chars[j++] = (char)uch;
--- a/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java	Tue Sep 27 09:04:49 2016 -0700
@@ -183,7 +183,7 @@
     public PathMatcher getPathMatcher(String syntaxAndInput) {
         int pos = syntaxAndInput.indexOf(':');
         if (pos <= 0 || pos == syntaxAndInput.length()) {
-            throw new IllegalArgumentException();
+            throw new IllegalArgumentException("pos is " + pos);
         }
         String syntax = syntaxAndInput.substring(0, pos);
         String input = syntaxAndInput.substring(pos + 1);
@@ -285,7 +285,8 @@
         for (OpenOption option : options) {
             Objects.requireNonNull(option);
             if (!(option instanceof StandardOpenOption)) {
-                throw new IllegalArgumentException();
+                throw new IllegalArgumentException(
+                    "option class: " + option.getClass());
             }
         }
         if (options.contains(StandardOpenOption.WRITE) ||
--- a/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java	Tue Sep 27 09:04:49 2016 -0700
@@ -122,7 +122,8 @@
     public final JrtPath getName(int index) {
         initOffsets();
         if (index < 0 || index >= offsets.length) {
-            throw new IllegalArgumentException();
+            throw new IllegalArgumentException("index: " +
+                index + ", offsets length: " + offsets.length);
         }
         int begin = offsets[index];
         int end;
@@ -139,7 +140,9 @@
         initOffsets();
         if (beginIndex < 0 || endIndex > offsets.length ||
             beginIndex >= endIndex) {
-            throw new IllegalArgumentException();
+            throw new IllegalArgumentException(
+                "beginIndex: " + beginIndex + ", endIndex: " + endIndex +
+                ", offsets length: " + offsets.length);
         }
         // starting/ending offsets
         int begin = offsets[beginIndex];
@@ -211,7 +214,8 @@
             return o;
         }
         if (jrtfs != o.jrtfs || isAbsolute() != o.isAbsolute()) {
-            throw new IllegalArgumentException();
+            throw new IllegalArgumentException(
+                "Incorrect filesystem or path: " + other);
         }
         final String tp = this.path;
         final String op = o.path;
@@ -366,7 +370,8 @@
     private JrtPath checkPath(Path path) {
         Objects.requireNonNull(path);
         if (!(path instanceof JrtPath))
-            throw new ProviderMismatchException();
+            throw new ProviderMismatchException("path class: " +
+                path.getClass());
         return (JrtPath) path;
     }
 
@@ -459,7 +464,7 @@
             }
             if (c == '\u0000') {
                 throw new InvalidPathException(path,
-                        "Path: nul character not allowed");
+                        "Path: NUL character not allowed");
             }
             to.append(c);
             prevC = c;
--- a/src/java.base/share/classes/jdk/internal/misc/VM.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/jdk/internal/misc/VM.java	Tue Sep 27 09:04:49 2016 -0700
@@ -50,7 +50,7 @@
     public static void initLevel(int value) {
         synchronized (lock) {
             if (value <= initLevel || value > SYSTEM_BOOTED)
-                throw new InternalError();
+                throw new InternalError("Bad level: " + value);
             initLevel = value;
             lock.notifyAll();
         }
--- a/src/java.base/share/classes/module-info.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/module-info.java	Tue Sep 27 09:04:49 2016 -0700
@@ -166,6 +166,7 @@
         jdk.charsets,
         jdk.compiler,
         jdk.jartool,
+        jdk.jdeps,
         jdk.jlink,
         jdk.net,
         jdk.scripting.nashorn,
@@ -189,7 +190,8 @@
         jdk.unsupported,
         jdk.vm.ci;
     exports jdk.internal.util.jar to
-        jdk.jartool;
+        jdk.jartool,
+        jdk.jdeps;
     exports jdk.internal.vm to
         java.management,
         jdk.jvmstat;
--- a/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java	Tue Sep 27 09:04:49 2016 -0700
@@ -328,8 +328,6 @@
     public SocketAddress receive(ByteBuffer dst) throws IOException {
         if (dst.isReadOnly())
             throw new IllegalArgumentException("Read-only buffer");
-        if (dst == null)
-            throw new NullPointerException();
         synchronized (readLock) {
             ensureOpen();
             // Socket was not bound before attempting receive
@@ -716,8 +714,6 @@
 
     @Override
     public DatagramChannel connect(SocketAddress sa) throws IOException {
-        int localPort = 0;
-
         synchronized(readLock) {
             synchronized(writeLock) {
                 synchronized (stateLock) {
--- a/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java	Tue Sep 27 09:04:49 2016 -0700
@@ -616,8 +616,6 @@
     }
 
     public boolean connect(SocketAddress sa) throws IOException {
-        int localPort = 0;
-
         synchronized (readLock) {
             synchronized (writeLock) {
                 ensureOpenAndUnconnected();
--- a/src/java.base/share/classes/sun/security/provider/SeedGenerator.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/share/classes/sun/security/provider/SeedGenerator.java	Tue Sep 27 09:04:49 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -344,7 +344,8 @@
                         try {
                             BogusThread bt = new BogusThread();
                             Thread t = new Thread
-                                (seedGroup, bt, "SeedGenerator Thread", 0, false);
+                                (seedGroup, bt, "SeedGenerator Thread", 0,
+                                        false);
                             t.start();
                         } catch (Exception e) {
                             throw new InternalError("internal error: " +
@@ -357,7 +358,8 @@
                         long startTime = System.nanoTime();
                         while (System.nanoTime() - startTime < 250000000) {
                             synchronized(this){};
-                            latch++;
+                            // Mask the sign bit and keep latch non-negative
+                            latch = (latch + 1) & 0x1FFFFFFF;
                         }
 
                         // Translate the value using the permutation, and xor
@@ -431,7 +433,7 @@
         // data and using it to mix the trivial permutation.
         // It should be evenly distributed. The specific values
         // are not crucial to the security of this class.
-        private static byte[] rndTab = {
+        private static final byte[] rndTab = {
             56, 30, -107, -6, -86, 25, -83, 75, -12, -64,
             5, -128, 78, 21, 16, 32, 70, -81, 37, -51,
             -43, -46, -108, 87, 29, 17, -55, 22, -11, -111,
--- a/src/java.base/windows/native/libnet/Inet4AddressImpl.c	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.base/windows/native/libnet/Inet4AddressImpl.c	Tue Sep 27 09:04:49 2016 -0700
@@ -33,6 +33,7 @@
 #include <process.h>
 #include <iphlpapi.h>
 #include <icmpapi.h>
+#include <WinError.h>
 
 #include "java_net_InetAddress.h"
 #include "java_net_Inet4AddressImpl.h"
@@ -442,7 +443,15 @@
     DWORD ReplySize = 0;
     jboolean ret = JNI_FALSE;
 
-    ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData);
+    // https://msdn.microsoft.com/en-us/library/windows/desktop/aa366051%28v=vs.85%29.aspx
+    ReplySize = sizeof(ICMP_ECHO_REPLY)   // The buffer should be large enough
+                                          // to hold at least one ICMP_ECHO_REPLY
+                                          // structure
+                + sizeof(SendData)        // plus RequestSize bytes of data.
+                + 8;                      // This buffer should also be large enough
+                                          // to also hold 8 more bytes of data
+                                          // (the size of an ICMP error message)
+
     ReplyBuffer = (VOID*) malloc(ReplySize);
     if (ReplyBuffer == NULL) {
         IcmpCloseHandle(hIcmpFile);
@@ -478,10 +487,47 @@
                                    (timeout < 1000) ? 1000 : timeout);   // DWORD Timeout
     }
 
-    if (dwRetVal != 0) {
+    if (dwRetVal == 0) { // if the call failed
+        TCHAR *buf;
+        DWORD err = WSAGetLastError();
+        switch (err) {
+            case ERROR_NO_NETWORK:
+            case ERROR_NETWORK_UNREACHABLE:
+            case ERROR_HOST_UNREACHABLE:
+            case ERROR_PROTOCOL_UNREACHABLE:
+            case ERROR_PORT_UNREACHABLE:
+            case ERROR_REQUEST_ABORTED:
+            case ERROR_INCORRECT_ADDRESS:
+            case ERROR_HOST_DOWN:
+            case ERROR_INVALID_COMPUTERNAME:
+            case ERROR_INVALID_NETNAME:
+            case WSAEHOSTUNREACH:   /* Host Unreachable */
+            case WSAENETUNREACH:    /* Network Unreachable */
+            case WSAENETDOWN:       /* Network is down */
+            case WSAEPFNOSUPPORT:   /* Protocol Family unsupported */
+            case IP_REQ_TIMED_OUT:
+                break;
+            default:
+                FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+                        NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                        (LPTSTR)&buf, 0, NULL);
+                NET_ThrowNew(env, err, buf);
+                LocalFree(buf);
+                break;
+        }
+    } else {
         PICMP_ECHO_REPLY pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer;
-        if ((int)pEchoReply->RoundTripTime <= timeout)
+
+        // This is to take into account the undocumented minimum
+        // timeout mentioned in the IcmpSendEcho call above.
+        // We perform an extra check to make sure that our
+        // roundtrip time was less than our desired timeout
+        // for cases where that timeout is < 1000ms.
+        if (pEchoReply->Status == IP_SUCCESS
+                && (int)pEchoReply->RoundTripTime <= timeout)
+        {
             ret = JNI_TRUE;
+        }
     }
 
     free(ReplyBuffer);
--- a/src/java.desktop/share/classes/com/sun/beans/finder/ConstructorFinder.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.desktop/share/classes/com/sun/beans/finder/ConstructorFinder.java	Tue Sep 27 09:04:49 2016 -0700
@@ -67,19 +67,22 @@
      */
     public static Constructor<?> findConstructor(Class<?> type, Class<?>...args) throws NoSuchMethodException {
         if (type.isPrimitive()) {
-            throw new NoSuchMethodException("Primitive wrapper does not contain constructors");
+            throw new NoSuchMethodException("Primitive wrapper does not contain constructors: "
+                + type.getName());
         }
         if (type.isInterface()) {
-            throw new NoSuchMethodException("Interface does not contain constructors");
+            throw new NoSuchMethodException("Interface does not contain constructors: "
+                + type.getName());
         }
         if (!FinderUtils.isExported(type)) {
-            throw new NoSuchMethodException("Class is not accessible");
+            throw new NoSuchMethodException("Class is not accessible: " + type.getName());
         }
         if (Modifier.isAbstract(type.getModifiers())) {
-            throw new NoSuchMethodException("Abstract class cannot be instantiated");
+            throw new NoSuchMethodException("Abstract class cannot be instantiated: "
+                + type.getName());
         }
         if (!Modifier.isPublic(type.getModifiers()) || !isPackageAccessible(type)) {
-            throw new NoSuchMethodException("Class is not accessible");
+            throw new NoSuchMethodException("Class is not accessible: " + type.getName());
         }
         PrimitiveWrapperMap.replacePrimitivesWithWrappers(args);
         Signature signature = new Signature(type, args);
--- a/src/java.desktop/share/classes/javax/imageio/ImageReader.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.desktop/share/classes/javax/imageio/ImageReader.java	Tue Sep 27 09:04:49 2016 -0700
@@ -2461,16 +2461,16 @@
             try {
                 bundle = ResourceBundle.getBundle(baseName, locale, this.getClass().getModule());
             } catch (MissingResourceException mre) {
-                throw new IllegalArgumentException("Bundle not found!");
+                throw new IllegalArgumentException("Bundle not found!", mre);
             }
 
             String warning = null;
             try {
                 warning = bundle.getString(keyword);
             } catch (ClassCastException cce) {
-                throw new IllegalArgumentException("Resource is not a String!");
+                throw new IllegalArgumentException("Resource is not a String!", cce);
             } catch (MissingResourceException mre) {
-                throw new IllegalArgumentException("Resource is missing!");
+                throw new IllegalArgumentException("Resource is missing!", mre);
             }
 
             listener.warningOccurred(this, warning);
--- a/src/java.desktop/share/classes/javax/imageio/ImageWriter.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.desktop/share/classes/javax/imageio/ImageWriter.java	Tue Sep 27 09:04:49 2016 -0700
@@ -1963,16 +1963,16 @@
             try {
                 bundle = ResourceBundle.getBundle(baseName, locale, this.getClass().getModule());
             } catch (MissingResourceException mre) {
-                throw new IllegalArgumentException("Bundle not found!");
+                throw new IllegalArgumentException("Bundle not found!", mre);
             }
 
             String warning = null;
             try {
                 warning = bundle.getString(keyword);
             } catch (ClassCastException cce) {
-                throw new IllegalArgumentException("Resource is not a String!");
+                throw new IllegalArgumentException("Resource is not a String!", cce);
             } catch (MissingResourceException mre) {
-                throw new IllegalArgumentException("Resource is missing!");
+                throw new IllegalArgumentException("Resource is missing!", mre);
             }
 
             listener.warningOccurred(this, imageIndex, warning);
--- a/src/java.desktop/unix/native/libjawt/jawt.c	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/java.desktop/unix/native/libjawt/jawt.c	Tue Sep 27 09:04:49 2016 -0700
@@ -39,6 +39,10 @@
  */
 JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt)
 {
+#if defined(HEADLESS)
+    /* there are no AWT libs available at all */
+    return JNI_FALSE;
+#else
     if (awt == NULL) {
         return JNI_FALSE;
     }
@@ -64,4 +68,5 @@
     }
 
     return JNI_TRUE;
+#endif
 }
--- a/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsKeyMaterialGenerator.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsKeyMaterialGenerator.java	Tue Sep 27 09:04:49 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -68,8 +68,8 @@
     // master secret as a P11Key
     private P11Key p11Key;
 
-    // version, e.g. 0x0301
-    private int version;
+    // whether SSLv3 is supported
+    private final boolean supportSSLv3;
 
     P11TlsKeyMaterialGenerator(Token token, String algorithm, long mechanism)
             throws PKCS11Exception {
@@ -77,6 +77,11 @@
         this.token = token;
         this.algorithm = algorithm;
         this.mechanism = mechanism;
+
+        // Given the current lookup order specified in SunPKCS11.java,
+        // if CKM_SSL3_KEY_AND_MAC_DERIVE is not used to construct this object,
+        // it means that this mech is disabled or unsupported.
+        this.supportSSLv3 = (mechanism == CKM_SSL3_KEY_AND_MAC_DERIVE);
     }
 
     protected void engineInit(SecureRandom random) {
@@ -89,20 +94,26 @@
         if (params instanceof TlsKeyMaterialParameterSpec == false) {
             throw new InvalidAlgorithmParameterException(MSG);
         }
-        this.spec = (TlsKeyMaterialParameterSpec)params;
+
+        TlsKeyMaterialParameterSpec spec = (TlsKeyMaterialParameterSpec)params;
+        int version = (spec.getMajorVersion() << 8) | spec.getMinorVersion();
+
+        if ((version == 0x0300 && !supportSSLv3) || (version < 0x0300) ||
+            (version > 0x0302)) {
+             throw new InvalidAlgorithmParameterException
+                    ("Only" + (supportSSLv3? " SSL 3.0,": "") +
+                     " TLS 1.0, and TLS 1.1 are supported (0x" +
+                     Integer.toHexString(version) + ")");
+        }
         try {
             p11Key = P11SecretKeyFactory.convertKey
                             (token, spec.getMasterSecret(), "TlsMasterSecret");
         } catch (InvalidKeyException e) {
             throw new InvalidAlgorithmParameterException("init() failed", e);
         }
-        version = (spec.getMajorVersion() << 8) | spec.getMinorVersion();
-        if ((version < 0x0300) && (version > 0x0302)) {
-            throw new InvalidAlgorithmParameterException
-                    ("Only SSL 3.0, TLS 1.0, and TLS 1.1 are supported");
-        }
-        // we assume the token supports both the CKM_SSL3_* and the CKM_TLS_*
-        // mechanisms
+        this.spec = spec;
+        this.mechanism = (version == 0x0300)?
+            CKM_SSL3_KEY_AND_MAC_DERIVE : CKM_TLS_KEY_AND_MAC_DERIVE;
     }
 
     protected void engineInit(int keysize, SecureRandom random) {
@@ -115,8 +126,6 @@
             throw new IllegalStateException
                 ("TlsKeyMaterialGenerator must be initialized");
         }
-        mechanism = (version == 0x0300) ? CKM_SSL3_KEY_AND_MAC_DERIVE
-                                         : CKM_TLS_KEY_AND_MAC_DERIVE;
         int macBits = spec.getMacKeyLength() << 3;
         int ivBits = spec.getIvLength() << 3;
 
--- a/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsMasterSecretGenerator.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsMasterSecretGenerator.java	Tue Sep 27 09:04:49 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,10 @@
     private TlsMasterSecretParameterSpec spec;
     private P11Key p11Key;
 
-    int version;
+    CK_VERSION ckVersion;
+
+    // whether SSLv3 is supported
+    private final boolean supportSSLv3;
 
     P11TlsMasterSecretGenerator(Token token, String algorithm, long mechanism)
             throws PKCS11Exception {
@@ -69,6 +72,11 @@
         this.token = token;
         this.algorithm = algorithm;
         this.mechanism = mechanism;
+
+        // Given the current lookup order specified in SunPKCS11.java, if
+        // CKM_SSL3_MASTER_KEY_DERIVE is not used to construct this object,
+        // it means that this mech is disabled or unsupported.
+        supportSSLv3 = (mechanism == CKM_SSL3_MASTER_KEY_DERIVE);
     }
 
     protected void engineInit(SecureRandom random) {
@@ -81,7 +89,17 @@
         if (params instanceof TlsMasterSecretParameterSpec == false) {
             throw new InvalidAlgorithmParameterException(MSG);
         }
-        this.spec = (TlsMasterSecretParameterSpec)params;
+
+        TlsMasterSecretParameterSpec spec = (TlsMasterSecretParameterSpec)params;
+        int version = (spec.getMajorVersion() << 8) | spec.getMinorVersion();
+        if ((version == 0x0300 && !supportSSLv3) || (version < 0x0300) ||
+            (version > 0x0302)) {
+             throw new InvalidAlgorithmParameterException
+                    ("Only" + (supportSSLv3? " SSL 3.0,": "") +
+                     " TLS 1.0, and TLS 1.1 are supported (0x" +
+                     Integer.toHexString(version) + ")");
+        }
+
         SecretKey key = spec.getPremasterSecret();
         // algorithm should be either TlsRsaPremasterSecret or TlsPremasterSecret,
         // but we omit the check
@@ -90,25 +108,7 @@
         } catch (InvalidKeyException e) {
             throw new InvalidAlgorithmParameterException("init() failed", e);
         }
-        version = (spec.getMajorVersion() << 8) | spec.getMinorVersion();
-        if ((version < 0x0300) || (version > 0x0302)) {
-            throw new InvalidAlgorithmParameterException
-                ("Only SSL 3.0, TLS 1.0, and TLS 1.1 supported");
-        }
-        // We assume the token supports the required mechanism. If it does not,
-        // generateKey() will fail and the failover should take care of us.
-    }
-
-    protected void engineInit(int keysize, SecureRandom random) {
-        throw new InvalidParameterException(MSG);
-    }
-
-    protected SecretKey engineGenerateKey() {
-        if (spec == null) {
-            throw new IllegalStateException
-                ("TlsMasterSecretGenerator must be initialized");
-        }
-        CK_VERSION ckVersion;
+        this.spec = spec;
         if (p11Key.getAlgorithm().equals("TlsRsaPremasterSecret")) {
             mechanism = (version == 0x0300) ? CKM_SSL3_MASTER_KEY_DERIVE
                                              : CKM_TLS_MASTER_KEY_DERIVE;
@@ -124,6 +124,17 @@
                                              : CKM_TLS_MASTER_KEY_DERIVE_DH;
             ckVersion = null;
         }
+    }
+
+    protected void engineInit(int keysize, SecureRandom random) {
+        throw new InvalidParameterException(MSG);
+    }
+
+    protected SecretKey engineGenerateKey() {
+        if (spec == null) {
+            throw new IllegalStateException
+                ("TlsMasterSecretGenerator must be initialized");
+        }
         byte[] clientRandom = spec.getClientRandom();
         byte[] serverRandom = spec.getServerRandom();
         CK_SSL3_RANDOM_DATA random =
@@ -139,13 +150,12 @@
             long keyID = token.p11.C_DeriveKey(session.id(),
                 new CK_MECHANISM(mechanism, params), p11Key.keyID, attributes);
             int major, minor;
-            ckVersion = params.pVersion;
-            if (ckVersion == null) {
+            if (params.pVersion == null) {
                 major = -1;
                 minor = -1;
             } else {
-                major = ckVersion.major;
-                minor = ckVersion.minor;
+                major = params.pVersion.major;
+                minor = params.pVersion.minor;
             }
             SecretKey key = P11Key.masterSecretKey(session, keyID,
                 "TlsMasterSecret", 48 << 3, attributes, major, minor);
@@ -156,5 +166,4 @@
             token.releaseSession(session);
         }
     }
-
 }
--- a/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsRsaPremasterSecretGenerator.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsRsaPremasterSecretGenerator.java	Tue Sep 27 09:04:49 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,12 +60,20 @@
     @SuppressWarnings("deprecation")
     private TlsRsaPremasterSecretParameterSpec spec;
 
+    // whether SSLv3 is supported
+    private final boolean supportSSLv3;
+
     P11TlsRsaPremasterSecretGenerator(Token token, String algorithm, long mechanism)
             throws PKCS11Exception {
         super();
         this.token = token;
         this.algorithm = algorithm;
         this.mechanism = mechanism;
+
+        // Given the current lookup order specified in SunPKCS11.java,
+        // if CKM_SSL3_PRE_MASTER_KEY_GEN is not used to construct this object,
+        // it means that this mech is disabled or unsupported.
+        this.supportSSLv3 = (mechanism == CKM_SSL3_PRE_MASTER_KEY_GEN);
     }
 
     protected void engineInit(SecureRandom random) {
@@ -78,7 +86,20 @@
         if (!(params instanceof TlsRsaPremasterSecretParameterSpec)) {
             throw new InvalidAlgorithmParameterException(MSG);
         }
-        this.spec = (TlsRsaPremasterSecretParameterSpec)params;
+
+        TlsRsaPremasterSecretParameterSpec spec =
+            (TlsRsaPremasterSecretParameterSpec) params;
+
+        int version = (spec.getMajorVersion() << 8) | spec.getMinorVersion();
+
+        if ((version == 0x0300 && !supportSSLv3) || (version < 0x0300) ||
+            (version > 0x0302)) {
+             throw new InvalidAlgorithmParameterException
+                    ("Only" + (supportSSLv3? " SSL 3.0,": "") +
+                     " TLS 1.0, and TLS 1.1 are supported (0x" +
+                     Integer.toHexString(version) + ")");
+        }
+        this.spec = spec;
     }
 
     protected void engineInit(int keysize, SecureRandom random) {
--- a/test/com/sun/net/httpserver/Test5.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/com/sun/net/httpserver/Test5.java	Tue Sep 27 09:04:49 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -145,6 +145,7 @@
         socket.close();
         s = new String (b,0,count, "ISO8859_1");
         if (!compare (s, result)) {
+            System.err.println(" Expected [" + result + "]\n actual [" + s + "]");
             throw new RuntimeException ("wrong string result");
         }
     }
--- a/test/java/io/PrintStream/FormatLocale.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/io/PrintStream/FormatLocale.java	Tue Sep 27 09:04:49 2016 -0700
@@ -21,10 +21,11 @@
  * questions.
  */
 
-/**
+/*
  * @test
  * @bug 8146156
  * @summary test whether conversion follows Locale.Category.FORMAT locale.
+ * @modules jdk.localedata
  * @run main/othervm FormatLocale
  */
 
--- a/test/java/lang/invoke/MethodHandlesTest.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/lang/invoke/MethodHandlesTest.java	Tue Sep 27 09:04:49 2016 -0700
@@ -632,6 +632,7 @@
     }
 
     public void testFindVirtualClone0() throws Throwable {
+        if (CAN_SKIP_WORKING)  return;
         // test some ad hoc system methods
         testFindVirtual(false, PUBLIC, Object.class, Object.class, "clone");
 
@@ -2798,11 +2799,17 @@
             toClauseMajor(postClauses, inits, steps, usePreds, finis);
             MethodHandle pre = MethodHandles.loop(preClauses);
             MethodHandle post = MethodHandles.loop(postClauses);
+            if (verbosity >= 6) {
+                System.out.println("pre-handle: " + pre);
+            }
             Object[] preResults = (Object[]) pre.invokeWithArguments(args);
             if (verbosity >= 4) {
                 System.out.println("pre-checked: expected " + Arrays.asList(preCheckedResults[i]) + ", actual " +
                         Arrays.asList(preResults));
             }
+            if (verbosity >= 6) {
+                System.out.println("post-handle: " + post);
+            }
             Object[] postResults = (Object[]) post.invokeWithArguments(args);
             if (verbosity >= 4) {
                 System.out.println("post-checked: expected " + Arrays.asList(postCheckedResults[i]) + ", actual " +
--- a/test/java/net/MulticastSocket/TimeToLive.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/net/MulticastSocket/TimeToLive.java	Tue Sep 27 09:04:49 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,26 +37,27 @@
     static int[] bad_ttls = { -1, 256 };
 
     public static void main(String[] args) throws Exception {
-        MulticastSocket socket = new MulticastSocket(6789);
-        int ttl = socket.getTimeToLive();
-        System.out.println("default ttl: " + ttl);
-        for (int i = 0; i < new_ttls.length; i++) {
-            socket.setTimeToLive(new_ttls[i]);
-            if (!(new_ttls[i] == socket.getTimeToLive())) {
-                throw new RuntimeException("test failure, set/get differ: " +
-                                           new_ttls[i] + " /  " +
-                                           socket.getTimeToLive());
+        try (MulticastSocket socket = new MulticastSocket()) {
+            int ttl = socket.getTimeToLive();
+            System.out.println("default ttl: " + ttl);
+            for (int i = 0; i < new_ttls.length; i++) {
+                socket.setTimeToLive(new_ttls[i]);
+                if (!(new_ttls[i] == socket.getTimeToLive())) {
+                    throw new RuntimeException("test failure, set/get differ: " +
+                            new_ttls[i] + " /  " +
+                            socket.getTimeToLive());
+                }
             }
-        }
-        for (int j = 0; j < bad_ttls.length; j++) {
-            boolean exception = false;
-            try {
-                socket.setTimeToLive(bad_ttls[j]);
-            } catch (IllegalArgumentException e) {
-                exception = true;
-            }
-            if (!exception) {
-                throw new RuntimeException("bad argument accepted: " + bad_ttls[j]);
+            for (int j = 0; j < bad_ttls.length; j++) {
+                boolean exception = false;
+                try {
+                    socket.setTimeToLive(bad_ttls[j]);
+                } catch (IllegalArgumentException e) {
+                    exception = true;
+                }
+                if (!exception) {
+                    throw new RuntimeException("bad argument accepted: " + bad_ttls[j]);
+                }
             }
         }
     }
--- a/test/java/net/ServerSocket/ThreadStop.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/net/ServerSocket/ThreadStop.java	Tue Sep 27 09:04:49 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -68,23 +68,23 @@
         thr.start();
 
         // give server time to block in ServerSocket.accept()
-        Thread.currentThread().sleep(2000);
+        Thread.sleep(2000);
 
         // "stop" the thread
         thr.stop();
 
         // give thread time to stop
-        Thread.currentThread().sleep(2000);
+        Thread.sleep(2000);
 
         // it's platform specific if Thread.stop interrupts the
         // thread - on Linux/Windows most likely that thread is
         // still in accept() so we connect to server which causes
         // it to unblock and do JNI-stuff with a pending exception
 
-        try {
-            Socket s = new Socket("localhost", svr.localPort());
-        } catch (IOException ioe) { }
-
+        try (Socket s = new Socket("localhost", svr.localPort())) {
+        } catch (IOException ioe) {
+        }
+        thr.join();
     }
 
 }
--- a/test/java/net/Socket/InheritHandle.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/net/Socket/InheritHandle.java	Tue Sep 27 09:04:49 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
    @author Chris Hegarty
  */
 
+import java.net.BindException;
 import java.net.ServerSocket;
 import java.io.File;
 import java.io.IOException;
@@ -74,6 +75,11 @@
         } catch (IOException ioe) {
             System.out.println("Cannot create process");
             ioe.printStackTrace();
+            try {
+                ss.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
             return;
         }
 
@@ -85,9 +91,18 @@
             System.out.println("Now close the socket and try to create another" +
                                " one listening on the same port");
             ss.close();
-            ss = new ServerSocket(port);
-            System.out.println("Second ServerSocket created successfully");
-            ss.close();
+            int retries = 0;
+            while (retries < 5) {
+                try (ServerSocket s = new ServerSocket(port);) {
+                    System.out.println("Second ServerSocket created successfully");
+                    break;
+                } catch (BindException e) {
+                    System.out.println("BindException \"" + e.getMessage() + "\", retrying...");
+                    Thread.sleep(100L);
+                    retries ++;
+                    continue;
+                }
+            }
 
         } catch (InterruptedException ie) {
         } catch (IOException ioe) {
--- a/test/java/util/Collections/EmptyNavigableMap.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/Collections/EmptyNavigableMap.java	Tue Sep 27 09:04:49 2016 -0700
@@ -33,7 +33,6 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Iterator;
-import java.util.NoSuchElementException;
 import java.util.NavigableMap;
 import java.util.SortedMap;
 import java.util.TreeMap;
@@ -41,10 +40,8 @@
 import org.testng.annotations.DataProvider;
 
 import static org.testng.Assert.fail;
-import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertSame;
 
 public class EmptyNavigableMap {
 
--- a/test/java/util/Collections/EmptyNavigableSet.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/Collections/EmptyNavigableSet.java	Tue Sep 27 09:04:49 2016 -0700
@@ -41,10 +41,9 @@
 import org.testng.annotations.DataProvider;
 
 import static org.testng.Assert.fail;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
 
 public class EmptyNavigableSet {
 
--- a/test/java/util/Deque/ChorusLine.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/Deque/ChorusLine.java	Tue Sep 27 09:04:49 2016 -0700
@@ -28,8 +28,14 @@
  * @author Martin Buchholz
  */
 
-import java.util.*;
-import java.util.concurrent.*;
+import java.util.ArrayDeque;
+import java.util.Collection;
+import java.util.Deque;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.NoSuchElementException;
+import java.util.concurrent.ConcurrentLinkedDeque;
+import java.util.concurrent.LinkedBlockingDeque;
 
 public class ChorusLine {
     private interface Tweaker {
--- a/test/java/util/PriorityQueue/ForgetMeNot.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/PriorityQueue/ForgetMeNot.java	Tue Sep 27 09:04:49 2016 -0700
@@ -28,7 +28,11 @@
  * @author Martin Buchholz
  */
 
-import java.util.*;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.PriorityQueue;
+import java.util.Queue;
 
 public class ForgetMeNot {
     private static void checkQ(PriorityQueue<Integer> q, Integer...elts) {
--- a/test/java/util/PriorityQueue/PriorityQueueSort.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/PriorityQueue/PriorityQueueSort.java	Tue Sep 27 09:04:49 2016 -0700
@@ -37,7 +37,13 @@
  * @summary Checks that a priority queue returns elements in sorted order across various operations
  */
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Queue;
+import java.util.PriorityQueue;
 
 public class PriorityQueueSort {
 
--- a/test/java/util/PriorityQueue/RemoveContains.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/PriorityQueue/RemoveContains.java	Tue Sep 27 09:04:49 2016 -0700
@@ -28,8 +28,17 @@
  * @author  Martin Buchholz
  */
 
-import java.util.*;
-import java.util.concurrent.*;
+import java.util.ArrayDeque;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.PriorityQueue;
+import java.util.Queue;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.PriorityBlockingQueue;
+import java.util.concurrent.LinkedTransferQueue;
 
 public class RemoveContains {
     static volatile int passed = 0, failed = 0;
--- a/test/java/util/concurrent/Executors/AutoShutdown.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/concurrent/Executors/AutoShutdown.java	Tue Sep 27 09:04:49 2016 -0700
@@ -31,8 +31,6 @@
  */
 
 import static java.util.concurrent.Executors.defaultThreadFactory;
-import static java.util.concurrent.Executors.newFixedThreadPool;
-import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
 import static java.util.concurrent.Executors.newSingleThreadExecutor;
 
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
--- a/test/java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java	Tue Sep 27 09:04:49 2016 -0700
@@ -83,15 +83,18 @@
         tpe.allowCoreThreadTimeOut(true);
         check(tpe.allowsCoreThreadTimeOut());
         equal(countExecutorThreads(), 0);
-        long t0 = System.nanoTime();
-        for (int i = 0; i < threadCount; i++)
-            tpe.submit(new Runnable() { public void run() {}});
-        int count = countExecutorThreads();
-        if (millisElapsedSince(t0) < timeoutMillis)
-            equal(count, threadCount);
+        long startTime = System.nanoTime();
+        for (int i = 0; i < threadCount; i++) {
+            tpe.submit(() -> {});
+            int count = countExecutorThreads();
+            if (millisElapsedSince(startTime) < timeoutMillis)
+                equal(count, i + 1);
+        }
         while (countExecutorThreads() > 0 &&
-               millisElapsedSince(t0) < 10 * 1000);
+               millisElapsedSince(startTime) < LONG_DELAY_MS)
+            Thread.yield();
         equal(countExecutorThreads(), 0);
+        check(millisElapsedSince(startTime) >= timeoutMillis);
         tpe.shutdown();
         check(tpe.allowsCoreThreadTimeOut());
         check(tpe.awaitTermination(LONG_DELAY_MS, MILLISECONDS));
--- a/test/java/util/concurrent/tck/AtomicIntegerArrayTest.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/concurrent/tck/AtomicIntegerArrayTest.java	Tue Sep 27 09:04:49 2016 -0700
@@ -303,7 +303,7 @@
 
     class Counter extends CheckedRunnable {
         final AtomicIntegerArray aa;
-        volatile int counts;
+        int decs;
         Counter(AtomicIntegerArray a) { aa = a; }
         public void realRun() {
             for (;;) {
@@ -314,7 +314,7 @@
                     if (v != 0) {
                         done = false;
                         if (aa.compareAndSet(i, v, v - 1))
-                            ++counts;
+                            decs++;
                     }
                 }
                 if (done)
@@ -334,13 +334,11 @@
             aa.set(i, countdown);
         Counter c1 = new Counter(aa);
         Counter c2 = new Counter(aa);
-        Thread t1 = new Thread(c1);
-        Thread t2 = new Thread(c2);
-        t1.start();
-        t2.start();
+        Thread t1 = newStartedThread(c1);
+        Thread t2 = newStartedThread(c2);
         t1.join();
         t2.join();
-        assertEquals(c1.counts+c2.counts, SIZE * countdown);
+        assertEquals(c1.decs + c2.decs, SIZE * countdown);
     }
 
     /**
--- a/test/java/util/concurrent/tck/AtomicLongArrayTest.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/concurrent/tck/AtomicLongArrayTest.java	Tue Sep 27 09:04:49 2016 -0700
@@ -302,7 +302,7 @@
 
     class Counter extends CheckedRunnable {
         final AtomicLongArray aa;
-        volatile long counts;
+        int decs;
         Counter(AtomicLongArray a) { aa = a; }
         public void realRun() {
             for (;;) {
@@ -313,7 +313,7 @@
                     if (v != 0) {
                         done = false;
                         if (aa.compareAndSet(i, v, v - 1))
-                            ++counts;
+                            decs++;
                     }
                 }
                 if (done)
@@ -333,13 +333,11 @@
             aa.set(i, countdown);
         Counter c1 = new Counter(aa);
         Counter c2 = new Counter(aa);
-        Thread t1 = new Thread(c1);
-        Thread t2 = new Thread(c2);
-        t1.start();
-        t2.start();
+        Thread t1 = newStartedThread(c1);
+        Thread t2 = newStartedThread(c2);
         t1.join();
         t2.join();
-        assertEquals(c1.counts+c2.counts, SIZE * countdown);
+        assertEquals(c1.decs + c2.decs, SIZE * countdown);
     }
 
     /**
--- a/test/java/util/concurrent/tck/CompletableFutureTest.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/concurrent/tck/CompletableFutureTest.java	Tue Sep 27 09:04:49 2016 -0700
@@ -388,7 +388,7 @@
         checkCompletedNormally(f, "test");
     }
 
-    abstract class CheckedAction {
+    abstract static class CheckedAction {
         int invocationCount = 0;
         final ExecutionMode m;
         CheckedAction(ExecutionMode m) { this.m = m; }
@@ -400,7 +400,7 @@
         void assertInvoked() { assertEquals(1, invocationCount); }
     }
 
-    abstract class CheckedIntegerAction extends CheckedAction {
+    abstract static class CheckedIntegerAction extends CheckedAction {
         Integer value;
         CheckedIntegerAction(ExecutionMode m) { super(m); }
         void assertValue(Integer expected) {
@@ -409,7 +409,7 @@
         }
     }
 
-    class IntegerSupplier extends CheckedAction
+    static class IntegerSupplier extends CheckedAction
         implements Supplier<Integer>
     {
         final Integer value;
@@ -428,7 +428,7 @@
         return (x == null) ? null : x + 1;
     }
 
-    class NoopConsumer extends CheckedIntegerAction
+    static class NoopConsumer extends CheckedIntegerAction
         implements Consumer<Integer>
     {
         NoopConsumer(ExecutionMode m) { super(m); }
@@ -438,7 +438,7 @@
         }
     }
 
-    class IncFunction extends CheckedIntegerAction
+    static class IncFunction extends CheckedIntegerAction
         implements Function<Integer,Integer>
     {
         IncFunction(ExecutionMode m) { super(m); }
@@ -456,7 +456,7 @@
             - ((y == null) ? 99 : y.intValue());
     }
 
-    class SubtractAction extends CheckedIntegerAction
+    static class SubtractAction extends CheckedIntegerAction
         implements BiConsumer<Integer, Integer>
     {
         SubtractAction(ExecutionMode m) { super(m); }
@@ -466,7 +466,7 @@
         }
     }
 
-    class SubtractFunction extends CheckedIntegerAction
+    static class SubtractFunction extends CheckedIntegerAction
         implements BiFunction<Integer, Integer, Integer>
     {
         SubtractFunction(ExecutionMode m) { super(m); }
@@ -476,14 +476,14 @@
         }
     }
 
-    class Noop extends CheckedAction implements Runnable {
+    static class Noop extends CheckedAction implements Runnable {
         Noop(ExecutionMode m) { super(m); }
         public void run() {
             invoked();
         }
     }
 
-    class FailingSupplier extends CheckedAction
+    static class FailingSupplier extends CheckedAction
         implements Supplier<Integer>
     {
         final CFException ex;
@@ -494,7 +494,7 @@
         }
     }
 
-    class FailingConsumer extends CheckedIntegerAction
+    static class FailingConsumer extends CheckedIntegerAction
         implements Consumer<Integer>
     {
         final CFException ex;
@@ -506,7 +506,7 @@
         }
     }
 
-    class FailingBiConsumer extends CheckedIntegerAction
+    static class FailingBiConsumer extends CheckedIntegerAction
         implements BiConsumer<Integer, Integer>
     {
         final CFException ex;
@@ -518,7 +518,7 @@
         }
     }
 
-    class FailingFunction extends CheckedIntegerAction
+    static class FailingFunction extends CheckedIntegerAction
         implements Function<Integer, Integer>
     {
         final CFException ex;
@@ -530,7 +530,7 @@
         }
     }
 
-    class FailingBiFunction extends CheckedIntegerAction
+    static class FailingBiFunction extends CheckedIntegerAction
         implements BiFunction<Integer, Integer, Integer>
     {
         final CFException ex;
@@ -542,7 +542,7 @@
         }
     }
 
-    class FailingRunnable extends CheckedAction implements Runnable {
+    static class FailingRunnable extends CheckedAction implements Runnable {
         final CFException ex;
         FailingRunnable(ExecutionMode m) { super(m); ex = new CFException(); }
         public void run() {
@@ -551,7 +551,7 @@
         }
     }
 
-    class CompletableFutureInc extends CheckedIntegerAction
+    static class CompletableFutureInc extends CheckedIntegerAction
         implements Function<Integer, CompletableFuture<Integer>>
     {
         CompletableFutureInc(ExecutionMode m) { super(m); }
@@ -564,7 +564,7 @@
         }
     }
 
-    class FailingCompletableFutureFunction extends CheckedIntegerAction
+    static class FailingCompletableFutureFunction extends CheckedIntegerAction
         implements Function<Integer, CompletableFuture<Integer>>
     {
         final CFException ex;
@@ -3604,29 +3604,53 @@
      * copy returns a CompletableFuture that is completed normally,
      * with the same value, when source is.
      */
-    public void testCopy() {
+    public void testCopy_normalCompletion() {
+        for (boolean createIncomplete : new boolean[] { true, false })
+        for (Integer v1 : new Integer[] { 1, null })
+    {
         CompletableFuture<Integer> f = new CompletableFuture<>();
+        if (!createIncomplete) assertTrue(f.complete(v1));
         CompletableFuture<Integer> g = f.copy();
-        checkIncomplete(f);
-        checkIncomplete(g);
-        f.complete(1);
-        checkCompletedNormally(f, 1);
-        checkCompletedNormally(g, 1);
-    }
+        if (createIncomplete) {
+            checkIncomplete(f);
+            checkIncomplete(g);
+            assertTrue(f.complete(v1));
+        }
+        checkCompletedNormally(f, v1);
+        checkCompletedNormally(g, v1);
+    }}
 
     /**
      * copy returns a CompletableFuture that is completed exceptionally
      * when source is.
      */
-    public void testCopy2() {
+    public void testCopy_exceptionalCompletion() {
+        for (boolean createIncomplete : new boolean[] { true, false })
+    {
+        CFException ex = new CFException();
         CompletableFuture<Integer> f = new CompletableFuture<>();
+        if (!createIncomplete) f.completeExceptionally(ex);
         CompletableFuture<Integer> g = f.copy();
-        checkIncomplete(f);
-        checkIncomplete(g);
-        CFException ex = new CFException();
-        f.completeExceptionally(ex);
+        if (createIncomplete) {
+            checkIncomplete(f);
+            checkIncomplete(g);
+            f.completeExceptionally(ex);
+        }
         checkCompletedExceptionally(f, ex);
         checkCompletedWithWrappedException(g, ex);
+    }}
+
+    /**
+     * Completion of a copy does not complete its source.
+     */
+    public void testCopy_oneWayPropagation() {
+        CompletableFuture<Integer> f = new CompletableFuture<>();
+        assertTrue(f.copy().complete(1));
+        assertTrue(f.copy().complete(null));
+        assertTrue(f.copy().cancel(true));
+        assertTrue(f.copy().cancel(false));
+        assertTrue(f.copy().completeExceptionally(new CFException()));
+        checkIncomplete(f);
     }
 
     /**
@@ -3991,7 +4015,10 @@
             .collect(Collectors.toList());
 
         List<CompletionStage<Integer>> stages = new ArrayList<>();
-        stages.add(new CompletableFuture<Integer>().minimalCompletionStage());
+        CompletionStage<Integer> min =
+            new CompletableFuture<Integer>().minimalCompletionStage();
+        stages.add(min);
+        stages.add(min.thenApply(x -> x));
         stages.add(CompletableFuture.completedStage(1));
         stages.add(CompletableFuture.failedStage(new CFException()));
 
@@ -4027,6 +4054,131 @@
             throw new Error("Methods did not throw UOE: " + bugs);
     }
 
+    /**
+     * minimalStage.toCompletableFuture() returns a CompletableFuture that
+     * is completed normally, with the same value, when source is.
+     */
+    public void testMinimalCompletionStage_toCompletableFuture_normalCompletion() {
+        for (boolean createIncomplete : new boolean[] { true, false })
+        for (Integer v1 : new Integer[] { 1, null })
+    {
+        CompletableFuture<Integer> f = new CompletableFuture<>();
+        CompletionStage<Integer> minimal = f.minimalCompletionStage();
+        if (!createIncomplete) assertTrue(f.complete(v1));
+        CompletableFuture<Integer> g = minimal.toCompletableFuture();
+        if (createIncomplete) {
+            checkIncomplete(f);
+            checkIncomplete(g);
+            assertTrue(f.complete(v1));
+        }
+        checkCompletedNormally(f, v1);
+        checkCompletedNormally(g, v1);
+    }}
+
+    /**
+     * minimalStage.toCompletableFuture() returns a CompletableFuture that
+     * is completed exceptionally when source is.
+     */
+    public void testMinimalCompletionStage_toCompletableFuture_exceptionalCompletion() {
+        for (boolean createIncomplete : new boolean[] { true, false })
+    {
+        CFException ex = new CFException();
+        CompletableFuture<Integer> f = new CompletableFuture<>();
+        CompletionStage<Integer> minimal = f.minimalCompletionStage();
+        if (!createIncomplete) f.completeExceptionally(ex);
+        CompletableFuture<Integer> g = minimal.toCompletableFuture();
+        if (createIncomplete) {
+            checkIncomplete(f);
+            checkIncomplete(g);
+            f.completeExceptionally(ex);
+        }
+        checkCompletedExceptionally(f, ex);
+        checkCompletedWithWrappedException(g, ex);
+    }}
+
+    /**
+     * minimalStage.toCompletableFuture() gives mutable CompletableFuture
+     */
+    public void testMinimalCompletionStage_toCompletableFuture_mutable() {
+        for (Integer v1 : new Integer[] { 1, null })
+    {
+        CompletableFuture<Integer> f = new CompletableFuture<>();
+        CompletionStage minimal = f.minimalCompletionStage();
+        CompletableFuture<Integer> g = minimal.toCompletableFuture();
+        assertTrue(g.complete(v1));
+        checkCompletedNormally(g, v1);
+        checkIncomplete(f);
+        checkIncomplete(minimal.toCompletableFuture());
+    }}
+
+    /**
+     * minimalStage.toCompletableFuture().join() awaits completion
+     */
+    public void testMinimalCompletionStage_toCompletableFuture_join() throws Exception {
+        for (boolean createIncomplete : new boolean[] { true, false })
+        for (Integer v1 : new Integer[] { 1, null })
+    {
+        CompletableFuture<Integer> f = new CompletableFuture<>();
+        if (!createIncomplete) assertTrue(f.complete(v1));
+        CompletionStage<Integer> minimal = f.minimalCompletionStage();
+        if (createIncomplete) assertTrue(f.complete(v1));
+        assertEquals(v1, minimal.toCompletableFuture().join());
+        assertEquals(v1, minimal.toCompletableFuture().get());
+        checkCompletedNormally(minimal.toCompletableFuture(), v1);
+    }}
+
+    /**
+     * Completion of a toCompletableFuture copy of a minimal stage
+     * does not complete its source.
+     */
+    public void testMinimalCompletionStage_toCompletableFuture_oneWayPropagation() {
+        CompletableFuture<Integer> f = new CompletableFuture<>();
+        CompletionStage<Integer> g = f.minimalCompletionStage();
+        assertTrue(g.toCompletableFuture().complete(1));
+        assertTrue(g.toCompletableFuture().complete(null));
+        assertTrue(g.toCompletableFuture().cancel(true));
+        assertTrue(g.toCompletableFuture().cancel(false));
+        assertTrue(g.toCompletableFuture().completeExceptionally(new CFException()));
+        checkIncomplete(g.toCompletableFuture());
+        f.complete(1);
+        checkCompletedNormally(g.toCompletableFuture(), 1);
+    }
+
+    /** Demo utility method for external reliable toCompletableFuture */
+    static <T> CompletableFuture<T> toCompletableFuture(CompletionStage<T> stage) {
+        CompletableFuture<T> f = new CompletableFuture<>();
+        stage.handle((T t, Throwable ex) -> {
+                         if (ex != null) f.completeExceptionally(ex);
+                         else f.complete(t);
+                         return null;
+                     });
+        return f;
+    }
+
+    /** Demo utility method to join a CompletionStage */
+    static <T> T join(CompletionStage<T> stage) {
+        return toCompletableFuture(stage).join();
+    }
+
+    /**
+     * Joining a minimal stage "by hand" works
+     */
+    public void testMinimalCompletionStage_join_by_hand() {
+        for (boolean createIncomplete : new boolean[] { true, false })
+        for (Integer v1 : new Integer[] { 1, null })
+    {
+        CompletableFuture<Integer> f = new CompletableFuture<>();
+        CompletionStage<Integer> minimal = f.minimalCompletionStage();
+        CompletableFuture<Integer> g = new CompletableFuture<>();
+        if (!createIncomplete) assertTrue(f.complete(v1));
+        minimal.thenAccept((x) -> g.complete(x));
+        if (createIncomplete) assertTrue(f.complete(v1));
+        g.join();
+        checkCompletedNormally(g, v1);
+        checkCompletedNormally(f, v1);
+        assertEquals(v1, join(minimal));
+    }}
+
     static class Monad {
         static class ZeroException extends RuntimeException {
             public ZeroException() { super("monadic zero"); }
@@ -4317,6 +4469,22 @@
             assertTrue(neverCompleted.thenRun(() -> {}).cancel(true));
     }
 
+    /**
+     * Checks for garbage retention when MinimalStage.toCompletableFuture()
+     * is invoked many times.
+     * 8161600: Garbage retention when source CompletableFutures are never completed
+     *
+     * As of 2016-07, fails with OOME:
+     * ant -Dvmoptions=-Xmx8m -Djsr166.expensiveTests=true -Djsr166.tckTestClass=CompletableFutureTest -Djsr166.methodFilter=testToCompletableFutureGarbageRetention tck
+     */
+    public void testToCompletableFutureGarbageRetention() throws Throwable {
+        final int n = expensiveTests ? 900_000 : 10;
+        CompletableFuture<Integer> neverCompleted = new CompletableFuture<>();
+        CompletionStage minimal = neverCompleted.minimalCompletionStage();
+        for (int i = 0; i < n; i++)
+            assertTrue(minimal.toCompletableFuture().cancel(true));
+    }
+
 //     static <U> U join(CompletionStage<U> stage) {
 //         CompletableFuture<U> f = new CompletableFuture<>();
 //         stage.whenComplete((v, ex) -> {
--- a/test/java/util/concurrent/tck/ConcurrentSkipListMapTest.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/concurrent/tck/ConcurrentSkipListMapTest.java	Tue Sep 27 09:04:49 2016 -0700
@@ -1024,7 +1024,7 @@
 
     static NavigableMap<Integer, Integer> newMap(Class cl) throws Exception {
         NavigableMap<Integer, Integer> result =
-            (NavigableMap<Integer, Integer>) cl.newInstance();
+            (NavigableMap<Integer, Integer>) cl.getConstructor().newInstance();
         assertEquals(0, result.size());
         assertFalse(result.keySet().iterator().hasNext());
         return result;
--- a/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java	Tue Sep 27 09:04:49 2016 -0700
@@ -725,7 +725,8 @@
     }
 
     static NavigableSet<Integer> newSet(Class cl) throws Exception {
-        NavigableSet<Integer> result = (NavigableSet<Integer>) cl.newInstance();
+        NavigableSet<Integer> result =
+            (NavigableSet<Integer>) cl.getConstructor().newInstance();
         assertEquals(0, result.size());
         assertFalse(result.iterator().hasNext());
         return result;
--- a/test/java/util/concurrent/tck/CyclicBarrierTest.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/concurrent/tck/CyclicBarrierTest.java	Tue Sep 27 09:04:49 2016 -0700
@@ -40,6 +40,7 @@
 import java.util.concurrent.CyclicBarrier;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -52,11 +53,6 @@
         return new TestSuite(CyclicBarrierTest.class);
     }
 
-    private volatile int countAction;
-    private class MyAction implements Runnable {
-        public void run() { ++countAction; }
-    }
-
     /**
      * Spin-waits till the number of waiters == numberOfWaiters.
      */
@@ -114,14 +110,16 @@
      * The supplied barrier action is run at barrier
      */
     public void testBarrierAction() throws Exception {
-        countAction = 0;
-        CyclicBarrier b = new CyclicBarrier(1, new MyAction());
+        final AtomicInteger count = new AtomicInteger(0);
+        final Runnable incCount = new Runnable() { public void run() {
+            count.getAndIncrement(); }};
+        CyclicBarrier b = new CyclicBarrier(1, incCount);
         assertEquals(1, b.getParties());
         assertEquals(0, b.getNumberWaiting());
         b.await();
         b.await();
         assertEquals(0, b.getNumberWaiting());
-        assertEquals(2, countAction);
+        assertEquals(2, count.get());
     }
 
     /**
--- a/test/java/util/concurrent/tck/DelayQueueTest.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/concurrent/tck/DelayQueueTest.java	Tue Sep 27 09:04:49 2016 -0700
@@ -121,10 +121,8 @@
         }
 
         public boolean equals(Object other) {
-            return equals((NanoDelay)other);
-        }
-        public boolean equals(NanoDelay other) {
-            return other.trigger == trigger;
+            return (other instanceof NanoDelay) &&
+                this.trigger == ((NanoDelay)other).trigger;
         }
 
         // suppress [overrides] javac warning
--- a/test/java/util/concurrent/tck/ForkJoinPoolTest.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/concurrent/tck/ForkJoinPoolTest.java	Tue Sep 27 09:04:49 2016 -0700
@@ -51,6 +51,7 @@
 import java.util.concurrent.RecursiveTask;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.ReentrantLock;
 
 import junit.framework.AssertionFailedError;
@@ -84,13 +85,6 @@
 
     // Some classes to test extension and factory methods
 
-    static class MyHandler implements Thread.UncaughtExceptionHandler {
-        volatile int catches = 0;
-        public void uncaughtException(Thread t, Throwable e) {
-            ++catches;
-        }
-    }
-
     static class MyError extends Error {}
 
     // to test handlers
@@ -101,9 +95,9 @@
 
     static class FailingThreadFactory
             implements ForkJoinPool.ForkJoinWorkerThreadFactory {
-        volatile int calls = 0;
+        final AtomicInteger calls = new AtomicInteger(0);
         public ForkJoinWorkerThread newThread(ForkJoinPool p) {
-            if (++calls > 1) return null;
+            if (calls.incrementAndGet() > 1) return null;
             return new FailingFJWSubclass(p);
         }
     }
--- a/test/java/util/concurrent/tck/JSR166TestCase.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/concurrent/tck/JSR166TestCase.java	Tue Sep 27 09:04:49 2016 -0700
@@ -1032,14 +1032,17 @@
         ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
         System.err.println("------ stacktrace dump start ------");
         for (ThreadInfo info : threadMXBean.dumpAllThreads(true, true)) {
-            String name = info.getThreadName();
+            final String name = info.getThreadName();
+            String lockName;
             if ("Signal Dispatcher".equals(name))
                 continue;
             if ("Reference Handler".equals(name)
-                && info.getLockName().startsWith("java.lang.ref.Reference$Lock"))
+                && (lockName = info.getLockName()) != null
+                && lockName.startsWith("java.lang.ref.Reference$Lock"))
                 continue;
             if ("Finalizer".equals(name)
-                && info.getLockName().startsWith("java.lang.ref.ReferenceQueue$Lock"))
+                && (lockName = info.getLockName()) != null
+                && lockName.startsWith("java.lang.ref.ReferenceQueue$Lock"))
                 continue;
             if ("checkForWedgedTest".equals(name))
                 continue;
@@ -1783,7 +1786,7 @@
      * A CyclicBarrier that uses timed await and fails with
      * AssertionFailedErrors instead of throwing checked exceptions.
      */
-    public class CheckedBarrier extends CyclicBarrier {
+    public static class CheckedBarrier extends CyclicBarrier {
         public CheckedBarrier(int parties) { super(parties); }
 
         public int await() {
--- a/test/java/util/concurrent/tck/ScheduledExecutorTest.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/concurrent/tck/ScheduledExecutorTest.java	Tue Sep 27 09:04:49 2016 -0700
@@ -537,15 +537,14 @@
      * isShutdown is false before shutdown, true after
      */
     public void testIsShutdown() {
-
         final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
-        try {
-            assertFalse(p.isShutdown());
+        assertFalse(p.isShutdown());
+        try (PoolCleaner cleaner = cleaner(p)) {
+            try {
+                p.shutdown();
+                assertTrue(p.isShutdown());
+            } catch (SecurityException ok) {}
         }
-        finally {
-            try { p.shutdown(); } catch (SecurityException ok) { return; }
-        }
-        assertTrue(p.isShutdown());
     }
 
     /**
--- a/test/java/util/concurrent/tck/TreeMapTest.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/concurrent/tck/TreeMapTest.java	Tue Sep 27 09:04:49 2016 -0700
@@ -829,7 +829,7 @@
 
     static NavigableMap<Integer, Integer> newMap(Class cl) throws Exception {
         NavigableMap<Integer, Integer> result
-            = (NavigableMap<Integer, Integer>) cl.newInstance();
+            = (NavigableMap<Integer, Integer>) cl.getConstructor().newInstance();
         assertEquals(0, result.size());
         assertFalse(result.keySet().iterator().hasNext());
         return result;
--- a/test/java/util/concurrent/tck/TreeSetTest.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/java/util/concurrent/tck/TreeSetTest.java	Tue Sep 27 09:04:49 2016 -0700
@@ -722,7 +722,8 @@
     }
 
     static NavigableSet<Integer> newSet(Class cl) throws Exception {
-        NavigableSet<Integer> result = (NavigableSet<Integer>) cl.newInstance();
+        NavigableSet<Integer> result =
+            (NavigableSet<Integer>) cl.getConstructor().newInstance();
         assertEquals(0, result.size());
         assertFalse(result.iterator().hasNext());
         return result;
--- a/test/sun/nio/cs/TestUnmappable.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/sun/nio/cs/TestUnmappable.java	Tue Sep 27 09:04:49 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,11 +28,11 @@
  * @bug 8008386
  * @summary (cs) Unmappable leading should be decoded to replacement.
  *          Tests for Shift_JIS and MS932 decoding
+ * @modules jdk.charsets
  * @run main TestUnmappable
  */
 
-import java.nio.*;
-import java.nio.charset.*;
+import java.nio.charset.Charset;
 
 public class TestUnmappable {
     public static void main(String args[]) throws Exception {
--- a/test/sun/security/pkcs11/tls/TestKeyMaterial.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/sun/security/pkcs11/tls/TestKeyMaterial.java	Tue Sep 27 09:04:49 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6316539
+ * @bug 6316539 8136355
  * @summary Known-answer-test for TlsKeyMaterial generator
  * @author Andreas Sterbenz
  * @library ..
@@ -37,6 +37,7 @@
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.security.Provider;
+import java.security.InvalidAlgorithmParameterException;
 import java.util.Arrays;
 import javax.crypto.KeyGenerator;
 import javax.crypto.SecretKey;
@@ -139,21 +140,28 @@
                         keyLength, expandedKeyLength, ivLength, macLength,
                         null, -1, -1);
 
-                    kg.init(spec);
-                    TlsKeyMaterialSpec result =
-                        (TlsKeyMaterialSpec)kg.generateKey();
-                    match(lineNumber, clientCipherBytes,
-                        result.getClientCipherKey(), cipherAlgorithm);
-                    match(lineNumber, serverCipherBytes,
-                        result.getServerCipherKey(), cipherAlgorithm);
-                    match(lineNumber, clientIv, result.getClientIv(), "");
-                    match(lineNumber, serverIv, result.getServerIv(), "");
-                    match(lineNumber, clientMacBytes, result.getClientMacKey(), "");
-                    match(lineNumber, serverMacBytes, result.getServerMacKey(), "");
-
-                } else {
+                    try {
+                        kg.init(spec);
+                        TlsKeyMaterialSpec result =
+                            (TlsKeyMaterialSpec)kg.generateKey();
+                        match(lineNumber, clientCipherBytes,
+                            result.getClientCipherKey(), cipherAlgorithm);
+                        match(lineNumber, serverCipherBytes,
+                            result.getServerCipherKey(), cipherAlgorithm);
+                        match(lineNumber, clientIv, result.getClientIv(), "");
+                        match(lineNumber, serverIv, result.getServerIv(), "");
+                        match(lineNumber, clientMacBytes, result.getClientMacKey(), "");
+                        match(lineNumber, serverMacBytes, result.getServerMacKey(), "");
+                    } catch (InvalidAlgorithmParameterException iape) {
+                        // SSLv3 support is removed in S12
+                        if (major == 3 && minor == 0) {
+                            System.out.println("Skip testing SSLv3");
+                            continue;
+                        }
+                    }
+               } else {
                     throw new Exception("Unknown line: " + line);
-                }
+               }
             }
             if (n == 0) {
                 throw new Exception("no tests");
--- a/test/sun/security/pkcs11/tls/TestMasterSecret.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/sun/security/pkcs11/tls/TestMasterSecret.java	Tue Sep 27 09:04:49 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6316539
+ * @bug 6316539 8136355
  * @summary Known-answer-test for TlsMasterSecret generator
  * @author Andreas Sterbenz
  * @library ..
@@ -38,6 +38,7 @@
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.security.Provider;
+import java.security.InvalidAlgorithmParameterException;
 import java.util.Arrays;
 import javax.crypto.KeyGenerator;
 import javax.crypto.SecretKey;
@@ -116,15 +117,24 @@
                         new TlsMasterSecretParameterSpec(premasterKey,
                             protoMajor, protoMinor, clientRandom, serverRandom,
                             null, -1, -1);
-                    kg.init(spec);
-                    TlsMasterSecret key = (TlsMasterSecret)kg.generateKey();
-                    byte[] enc = key.getEncoded();
-                    if (Arrays.equals(master, enc) == false) {
-                        throw new Exception("mismatch line: " + lineNumber);
-                    }
-                    if ((preMajor != key.getMajorVersion()) ||
-                            (preMinor != key.getMinorVersion())) {
-                        throw new Exception("version mismatch line: " + lineNumber);
+
+                    try {
+                        kg.init(spec);
+                        TlsMasterSecret key = (TlsMasterSecret)kg.generateKey();
+                        byte[] enc = key.getEncoded();
+                        if (Arrays.equals(master, enc) == false) {
+                            throw new Exception("mismatch line: " + lineNumber);
+                        }
+                        if ((preMajor != key.getMajorVersion()) ||
+                                (preMinor != key.getMinorVersion())) {
+                           throw new Exception("version mismatch line: " + lineNumber);
+                        }
+                    } catch (InvalidAlgorithmParameterException iape) {
+                        // SSLv3 support is removed in S12
+                        if (preMajor == 3 && preMinor == 0) {
+                            System.out.println("Skip testing SSLv3");
+                            continue;
+                        }
                     }
                 } else {
                     throw new Exception("Unknown line: " + line);
--- a/test/sun/security/pkcs11/tls/TestPremaster.java	Fri Sep 23 13:32:21 2016 -0700
+++ b/test/sun/security/pkcs11/tls/TestPremaster.java	Tue Sep 27 09:04:49 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6316539
+ * @bug 6316539 8136355
  * @summary Basic tests for TlsRsaPremasterSecret generator
  * @author Andreas Sterbenz
  * @library ..
@@ -34,6 +34,7 @@
  */
 
 import java.security.Provider;
+import java.security.InvalidAlgorithmParameterException;
 import javax.crypto.KeyGenerator;
 import javax.crypto.SecretKey;
 import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec;
@@ -61,7 +62,7 @@
             System.out.println("OK: " + e);
         }
 
-        int[] protocolVersions = {0x0300, 0x0301, 0x0302, 0x0400};
+        int[] protocolVersions = {0x0300, 0x0301, 0x0302};
         for (int clientVersion : protocolVersions) {
             for (int serverVersion : protocolVersions) {
                 test(kg, clientVersion, serverVersion);
@@ -81,8 +82,18 @@
                 "Testing RSA pre-master secret key generation between " +
                 "client (0x%04X) and server(0x%04X)%n",
                 clientVersion, serverVersion);
-        kg.init(new TlsRsaPremasterSecretParameterSpec(
+        try {
+            kg.init(new TlsRsaPremasterSecretParameterSpec(
                                     clientVersion, serverVersion));
+        } catch (InvalidAlgorithmParameterException iape) {
+            // S12 removed support for SSL v3.0
+            if (clientVersion == 0x300 || serverVersion == 0x300) {
+                System.out.println("Skip testing SSLv3 due to no support");
+                return;
+            }
+            // unexpected, pass it up
+            throw iape;
+        }
         SecretKey key = kg.generateKey();
         byte[] encoded = key.getEncoded();
         if (encoded != null) {  // raw key material may be not extractable