changeset 40264:9ce9bf3a2453

Merge
author lana
date Thu, 11 Aug 2016 17:02:46 +0000
parents 31948dbd697e 6d435de7abbc
children e73a9c4ada83 3b33b57c0096
files jdk/src/java.base/share/conf/security/cacerts
diffstat 259 files changed, 4138 insertions(+), 1701 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/make/GenerateModuleSummary.gmk	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/make/GenerateModuleSummary.gmk	Thu Aug 11 17:02:46 2016 +0000
@@ -42,6 +42,6 @@
 
 $(GENGRAPHS_DIR)/module-summary.html: $(BUILD_JIGSAW_TOOLS) $(GENGRAPHS_DIR)/technology-summary.html
 	$(MKDIR) -p $(@D)
-	$(TOOL_MODULESUMMARY) -o $@ -mp $(IMAGES_OUTPUTDIR)/jmods
+	$(TOOL_MODULESUMMARY) -o $@ --module-path $(IMAGES_OUTPUTDIR)/jmods
 
 all: $(GENGRAPHS_DIR)/jdk.dot $(GENGRAPHS_DIR)/module-summary.html
--- a/jdk/make/ModuleTools.gmk	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/make/ModuleTools.gmk	Thu Aug 11 17:02:46 2016 +0000
@@ -36,12 +36,12 @@
     INCLUDES := build/tools/deps \
                 build/tools/jigsaw, \
     BIN := $(TOOLS_CLASSES_DIR), \
-    ADD_JAVAC_FLAGS := -XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED ))
+    ADD_JAVAC_FLAGS := --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED ))
 
 
 TOOL_GENGRAPHS := $(BUILD_JAVA) -esa -ea -cp $(TOOLS_CLASSES_DIR) \
     build.tools.jigsaw.GenGraphs
 
 TOOL_MODULESUMMARY := $(BUILD_JAVA) -esa -ea -cp $(TOOLS_CLASSES_DIR) \
-    -XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED \
+    --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED \
     build.tools.jigsaw.ModuleSummary
--- a/jdk/make/Tools.gmk	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/make/Tools.gmk	Thu Aug 11 17:02:46 2016 +0000
@@ -38,7 +38,7 @@
 ################################################################################
 
 ifeq ($(BOOT_JDK_MODULAR), true)
-  COMPILEFONTCONFIG_ADD_EXPORTS := -XaddExports:java.desktop/sun.awt=ALL-UNNAMED
+  COMPILEFONTCONFIG_ADD_EXPORTS := --add-exports java.desktop/sun.awt=ALL-UNNAMED
 endif
 
 TOOL_COMPILEFONTCONFIG = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
@@ -94,7 +94,7 @@
 # Nimbus is used somewhere in the swing build.
 
 ifeq ($(BOOT_JDK_MODULAR), true)
-  COMPILENIMBUS_ADD_MODS := -addmods java.xml.bind
+  COMPILENIMBUS_ADD_MODS := --add-modules java.xml.bind
 endif
 
 TOOL_GENERATENIMBUS = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
--- a/jdk/make/copy/Copy-java.base.gmk	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/make/copy/Copy-java.base.gmk	Thu Aug 11 17:02:46 2016 +0000
@@ -203,7 +203,7 @@
 ################################################################################
 
 ifeq ($(CACERTS_FILE), )
-  CACERTS_FILE := $(JDK_TOPDIR)/src/java.base/share/conf/security/cacerts
+  CACERTS_FILE := $(JDK_TOPDIR)/src/java.base/share/lib/security/cacerts
 endif
 
 CACERTS_DST := $(LIB_DST_DIR)/security/cacerts
--- a/jdk/make/gendata/GendataBreakIterator.gmk	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/make/gendata/GendataBreakIterator.gmk	Thu Aug 11 17:02:46 2016 +0000
@@ -63,11 +63,11 @@
 
 ifeq ($(BOOT_JDK_MODULAR), true)
   BREAK_ITERATOR_BOOTCLASSPATH := \
-      -Xpatch:java.base=$(BREAK_ITERATOR_CLASSES)/java.base \
-      -Xpatch:jdk.localedata=$(BREAK_ITERATOR_CLASSES)/jdk.localedata \
-      -XaddExports:java.base/sun.text=ALL-UNNAMED \
-      -XaddExports:java.base/sun.text.resources=ALL-UNNAMED \
-      -XaddExports:jdk.localedata/sun.text.resources.ext=ALL-UNNAMED \
+      --patch-module java.base=$(BREAK_ITERATOR_CLASSES)/java.base \
+      --patch-module jdk.localedata=$(BREAK_ITERATOR_CLASSES)/jdk.localedata \
+      --add-exports java.base/sun.text=ALL-UNNAMED \
+      --add-exports java.base/sun.text.resources=ALL-UNNAMED \
+      --add-exports jdk.localedata/sun.text.resources.ext=ALL-UNNAMED \
       #
 else
   BREAK_ITERATOR_BOOTCLASSPATH := -Xbootclasspath/p:$(call PathList, \
--- a/jdk/make/launcher/Launcher-java.desktop.gmk	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/make/launcher/Launcher-java.desktop.gmk	Thu Aug 11 17:02:46 2016 +0000
@@ -31,7 +31,7 @@
 ifndef BUILD_HEADLESS_ONLY
   $(eval $(call SetupBuildLauncher, appletviewer, \
       MAIN_CLASS := sun.applet.Main, \
-      JAVA_ARGS := -addmods ALL-DEFAULT, \
+      JAVA_ARGS := --add-modules ALL-DEFAULT, \
       LIBS_unix := $(X_LIBS), \
   ))
 endif
--- a/jdk/make/launcher/Launcher-java.scripting.gmk	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/make/launcher/Launcher-java.scripting.gmk	Thu Aug 11 17:02:46 2016 +0000
@@ -27,5 +27,5 @@
 
 $(eval $(call SetupBuildLauncher, jrunscript, \
     MAIN_CLASS := com.sun.tools.script.shell.Main, \
-    JAVA_ARGS := -addmods ALL-DEFAULT, \
+    JAVA_ARGS := --add-modules ALL-DEFAULT, \
 ))
--- a/jdk/make/launcher/Launcher-jdk.compiler.gmk	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/make/launcher/Launcher-jdk.compiler.gmk	Thu Aug 11 17:02:46 2016 +0000
@@ -27,7 +27,7 @@
 
 $(eval $(call SetupBuildLauncher, javac, \
    MAIN_CLASS := com.sun.tools.javac.Main, \
-   JAVA_ARGS := -addmods ALL-DEFAULT, \
+   JAVA_ARGS := --add-modules ALL-DEFAULT, \
    CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS \
         -DNEVER_ACT_AS_SERVER_CLASS_MACHINE, \
 ))
--- a/jdk/make/launcher/Launcher-jdk.javadoc.gmk	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/make/launcher/Launcher-jdk.javadoc.gmk	Thu Aug 11 17:02:46 2016 +0000
@@ -27,7 +27,7 @@
 
 $(eval $(call SetupBuildLauncher, javadoc, \
     MAIN_CLASS := jdk.javadoc.internal.tool.Main, \
-    JAVA_ARGS := -addmods ALL-DEFAULT, \
+    JAVA_ARGS := --add-modules ALL-DEFAULT, \
     CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS \
         -DNEVER_ACT_AS_SERVER_CLASS_MACHINE, \
 ))
--- a/jdk/make/launcher/Launcher-jdk.jlink.gmk	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/make/launcher/Launcher-jdk.jlink.gmk	Thu Aug 11 17:02:46 2016 +0000
@@ -32,7 +32,7 @@
 
 $(eval $(call SetupBuildLauncher, jlink,\
     MAIN_CLASS := jdk.tools.jlink.internal.Main, \
-    JAVA_ARGS := -addmods ALL-DEFAULT, \
+    JAVA_ARGS :=  --add-modules ALL-DEFAULT, \
     CFLAGS := -DENABLE_ARG_FILES \
         -DEXPAND_CLASSPATH_WILDCARDS \
         -DNEVER_ACT_AS_SERVER_CLASS_MACHINE, \
--- a/jdk/make/launcher/Launcher-jdk.scripting.nashorn.shell.gmk	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/make/launcher/Launcher-jdk.scripting.nashorn.shell.gmk	Thu Aug 11 17:02:46 2016 +0000
@@ -27,6 +27,6 @@
 
 $(eval $(call SetupBuildLauncher, jjs, \
     MAIN_CLASS := jdk.nashorn.tools.jjs.Main, \
-    JAVA_ARGS := -addmods ALL-DEFAULT, \
+    JAVA_ARGS := --add-modules ALL-DEFAULT, \
     CFLAGS := -DENABLE_ARG_FILES, \
 ))
--- a/jdk/make/src/classes/build/tools/jigsaw/ModuleSummary.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/make/src/classes/build/tools/jigsaw/ModuleSummary.java	Thu Aug 11 17:02:46 2016 +0000
@@ -51,7 +51,7 @@
 import static build.tools.jigsaw.ModuleSummary.HtmlDocument.Division.*;
 
 public class ModuleSummary {
-    private static final String USAGE = "Usage: ModuleSummary -mp <dir> -o <outfile> [-root mn]*";
+    private static final String USAGE = "Usage: ModuleSummary --module-path <dir> -o <outfile> [--root mn]*";
 
     public static void main(String[] args) throws Exception {
         int i=0;
@@ -61,13 +61,13 @@
         while (i < args.length && args[i].startsWith("-")) {
             String arg = args[i++];
             switch (arg) {
-                case "-mp":
+                case "--module-path":
                     modpath = Paths.get(args[i++]);
                     break;
                 case "-o":
                     outfile = Paths.get(args[i++]);
                     break;
-                case "-root":
+                case "--root":
                     roots.add(args[i++]);
                 default:
                     System.err.println(USAGE);
--- a/jdk/src/java.base/share/classes/java/io/CharArrayReader.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/io/CharArrayReader.java	Thu Aug 11 17:02:46 2016 +0000
@@ -131,8 +131,10 @@
             if (pos >= count) {
                 return -1;
             }
-            if (pos + len > count) {
-                len = count - pos;
+
+            int avail = count - pos;
+            if (len > avail) {
+                len = avail;
             }
             if (len <= 0) {
                 return 0;
@@ -158,8 +160,10 @@
     public long skip(long n) throws IOException {
         synchronized (lock) {
             ensureOpen();
-            if (pos + n > count) {
-                n = count - pos;
+
+            long avail = count - pos;
+            if (n > avail) {
+                n = avail;
             }
             if (n < 0) {
                 return 0;
--- a/jdk/src/java.base/share/classes/java/io/StringBufferInputStream.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/io/StringBufferInputStream.java	Thu Aug 11 17:02:46 2016 +0000
@@ -118,8 +118,10 @@
         if (pos >= count) {
             return -1;
         }
-        if (pos + len > count) {
-            len = count - pos;
+
+        int avail = count - pos;
+        if (len > avail) {
+            len = avail;
         }
         if (len <= 0) {
             return 0;
--- a/jdk/src/java.base/share/classes/java/lang/System.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/System.java	Thu Aug 11 17:02:46 2016 +0000
@@ -644,23 +644,20 @@
      * <code>getProperties</code> operation, it may choose to permit the
      * {@link #getProperty(String)} operation.
      *
-     * @implNote In addition to the standard system properties, the {@code
-     * java} launcher may create the Java Virtual Machine with system
-     * properties that have the following keys:
+     * @implNote In addition to the standard system properties, the system
+     * properties may include the following keys:
      * <table summary="Shows property keys and associated values">
      * <tr><th>Key</th>
      *     <th>Description of Associated Value</th></tr>
      * <tr><td>{@code jdk.module.path}</td>
-     *     <td>Application module path</td></tr>
-     * <tr><td>{@code jdk.upgrade.module.path}</td>
+     *     <td>The application module path</td></tr>
+     * <tr><td>{@code jdk.module.upgrade.path}</td>
      *     <td>The upgrade module path</td></tr>
      * <tr><td>{@code jdk.module.main}</td>
      *     <td>The module name of the initial/main module</td></tr>
      * <tr><td>{@code jdk.module.main.class}</td>
      *     <td>The main class name of the initial module</td></tr>
      * </table>
-     * These properties may also be set by custom launchers that use the JNI
-     * invocation API to create the Java Virtual Machine.
      *
      * @return     the system properties
      * @exception  SecurityException  if a security manager exists and its
--- a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java	Thu Aug 11 17:02:46 2016 +0000
@@ -587,26 +587,7 @@
             return bmhClass;
         }
 
-        /**
-         * @implNote this method is used by GenerateBMHClassesPlugin to enable
-         * ahead-of-time generation of BMH classes at link time. It does
-         * added validation since this string may be user provided.
-         */
-        static Map.Entry<String, byte[]> generateConcreteBMHClassBytes(
-                final String types) {
-            for (char c : types.toCharArray()) {
-                if ("LIJFD".indexOf(c) < 0) {
-                    throw new IllegalArgumentException("All characters must "
-                            + "correspond to a basic field type: LIJFD");
-                }
-            }
-            String shortTypes = LambdaForm.shortenSignature(types);
-            final String className  = speciesInternalClassName(shortTypes);
-            return Map.entry(className,
-                    generateConcreteBMHClassBytes(shortTypes, types, className));
-        }
-
-        private static String speciesInternalClassName(String shortTypes) {
+        static String speciesInternalClassName(String shortTypes) {
             return SPECIES_PREFIX_PATH + shortTypes;
         }
 
--- a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java	Thu Aug 11 17:02:46 2016 +0000
@@ -186,7 +186,7 @@
         return mtype.form().setCachedLambdaForm(which, lform);
     }
 
-    private static LambdaForm makePreparedLambdaForm(MethodType mtype, int which) {
+    static LambdaForm makePreparedLambdaForm(MethodType mtype, int which) {
         boolean needsInit = (which == LF_INVSTATIC_INIT);
         boolean doesAlloc = (which == LF_NEWINVSPECIAL);
         String linkerName, lambdaName;
@@ -248,20 +248,6 @@
         return lform;
     }
 
-    /*
-     * NOTE: This method acts as an API hook for use by the
-     * GenerateJLIClassesPlugin to generate a class wrapping DirectMethodHandle
-     * methods for an array of method types.
-     */
-    static byte[] generateDMHClassBytes(String className, MethodType[] methodTypes, int[] types) {
-        LambdaForm[] forms = new LambdaForm[methodTypes.length];
-        for (int i = 0; i < forms.length; i++) {
-            forms[i] = makePreparedLambdaForm(methodTypes[i], types[i]);
-            methodTypes[i] = forms[i].methodType();
-        }
-        return InvokerBytecodeGenerator.generateCodeBytesForMultiple(className, forms, methodTypes);
-    }
-
     static Object findDirectMethodHandle(Name name) {
         if (name.function == NF_internalMemberName ||
             name.function == NF_internalMemberNameEnsureInit ||
@@ -515,7 +501,7 @@
     // Enumerate the different field kinds using Wrapper,
     // with an extra case added for checked references.
     private static final int
-            FT_LAST_WRAPPER    = Wrapper.values().length-1,
+            FT_LAST_WRAPPER    = Wrapper.COUNT-1,
             FT_UNCHECKED_REF   = Wrapper.OBJECT.ordinal(),
             FT_CHECKED_REF     = FT_LAST_WRAPPER+1,
             FT_LIMIT           = FT_LAST_WRAPPER+2;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java	Thu Aug 11 17:02:46 2016 +0000
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.lang.invoke;
+
+import java.util.Map;
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.Opcodes;
+
+/**
+ * Helper class to assist the GenerateJLIClassesPlugin to get access to
+ * generate classes ahead of time.
+ */
+class GenerateJLIClassesHelper {
+
+    static byte[] generateDMHClassBytes(String className,
+            MethodType[] methodTypes, int[] types) {
+        LambdaForm[] forms = new LambdaForm[methodTypes.length];
+        for (int i = 0; i < forms.length; i++) {
+            forms[i] = DirectMethodHandle.makePreparedLambdaForm(methodTypes[i],
+                                                                 types[i]);
+            methodTypes[i] = forms[i].methodType();
+        }
+        return generateCodeBytesForLFs(className, forms, methodTypes);
+    }
+
+    /*
+     * Generate customized code for a set of LambdaForms of specified types into
+     * a class with a specified name.
+     */
+    private static byte[] generateCodeBytesForLFs(String className,
+            LambdaForm[] forms, MethodType[] types) {
+        assert(forms.length == types.length);
+
+        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
+        cw.visit(Opcodes.V1_8, Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER,
+                className, null, InvokerBytecodeGenerator.INVOKER_SUPER_NAME, null);
+        cw.visitSource(className.substring(className.lastIndexOf('/') + 1), null);
+        for (int i = 0; i < forms.length; i++) {
+            InvokerBytecodeGenerator g
+                    = new InvokerBytecodeGenerator(className, forms[i], types[i]);
+            g.setClassWriter(cw);
+            g.addMethod();
+        }
+        return cw.toByteArray();
+    }
+
+    static Map.Entry<String, byte[]> generateConcreteBMHClassBytes(
+            final String types) {
+        for (char c : types.toCharArray()) {
+            if ("LIJFD".indexOf(c) < 0) {
+                throw new IllegalArgumentException("All characters must "
+                        + "correspond to a basic field type: LIJFD");
+            }
+        }
+        String shortTypes = LambdaForm.shortenSignature(types);
+        final String className =
+                BoundMethodHandle.Factory.speciesInternalClassName(shortTypes);
+        return Map.entry(className,
+                         BoundMethodHandle.Factory.generateConcreteBMHClassBytes(
+                                 shortTypes, types, className));
+    }
+}
--- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Thu Aug 11 17:02:46 2016 +0000
@@ -70,7 +70,7 @@
     private static final String LLV_SIG = "(L" + OBJ + ";L" + OBJ + ";)V";
 
     /** Name of its super class*/
-    private static final String INVOKER_SUPER_NAME = OBJ;
+    static final String INVOKER_SUPER_NAME = OBJ;
 
     /** Name of new class */
     private final String className;
@@ -124,7 +124,7 @@
     }
 
     /** For generating customized code for a single LambdaForm. */
-    private InvokerBytecodeGenerator(String className, LambdaForm form, MethodType invokerType) {
+    InvokerBytecodeGenerator(String className, LambdaForm form, MethodType invokerType) {
         this(form, form.names.length,
              className, form.debugName, invokerType);
         // Create an array to map name indexes to locals indexes.
@@ -655,35 +655,11 @@
         return classFile;
     }
 
-    /*
-     * NOTE: This is used from GenerateJLIClassesPlugin via
-     * DirectMethodHandle::generateDMHClassBytes.
-     *
-     * Generate customized code for a set of LambdaForms of specified types into
-     * a class with a specified name.
-     */
-    static byte[] generateCodeBytesForMultiple(String className,
-            LambdaForm[] forms, MethodType[] types) {
-        assert(forms.length == types.length);
-
-        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
-        cw.visit(Opcodes.V1_8, Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER,
-                className, null, INVOKER_SUPER_NAME, null);
-        cw.visitSource(className.substring(className.lastIndexOf('/') + 1), null);
-        for (int i = 0; i < forms.length; i++) {
-            InvokerBytecodeGenerator g
-                    = new InvokerBytecodeGenerator(className, forms[i], types[i]);
-            g.setClassWriter(cw);
-            g.addMethod();
-        }
-        return cw.toByteArray();
-    }
-
-    private void setClassWriter(ClassWriter cw) {
+    void setClassWriter(ClassWriter cw) {
         this.cw = cw;
     }
 
-    private void addMethod() {
+    void addMethod() {
         methodPrologue();
 
         // Suppress this method in backtraces displayed to the user.
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java	Thu Aug 11 17:02:46 2016 +0000
@@ -60,7 +60,7 @@
     }
 
     /** A description of a cached transform, possibly associated with the result of the transform.
-     *  The logical content is a sequence of byte values, starting with a Kind.ordinal value.
+     *  The logical content is a sequence of byte values, starting with a kind value.
      *  The sequence is unterminated, ending with an indefinite number of zero bytes.
      *  Sequences that are simple (short enough and with small enough values) pack into a 64-bit long.
      */
@@ -68,17 +68,22 @@
         final long packedBytes;
         final byte[] fullBytes;
 
-        private enum Kind {
-            NO_KIND,  // necessary because ordinal must be greater than zero
-            BIND_ARG, ADD_ARG, DUP_ARG,
-            SPREAD_ARGS,
-            FILTER_ARG, FILTER_RETURN, FILTER_RETURN_TO_ZERO,
-            COLLECT_ARGS, COLLECT_ARGS_TO_VOID, COLLECT_ARGS_TO_ARRAY,
-            FOLD_ARGS, FOLD_ARGS_TO_VOID,
-            PERMUTE_ARGS,
-            LOCAL_TYPES
-            //maybe add more for guard with test, catch exception, pointwise type conversions
-        }
+        // maybe add more for guard with test, catch exception, pointwise type conversions
+        private static final byte
+                BIND_ARG = 1,
+                ADD_ARG = 2,
+                DUP_ARG = 3,
+                SPREAD_ARGS = 4,
+                FILTER_ARG = 5,
+                FILTER_RETURN = 6,
+                FILTER_RETURN_TO_ZERO = 7,
+                COLLECT_ARGS = 8,
+                COLLECT_ARGS_TO_VOID = 9,
+                COLLECT_ARGS_TO_ARRAY = 10,
+                FOLD_ARGS = 11,
+                FOLD_ARGS_TO_VOID = 12,
+                PERMUTE_ARGS = 13,
+                LOCAL_TYPES = 14;
 
         private static final boolean STRESS_TEST = false; // turn on to disable most packing
         private static final int
@@ -131,20 +136,6 @@
             return bytes;
         }
 
-        private byte byteAt(int i) {
-            long pb = packedBytes;
-            if (pb == 0) {
-                if (i >= fullBytes.length)  return 0;
-                return fullBytes[i];
-            }
-            assert(fullBytes == null);
-            if (i > PACKED_BYTE_MAX_LENGTH)  return 0;
-            int pos = (i * PACKED_BYTE_SIZE);
-            return (byte)((pb >>> pos) & PACKED_BYTE_MASK);
-        }
-
-        Kind kind() { return Kind.values()[byteAt(0)]; }
-
         private Transform(long packedBytes, byte[] fullBytes, LambdaForm result) {
             super(result);
             this.packedBytes = packedBytes;
@@ -162,44 +153,39 @@
             assert((b & 0xFF) == b);  // incoming value must fit in *unsigned* byte
             return (byte)b;
         }
-        private static byte bval(Kind k) {
-            return bval(k.ordinal());
-        }
-        static Transform of(Kind k, int b1) {
+        static Transform of(byte k, int b1) {
             byte b0 = bval(k);
             if (inRange(b0 | b1))
                 return new Transform(packedBytes(b0, b1));
             else
                 return new Transform(fullBytes(b0, b1));
         }
-        static Transform of(Kind k, int b1, int b2) {
-            byte b0 = (byte) k.ordinal();
+        static Transform of(byte b0, int b1, int b2) {
             if (inRange(b0 | b1 | b2))
                 return new Transform(packedBytes(b0, b1, b2));
             else
                 return new Transform(fullBytes(b0, b1, b2));
         }
-        static Transform of(Kind k, int b1, int b2, int b3) {
-            byte b0 = (byte) k.ordinal();
+        static Transform of(byte b0, int b1, int b2, int b3) {
             if (inRange(b0 | b1 | b2 | b3))
                 return new Transform(packedBytes(b0, b1, b2, b3));
             else
                 return new Transform(fullBytes(b0, b1, b2, b3));
         }
         private static final byte[] NO_BYTES = {};
-        static Transform of(Kind k, int... b123) {
-            return ofBothArrays(k, b123, NO_BYTES);
+        static Transform of(byte kind, int... b123) {
+            return ofBothArrays(kind, b123, NO_BYTES);
         }
-        static Transform of(Kind k, int b1, byte[] b234) {
-            return ofBothArrays(k, new int[]{ b1 }, b234);
+        static Transform of(byte kind, int b1, byte[] b234) {
+            return ofBothArrays(kind, new int[]{ b1 }, b234);
         }
-        static Transform of(Kind k, int b1, int b2, byte[] b345) {
-            return ofBothArrays(k, new int[]{ b1, b2 }, b345);
+        static Transform of(byte kind, int b1, int b2, byte[] b345) {
+            return ofBothArrays(kind, new int[]{ b1, b2 }, b345);
         }
-        private static Transform ofBothArrays(Kind k, int[] b123, byte[] b456) {
+        private static Transform ofBothArrays(byte kind, int[] b123, byte[] b456) {
             byte[] fullBytes = new byte[1 + b123.length + b456.length];
             int i = 0;
-            fullBytes[i++] = bval(k);
+            fullBytes[i++] = bval(kind);
             for (int bv : b123) {
                 fullBytes[i++] = bval(bv);
             }
@@ -449,7 +435,7 @@
     // Each editing method can (potentially) cache the edited LF so that it can be reused later.
 
     LambdaForm bindArgumentForm(int pos) {
-        Transform key = Transform.of(Transform.Kind.BIND_ARG, pos);
+        Transform key = Transform.of(Transform.BIND_ARG, pos);
         LambdaForm form = getInCache(key);
         if (form != null) {
             assert(form.parameterConstraint(0) == newSpeciesData(lambdaForm.parameterType(pos)));
@@ -484,7 +470,7 @@
     }
 
     LambdaForm addArgumentForm(int pos, BasicType type) {
-        Transform key = Transform.of(Transform.Kind.ADD_ARG, pos, type.ordinal());
+        Transform key = Transform.of(Transform.ADD_ARG, pos, type.ordinal());
         LambdaForm form = getInCache(key);
         if (form != null) {
             assert(form.arity == lambdaForm.arity+1);
@@ -501,7 +487,7 @@
     }
 
     LambdaForm dupArgumentForm(int srcPos, int dstPos) {
-        Transform key = Transform.of(Transform.Kind.DUP_ARG, srcPos, dstPos);
+        Transform key = Transform.of(Transform.DUP_ARG, srcPos, dstPos);
         LambdaForm form = getInCache(key);
         if (form != null) {
             assert(form.arity == lambdaForm.arity-1);
@@ -530,7 +516,7 @@
                 elementTypeKey = TYPE_LIMIT + Wrapper.forPrimitiveType(elementType).ordinal();
             }
         }
-        Transform key = Transform.of(Transform.Kind.SPREAD_ARGS, pos, elementTypeKey, arrayLength);
+        Transform key = Transform.of(Transform.SPREAD_ARGS, pos, elementTypeKey, arrayLength);
         LambdaForm form = getInCache(key);
         if (form != null) {
             assert(form.arity == lambdaForm.arity - arrayLength + 1);
@@ -569,9 +555,9 @@
             return filterArgumentForm(pos, basicType(collectorType.parameterType(0)));
         }
         byte[] newTypes = BasicType.basicTypesOrd(collectorType.parameterArray());
-        Transform.Kind kind = (dropResult
-                ? Transform.Kind.COLLECT_ARGS_TO_VOID
-                : Transform.Kind.COLLECT_ARGS);
+        byte kind = (dropResult
+                ? Transform.COLLECT_ARGS_TO_VOID
+                : Transform.COLLECT_ARGS);
         if (dropResult && collectorArity == 0)  pos = 1;  // pure side effect
         Transform key = Transform.of(kind, pos, collectorArity, newTypes);
         LambdaForm form = getInCache(key);
@@ -598,7 +584,7 @@
             argTypeKey = TYPE_LIMIT + Wrapper.forPrimitiveType(elementType).ordinal();
         }
         assert(collectorType.parameterList().equals(Collections.nCopies(collectorArity, elementType)));
-        Transform.Kind kind = Transform.Kind.COLLECT_ARGS_TO_ARRAY;
+        byte kind = Transform.COLLECT_ARGS_TO_ARRAY;
         Transform key = Transform.of(kind, pos, collectorArity, argTypeKey);
         LambdaForm form = getInCache(key);
         if (form != null) {
@@ -634,7 +620,7 @@
     }
 
     LambdaForm filterArgumentForm(int pos, BasicType newType) {
-        Transform key = Transform.of(Transform.Kind.FILTER_ARG, pos, newType.ordinal());
+        Transform key = Transform.of(Transform.FILTER_ARG, pos, newType.ordinal());
         LambdaForm form = getInCache(key);
         if (form != null) {
             assert(form.arity == lambdaForm.arity);
@@ -710,7 +696,7 @@
     }
 
     LambdaForm filterReturnForm(BasicType newType, boolean constantZero) {
-        Transform.Kind kind = (constantZero ? Transform.Kind.FILTER_RETURN_TO_ZERO : Transform.Kind.FILTER_RETURN);
+        byte kind = (constantZero ? Transform.FILTER_RETURN_TO_ZERO : Transform.FILTER_RETURN);
         Transform key = Transform.of(kind, newType.ordinal());
         LambdaForm form = getInCache(key);
         if (form != null) {
@@ -762,11 +748,11 @@
 
     LambdaForm foldArgumentsForm(int foldPos, boolean dropResult, MethodType combinerType) {
         int combinerArity = combinerType.parameterCount();
-        Transform.Kind kind = (dropResult ? Transform.Kind.FOLD_ARGS_TO_VOID : Transform.Kind.FOLD_ARGS);
+        byte kind = (dropResult ? Transform.FOLD_ARGS_TO_VOID : Transform.FOLD_ARGS);
         Transform key = Transform.of(kind, foldPos, combinerArity);
         LambdaForm form = getInCache(key);
         if (form != null) {
-            assert(form.arity == lambdaForm.arity - (kind == Transform.Kind.FOLD_ARGS ? 1 : 0));
+            assert(form.arity == lambdaForm.arity - (kind == Transform.FOLD_ARGS ? 1 : 0));
             return form;
         }
         form = makeArgumentCombinationForm(foldPos, combinerType, true, dropResult);
@@ -786,7 +772,7 @@
         }
         assert(skip + reorder.length == lambdaForm.arity);
         if (nullPerm)  return lambdaForm;  // do not bother to cache
-        Transform key = Transform.of(Transform.Kind.PERMUTE_ARGS, reorder);
+        Transform key = Transform.of(Transform.PERMUTE_ARGS, reorder);
         LambdaForm form = getInCache(key);
         if (form != null) {
             assert(form.arity == skip+inTypes) : form;
@@ -855,7 +841,7 @@
         int[] desc = BasicType.basicTypeOrds(localTypes);
         desc = Arrays.copyOf(desc, desc.length + 1);
         desc[desc.length - 1] = pos;
-        Transform key = Transform.of(Transform.Kind.LOCAL_TYPES, desc);
+        Transform key = Transform.of(Transform.LOCAL_TYPES, desc);
         LambdaForm form = getInCache(key);
         if (form != null) {
             return form;
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java	Thu Aug 11 17:02:46 2016 +0000
@@ -25,8 +25,6 @@
 
 package java.lang.invoke;
 
-import jdk.internal.misc.JavaLangInvokeAccess;
-import jdk.internal.misc.SharedSecrets;
 import sun.invoke.util.BytecodeDescriptor;
 import sun.invoke.util.VerifyAccess;
 
@@ -37,7 +35,6 @@
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Module;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
@@ -1002,7 +999,9 @@
                     Collections.addAll(result, buf0);
                 }
             }
-            result.addAll(Arrays.asList(buf).subList(0, bufCount));
+            for (int i = 0; i < bufCount; i++) {
+                result.add(buf[i]);
+            }
             // Signature matching is not the same as type matching, since
             // one signature might correspond to several types.
             // So if matchType is a Class or MethodType, refilter the results.
@@ -1150,27 +1149,4 @@
             return buf;
         }
     }
-
-    static {
-        // StackFrameInfo stores Member and this provides the shared secrets
-        // for stack walker to access MemberName information.
-        SharedSecrets.setJavaLangInvokeAccess(new JavaLangInvokeAccess() {
-            @Override
-            public Object newMemberName() {
-                return new MemberName();
-            }
-
-            @Override
-            public String getName(Object mname) {
-                MemberName memberName = (MemberName)mname;
-                return memberName.getName();
-            }
-
-            @Override
-            public boolean isNative(Object mname) {
-                MemberName memberName = (MemberName)mname;
-                return memberName.isNative();
-            }
-        });
-    }
 }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Thu Aug 11 17:02:46 2016 +0000
@@ -25,6 +25,8 @@
 
 package java.lang.invoke;
 
+import jdk.internal.misc.JavaLangInvokeAccess;
+import jdk.internal.misc.SharedSecrets;
 import jdk.internal.org.objectweb.asm.AnnotationVisitor;
 import jdk.internal.org.objectweb.asm.ClassWriter;
 import jdk.internal.org.objectweb.asm.MethodVisitor;
@@ -44,6 +46,7 @@
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.function.Function;
 import java.util.stream.Stream;
 
@@ -1710,6 +1713,39 @@
         } catch (ReflectiveOperationException ex) {
             throw newInternalError(ex);
         }
+
+        SharedSecrets.setJavaLangInvokeAccess(new JavaLangInvokeAccess() {
+            @Override
+            public Object newMemberName() {
+                return new MemberName();
+            }
+
+            @Override
+            public String getName(Object mname) {
+                MemberName memberName = (MemberName)mname;
+                return memberName.getName();
+            }
+
+            @Override
+            public boolean isNative(Object mname) {
+                MemberName memberName = (MemberName)mname;
+                return memberName.isNative();
+            }
+
+            @Override
+            public byte[] generateDMHClassBytes(String className,
+            MethodType[] methodTypes, int[] types) {
+                return GenerateJLIClassesHelper
+                        .generateDMHClassBytes(className, methodTypes, types);
+            }
+
+            @Override
+            public Map.Entry<String, byte[]> generateConcreteBMHClassBytes(
+                    final String types) {
+                return GenerateJLIClassesHelper
+                        .generateConcreteBMHClassBytes(types);
+            }
+        });
     }
 
     /** Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore(). */
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Thu Aug 11 17:02:46 2016 +0000
@@ -3115,7 +3115,7 @@
         return dropArguments(zero(type.returnType()), 0, type.parameterList());
     }
 
-    private static final MethodHandle[] IDENTITY_MHS = new MethodHandle[Wrapper.values().length];
+    private static final MethodHandle[] IDENTITY_MHS = new MethodHandle[Wrapper.COUNT];
     private static MethodHandle makeIdentity(Class<?> ptype) {
         MethodType mtype = methodType(ptype, ptype);
         LambdaForm lform = LambdaForm.identityForm(BasicType.basicType(ptype));
@@ -3133,7 +3133,7 @@
         assert(btw == Wrapper.OBJECT);
         return makeZero(rtype);
     }
-    private static final MethodHandle[] ZERO_MHS = new MethodHandle[Wrapper.values().length];
+    private static final MethodHandle[] ZERO_MHS = new MethodHandle[Wrapper.COUNT];
     private static MethodHandle makeZero(Class<?> rtype) {
         MethodType mtype = methodType(rtype);
         LambdaForm lform = LambdaForm.zeroForm(BasicType.basicType(rtype));
--- a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java	Thu Aug 11 17:02:46 2016 +0000
@@ -281,8 +281,7 @@
                     if (c == TAG_CONST) {
                         Object cnst = constants[constC++];
                         el.add(new RecipeElement(cnst));
-                    }
-                    if (c == TAG_ARG) {
+                    } else if (c == TAG_ARG) {
                         el.add(new RecipeElement(argC++));
                     }
                 } else {
@@ -322,32 +321,30 @@
     private static final class RecipeElement {
         private final Object value;
         private final int argPos;
-        private final Tag tag;
 
         public RecipeElement(Object cnst) {
             this.value = Objects.requireNonNull(cnst);
             this.argPos = -1;
-            this.tag = Tag.CONST;
         }
 
         public RecipeElement(int arg) {
             this.value = null;
+            assert (arg >= 0);
             this.argPos = arg;
-            this.tag = Tag.ARG;
         }
 
         public Object getValue() {
-            assert (tag == Tag.CONST);
+            assert (isConst());
             return value;
         }
 
         public int getArgPos() {
-            assert (tag == Tag.ARG);
+            assert (!isConst());
             return argPos;
         }
 
-        public Tag getTag() {
-            return tag;
+        public boolean isConst() {
+            return argPos == -1;
         }
 
         @Override
@@ -357,22 +354,19 @@
 
             RecipeElement that = (RecipeElement) o;
 
-            if (tag != that.tag) return false;
-            if (tag == Tag.CONST && (!value.equals(that.value))) return false;
-            if (tag == Tag.ARG && (argPos != that.argPos)) return false;
+            boolean isConst = isConst();
+            if (isConst != that.isConst()) return false;
+            if (isConst && (!value.equals(that.value))) return false;
+            if (!isConst && (argPos != that.argPos)) return false;
             return true;
         }
 
         @Override
         public int hashCode() {
-            return tag.hashCode();
+            return argPos;
         }
     }
 
-    private enum Tag {
-        CONST, ARG
-    }
-
     /**
      * Facilitates the creation of optimized String concatenation methods, that
      * can be used to efficiently concatenate a known number of arguments of
@@ -880,31 +874,24 @@
 
                 int off = 0;
                 for (RecipeElement el : recipe.getElements()) {
-                    switch (el.getTag()) {
-                        case CONST: {
-                            // Guaranteed non-null, no null check required.
-                            break;
+                    if (el.isConst()) {
+                        // Guaranteed non-null, no null check required.
+                    } else {
+                        // Null-checks are needed only for String arguments, and when a previous stage
+                        // did not do implicit null-checks. If a String is null, we eagerly replace it
+                        // with "null" constant. Note, we omit Objects here, because we don't call
+                        // .length() on them down below.
+                        int ac = el.getArgPos();
+                        Class<?> cl = arr[ac];
+                        if (cl == String.class && !guaranteedNonNull[ac]) {
+                            Label l0 = new Label();
+                            mv.visitIntInsn(ALOAD, off);
+                            mv.visitJumpInsn(IFNONNULL, l0);
+                            mv.visitLdcInsn("null");
+                            mv.visitIntInsn(ASTORE, off);
+                            mv.visitLabel(l0);
                         }
-                        case ARG: {
-                            // Null-checks are needed only for String arguments, and when a previous stage
-                            // did not do implicit null-checks. If a String is null, we eagerly replace it
-                            // with "null" constant. Note, we omit Objects here, because we don't call
-                            // .length() on them down below.
-                            int ac = el.getArgPos();
-                            Class<?> cl = arr[ac];
-                            if (cl == String.class && !guaranteedNonNull[ac]) {
-                                Label l0 = new Label();
-                                mv.visitIntInsn(ALOAD, off);
-                                mv.visitJumpInsn(IFNONNULL, l0);
-                                mv.visitLdcInsn("null");
-                                mv.visitIntInsn(ASTORE, off);
-                                mv.visitLabel(l0);
-                            }
-                            off += getParameterSize(cl);
-                            break;
-                        }
-                        default:
-                            throw new StringConcatException("Unhandled tag: " + el.getTag());
+                        off += getParameterSize(cl);
                     }
                 }
             }
@@ -925,37 +912,30 @@
                 mv.visitInsn(ICONST_0);
 
                 for (RecipeElement el : recipe.getElements()) {
-                    switch (el.getTag()) {
-                        case CONST: {
-                            Object cnst = el.getValue();
-                            len += cnst.toString().length();
-                            break;
+                    if (el.isConst()) {
+                        Object cnst = el.getValue();
+                        len += cnst.toString().length();
+                    } else {
+                        /*
+                            If an argument is String, then we can call .length() on it. Sized/Exact modes have
+                            converted arguments for us. If an argument is primitive, we can provide a guess
+                            for its String representation size.
+                        */
+                        Class<?> cl = arr[el.getArgPos()];
+                        if (cl == String.class) {
+                            mv.visitIntInsn(ALOAD, off);
+                            mv.visitMethodInsn(
+                                    INVOKEVIRTUAL,
+                                    "java/lang/String",
+                                    "length",
+                                    "()I",
+                                    false
+                            );
+                            mv.visitInsn(IADD);
+                        } else if (cl.isPrimitive()) {
+                            len += estimateSize(cl);
                         }
-                        case ARG: {
-                            /*
-                                If an argument is String, then we can call .length() on it. Sized/Exact modes have
-                                converted arguments for us. If an argument is primitive, we can provide a guess
-                                for its String representation size.
-                            */
-                            Class<?> cl = arr[el.getArgPos()];
-                            if (cl == String.class) {
-                                mv.visitIntInsn(ALOAD, off);
-                                mv.visitMethodInsn(
-                                        INVOKEVIRTUAL,
-                                        "java/lang/String",
-                                        "length",
-                                        "()I",
-                                        false
-                                );
-                                mv.visitInsn(IADD);
-                            } else if (cl.isPrimitive()) {
-                                len += estimateSize(cl);
-                            }
-                            off += getParameterSize(cl);
-                            break;
-                        }
-                        default:
-                            throw new StringConcatException("Unhandled tag: " + el.getTag());
+                        off += getParameterSize(cl);
                     }
                 }
 
@@ -987,23 +967,17 @@
                 int off = 0;
                 for (RecipeElement el : recipe.getElements()) {
                     String desc;
-                    switch (el.getTag()) {
-                        case CONST: {
-                            Object cnst = el.getValue();
-                            mv.visitLdcInsn(cnst);
-                            desc = getSBAppendDesc(cnst.getClass());
-                            break;
-                        }
-                        case ARG: {
-                            Class<?> cl = arr[el.getArgPos()];
-                            mv.visitVarInsn(getLoadOpcode(cl), off);
-                            off += getParameterSize(cl);
-                            desc = getSBAppendDesc(cl);
-                            break;
-                        }
-                        default:
-                            throw new StringConcatException("Unhandled tag: " + el.getTag());
+                    if (el.isConst()) {
+                        Object cnst = el.getValue();
+                        mv.visitLdcInsn(cnst);
+                        desc = getSBAppendDesc(cnst.getClass());
+                    } else {
+                        Class<?> cl = arr[el.getArgPos()];
+                        mv.visitVarInsn(getLoadOpcode(cl), off);
+                        off += getParameterSize(cl);
+                        desc = getSBAppendDesc(cl);
                     }
+
                     mv.visitMethodInsn(
                             INVOKEVIRTUAL,
                             "java/lang/StringBuilder",
@@ -1279,26 +1253,19 @@
             // call the usual String.length(). Primitive values string sizes can be estimated.
             int initial = 0;
             for (RecipeElement el : recipe.getElements()) {
-                switch (el.getTag()) {
-                    case CONST: {
-                        Object cnst = el.getValue();
-                        initial += cnst.toString().length();
-                        break;
+                if (el.isConst()) {
+                    Object cnst = el.getValue();
+                    initial += cnst.toString().length();
+                } else {
+                    final int i = el.getArgPos();
+                    Class<?> type = ptypesList.get(i);
+                    if (type.isPrimitive()) {
+                        MethodHandle est = MethodHandles.constant(int.class, estimateSize(type));
+                        est = MethodHandles.dropArguments(est, 0, type);
+                        lengthers[i] = est;
+                    } else {
+                        lengthers[i] = STRING_LENGTH;
                     }
-                    case ARG: {
-                        final int i = el.getArgPos();
-                        Class<?> type = ptypesList.get(i);
-                        if (type.isPrimitive()) {
-                            MethodHandle est = MethodHandles.constant(int.class, estimateSize(type));
-                            est = MethodHandles.dropArguments(est, 0, type);
-                            lengthers[i] = est;
-                        } else {
-                            lengthers[i] = STRING_LENGTH;
-                        }
-                        break;
-                    }
-                    default:
-                        throw new StringConcatException("Unhandled tag: " + el.getTag());
                 }
             }
 
@@ -1311,26 +1278,19 @@
             for (int i = elements.size() - 1; i >= 0; i--) {
                 RecipeElement el = elements.get(i);
                 MethodHandle appender;
-                switch (el.getTag()) {
-                    case CONST: {
-                        Object constant = el.getValue();
-                        MethodHandle mh = appender(adaptToStringBuilder(constant.getClass()));
-                        appender = MethodHandles.insertArguments(mh, 1, constant);
-                        break;
+                if (el.isConst()) {
+                    Object constant = el.getValue();
+                    MethodHandle mh = appender(adaptToStringBuilder(constant.getClass()));
+                    appender = MethodHandles.insertArguments(mh, 1, constant);
+                } else {
+                    int ac = el.getArgPos();
+                    appender = appender(ptypesList.get(ac));
+
+                    // Insert dummy arguments to match the prefix in the signature.
+                    // The actual appender argument will be the ac-ith argument.
+                    if (ac != 0) {
+                        appender = MethodHandles.dropArguments(appender, 1, ptypesList.subList(0, ac));
                     }
-                    case ARG: {
-                        int ac = el.getArgPos();
-                        appender = appender(ptypesList.get(ac));
-
-                        // Insert dummy arguments to match the prefix in the signature.
-                        // The actual appender argument will be the ac-ith argument.
-                        if (ac != 0) {
-                            appender = MethodHandles.dropArguments(appender, 1, ptypesList.subList(0, ac));
-                        }
-                        break;
-                    }
-                    default:
-                        throw new StringConcatException("Unhandled tag: " + el.getTag());
                 }
                 builder = MethodHandles.foldArguments(builder, appender);
             }
@@ -1521,19 +1481,12 @@
             // *ending* index.
             for (RecipeElement el : recipe.getElements()) {
                 MethodHandle prepender;
-                switch (el.getTag()) {
-                    case CONST: {
-                        Object cnst = el.getValue();
-                        prepender = MethodHandles.insertArguments(prepender(cnst.getClass()), 3, cnst);
-                        break;
-                    }
-                    case ARG: {
-                        int pos = el.getArgPos();
-                        prepender = selectArgument(prepender(ptypesList.get(pos)), 3, ptypesList, pos);
-                        break;
-                    }
-                    default:
-                        throw new StringConcatException("Unhandled tag: " + el.getTag());
+                if (el.isConst()) {
+                    Object cnst = el.getValue();
+                    prepender = MethodHandles.insertArguments(prepender(cnst.getClass()), 3, cnst);
+                } else {
+                    int pos = el.getArgPos();
+                    prepender = selectArgument(prepender(ptypesList.get(pos)), 3, ptypesList, pos);
                 }
 
                 // Remove "old" index from arguments
@@ -1573,43 +1526,36 @@
             byte initialCoder = INITIAL_CODER;
             int initialLen = 0;    // initial length, in characters
             for (RecipeElement el : recipe.getElements()) {
-                switch (el.getTag()) {
-                    case CONST: {
-                        Object constant = el.getValue();
-                        String s = constant.toString();
-                        initialCoder = (byte) coderMixer(String.class).invoke(initialCoder, s);
-                        initialLen += s.length();
-                        break;
-                    }
-                    case ARG: {
-                        int ac = el.getArgPos();
+                if (el.isConst()) {
+                    Object constant = el.getValue();
+                    String s = constant.toString();
+                    initialCoder = (byte) coderMixer(String.class).invoke(initialCoder, s);
+                    initialLen += s.length();
+                } else {
+                    int ac = el.getArgPos();
 
-                        Class<?> argClass = ptypesList.get(ac);
-                        MethodHandle lm = selectArgument(lengthMixer(argClass), 1, ptypesList, ac);
-                        lm = MethodHandles.dropArguments(lm, 0, byte.class); // (*)
-                        lm = MethodHandles.dropArguments(lm, 2, byte.class);
+                    Class<?> argClass = ptypesList.get(ac);
+                    MethodHandle lm = selectArgument(lengthMixer(argClass), 1, ptypesList, ac);
+                    lm = MethodHandles.dropArguments(lm, 0, byte.class); // (*)
+                    lm = MethodHandles.dropArguments(lm, 2, byte.class);
 
-                        MethodHandle cm = selectArgument(coderMixer(argClass),  1, ptypesList, ac);
-                        cm = MethodHandles.dropArguments(cm, 0, int.class);  // (**)
+                    MethodHandle cm = selectArgument(coderMixer(argClass),  1, ptypesList, ac);
+                    cm = MethodHandles.dropArguments(cm, 0, int.class);  // (**)
 
-                        // Read this bottom up:
+                    // Read this bottom up:
 
-                        // 4. Drop old index and coder, producing ("new-index", "new-coder", <args>)
-                        mh = MethodHandles.dropArguments(mh, 2, int.class, byte.class);
+                    // 4. Drop old index and coder, producing ("new-index", "new-coder", <args>)
+                    mh = MethodHandles.dropArguments(mh, 2, int.class, byte.class);
 
-                        // 3. Compute "new-index", producing ("new-index", "new-coder", "old-index", "old-coder", <args>)
-                        //    Length mixer ignores both "new-coder" and "old-coder" due to dropArguments above (*)
-                        mh = MethodHandles.foldArguments(mh, lm);
+                    // 3. Compute "new-index", producing ("new-index", "new-coder", "old-index", "old-coder", <args>)
+                    //    Length mixer ignores both "new-coder" and "old-coder" due to dropArguments above (*)
+                    mh = MethodHandles.foldArguments(mh, lm);
 
-                        // 2. Compute "new-coder", producing ("new-coder", "old-index", "old-coder", <args>)
-                        //    Coder mixer ignores the "old-index" arg due to dropArguments above (**)
-                        mh = MethodHandles.foldArguments(mh, cm);
+                    // 2. Compute "new-coder", producing ("new-coder", "old-index", "old-coder", <args>)
+                    //    Coder mixer ignores the "old-index" arg due to dropArguments above (**)
+                    mh = MethodHandles.foldArguments(mh, cm);
 
-                        // 1. The mh shape here is ("old-index", "old-coder", <args>)
-                        break;
-                    }
-                    default:
-                        throw new StringConcatException("Unhandled tag: " + el.getTag());
+                    // 1. The mh shape here is ("old-index", "old-coder", <args>)
                 }
             }
 
--- a/jdk/src/java.base/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java	Thu Aug 11 17:02:46 2016 +0000
@@ -38,7 +38,7 @@
         super(Opcodes.ASM5, mv);
     }
 
-    private static final int NUM_WRAPPERS = Wrapper.values().length;
+    private static final int NUM_WRAPPERS = Wrapper.COUNT;
 
     private static final String NAME_OBJECT = "java/lang/Object";
     private static final String WRAPPER_PREFIX = "Ljava/lang/";
--- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java	Thu Aug 11 17:02:46 2016 +0000
@@ -1057,57 +1057,11 @@
     Object addAndGet(Object... args);
 
     enum AccessType {
-        GET(Object.class) {
-            @Override
-            MethodType accessModeType(Class<?> receiver, Class<?> value,
-                                      Class<?>... intermediate) {
-                Class<?>[] ps =  allocateParameters(0, receiver, intermediate);
-                fillParameters(ps, receiver, intermediate);
-                return MethodType.methodType(value, ps);
-            }
-        },
-        SET(void.class) {
-            @Override
-            MethodType accessModeType(Class<?> receiver, Class<?> value,
-                                      Class<?>... intermediate) {
-                Class<?>[] ps =  allocateParameters(1, receiver, intermediate);
-                int i = fillParameters(ps, receiver, intermediate);
-                ps[i] = value;
-                return MethodType.methodType(void.class, ps);
-            }
-        },
-        COMPARE_AND_SWAP(boolean.class) {
-            @Override
-            MethodType accessModeType(Class<?> receiver, Class<?> value,
-                                      Class<?>... intermediate) {
-                Class<?>[] ps =  allocateParameters(2, receiver, intermediate);
-                int i = fillParameters(ps, receiver, intermediate);
-                ps[i++] = value;
-                ps[i] = value;
-                return MethodType.methodType(boolean.class, ps);
-            }
-        },
-        COMPARE_AND_EXCHANGE(Object.class) {
-            @Override
-            MethodType accessModeType(Class<?> receiver, Class<?> value,
-                                      Class<?>... intermediate) {
-                Class<?>[] ps =  allocateParameters(2, receiver, intermediate);
-                int i = fillParameters(ps, receiver, intermediate);
-                ps[i++] = value;
-                ps[i] = value;
-                return MethodType.methodType(value, ps);
-            }
-        },
-        GET_AND_UPDATE(Object.class) {
-            @Override
-            MethodType accessModeType(Class<?> receiver, Class<?> value,
-                                      Class<?>... intermediate) {
-                Class<?>[] ps =  allocateParameters(1, receiver, intermediate);
-                int i = fillParameters(ps, receiver, intermediate);
-                ps[i] = value;
-                return MethodType.methodType(value, ps);
-            }
-        };
+        GET(Object.class),
+        SET(void.class),
+        COMPARE_AND_SWAP(boolean.class),
+        COMPARE_AND_EXCHANGE(Object.class),
+        GET_AND_UPDATE(Object.class);
 
         final Class<?> returnType;
         final boolean isMonomorphicInReturnType;
@@ -1117,8 +1071,41 @@
             isMonomorphicInReturnType = returnType != Object.class;
         }
 
-        abstract MethodType accessModeType(Class<?> receiver, Class<?> value,
-                                           Class<?>... intermediate);
+        MethodType accessModeType(Class<?> receiver, Class<?> value,
+                                  Class<?>... intermediate) {
+            Class<?>[] ps;
+            int i;
+            switch (this) {
+                case GET:
+                    ps = allocateParameters(0, receiver, intermediate);
+                    fillParameters(ps, receiver, intermediate);
+                    return MethodType.methodType(value, ps);
+                case SET:
+                    ps = allocateParameters(1, receiver, intermediate);
+                    i = fillParameters(ps, receiver, intermediate);
+                    ps[i] = value;
+                    return MethodType.methodType(void.class, ps);
+                case COMPARE_AND_SWAP:
+                    ps = allocateParameters(2, receiver, intermediate);
+                    i = fillParameters(ps, receiver, intermediate);
+                    ps[i++] = value;
+                    ps[i] = value;
+                    return MethodType.methodType(boolean.class, ps);
+                case COMPARE_AND_EXCHANGE:
+                    ps = allocateParameters(2, receiver, intermediate);
+                    i = fillParameters(ps, receiver, intermediate);
+                    ps[i++] = value;
+                    ps[i] = value;
+                    return MethodType.methodType(value, ps);
+                case GET_AND_UPDATE:
+                    ps = allocateParameters(1, receiver, intermediate);
+                    i = fillParameters(ps, receiver, intermediate);
+                    ps[i] = value;
+                    return MethodType.methodType(value, ps);
+                default:
+                    throw new InternalError("Unknown AccessType");
+            }
+        }
 
         private static Class<?>[] allocateParameters(int values,
                                                      Class<?> receiver, Class<?>... intermediate) {
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleReference.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleReference.java	Thu Aug 11 17:02:46 2016 +0000
@@ -169,7 +169,7 @@
 
 
     /**
-     * Returns {@code true} if this module has been patched via -Xpatch.
+     * Returns {@code true} if this module has been patched via --patch-module.
      */
     boolean isPatched() {
         return patched;
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleReferences.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleReferences.java	Thu Aug 11 17:02:46 2016 +0000
@@ -68,7 +68,7 @@
 
     /**
      * Creates a ModuleReference to a module or to patched module when
-     * creating modules for the boot Layer and -Xpatch is specified.
+     * creating modules for the boot Layer and --patch-module is specified.
      */
     private static ModuleReference newModule(ModuleDescriptor md,
                                              URI uri,
--- a/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java	Thu Aug 11 17:02:46 2016 +0000
@@ -178,7 +178,7 @@
         ModuleReference mref =
             new ModuleReference(md, uri, readerSupplier, hash);
 
-        // may need a reference to a patched module if -Xpatch specified
+        // may need a reference to a patched module if --patch-module specified
         mref = ModulePatcher.interposeIfNeeded(mref);
 
         return mref;
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangInvokeAccess.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangInvokeAccess.java	Thu Aug 11 17:02:46 2016 +0000
@@ -25,19 +25,42 @@
 
 package jdk.internal.misc;
 
+import java.lang.invoke.MethodType;
+import java.util.Map;
+
 public interface JavaLangInvokeAccess {
     /**
-     * Create a new MemberName instance
+     * Create a new MemberName instance. Used by {@see StackFrameInfo}.
      */
     Object newMemberName();
 
     /**
-     * Returns the name for the given MemberName
+     * Returns the name for the given MemberName. Used by {@see StackFrameInfo}.
      */
     String getName(Object mname);
 
     /**
-     * Returns {@code true} if the given MemberName is a native method
+     * Returns {@code true} if the given MemberName is a native method. Used by
+     * {@see StackFrameInfo}.
      */
     boolean isNative(Object mname);
+
+    /**
+     * Returns a {@code byte[]} containing the bytecode for a class implementing
+     * DirectMethodHandle of each pairwise combination of {@code MethodType} and
+     * an {@code int} representing method type.  Used by
+     * GenerateJLIClassesPlugin to generate such a class during the jlink phase.
+     */
+    byte[] generateDMHClassBytes(String className, MethodType[] methodTypes,
+            int[] types);
+
+    /**
+     * Returns a {@code byte[]} containing the bytecode for a BoundMethodHandle
+     * species class implementing the signature defined by {@code types}. Used
+     * by GenerateBMHClassesPlugin to enable generation of such classes during
+     * the jlink phase. Should do some added validation since this string may be
+     * user provided.
+     */
+    Map.Entry<String, byte[]> generateConcreteBMHClassBytes(
+            final String types);
 }
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java	Thu Aug 11 17:02:46 2016 +0000
@@ -95,7 +95,7 @@
     public static JavaLangInvokeAccess getJavaLangInvokeAccess() {
         if (javaLangInvokeAccess == null) {
             try {
-                Class<?> c = Class.forName("java.lang.invoke.MemberName");
+                Class<?> c = Class.forName("java.lang.invoke.MethodHandleImpl");
                 unsafe.ensureClassInitialized(c);
             } catch (ClassNotFoundException e) {};
         }
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java	Thu Aug 11 17:02:46 2016 +0000
@@ -56,8 +56,8 @@
  * The {@link #boot() boot} method is called early in the startup to initialize
  * the module system. In summary, the boot method creates a Configuration by
  * resolving a set of module names specified via the launcher (or equivalent)
- * -m and -addmods options. The modules are located on a module path that is
- * constructed from the upgrade module path, system modules, and application
+ * -m and --add-modules options. The modules are located on a module path that
+ * is constructed from the upgrade module path, system modules, and application
  * module path. The Configuration is instantiated as the boot Layer with each
  * module in the the configuration defined to one of the built-in class loaders.
  */
@@ -127,16 +127,16 @@
 
         long t2 = System.nanoTime();
 
-        // -upgrademodulepath option specified to launcher
+        // --upgrade-module-path option specified to launcher
         ModuleFinder upgradeModulePath
-            = createModulePathFinder("jdk.upgrade.module.path");
+            = createModulePathFinder("jdk.module.upgrade.path");
         if (upgradeModulePath != null)
             systemModules = ModuleFinder.compose(upgradeModulePath, systemModules);
 
-        // -modulepath option specified to the launcher
+        // --module-path option specified to the launcher
         ModuleFinder appModulePath = createModulePathFinder("jdk.module.path");
 
-        // The module finder: [-upgrademodulepath] system [-modulepath]
+        // The module finder: [--upgrade-module-path] system [--module-path]
         ModuleFinder finder = systemModules;
         if (appModulePath != null)
             finder = ModuleFinder.compose(finder, appModulePath);
@@ -149,11 +149,11 @@
         if (mainModule != null)
             roots.add(mainModule);
 
-        // additional module(s) specified by -addmods
+        // additional module(s) specified by --add-modules
         boolean addAllDefaultModules = false;
         boolean addAllSystemModules = false;
         boolean addAllApplicationModules = false;
-        String propValue = System.getProperty("jdk.launcher.addmods");
+        String propValue = getAndRemoveProperty("jdk.module.addmods");
         if (propValue != null) {
             for (String mod: propValue.split(",")) {
                 switch (mod) {
@@ -172,8 +172,8 @@
             }
         }
 
-        // -limitmods
-        propValue = System.getProperty("jdk.launcher.limitmods");
+        // --limit-modules
+        propValue = getAndRemoveProperty("jdk.module.limitmods");
         if (propValue != null) {
             Set<String> mods = new HashSet<>();
             for (String mod: propValue.split(",")) {
@@ -216,7 +216,7 @@
             }
         }
 
-        // If `-addmods ALL-SYSTEM` is specified then all observable system
+        // If `--add-modules ALL-SYSTEM` is specified then all observable system
         // modules will be resolved.
         if (addAllSystemModules) {
             ModuleFinder f = finder;  // observable modules
@@ -228,9 +228,9 @@
                 .forEach(mn -> roots.add(mn));
         }
 
-        // If `-addmods ALL-MODULE-PATH` is specified then all observable
+        // If `--add-modules ALL-MODULE-PATH` is specified then all observable
         // modules on the application module path will be resolved.
-        if  (appModulePath != null && addAllApplicationModules) {
+        if (appModulePath != null && addAllApplicationModules) {
             ModuleFinder f = finder;  // observable modules
             appModulePath.findAll()
                 .stream()
@@ -250,7 +250,7 @@
         if (baseUri.getScheme().equals("jrt")   // toLowerCase not needed here
                 && (upgradeModulePath == null)
                 && (appModulePath == null)
-                && (System.getProperty("jdk.launcher.patch.0") == null)) {
+                && (!ModulePatcher.isBootLayerPatched())) {
             needPostResolutionChecks = false;
         }
 
@@ -317,7 +317,7 @@
         PerfCounters.loadModulesTime.addElapsedTimeFrom(t5);
 
 
-        // -XaddReads and -XaddExports
+        // --add-reads and --add-exports
         addExtraReads(bootLayer);
         addExtraExports(bootLayer);
 
@@ -394,13 +394,13 @@
 
 
     /**
-     * Process the -XaddReads options to add any additional read edges that
+     * Process the --add-reads options to add any additional read edges that
      * are specified on the command-line.
      */
     private static void addExtraReads(Layer bootLayer) {
 
         // decode the command line options
-        Map<String, Set<String>> map = decode("jdk.launcher.addreads.");
+        Map<String, Set<String>> map = decode("jdk.module.addreads.");
 
         for (Map.Entry<String, Set<String>> e : map.entrySet()) {
 
@@ -431,13 +431,13 @@
 
 
     /**
-     * Process the -XaddExports options to add any additional read edges that
+     * Process the --add-exports options to add any additional read edges that
      * are specified on the command-line.
      */
     private static void addExtraExports(Layer bootLayer) {
 
         // decode the command line options
-        Map<String, Set<String>> map = decode("jdk.launcher.addexports.");
+        Map<String, Set<String>> map = decode("jdk.module.addexports.");
 
         for (Map.Entry<String, Set<String>> e : map.entrySet()) {
 
@@ -483,13 +483,14 @@
 
 
     /**
-     * Decodes the values of -XaddReads or -XaddExports options
+     * Decodes the values of --add-reads or --add-exports options
      *
      * The format of the options is: $KEY=$MODULE(,$MODULE)*
      */
     private static Map<String, Set<String>> decode(String prefix) {
         int index = 0;
-        String value = System.getProperty(prefix + index);
+        // the system property is removed after decoding
+        String value = getAndRemoveProperty(prefix + index);
         if (value == null)
             return Collections.emptyMap();
 
@@ -522,12 +523,18 @@
             }
 
             index++;
-            value = System.getProperty(prefix + index);
+            value = getAndRemoveProperty(prefix + index);
         }
 
         return map;
     }
 
+    /**
+     * Gets and remove the named system property
+     */
+    private static String getAndRemoveProperty(String key) {
+        return (String)System.getProperties().remove(key);
+    }
 
     /**
      * Throws a RuntimeException with the given message
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java	Thu Aug 11 17:02:46 2016 +0000
@@ -58,7 +58,7 @@
 
 
 /**
- * Provides support for patching modules in the boot layer with -Xpatch.
+ * Provides support for patching modules in the boot layer with --patch-module.
  */
 
 public final class ModulePatcher {
@@ -66,28 +66,27 @@
     private static final JavaLangModuleAccess JLMA
         = SharedSecrets.getJavaLangModuleAccess();
 
-    // the prefix of the system properties that encode the value of -Xpatch
-    private static final String PATCH_PROPERTY_PREFIX = "jdk.launcher.patch.";
+    // the prefix of the system properties that encode the value of --patch-module
+    private static final String PATCH_PROPERTY_PREFIX = "jdk.module.patch.";
 
     // module name -> sequence of patches (directories or JAR files)
     private static final Map<String, List<Path>> PATCH_MAP = decodeProperties();
 
     private ModulePatcher() { }
 
-
     /**
-     * Decodes the values of -Xpatch options, returning a Map of module name to
-     * list of file paths.
+     * Decodes the values of --patch-module options, returning a Map of module
+     * name to list of file paths.
      *
      * @throws IllegalArgumentException if the the module name is missing or
-     *         -Xpatch is used more than once to patch the same module
+     *         --patch-module is used more than once to patch the same module
      */
     private static Map<String, List<Path>> decodeProperties() {
 
         int index = 0;
-        String value = System.getProperty(PATCH_PROPERTY_PREFIX + index);
+        String value = getAndRemoveProperty(PATCH_PROPERTY_PREFIX + index);
         if (value == null)
-            return Collections.emptyMap();  // -Xpatch not specified
+            return Collections.emptyMap();  // --patch-module not specified
 
         Map<String, List<Path>> map = new HashMap<>();
         while (value != null) {
@@ -115,7 +114,7 @@
             }
 
             index++;
-            value = System.getProperty(PATCH_PROPERTY_PREFIX + index);
+            value = getAndRemoveProperty(PATCH_PROPERTY_PREFIX + index);
         }
 
         return map;
@@ -123,6 +122,14 @@
 
 
     /**
+     * Returns {@code true} is --patch-module is specified to patch modules
+     * in the boot layer.
+     */
+    static boolean isBootLayerPatched() {
+        return !PATCH_MAP.isEmpty();
+    }
+
+    /**
      * Returns a module reference that interposes on the given module if
      * needed. If there are no patches for the given module then the module
      * reference is simply returned. Otherwise the patches for the module
@@ -537,6 +544,13 @@
     }
 
     /**
+     * Gets and remove the named system property
+     */
+    private static String getAndRemoveProperty(String key) {
+        return (String)System.getProperties().remove(key);
+    }
+
+    /**
      * Derives a package name from the name of an entry in a JAR file.
      */
     private static String toPackageName(Path file, JarEntry entry) {
--- a/jdk/src/java.base/share/classes/module-info.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/module-info.java	Thu Aug 11 17:02:46 2016 +0000
@@ -128,6 +128,7 @@
     exports jdk.internal.logger to
         java.logging;
     exports jdk.internal.org.objectweb.asm to
+        jdk.jartool,
         jdk.jlink,
         jdk.scripting.nashorn,
         jdk.vm.ci;
--- a/jdk/src/java.base/share/classes/sun/invoke/util/ValueConversions.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/invoke/util/ValueConversions.java	Thu Aug 11 17:02:46 2016 +0000
@@ -29,27 +29,32 @@
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodHandles.Lookup;
 import java.lang.invoke.MethodType;
-import java.util.EnumMap;
+import jdk.internal.vm.annotation.Stable;
 
 public class ValueConversions {
     private static final Class<?> THIS_CLASS = ValueConversions.class;
     private static final Lookup IMPL_LOOKUP = MethodHandles.lookup();
 
-    /** Thread-safe canonicalized mapping from Wrapper to MethodHandle
+    /**
+     * Thread-safe canonicalized mapping from Wrapper to MethodHandle
      * with unsynchronized reads and synchronized writes.
-     * It's safe to publish MethodHandles by data race because they are immutable. */
+     * It's safe to publish MethodHandles by data race because they are immutable.
+     */
     private static class WrapperCache {
-        /** EnumMap uses preconstructed array internally, which is constant during it's lifetime. */
-        private final EnumMap<Wrapper, MethodHandle> map = new EnumMap<>(Wrapper.class);
+        @Stable
+        private final MethodHandle[] map = new MethodHandle[Wrapper.COUNT];
 
         public MethodHandle get(Wrapper w) {
-            return map.get(w);
+            return map[w.ordinal()];
         }
         public synchronized MethodHandle put(final Wrapper w, final MethodHandle mh) {
-            // Simulate CAS to avoid racy duplication
-            MethodHandle prev = map.putIfAbsent(w, mh);
-            if (prev != null)  return prev;
-            return mh;
+            MethodHandle prev = map[w.ordinal()];
+            if (prev != null) {
+                return prev;
+            } else {
+                map[w.ordinal()] = mh;
+                return mh;
+            }
         }
     }
 
@@ -623,7 +628,7 @@
         return (x ? (byte)1 : (byte)0);
     }
 
-    private static final WrapperCache[] CONVERT_PRIMITIVE_FUNCTIONS = newWrapperCaches(Wrapper.values().length);
+    private static final WrapperCache[] CONVERT_PRIMITIVE_FUNCTIONS = newWrapperCaches(Wrapper.COUNT);
 
     public static MethodHandle convertPrimitive(Wrapper wsrc, Wrapper wdst) {
         WrapperCache cache = CONVERT_PRIMITIVE_FUNCTIONS[wsrc.ordinal()];
--- a/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java	Thu Aug 11 17:02:46 2016 +0000
@@ -42,6 +42,8 @@
     VOID   (     Void.class,    void.class, 'V',           null, Format.other(    0)),
     ;
 
+    public static final int COUNT = 10;
+
     private final Class<?> wrapperType;
     private final Class<?> primitiveType;
     private final char     basicTypeChar;
@@ -160,7 +162,10 @@
         return true;
     }
 
-    static { assert(checkConvertibleFrom()); }
+    static {
+        assert(checkConvertibleFrom());
+        assert(COUNT == Wrapper.values().length);
+    }
     private static boolean checkConvertibleFrom() {
         // Check the matrix for correct classification of widening conversions.
         for (Wrapper w : values()) {
--- a/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java	Thu Aug 11 17:02:46 2016 +0000
@@ -60,8 +60,6 @@
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.text.Normalizer;
 import java.text.MessageFormat;
 import java.util.ResourceBundle;
@@ -905,7 +903,7 @@
 
         ModuleFinder finder = jdk.internal.module.ModuleBootstrap.finder();
 
-        int colon = optionFlag.indexOf(':');
+        int colon = optionFlag.indexOf('=');
         if (colon == -1) {
             finder.findAll().stream()
                 .sorted(Comparator.comparing(ModuleReference::descriptor))
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Thu Aug 11 17:02:46 2016 +0000
@@ -27,7 +27,7 @@
 java.launcher.opt.header  =   Usage: {0} [options] class [args...]\n\
 \           (to execute a class)\n   or  {0} [options] -jar jarfile [args...]\n\
 \           (to execute a jar file)\n\
-\   or  {0} [options] -mp <modulepath> -m <modulename>[/<mainclass>] [args...]\n\
+\   or  {0} [options] -p <modulepath> -m <modulename>[/<mainclass>] [args...]\n\
 \           (to execute the main class in a module)\n\
 where options include:\n
 
@@ -41,24 +41,28 @@
 # Translators please note do not translate the options themselves
 java.launcher.opt.footer     =\    -cp <class search path of directories and zip/jar files>\n\
 \    -classpath <class search path of directories and zip/jar files>\n\
+\    --class-path <class search path of directories and zip/jar files>\n\
 \                  A {0} separated list of directories, JAR archives,\n\
 \                  and ZIP archives to search for class files.\n\
-\    -mp <module path>\n\
-\    -modulepath <module path>...\n\
+\    -p <module path>\n\
+\    --module-path <module path>...\n\
 \                  A {0} separated list of directories, each directory\n\
 \                  is a directory of modules.\n\
-\    -upgrademodulepath <module path>...\n\
+\    --upgrade-module-path <module path>...\n\
 \                  A {0} separated list of directories, each directory\n\
 \                  is a directory of modules that replace upgradeable\n\
 \                  modules in the runtime image\n\
-\    -m <modulename>[/<mainclass>]\n\
+\    -m <module>[/<mainclass>]\n\
+\    --module <modulename>[/<mainclass>]\n\
 \                  the initial module to resolve, and the name of the main class\n\
 \                  to execute if not specified by the module\n\
-\    -addmods <modulename>[,<modulename>...]\n\
-\                  root modules to resolve in addition to the initial module\n\
-\    -limitmods <modulename>[,<modulename>...]\n\
+\    --add-modules <modulename>[,<modulename>...]\n\
+\                  root modules to resolve in addition to the initial module.\n\
+\                  <modulename> can also be ALL-DEFAULT, ALL-SYSTEM,\n\
+\                  ALL-MODULE-PATH.\n\
+\    --limit-modules <modulename>[,<modulename>...]\n\
 \                  limit the universe of observable modules\n\
-\    -listmods[:<modulename>[,<modulename>...]]\n\
+\    --list-modules [<modulename>[,<modulename>...]]\n\
 \                  list the observable modules and exit\n\
 \    --dry-run     create VM but do not execute main method.\n\
 \                  This --dry-run option may be useful for validating the\n\
@@ -69,7 +73,8 @@
 \                  enable verbose output\n\
 \    -version      print product version and exit\n\
 \    -showversion  print product version and continue\n\
-\    -? -help      print this help message\n\
+\    -? -help --help\n\
+\                  print this help message\n\
 \    -X            print help on non-standard options\n\
 \    -ea[:<packagename>...|:<classname>]\n\
 \    -enableassertions[:<packagename>...|:<classname>]\n\
@@ -91,6 +96,8 @@
 \    -splash:<imagepath>\n\
 \                  show splash screen with specified image\n\
 \    @<filepath>   read options from the specified file\n\
+\To specify an argument for a long option, you can use --<name>=<value> or\n\
+\--<name> <value>.\n\
 
 See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
 
@@ -123,17 +130,21 @@
 \                      show all property settings and continue\n\
 \    -XshowSettings:locale\n\
 \                      show all locale related settings and continue\n\
-\    -XaddReads:<module>=<other-module>(,<other-module>)*\n\
-\                      <module> reads other modules,\n\
-\                      regardless of module declaration\n\
-\    -XaddExports:<module>/<package>=<other-module>(,<other-module>)*\n\
-\                      <module> exports <package> to other modules,\n\
-\                      regardless of module declaration\n\
-\    -Xpatch:<module>=<file>({0}<file>)*\n\
+\    -Xdisable-@files  disable further argument file expansion\n\
+\    --add-reads <module>=<target-module>(,<target-module>)*\n\
+\                      updates <module> to read <target-module>, regardless\n\
+\                      of module declaration. \n\
+\                      <target-module> can be ALL-UNNAMED to read all unnamed\n\
+\                      modules.\n\
+\    --add-exports <module>/<package>=<target-module>(,<target-module>)*\n\
+\                      updates <module> to export <package> to <target-module>,\n\
+\                      regardless of module declaration.\n\
+\                      <target-module> can be ALL-UNNAMED to export to all\n\
+\                      unnamed modules.\n\
+\    --patch-module <module>=<file>({0}<file>)*\n\
 \                      Override or augment a module with classes and resources\n\
-\                      in JAR files or directories\n\
-\    -Xdisable-@files  disable further argument file expansion\n\n\
-The -X options are non-standard and subject to change without notice.\n
+\                      in JAR files or directories.\n\n\
+These options are non-standard and subject to change without notice.\n
 
 # Translators please note do not translate the options themselves
 java.launcher.X.macosx.usage=\
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java	Thu Aug 11 17:02:46 2016 +0000
@@ -1994,7 +1994,7 @@
 
     private StaplingParameters processStapling(ClientHello mesg) {
         StaplingParameters params = null;
-        ExtensionType ext;
+        ExtensionType ext = null;
         StatusRequestType type = null;
         StatusRequest req = null;
         Map<X509Certificate, byte[]> responses;
@@ -2012,33 +2012,40 @@
         CertStatusReqListV2Extension statReqExtV2 =
                 (CertStatusReqListV2Extension)mesg.extensions.get(
                         ExtensionType.EXT_STATUS_REQUEST_V2);
-        // Keep processing only if either status_request or status_request_v2
-        // has been sent in the ClientHello.
-        if (statReqExt == null && statReqExtV2 == null) {
-            return null;
-        }
 
         // Determine which type of stapling we are doing and assert the
         // proper extension in the server hello.
         // Favor status_request_v2 over status_request and ocsp_multi
         // over ocsp.
         // If multiple ocsp or ocsp_multi types exist, select the first
-        // instance of a given type
-        ext = ExtensionType.EXT_STATUS_REQUEST;
+        // instance of a given type.  Also since we don't support ResponderId
+        // selection yet, only accept a request if the ResponderId field
+        // is empty.
         if (statReqExtV2 != null) {             // RFC 6961 stapling
             ext = ExtensionType.EXT_STATUS_REQUEST_V2;
             List<CertStatusReqItemV2> reqItems =
                     statReqExtV2.getRequestItems();
             int ocspIdx = -1;
             int ocspMultiIdx = -1;
-            for (int pos = 0; pos < reqItems.size(); pos++) {
+            for (int pos = 0; (pos < reqItems.size() &&
+                    (ocspIdx == -1 || ocspMultiIdx == -1)); pos++) {
                 CertStatusReqItemV2 item = reqItems.get(pos);
-                if (ocspIdx < 0 && item.getType() ==
-                        StatusRequestType.OCSP) {
-                    ocspIdx = pos;
-                } else if (ocspMultiIdx < 0 && item.getType() ==
-                        StatusRequestType.OCSP_MULTI) {
-                    ocspMultiIdx = pos;
+                StatusRequestType curType = item.getType();
+                if (ocspIdx < 0 && curType == StatusRequestType.OCSP) {
+                    OCSPStatusRequest ocspReq =
+                            (OCSPStatusRequest)item.getRequest();
+                    if (ocspReq.getResponderIds().isEmpty()) {
+                        ocspIdx = pos;
+                    }
+                } else if (ocspMultiIdx < 0 &&
+                        curType == StatusRequestType.OCSP_MULTI) {
+                    // If the type is OCSP, then the request
+                    // is guaranteed to be OCSPStatusRequest
+                    OCSPStatusRequest ocspReq =
+                            (OCSPStatusRequest)item.getRequest();
+                    if (ocspReq.getResponderIds().isEmpty()) {
+                        ocspMultiIdx = pos;
+                    }
                 }
             }
             if (ocspMultiIdx >= 0) {
@@ -2047,16 +2054,47 @@
             } else if (ocspIdx >= 0) {
                 type = reqItems.get(ocspIdx).getType();
                 req = reqItems.get(ocspIdx).getRequest();
+            } else {
+                if (debug != null && Debug.isOn("handshake")) {
+                    System.out.println("Warning: No suitable request " +
+                            "found in the status_request_v2 extension.");
+                }
             }
-        } else {                                // RFC 6066 stapling
-            type = StatusRequestType.OCSP;
-            req = statReqExt.getRequest();
+        }
+
+        // Only attempt to process a status_request extension if:
+        // * The status_request extension is set AND
+        // * either the status_request_v2 extension is not present OR
+        // * none of the underlying OCSPStatusRequest structures is suitable
+        // for stapling.
+        // If either of the latter two bullet items is true the ext, type and
+        // req variables should all be null.  If any are null we will try
+        // processing an asserted status_request.
+        if ((statReqExt != null) &&
+               (ext == null || type == null || req == null)) {
+            ext = ExtensionType.EXT_STATUS_REQUEST;
+            type = statReqExt.getType();
+            if (type == StatusRequestType.OCSP) {
+                // If the type is OCSP, then the request is guaranteed
+                // to be OCSPStatusRequest
+                OCSPStatusRequest ocspReq =
+                        (OCSPStatusRequest)statReqExt.getRequest();
+                if (ocspReq.getResponderIds().isEmpty()) {
+                    req = ocspReq;
+                } else {
+                    if (debug != null && Debug.isOn("handshake")) {
+                        req = null;
+                        System.out.println("Warning: No suitable request " +
+                                "found in the status_request extension.");
+                    }
+                }
+            }
         }
 
         // If, after walking through the extensions we were unable to
         // find a suitable StatusRequest, then stapling is disabled.
-        // Both statReqType and statReqData must have been set to continue.
-        if (type == null || req == null) {
+        // The ext, type and req variables must have been set to continue.
+        if (type == null || req == null || ext == null) {
             return null;
         }
 
--- a/jdk/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java	Thu Aug 11 17:02:46 2016 +0000
@@ -63,8 +63,6 @@
         // this class is not meant to be instantiated
     }
 
-    private static final String JKS = "jks";
-
     private static final Collator collator = Collator.getInstance();
     static {
         // this is for case insensitive string comparisons
@@ -113,24 +111,24 @@
     }
 
     /**
+     * Returns the file name of the keystore with the configured CA certificates.
+     */
+    public static String getCacerts() {
+        String sep = File.separator;
+        return System.getProperty("java.home") + sep
+                + "lib" + sep + "security" + sep
+                + "cacerts";
+    }
+
+    /**
      * Returns the keystore with the configured CA certificates.
      */
-    public static KeyStore getCacertsKeyStore()
-        throws Exception
-    {
-        String sep = File.separator;
-        File file = new File(System.getProperty("java.home") + sep
-                             + "lib" + sep + "security" + sep
-                             + "cacerts");
+    public static KeyStore getCacertsKeyStore() throws Exception {
+        File file = new File(getCacerts());
         if (!file.exists()) {
             return null;
         }
-        KeyStore caks = null;
-        try (FileInputStream fis = new FileInputStream(file)) {
-            caks = KeyStore.getInstance(JKS);
-            caks.load(fis, null);
-        }
-        return caks;
+        return KeyStore.getInstance(file, (char[])null);
     }
 
     public static char[] getPassWithModifier(String modifier, String arg,
--- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Thu Aug 11 17:02:46 2016 +0000
@@ -153,6 +153,7 @@
     private boolean trustcacerts = false;
     private boolean protectedPath = false;
     private boolean srcprotectedPath = false;
+    private boolean cacerts = false;
     private CertificateFactory cf = null;
     private KeyStore caks = null; // "cacerts" keystore
     private char[] srcstorePass = null;
@@ -169,15 +170,15 @@
             STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER,
             PROVIDERCLASS, PROVIDERPATH, V, PROTECTED),
         CHANGEALIAS("Changes.an.entry.s.alias",
-            ALIAS, DESTALIAS, KEYPASS, KEYSTORE, STOREPASS,
+            ALIAS, DESTALIAS, KEYPASS, KEYSTORE, CACERTS, STOREPASS,
             STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS,
             PROVIDERPATH, V, PROTECTED),
         DELETE("Deletes.an.entry",
-            ALIAS, KEYSTORE, STOREPASS, STORETYPE,
+            ALIAS, KEYSTORE, CACERTS, STOREPASS, STORETYPE,
             PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS,
             PROVIDERPATH, V, PROTECTED),
         EXPORTCERT("Exports.certificate",
-            RFC, ALIAS, FILEOUT, KEYSTORE, STOREPASS,
+            RFC, ALIAS, FILEOUT, KEYSTORE, CACERTS, STOREPASS,
             STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS,
             PROVIDERPATH, V, PROTECTED),
         GENKEYPAIR("Generates.a.key.pair",
@@ -196,7 +197,7 @@
             PROVIDERCLASS, PROVIDERPATH, V, PROTECTED),
         IMPORTCERT("Imports.a.certificate.or.a.certificate.chain",
             NOPROMPT, TRUSTCACERTS, PROTECTED, ALIAS, FILEIN,
-            KEYPASS, KEYSTORE, STOREPASS, STORETYPE,
+            KEYPASS, KEYSTORE, CACERTS, STOREPASS, STORETYPE,
             PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS,
             PROVIDERPATH, V),
         IMPORTPASS("Imports.a.password",
@@ -215,7 +216,7 @@
             STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS,
             PROVIDERPATH, V),
         LIST("Lists.entries.in.a.keystore",
-            RFC, ALIAS, KEYSTORE, STOREPASS, STORETYPE,
+            RFC, ALIAS, KEYSTORE, CACERTS, STOREPASS, STORETYPE,
             PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS,
             PROVIDERPATH, V, PROTECTED),
         PRINTCERT("Prints.the.content.of.a.certificate",
@@ -225,7 +226,7 @@
         PRINTCRL("Prints.the.content.of.a.CRL.file",
             FILEIN, V),
         STOREPASSWD("Changes.the.store.password.of.a.keystore",
-            NEW, KEYSTORE, STOREPASS, STORETYPE, PROVIDERNAME,
+            NEW, KEYSTORE, CACERTS, STOREPASS, STORETYPE, PROVIDERNAME,
             ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V),
 
         // Undocumented start here, KEYCLONE is used a marker in -help;
@@ -306,6 +307,7 @@
         KEYPASS("keypass", "<arg>", "key.password"),
         KEYSIZE("keysize", "<size>", "key.bit.size"),
         KEYSTORE("keystore", "<keystore>", "keystore.name"),
+        CACERTS("cacerts", null, "access.the.cacerts.keystore"),
         NEW("new", "<arg>", "new.password"),
         NOPROMPT("noprompt", null, "do.not.prompt"),
         OUTFILE("outfile", "<file>", "output.file.name"),
@@ -472,14 +474,16 @@
                 help = true;
             } else if (collator.compare(flags, "-conf") == 0) {
                 i++;
-            }
-
-            /*
-             * specifiers
-             */
-            else if (collator.compare(flags, "-keystore") == 0 ||
-                    collator.compare(flags, "-destkeystore") == 0) {
+            } else if (collator.compare(flags, "-keystore") == 0) {
                 ksfname = args[++i];
+                if (new File(ksfname).getCanonicalPath().equals(
+                        new File(KeyStoreUtil.getCacerts()).getCanonicalPath())) {
+                    System.err.println(rb.getString("warning.cacerts.option"));
+                }
+            } else if (collator.compare(flags, "-destkeystore") == 0) {
+                ksfname = args[++i];
+            } else if (collator.compare(flags, "-cacerts") == 0) {
+                cacerts = true;
             } else if (collator.compare(flags, "-storepass") == 0 ||
                     collator.compare(flags, "-deststorepass") == 0) {
                 storePass = getPass(modifier, args[++i]);
@@ -636,6 +640,15 @@
      * Execute the commands.
      */
     void doCommands(PrintStream out) throws Exception {
+
+        if (cacerts) {
+            if (ksfname != null || storetype != null) {
+                throw new IllegalArgumentException(rb.getString
+                        ("the.keystore.or.storetype.option.cannot.be.used.with.the.cacerts.option"));
+            }
+            ksfname = KeyStoreUtil.getCacerts();
+        }
+
         if (storetype == null) {
             storetype = KeyStore.getDefaultType();
         }
--- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Resources.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Resources.java	Thu Aug 11 17:02:46 2016 +0000
@@ -127,6 +127,10 @@
                 "key bit size"}, //-keysize
         {"keystore.name",
                 "keystore name"}, //-keystore
+        {"access.the.cacerts.keystore",
+                "access the cacerts keystore"}, // -cacerts
+        {"warning.cacerts.option",
+                "Warning: use -cacerts option to access cacerts keystore"},
         {"new.password",
                 "new password"}, //-new
         {"do.not.prompt",
@@ -194,6 +198,8 @@
         {"Command.option.flag.needs.an.argument.", "Command option {0} needs an argument."},
         {"Warning.Different.store.and.key.passwords.not.supported.for.PKCS12.KeyStores.Ignoring.user.specified.command.value.",
                 "Warning:  Different store and key passwords not supported for PKCS12 KeyStores. Ignoring user-specified {0} value."},
+        {"the.keystore.or.storetype.option.cannot.be.used.with.the.cacerts.option",
+            "The -keystore or -storetype option cannot be used with the -cacerts option"},
         {".keystore.must.be.NONE.if.storetype.is.{0}",
                 "-keystore must be NONE if -storetype is {0}"},
         {"Too.many.retries.program.terminated",
Binary file jdk/src/java.base/share/conf/security/cacerts has changed
Binary file jdk/src/java.base/share/lib/security/cacerts has changed
--- a/jdk/src/java.base/share/native/libjli/args.c	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/native/libjli/args.c	Thu Aug 11 17:02:46 2016 +0000
@@ -102,24 +102,21 @@
 
     // All arguments arrive here must be a launcher argument,
     // ie. by now, all argfile expansions must have been performed.
-    if (*arg++ == '-') {
+    if (*arg == '-') {
         expectingNoDashArg = JNI_FALSE;
-        if (JLI_StrCmp(arg, "cp") == 0 ||
-            JLI_StrCmp(arg, "classpath") == 0 ||
-            JLI_StrCmp(arg, "addmods") == 0 ||
-            JLI_StrCmp(arg, "limitmods") == 0 ||
-            JLI_StrCmp(arg, "mp") == 0 ||
-            JLI_StrCmp(arg, "modulepath") == 0 ||
-            JLI_StrCmp(arg, "upgrademodulepath") == 0) {
+        if (IsWhiteSpaceOption(arg)) {
+            // expect an argument
             expectingNoDashArg = JNI_TRUE;
-        } else if (JLI_StrCmp(arg, "jar") == 0 ||
-                   JLI_StrCmp(arg, "m") == 0) {
-            // This is tricky, we do expect NoDashArg
-            // But that is considered main class to stop expansion
-            expectingNoDashArg = JNI_FALSE;
-            // We can not just update the idx here because if -jar @file
-            // still need expansion of @file to get the argument for -jar
-        } else if (JLI_StrCmp(arg, "Xdisable-@files") == 0) {
+
+            if (JLI_StrCmp(arg, "-jar") == 0 ||
+                JLI_StrCmp(arg, "-m") == 0) {
+                // This is tricky, we do expect NoDashArg
+                // But that is considered main class to stop expansion
+                expectingNoDashArg = JNI_FALSE;
+                // We can not just update the idx here because if -jar @file
+                // still need expansion of @file to get the argument for -jar
+            }
+        } else if (JLI_StrCmp(arg, "-Xdisable-@files") == 0) {
             stopExpansion = JNI_TRUE;
         }
     } else {
--- a/jdk/src/java.base/share/native/libjli/java.c	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/native/libjli/java.c	Thu Aug 11 17:02:46 2016 +0000
@@ -69,7 +69,7 @@
 static jboolean printUsage = JNI_FALSE;   /* print and exit*/
 static jboolean printXUsage = JNI_FALSE;  /* print and exit*/
 static jboolean dryRun = JNI_FALSE;       /* initialize VM and exit */
-static char     *showSettings = NULL;      /* print but continue */
+static char     *showSettings = NULL;     /* print but continue */
 static char     *listModules = NULL;
 
 static const char *_program_name;
@@ -99,17 +99,9 @@
  * Prototypes for functions internal to launcher.
  */
 static void SetClassPath(const char *s);
-static void SetModulePath(const char *s);
-static void SetUpgradeModulePath(const char *s);
 static void SetMainModule(const char *s);
-static void SetAddModulesProp(const char *mods);
-static void SetLimitModulesProp(const char *mods);
-static void SetAddReadsProp(const jint n, const char *s);
-static void SetAddExportsProp(const jint n, const char *s);
-static void SetPatchProp(const jint n, const char *s);
 static void SelectVersion(int argc, char **argv, char **main_class);
 static void SetJvmEnvironment(int argc, char **argv);
-static jboolean IsWhiteSpaceOptionArgument(const char* name);
 static jboolean ParseArguments(int *pargc, char ***pargv,
                                int *pmode, char **pwhat,
                                int *pret, const char *jrepath);
@@ -133,6 +125,18 @@
 static void DumpState();
 static jboolean RemovableOption(char *option);
 
+enum OptionKind {
+    LAUNCHER_OPTION = 0,
+    LAUNCHER_OPTION_WITH_ARGUMENT,
+    LAUNCHER_MAIN_OPTION,
+    VM_LONG_OPTION,
+    VM_LONG_OPTION_WITH_ARGUMENT,
+    VM_OPTION
+};
+
+static int GetOpt(int *pargc, char ***pargv, char **poption, char **pvalue);
+static jboolean IsOptionWithArgument(int argc, char **argv);
+
 /* Maximum supported entries from jvm.cfg. */
 #define INIT_MAX_KNOWN_VMS      10
 
@@ -162,6 +166,19 @@
 static void FreeKnownVMs();
 static jboolean IsWildCardEnabled();
 
+/*
+ * This reports error.  VM will not be created and no usage is printed.
+ */
+#define REPORT_ERROR(AC_ok, AC_failure_message, AC_questionable_arg) \
+    do { \
+        if (!AC_ok) { \
+            JLI_ReportErrorMessage(AC_failure_message, AC_questionable_arg); \
+            printUsage = JNI_FALSE; \
+            *pret = 1; \
+            return JNI_FALSE; \
+        } \
+    } while (JNI_FALSE)
+
 #define ARG_CHECK(AC_arg_count, AC_failure_message, AC_questionable_arg) \
     do { \
         if (AC_arg_count < 1) { \
@@ -511,17 +528,73 @@
 }
 
 /*
- * Test if the given option name has a whitespace separated argument.
+ * Test if the given name is one of the class path options.
+ */
+static jboolean
+IsClassPathOption(const char* name) {
+    return JLI_StrCmp(name, "-classpath") == 0 ||
+           JLI_StrCmp(name, "-cp") == 0 ||
+           JLI_StrCmp(name, "--class-path") == 0;
+}
+
+/*
+ * Test if the given name is a launcher option taking the main entry point.
+ */
+static jboolean
+IsLauncherMainOption(const char* name) {
+    return JLI_StrCmp(name, "--module") == 0 ||
+           JLI_StrCmp(name, "-m") == 0;
+}
+
+/*
+ * Test if the given name is a white-space launcher option.
+ */
+static jboolean
+IsLauncherOption(const char* name) {
+    return IsClassPathOption(name) ||
+           IsLauncherMainOption(name) ||
+           JLI_StrCmp(name, "--list-modules") == 0;
+}
+
+#ifndef OLD_MODULE_OPTIONS
+/*
+ * Old module options for transition
+ */
+static jboolean
+IsOldModuleOption(const char* name) {
+    return JLI_StrCmp(name, "-modulepath") == 0 ||
+    JLI_StrCmp(name, "-mp") == 0 ||
+    JLI_StrCmp(name, "-upgrademodulepath") == 0 ||
+    JLI_StrCmp(name, "-addmods") == 0 ||
+    JLI_StrCmp(name, "-limitmods") == 0;
+}
+#endif
+
+/*
+ * Test if the given name is a module-system white-space option that
+ * will be passed to the VM with its corresponding long-form option
+ * name and "=" delimiter.
+ */
+static jboolean
+IsModuleOption(const char* name) {
+    return JLI_StrCmp(name, "--module-path") == 0 ||
+           JLI_StrCmp(name, "-p") == 0 ||
+           JLI_StrCmp(name, "--upgrade-module-path") == 0 ||
+           JLI_StrCmp(name, "--add-modules") == 0 ||
+           JLI_StrCmp(name, "--limit-modules") == 0 ||
+           JLI_StrCmp(name, "--add-exports") == 0 ||
+           JLI_StrCmp(name, "--add-reads") == 0 ||
+           JLI_StrCmp(name, "--patch-module") == 0 ||
+           IsOldModuleOption(name);
+}
+
+/*
+ * Test if the given name has a white space option.
  */
 jboolean
-IsWhiteSpaceOptionArgument(const char* name) {
-    return JLI_StrCmp(name, "-classpath") == 0 ||
-           JLI_StrCmp(name, "-cp") == 0 ||
-           JLI_StrCmp(name, "-modulepath") == 0 ||
-           JLI_StrCmp(name, "-mp") == 0 ||
-           JLI_StrCmp(name, "-upgrademodulepath") == 0 ||
-           JLI_StrCmp(name, "-addmods") == 0 ||
-           JLI_StrCmp(name, "-limitmods") == 0;
+IsWhiteSpaceOption(const char* name) {
+    return IsModuleOption(name) ||
+           IsLauncherOption(name);
 }
 
 /*
@@ -559,7 +632,7 @@
                 continue;
             }
         } else {
-            if (IsWhiteSpaceOptionArgument(arg)) {
+            if (IsWhiteSpaceOption(arg)) {
                 newArgv[newArgvIdx++] = arg;
                 argi++;
                 if (argi < argc) {
@@ -701,7 +774,7 @@
         if (i > 0) {
             char *prev = argv[i - 1];
             // skip non-dash arg preceded by class path specifiers
-            if (*arg != '-' && IsWhiteSpaceOptionArgument(prev)) {
+            if (*arg != '-' && IsWhiteSpaceOption(prev)) {
                 continue;
             }
 
@@ -709,6 +782,7 @@
                     || JLI_StrCmp(arg, "-version") == 0
                     || JLI_StrCmp(arg, "-fullversion") == 0
                     || JLI_StrCmp(arg, "-help") == 0
+                    || JLI_StrCmp(arg, "--help") == 0
                     || JLI_StrCmp(arg, "-?") == 0
                     || JLI_StrCmp(arg, "-jar") == 0
                     || JLI_StrCmp(arg, "-X") == 0) {
@@ -882,39 +956,16 @@
 }
 
 static void
-SetModulePath(const char *s)
+AddLongFormOption(const char *option, const char *arg)
 {
+    static const char format[] = "%s=%s";
     char *def;
-    const char *orig = s;
-    static const char format[] = "-Djdk.module.path=%s";
-    if (s == NULL)
-        return;
-    s = JLI_WildcardExpandClasspath(s);
-    def = JLI_MemAlloc(sizeof(format)
-                       - 2 /* strlen("%s") */
-                       + JLI_StrLen(s));
-    sprintf(def, format, s);
+    size_t def_len;
+
+    def_len = JLI_StrLen(option) + 1 + JLI_StrLen(arg) + 1;
+    def = JLI_MemAlloc(def_len);
+    JLI_Snprintf(def, def_len, format, option, arg);
     AddOption(def, NULL);
-    if (s != orig)
-        JLI_MemFree((char *) s);
-}
-
-static void
-SetUpgradeModulePath(const char *s)
-{
-    char *def;
-    const char *orig = s;
-    static const char format[] = "-Djdk.upgrade.module.path=%s";
-    if (s == NULL)
-        return;
-    s = JLI_WildcardExpandClasspath(s);
-    def = JLI_MemAlloc(sizeof(format)
-                       - 2 /* strlen("%s") */
-                       + JLI_StrLen(s));
-    sprintf(def, format, s);
-    AddOption(def, NULL);
-    if (s != orig)
-        JLI_MemFree((char *) s);
 }
 
 static void
@@ -939,46 +990,6 @@
     AddOption(def, NULL);
 }
 
-static void
-SetAddModulesProp(const char *mods) {
-    size_t buflen = JLI_StrLen(mods) + 40;
-    char *prop = (char *)JLI_MemAlloc(buflen);
-    JLI_Snprintf(prop, buflen, "-Djdk.launcher.addmods=%s", mods);
-    AddOption(prop, NULL);
-}
-
-static void
-SetLimitModulesProp(const char *mods) {
-    size_t buflen = JLI_StrLen(mods) + 40;
-    char *prop = (char *)JLI_MemAlloc(buflen);
-    JLI_Snprintf(prop, buflen, "-Djdk.launcher.limitmods=%s", mods);
-    AddOption(prop, NULL);
-}
-
-static void
-SetAddReadsProp(const jint n, const char *s) {
-    size_t buflen = JLI_StrLen(s) + 40;
-    char *prop = (char *)JLI_MemAlloc(buflen);
-    JLI_Snprintf(prop, buflen, "-Djdk.launcher.addreads.%d=%s", n, s);
-    AddOption(prop, NULL);
-}
-
-static void
-SetAddExportsProp(const jint n, const char *s) {
-    size_t buflen = JLI_StrLen(s) + 40;
-    char *prop = (char *)JLI_MemAlloc(buflen);
-    JLI_Snprintf(prop, buflen, "-Djdk.launcher.addexports.%d=%s", n, s);
-    AddOption(prop, NULL);
-}
-
-static void
-SetPatchProp(const jint n, const char *s) {
-    size_t buflen = JLI_StrLen(s) + 40;
-    char *prop = (char *)JLI_MemAlloc(buflen);
-    JLI_Snprintf(prop, buflen, "-Djdk.launcher.patch.%d=%s", n, s);
-    AddOption(prop, NULL);
-}
-
 /*
  * The SelectVersion() routine ensures that an appropriate version of
  * the JRE is running.  The specification for the appropriate version
@@ -1003,6 +1014,7 @@
     char    *splash_jar_name = NULL;
     char    *env_in;
     int     res;
+    jboolean has_arg;
 
     /*
      * If the version has already been selected, set *main_class
@@ -1033,9 +1045,11 @@
      * This capability is no longer available with JRE versions 1.9 and later.
      * These command line options are reported as errors.
      */
+
     argc--;
     argv++;
     while ((arg = *argv) != 0 && *arg == '-') {
+        has_arg = IsOptionWithArgument(argc, argv);
         if (JLI_StrCCmp(arg, "-version:") == 0) {
             JLI_ReportErrorMessage(SPC_ERROR1);
         } else if (JLI_StrCmp(arg, "-jre-restrict-search") == 0) {
@@ -1045,10 +1059,12 @@
         } else {
             if (JLI_StrCmp(arg, "-jar") == 0)
                 jarflag = 1;
-            if (IsWhiteSpaceOptionArgument(arg) && (argc >= 2)) {
-                argc--;
-                argv++;
-                arg = *argv;
+            if (IsWhiteSpaceOption(arg)) {
+                if (has_arg) {
+                    argc--;
+                    argv++;
+                    arg = *argv;
+                }
             }
 
             /*
@@ -1140,6 +1156,108 @@
 }
 
 /*
+ * Test if the current argv is an option, i.e. with a leading `-`
+ * and followed with an argument without a leading `-`.
+ */
+static jboolean
+IsOptionWithArgument(int argc, char** argv) {
+    char* option;
+    char* arg;
+
+    if (argc <= 1)
+        return JNI_FALSE;
+
+    option = *argv;
+    arg = *(argv+1);
+    return *option == '-' && *arg != '-';
+}
+
+/*
+ * Gets the option, and its argument if the option has an argument.
+ * It will update *pargc, **pargv to the next option.
+ */
+static int
+GetOpt(int *pargc, char ***pargv, char **poption, char **pvalue) {
+    int argc = *pargc;
+    char** argv = *pargv;
+    char* arg = *argv;
+
+    char* option = arg;
+    char* value = NULL;
+    char* equals = NULL;
+    int kind = LAUNCHER_OPTION;
+    jboolean has_arg = JNI_FALSE;
+
+    // check if this option may be a white-space option with an argument
+    has_arg = IsOptionWithArgument(argc, argv);
+
+    argv++; --argc;
+    if (IsLauncherOption(arg)) {
+        if (has_arg) {
+            value = *argv;
+            argv++; --argc;
+        }
+        kind = IsLauncherMainOption(arg) ? LAUNCHER_MAIN_OPTION
+                                         : LAUNCHER_OPTION_WITH_ARGUMENT;
+    } else if (IsModuleOption(arg)) {
+        kind = VM_LONG_OPTION_WITH_ARGUMENT;
+        if (has_arg) {
+            value = *argv;
+            argv++; --argc;
+        }
+
+        /*
+         * Support short form alias
+         */
+        if (JLI_StrCmp(arg, "-p") == 0) {
+            option = "--module-path";
+        }
+
+    } else if (JLI_StrCCmp(arg, "--") == 0 && (equals = JLI_StrChr(arg, '=')) != NULL) {
+        value = equals+1;
+        if (JLI_StrCCmp(arg, "--list-modules=") == 0 ||
+            JLI_StrCCmp(arg, "--module=") == 0 ||
+            JLI_StrCCmp(arg, "--class-path=") == 0) {
+            kind = LAUNCHER_OPTION_WITH_ARGUMENT;
+        } else {
+            kind = VM_LONG_OPTION;
+        }
+    }
+
+#ifndef OLD_MODULE_OPTIONS
+    // for transition to support both old and new syntax
+    if (JLI_StrCmp(arg, "-modulepath") == 0 ||
+        JLI_StrCmp(arg, "-mp") == 0) {
+        option = "--module-path";
+    } else if (JLI_StrCmp(arg, "-upgrademodulepath") == 0) {
+        option = "--upgrade-module-path";
+    } else if (JLI_StrCmp(arg, "-addmods") == 0) {
+        option = "--add-modules";
+    } else if (JLI_StrCmp(arg, "-limitmods") == 0) {
+        option = "--limit-modules";
+    } else if (JLI_StrCCmp(arg, "-XaddExports:") == 0) {
+        option = "--add-exports";
+        value = arg + 13;
+        kind = VM_LONG_OPTION_WITH_ARGUMENT;
+    } else if (JLI_StrCCmp(arg, "-XaddReads:") == 0) {
+        option = "--add-reads";
+        value = arg + 11;
+        kind = VM_LONG_OPTION_WITH_ARGUMENT;
+    } else if (JLI_StrCCmp(arg, "-Xpatch:") == 0) {
+        option = "--patch-module";
+        value = arg + 8;
+        kind = VM_LONG_OPTION_WITH_ARGUMENT;
+    }
+#endif
+
+    *pargc = argc;
+    *pargv = argv;
+    *poption = option;
+    *pvalue = value;
+    return kind;
+}
+
+/*
  * Parses command line arguments.  Returns JNI_FALSE if launcher
  * should exit without starting vm, returns JNI_TRUE if vm needs
  * to be started to process given options.  *pret (the launcher
@@ -1158,52 +1276,85 @@
     *pret = 0;
 
     while ((arg = *argv) != 0 && *arg == '-') {
-        argv++; --argc;
-        if (JLI_StrCmp(arg, "-classpath") == 0 || JLI_StrCmp(arg, "-cp") == 0) {
-            ARG_CHECK (argc, ARG_ERROR1, arg);
-            SetClassPath(*argv);
+        char *option = NULL;
+        char *value = NULL;
+        int kind = GetOpt(&argc, &argv, &option, &value);
+        jboolean has_arg = value != NULL;
+
+/*
+ * Option to set main entry point
+ */
+        if (JLI_StrCmp(arg, "-jar") == 0) {
+            ARG_CHECK(argc, ARG_ERROR2, arg);
+            mode = LM_JAR;
+        } else if (JLI_StrCmp(arg, "--module") == 0 ||
+                   JLI_StrCCmp(arg, "--module=") == 0 ||
+                   JLI_StrCmp(arg, "-m") == 0) {
+            REPORT_ERROR (has_arg, ARG_ERROR5, arg);
+            SetMainModule(value);
+            mode = LM_MODULE;
+            if (has_arg) {
+               *pwhat = value;
+                break;
+            }
+        } else if (JLI_StrCmp(arg, "--class-path") == 0 ||
+                   JLI_StrCCmp(arg, "--class-path=") == 0 ||
+                   JLI_StrCmp(arg, "-classpath") == 0 ||
+                   JLI_StrCmp(arg, "-cp") == 0) {
+            REPORT_ERROR (has_arg, ARG_ERROR1, arg);
+            SetClassPath(value);
             mode = LM_CLASS;
-            argv++; --argc;
-        } else if (JLI_StrCmp(arg, "-modulepath") == 0 || JLI_StrCmp(arg, "-mp") == 0) {
-            ARG_CHECK (argc, ARG_ERROR4, arg);
-            SetModulePath(*argv);
-            argv++; --argc;
-        } else if (JLI_StrCmp(arg, "-upgrademodulepath") == 0) {
-            ARG_CHECK (argc, ARG_ERROR4, arg);
-            SetUpgradeModulePath(*argv);
-            argv++; --argc;
-        } else if (JLI_StrCmp(arg, "-jar") == 0) {
-            ARG_CHECK (argc, ARG_ERROR2, arg);
-            mode = LM_JAR;
-        } else if (JLI_StrCmp(arg, "-m") == 0) {
-            ARG_CHECK (argc, ARG_ERROR5, arg);
-            SetMainModule(*argv);
-            mode = LM_MODULE;
-        } else if (JLI_StrCmp(arg, "-addmods") == 0) {
-            ARG_CHECK (argc, ARG_ERROR6, arg);
-            SetAddModulesProp(*argv);
-            argv++; --argc;
-        } else if (JLI_StrCmp(arg, "-limitmods") == 0) {
-            ARG_CHECK (argc, ARG_ERROR6, arg);
-            SetLimitModulesProp(*argv);
-            argv++; --argc;
-        } else if (JLI_StrCmp(arg, "-listmods") == 0 ||
-                   JLI_StrCCmp(arg, "-listmods:") == 0) {
+        } else if (JLI_StrCmp(arg, "--list-modules") == 0 ||
+                   JLI_StrCCmp(arg, "--list-modules=") == 0) {
             listModules = arg;
+
+            // set listModules to --list-modules=<module-names> if argument is specified
+            if (JLI_StrCmp(arg, "--list-modules") == 0 && has_arg) {
+                static const char format[] = "%s=%s";
+                size_t buflen = JLI_StrLen(option) + 2 + JLI_StrLen(value);
+                listModules = JLI_MemAlloc(buflen);
+                JLI_Snprintf(listModules, buflen, format, option, value);
+            }
             return JNI_TRUE;
-        } else if (JLI_StrCCmp(arg, "-XaddReads:") == 0) {
-            static jint n;
-            char *value = arg + 11;
-            SetAddReadsProp(n++, value);
-        } else if (JLI_StrCCmp(arg, "-XaddExports:") == 0) {
-            static jint n;
-            char *value = arg + 13;
-            SetAddExportsProp(n++, value);
-        } else if (JLI_StrCCmp(arg, "-Xpatch:") == 0) {
-            static jint n;
-            char *value = arg + 8;
-            SetPatchProp(n++, value);
-        } else if (JLI_StrCmp(arg, "-help") == 0 ||
+/*
+ * Parse white-space options
+ */
+        } else if (has_arg) {
+            if (kind == VM_LONG_OPTION) {
+                AddOption(option, NULL);
+            } else if (kind == VM_LONG_OPTION_WITH_ARGUMENT) {
+                AddLongFormOption(option, value);
+            }
+/*
+ * Error missing argument
+ */
+        } else if (!has_arg && IsWhiteSpaceOption(arg)) {
+            if (JLI_StrCmp(arg, "--module-path") == 0 ||
+                JLI_StrCmp(arg, "-p") == 0 ||
+                JLI_StrCmp(arg, "--upgrade-module-path") == 0) {
+                REPORT_ERROR (has_arg, ARG_ERROR4, arg);
+            } else if (JLI_StrCmp(arg, "--add-modules") == 0 ||
+                       JLI_StrCmp(arg, "--limit-modules") == 0 ||
+                       JLI_StrCmp(arg, "--add-exports") == 0 ||
+                       JLI_StrCmp(arg, "--add-reads") == 0 ||
+                       JLI_StrCmp(arg, "--patch-module") == 0) {
+                REPORT_ERROR (has_arg, ARG_ERROR6, arg);
+            }
+#ifndef OLD_MODULE_OPTIONS
+            else if (JLI_StrCmp(arg, "-modulepath") == 0 ||
+                     JLI_StrCmp(arg, "-mp") == 0 ||
+                     JLI_StrCmp(arg, "-upgrademodulepath") == 0) {
+                REPORT_ERROR (has_arg, ARG_ERROR4, arg);
+            } else if (JLI_StrCmp(arg, "-addmods") == 0 ||
+                       JLI_StrCmp(arg, "-limitmods") == 0) {
+                REPORT_ERROR (has_arg, ARG_ERROR6, arg);
+            }
+#endif
+/*
+ * The following cases will cause the argument parsing to stop
+ */
+        } else if (JLI_StrCmp(arg, "--help") == 0 ||
+                   JLI_StrCmp(arg, "-help") == 0 ||
                    JLI_StrCmp(arg, "-h") == 0 ||
                    JLI_StrCmp(arg, "-?") == 0) {
             printUsage = JNI_TRUE;
@@ -1282,7 +1433,7 @@
         }
     }
 
-    if (--argc >= 0) {
+    if (*pwhat == NULL && --argc >= 0) {
         *pwhat = *argv++;
     }
 
@@ -1692,7 +1843,7 @@
 ListModules(JNIEnv *env, char *optString)
 {
     jmethodID listModulesID;
-    jstring joptString;
+    jstring joptString = NULL;
     jclass cls = GetLauncherHelperClass(env);
     NULL_CHECK(cls);
     NULL_CHECK(listModulesID = (*env)->GetStaticMethodID(env, cls,
--- a/jdk/src/java.base/share/native/libjli/java.h	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.base/share/native/libjli/java.h	Thu Aug 11 17:02:46 2016 +0000
@@ -161,6 +161,7 @@
 jint ReadKnownVMs(const char *jvmcfg, jboolean speculative);
 char *CheckJvmType(int *argc, char ***argv, jboolean speculative);
 void AddOption(char *str, void *info);
+jboolean IsWhiteSpaceOption(const char* name);
 
 enum ergo_policy {
    DEFAULT_POLICY = 0,
--- a/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.h	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.h	Thu Aug 11 17:02:46 2016 +0000
@@ -26,7 +26,7 @@
 #include <signal.h>
 #include <stdlib.h>
 
-double getNativeScaleFactor();
+double getNativeScaleFactor(char *output_name);
 
 #endif
 
--- a/jdk/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c	Thu Aug 11 17:02:46 2016 +0000
@@ -806,7 +806,7 @@
 #ifndef __linux__
     return JNI_FALSE;
 #endif
-    *scaleFactor = getNativeScaleFactor();
+    *scaleFactor = getNativeScaleFactor(NULL);
     if (*scaleFactor == 2.0) {
         size_t length = 0;
         char *stringToAppend = ".java-scale2x";
--- a/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java	Thu Aug 11 17:02:46 2016 +0000
@@ -31,7 +31,7 @@
 /*
  * I/O abstraction used to implement WebSocket.
  */
-public interface RawChannel {
+interface RawChannel {
 
     interface RawEvent {
 
--- a/jdk/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5InitCredential.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5InitCredential.java	Thu Aug 11 17:02:46 2016 +0000
@@ -235,8 +235,11 @@
      */
     public int getInitLifetime() throws GSSException {
         int retVal = 0;
-        retVal = (int)(getEndTime().getTime()
-                       - (new Date().getTime()));
+        Date d = getEndTime();
+        if (d == null) {
+            return 0;
+        }
+        retVal = (int)(d.getTime() - (new Date().getTime()));
 
         return retVal/1000;
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/FingerPrint.java	Thu Aug 11 17:02:46 2016 +0000
@@ -0,0 +1,324 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.tools.jar;
+
+import jdk.internal.org.objectweb.asm.*;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A FingerPrint is an abstract representation of a JarFile entry that contains
+ * information to determine if the entry represents a class or a
+ * resource, and whether two entries are identical.  If the FingerPrint represents
+ * a class, it also contains information to (1) describe the public API;
+ * (2) compare the public API of this class with another class;  (3) determine
+ * whether or not it's a nested class and, if so, the name of the associated
+ * top level class; and (4) for an canonically ordered set of classes determine
+ * if the class versions are compatible.  A set of classes is canonically
+ * ordered if the classes in the set have the same name, and the base class
+ * precedes the versioned classes and if each versioned class with version
+ * {@code n} precedes classes with versions {@code > n} for all versions
+ * {@code n}.
+ */
+final class FingerPrint {
+    private static final MessageDigest MD;
+
+    private final byte[] sha1;
+    private final ClassAttributes attrs;
+    private final boolean isClassEntry;
+    private final String entryName;
+
+    static {
+        try {
+            MD = MessageDigest.getInstance("SHA-1");
+        } catch (NoSuchAlgorithmException x) {
+            // log big problem?
+            throw new RuntimeException(x);
+        }
+    }
+
+    public FingerPrint(String entryName,byte[] bytes) throws IOException {
+        this.entryName = entryName;
+        if (entryName.endsWith(".class") && isCafeBabe(bytes)) {
+            isClassEntry = true;
+            sha1 = sha1(bytes, 8);  // skip magic number and major/minor version
+            attrs = getClassAttributes(bytes);
+        } else {
+            isClassEntry = false;
+            sha1 = sha1(bytes);
+            attrs = new ClassAttributes();   // empty class
+        }
+    }
+
+    public boolean isClass() {
+        return isClassEntry;
+    }
+
+    public boolean isNestedClass() {
+        return attrs.nestedClass;
+    }
+
+    public boolean isPublicClass() {
+        return attrs.publicClass;
+    }
+
+    public boolean isIdentical(FingerPrint that) {
+        if (that == null) return false;
+        if (this == that) return true;
+        return isEqual(this.sha1, that.sha1);
+    }
+
+    public boolean isCompatibleVersion(FingerPrint that) {
+        return attrs.version >= that.attrs.version;
+    }
+
+    public boolean isSameAPI(FingerPrint that) {
+        if (that == null) return false;
+        return attrs.equals(that.attrs);
+    }
+
+    public String name() {
+        String name = attrs.name;
+        return name == null ? entryName : name;
+    }
+
+    public String topLevelName() {
+        String name = attrs.topLevelName;
+        return name == null ? name() : name;
+    }
+
+    private byte[] sha1(byte[] entry) {
+        MD.update(entry);
+        return MD.digest();
+    }
+
+    private byte[] sha1(byte[] entry, int offset) {
+        MD.update(entry, offset, entry.length - offset);
+        return MD.digest();
+    }
+
+    private boolean isEqual(byte[] sha1_1, byte[] sha1_2) {
+        return MessageDigest.isEqual(sha1_1, sha1_2);
+    }
+
+    private static final byte[] cafeBabe = {(byte)0xca, (byte)0xfe, (byte)0xba, (byte)0xbe};
+
+    private boolean isCafeBabe(byte[] bytes) {
+        if (bytes.length < 4) return false;
+        for (int i = 0; i < 4; i++) {
+            if (bytes[i] != cafeBabe[i]) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private ClassAttributes getClassAttributes(byte[] bytes) {
+        ClassReader rdr = new ClassReader(bytes);
+        ClassAttributes attrs = new ClassAttributes();
+        rdr.accept(attrs, 0);
+        return attrs;
+    }
+
+    private static final class Field {
+        private final int access;
+        private final String name;
+        private final String desc;
+
+        Field(int access, String name, String desc) {
+            this.access = access;
+            this.name = name;
+            this.desc = desc;
+        }
+
+        @Override
+        public boolean equals(Object that) {
+            if (that == null) return false;
+            if (this == that) return true;
+            if (!(that instanceof Field)) return false;
+            Field field = (Field)that;
+            return (access == field.access) && name.equals(field.name)
+                    && desc.equals(field.desc);
+        }
+
+        @Override
+        public int hashCode() {
+            int result = 17;
+            result = 37 * result + access;
+            result = 37 * result + name.hashCode();
+            result = 37 * result + desc.hashCode();
+            return result;
+        }
+    }
+
+    private static final class Method {
+        private final int access;
+        private final String name;
+        private final String desc;
+        private final Set<String> exceptions;
+
+        Method(int access, String name, String desc, Set<String> exceptions) {
+            this.access = access;
+            this.name = name;
+            this.desc = desc;
+            this.exceptions = exceptions;
+        }
+
+        @Override
+        public boolean equals(Object that) {
+            if (that == null) return false;
+            if (this == that) return true;
+            if (!(that instanceof Method)) return false;
+            Method method = (Method)that;
+            return (access == method.access) && name.equals(method.name)
+                    && desc.equals(method.desc)
+                    && exceptions.equals(method.exceptions);
+        }
+
+        @Override
+        public int hashCode() {
+            int result = 17;
+            result = 37 * result + access;
+            result = 37 * result + name.hashCode();
+            result = 37 * result + desc.hashCode();
+            result = 37 * result + exceptions.hashCode();
+            return result;
+        }
+    }
+
+    private static final class ClassAttributes extends ClassVisitor {
+        private String name;
+        private String topLevelName;
+        private String superName;
+        private int version;
+        private int access;
+        private boolean publicClass;
+        private boolean nestedClass;
+        private final Set<Field> fields = new HashSet<>();
+        private final Set<Method> methods = new HashSet<>();
+
+        public ClassAttributes() {
+            super(Opcodes.ASM5);
+        }
+
+        private boolean isPublic(int access) {
+            return ((access & Opcodes.ACC_PUBLIC) == Opcodes.ACC_PUBLIC)
+                    || ((access & Opcodes.ACC_PROTECTED) == Opcodes.ACC_PROTECTED);
+        }
+
+        @Override
+        public void visit(int version, int access, String name, String signature,
+                          String superName, String[] interfaces) {
+            this.version = version;
+            this.access = access;
+            this.name = name;
+            this.nestedClass = name.contains("$");
+            this.superName = superName;
+            this.publicClass = isPublic(access);
+        }
+
+        @Override
+        public void visitOuterClass(String owner, String name, String desc) {
+            if (!this.nestedClass) return;
+            this.topLevelName = owner;
+        }
+
+        @Override
+        public void visitInnerClass(String name, String outerName, String innerName,
+                                    int access) {
+            if (!this.nestedClass) return;
+            if (outerName == null) return;
+            if (!this.name.equals(name)) return;
+            if (this.topLevelName == null) this.topLevelName = outerName;
+        }
+
+        @Override
+        public FieldVisitor visitField(int access, String name, String desc,
+                                       String signature, Object value) {
+            if (isPublic(access)) {
+                fields.add(new Field(access, name, desc));
+            }
+            return null;
+        }
+
+        @Override
+        public MethodVisitor visitMethod(int access, String name, String desc,
+                                         String signature, String[] exceptions) {
+            if (isPublic(access)) {
+                Set<String> exceptionSet = new HashSet<>();
+                if (exceptions != null) {
+                    for (String e : exceptions) {
+                        exceptionSet.add(e);
+                    }
+                }
+                // treat type descriptor as a proxy for signature because signature
+                // is usually null, need to strip off the return type though
+                int n;
+                if (desc != null && (n = desc.lastIndexOf(')')) != -1) {
+                    desc = desc.substring(0, n + 1);
+                    methods.add(new Method(access, name, desc, exceptionSet));
+                }
+            }
+            return null;
+        }
+
+        @Override
+        public void visitEnd() {
+            this.nestedClass = this.topLevelName != null;
+        }
+
+        @Override
+        public boolean equals(Object that) {
+            if (that == null) return false;
+            if (this == that) return true;
+            if (!(that instanceof ClassAttributes)) return false;
+            ClassAttributes clsAttrs = (ClassAttributes)that;
+            boolean superNameOkay = superName != null
+                    ? superName.equals(clsAttrs.superName) : true;
+            return access == clsAttrs.access
+                    && superNameOkay
+                    && fields.equals(clsAttrs.fields)
+                    && methods.equals(clsAttrs.methods);
+        }
+
+        @Override
+        public int hashCode() {
+            int result = 17;
+            result = 37 * result + access;
+            result = 37 * result + superName != null ? superName.hashCode() : 0;
+            result = 37 * result + fields.hashCode();
+            result = 37 * result + methods.hashCode();
+            return result;
+        }
+    }
+}
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java	Thu Aug 11 17:02:46 2016 +0000
@@ -91,7 +91,7 @@
                     tool.xflag = true;
                 }
             },
-            new Option(false, OptionType.MAIN_OPERATION, "--print-module-descriptor", "-p") {
+            new Option(false, OptionType.MAIN_OPERATION, "--print-module-descriptor", "-d") {
                 void process(Main tool, String opt, String arg) throws BadArgs {
                     if (tool.cflag || tool.iflag  || tool.tflag || tool.uflag || tool.xflag)
                         throw new BadArgs("error.multiple.main.operations").showUsage(true);
@@ -145,7 +145,7 @@
                     }
                 }
             },
-            new Option(true, OptionType.CREATE_UPDATE, "--modulepath", "--mp") {
+            new Option(true, OptionType.CREATE_UPDATE, "--module-path", "-p") {
                 void process(Main jartool, String opt, String arg) {
                     String[] dirs = arg.split(File.pathSeparator);
                     Path[] paths = new Path[dirs.length];
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Thu Aug 11 17:02:46 2016 +0000
@@ -42,6 +42,7 @@
 import java.nio.file.Path;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
 import java.util.*;
 import java.util.function.Consumer;
 import java.util.function.Function;
@@ -278,23 +279,20 @@
                     }
                 }
             }
+
             if (cflag) {
                 Manifest manifest = null;
-                InputStream in = null;
-
                 if (!Mflag) {
                     if (mname != null) {
-                        in = new FileInputStream(mname);
-                        manifest = new Manifest(new BufferedInputStream(in));
+                        try (InputStream in = new FileInputStream(mname)) {
+                            manifest = new Manifest(new BufferedInputStream(in));
+                        }
                     } else {
                         manifest = new Manifest();
                     }
                     addVersion(manifest);
                     addCreatedBy(manifest);
                     if (isAmbiguousMainClass(manifest)) {
-                        if (in != null) {
-                            in.close();
-                        }
                         return false;
                     }
                     if (ename != null) {
@@ -304,11 +302,13 @@
                         addMultiRelease(manifest);
                     }
                 }
+
                 Map<String,Path> moduleInfoPaths = new HashMap<>();
                 for (int version : filesMap.keySet()) {
                     String[] files = filesMap.get(version);
                     expand(null, files, false, moduleInfoPaths, version);
                 }
+
                 Map<String,byte[]> moduleInfos = new LinkedHashMap<>();
                 if (!moduleInfoPaths.isEmpty()) {
                     if (!checkModuleInfos(moduleInfoPaths))
@@ -332,84 +332,61 @@
                     return false;
                 }
 
-                OutputStream out;
-                if (fname != null) {
-                    out = new FileOutputStream(fname);
-                } else {
-                    out = new FileOutputStream(FileDescriptor.out);
-                    if (vflag) {
-                        // Disable verbose output so that it does not appear
-                        // on stdout along with file data
-                        // error("Warning: -v option ignored");
-                        vflag = false;
-                    }
+                if (vflag && fname == null) {
+                    // Disable verbose output so that it does not appear
+                    // on stdout along with file data
+                    // error("Warning: -v option ignored");
+                    vflag = false;
                 }
-                File tmpfile = null;
-                final OutputStream finalout = out;
+
                 final String tmpbase = (fname == null)
                         ? "tmpjar"
                         : fname.substring(fname.indexOf(File.separatorChar) + 1);
+                File tmpfile = createTemporaryFile(tmpbase, ".jar");
+
+                try (OutputStream out = new FileOutputStream(tmpfile)) {
+                    create(new BufferedOutputStream(out, 4096), manifest, moduleInfos);
+                }
+
                 if (nflag) {
-                    tmpfile = createTemporaryFile(tmpbase, ".jar");
-                    out = new FileOutputStream(tmpfile);
-                }
-                create(new BufferedOutputStream(out, 4096), manifest, moduleInfos);
-
-                if (in != null) {
-                    in.close();
-                }
-                out.close();
-                if (nflag) {
-                    JarFile jarFile = null;
-                    File packFile = null;
-                    JarOutputStream jos = null;
+                    File packFile = createTemporaryFile(tmpbase, ".pack");
                     try {
                         Packer packer = Pack200.newPacker();
                         Map<String, String> p = packer.properties();
                         p.put(Packer.EFFORT, "1"); // Minimal effort to conserve CPU
-                        jarFile = new JarFile(tmpfile.getCanonicalPath());
-                        packFile = createTemporaryFile(tmpbase, ".pack");
-                        out = new FileOutputStream(packFile);
-                        packer.pack(jarFile, out);
-                        jos = new JarOutputStream(finalout);
-                        Unpacker unpacker = Pack200.newUnpacker();
-                        unpacker.unpack(packFile, jos);
-                    } catch (IOException ioe) {
-                        fatalError(ioe);
-                    } finally {
-                        if (jarFile != null) {
-                            jarFile.close();
+                        try (
+                                JarFile jarFile = new JarFile(tmpfile.getCanonicalPath());
+                                OutputStream pack = new FileOutputStream(packFile)
+                        ) {
+                            packer.pack(jarFile, pack);
                         }
-                        if (out != null) {
-                            out.close();
-                        }
-                        if (jos != null) {
-                            jos.close();
-                        }
-                        if (tmpfile != null && tmpfile.exists()) {
+                        if (tmpfile.exists()) {
                             tmpfile.delete();
                         }
-                        if (packFile != null && packFile.exists()) {
-                            packFile.delete();
+                        tmpfile = createTemporaryFile(tmpbase, ".jar");
+                        try (
+                                OutputStream out = new FileOutputStream(tmpfile);
+                                JarOutputStream jos = new JarOutputStream(out)
+                        ) {
+                            Unpacker unpacker = Pack200.newUnpacker();
+                            unpacker.unpack(packFile, jos);
                         }
+                    } finally {
+                        Files.deleteIfExists(packFile.toPath());
                     }
                 }
+
+                validateAndClose(tmpfile);
+
             } else if (uflag) {
                 File inputFile = null, tmpFile = null;
-                FileInputStream in;
-                FileOutputStream out;
                 if (fname != null) {
                     inputFile = new File(fname);
                     tmpFile = createTempFileInSameDirectoryAs(inputFile);
-                    in = new FileInputStream(inputFile);
-                    out = new FileOutputStream(tmpFile);
                 } else {
-                    in = new FileInputStream(FileDescriptor.in);
-                    out = new FileOutputStream(FileDescriptor.out);
                     vflag = false;
+                    tmpFile = createTemporaryFile("tmpjar", ".jar");
                 }
-                InputStream manifest = (!Mflag && (mname != null)) ?
-                    (new FileInputStream(mname)) : null;
 
                 Map<String,Path> moduleInfoPaths = new HashMap<>();
                 for (int version : filesMap.keySet()) {
@@ -421,8 +398,19 @@
                 for (Map.Entry<String,Path> e : moduleInfoPaths.entrySet())
                     moduleInfos.put(e.getKey(), readModuleInfo(e.getValue()));
 
-                boolean updateOk = update(in, new BufferedOutputStream(out),
-                                          manifest, moduleInfos, null);
+                try (
+                        FileInputStream in = (fname != null) ? new FileInputStream(inputFile)
+                                : new FileInputStream(FileDescriptor.in);
+                        FileOutputStream out = new FileOutputStream(tmpFile);
+                        InputStream manifest = (!Mflag && (mname != null)) ?
+                                (new FileInputStream(mname)) : null;
+                ) {
+                        boolean updateOk = update(in, new BufferedOutputStream(out),
+                                manifest, moduleInfos, null);
+                        if (ok) {
+                            ok = updateOk;
+                        }
+                }
 
                 // Consistency checks for modular jars.
                 if (!moduleInfos.isEmpty()) {
@@ -430,23 +418,8 @@
                         return false;
                 }
 
-                if (ok) {
-                    ok = updateOk;
-                }
-                in.close();
-                out.close();
-                if (manifest != null) {
-                    manifest.close();
-                }
-                if (ok && fname != null) {
-                    // on Win32, we need this delete
-                    inputFile.delete();
-                    if (!tmpFile.renameTo(inputFile)) {
-                        tmpFile.delete();
-                        throw new IOException(getMsg("error.write.file"));
-                    }
-                    tmpFile.delete();
-                }
+                validateAndClose(tmpFile);
+
             } else if (tflag) {
                 replaceFSC(filesMap);
                 // For the "list table contents" action, access using the
@@ -520,6 +493,28 @@
         return ok;
     }
 
+    private void validateAndClose(File tmpfile) throws IOException {
+        if (ok && isMultiRelease) {
+            ok = validate(tmpfile.getCanonicalPath());
+            if (!ok) {
+                error(formatMsg("error.validator.jarfile.invalid", fname));
+            }
+        }
+
+        Path path = tmpfile.toPath();
+        try {
+            if (ok) {
+                if (fname != null) {
+                    Files.move(path, Paths.get(fname), StandardCopyOption.REPLACE_EXISTING);
+                } else {
+                    Files.copy(path, new FileOutputStream(FileDescriptor.out));
+                }
+            }
+        } finally {
+            Files.deleteIfExists(path);
+        }
+    }
+
     private String[] filesMapToFiles(Map<Integer,String[]> filesMap) {
         if (filesMap.isEmpty()) return null;
         return filesMap.entrySet()
@@ -534,6 +529,76 @@
                 .map(f -> (new EntryName(f, version)).entryName);
     }
 
+    // sort base entries before versioned entries, and sort entry classes with
+    // nested classes so that the top level class appears before the associated
+    // nested class
+    private Comparator<JarEntry> entryComparator = (je1, je2) ->  {
+        String s1 = je1.getName();
+        String s2 = je2.getName();
+        if (s1.equals(s2)) return 0;
+        boolean b1 = s1.startsWith(VERSIONS_DIR);
+        boolean b2 = s2.startsWith(VERSIONS_DIR);
+        if (b1 && !b2) return 1;
+        if (!b1 && b2) return -1;
+        int n = 0; // starting char for String compare
+        if (b1 && b2) {
+            // normally strings would be sorted so "10" goes before "9", but
+            // version number strings need to be sorted numerically
+            n = VERSIONS_DIR.length();   // skip the common prefix
+            int i1 = s1.indexOf('/', n);
+            int i2 = s1.indexOf('/', n);
+            if (i1 == -1) throw new InvalidJarException(s1);
+            if (i2 == -1) throw new InvalidJarException(s2);
+            // shorter version numbers go first
+            if (i1 != i2) return i1 - i2;
+            // otherwise, handle equal length numbers below
+        }
+        int l1 = s1.length();
+        int l2 = s2.length();
+        int lim = Math.min(l1, l2);
+        for (int k = n; k < lim; k++) {
+            char c1 = s1.charAt(k);
+            char c2 = s2.charAt(k);
+            if (c1 != c2) {
+                // change natural ordering so '.' comes before '$'
+                // i.e. top level classes come before nested classes
+                if (c1 == '$' && c2 == '.') return 1;
+                if (c1 == '.' && c2 == '$') return -1;
+                return c1 - c2;
+            }
+        }
+        return l1 - l2;
+    };
+
+    private boolean validate(String fname) {
+        boolean valid;
+
+        try (JarFile jf = new JarFile(fname)) {
+            Validator validator = new Validator(this, jf);
+            jf.stream()
+                    .filter(e -> !e.isDirectory())
+                    .filter(e -> !e.getName().equals(MANIFEST_NAME))
+                    .filter(e -> !e.getName().endsWith(MODULE_INFO))
+                    .sorted(entryComparator)
+                    .forEachOrdered(validator);
+             valid = validator.isValid();
+        } catch (IOException e) {
+            error(formatMsg2("error.validator.jarfile.exception", fname, e.getMessage()));
+            valid = false;
+        } catch (InvalidJarException e) {
+            error(formatMsg("error.validator.bad.entry.name", e.getMessage()));
+            valid = false;
+        }
+        return valid;
+    }
+
+    private static class InvalidJarException extends RuntimeException {
+        private static final long serialVersionUID = -3642329147299217726L;
+        InvalidJarException(String msg) {
+            super(msg);
+        }
+    }
+
     /**
      * Parses command line arguments.
      */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java	Thu Aug 11 17:02:46 2016 +0000
@@ -0,0 +1,242 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.tools.jar;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Consumer;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+final class Validator implements Consumer<JarEntry> {
+    private final static boolean DEBUG = Boolean.getBoolean("jar.debug");
+    private final  Map<String,FingerPrint> fps = new HashMap<>();
+    private final int vdlen = Main.VERSIONS_DIR.length();
+    private final Main main;
+    private final JarFile jf;
+    private int oldVersion = -1;
+    private String currentTopLevelName;
+    private boolean isValid = true;
+
+    Validator(Main main, JarFile jf) {
+        this.main = main;
+        this.jf = jf;
+    }
+
+    boolean isValid() {
+        return isValid;
+    }
+
+    /*
+     *  Validator has state and assumes entries provided to accept are ordered
+     *  from base entries first and then through the versioned entries in
+     *  ascending version order.  Also, to find isolated nested classes,
+     *  classes must be ordered so that the top level class is before the associated
+     *  nested class(es).
+    */
+    public void accept(JarEntry je) {
+        String entryName = je.getName();
+
+        // directories are always accepted
+        if (entryName.endsWith("/")) {
+            debug("%s is a directory", entryName);
+            return;
+        }
+
+        // figure out the version and basename from the JarEntry
+        int version;
+        String basename;
+        if (entryName.startsWith(Main.VERSIONS_DIR)) {
+            int n = entryName.indexOf("/", vdlen);
+            if (n == -1) {
+                main.error(Main.formatMsg("error.validator.version.notnumber", entryName));
+                isValid = false;
+                return;
+            }
+            String v = entryName.substring(vdlen, n);
+            try {
+                version = Integer.parseInt(v);
+            } catch (NumberFormatException x) {
+                main.error(Main.formatMsg("error.validator.version.notnumber", entryName));
+                isValid = false;
+                return;
+            }
+            if (n == entryName.length()) {
+                main.error(Main.formatMsg("error.validator.entryname.tooshort", entryName));
+                isValid = false;
+                return;
+            }
+            basename = entryName.substring(n + 1);
+        } else {
+            version = 0;
+            basename = entryName;
+        }
+        debug("\n===================\nversion %d %s", version, entryName);
+
+        if (oldVersion != version) {
+            oldVersion = version;
+            currentTopLevelName = null;
+        }
+
+        // analyze the entry, keeping key attributes
+        FingerPrint fp;
+        try (InputStream is = jf.getInputStream(je)) {
+            fp = new FingerPrint(basename, is.readAllBytes());
+        } catch (IOException x) {
+            main.error(x.getMessage());
+            isValid = false;
+            return;
+        }
+        String internalName = fp.name();
+
+        // process a base entry paying attention to nested classes
+        if (version == 0) {
+            debug("base entry found");
+            if (fp.isNestedClass()) {
+                debug("nested class found");
+                if (fp.topLevelName().equals(currentTopLevelName)) {
+                    fps.put(internalName, fp);
+                    return;
+                }
+                main.error(Main.formatMsg("error.validator.isolated.nested.class", entryName));
+                isValid = false;
+                return;
+            }
+            // top level class or resource entry
+            if (fp.isClass()) {
+                currentTopLevelName = fp.topLevelName();
+                if (!checkInternalName(entryName, basename, internalName)) {
+                    isValid = false;
+                    return;
+                }
+            }
+            fps.put(internalName, fp);
+            return;
+        }
+
+        // process a versioned entry, look for previous entry with same name
+        FingerPrint matchFp = fps.get(internalName);
+        debug("looking for match");
+        if (matchFp == null) {
+            debug("no match found");
+            if (fp.isClass()) {
+                if (fp.isNestedClass()) {
+                    if (!checkNestedClass(version, entryName, internalName, fp)) {
+                        isValid = false;
+                    }
+                    return;
+                }
+                if (fp.isPublicClass()) {
+                    main.error(Main.formatMsg("error.validator.new.public.class", entryName));
+                    isValid = false;
+                    return;
+                }
+                debug("%s is a non-public class entry", entryName);
+                fps.put(internalName, fp);
+                currentTopLevelName = fp.topLevelName();
+                return;
+            }
+            debug("%s is a resource entry");
+            fps.put(internalName, fp);
+            return;
+        }
+        debug("match found");
+
+        // are the two classes/resources identical?
+        if (fp.isIdentical(matchFp)) {
+            main.error(Main.formatMsg("error.validator.identical.entry", entryName));
+            return;  // it's okay, just takes up room
+        }
+        debug("sha1 not equal -- different bytes");
+
+        // ok, not identical, check for compatible class version and api
+        if (fp.isClass()) {
+            if (fp.isNestedClass()) {
+                if (!checkNestedClass(version, entryName, internalName, fp)) {
+                    isValid = false;
+                }
+                return;
+            }
+            debug("%s is a class entry", entryName);
+            if (!fp.isCompatibleVersion(matchFp)) {
+                main.error(Main.formatMsg("error.validator.incompatible.class.version", entryName));
+                isValid = false;
+                return;
+            }
+            if (!fp.isSameAPI(matchFp)) {
+                main.error(Main.formatMsg("error.validator.different.api", entryName));
+                isValid = false;
+                return;
+            }
+            if (!checkInternalName(entryName, basename, internalName)) {
+                isValid = false;
+                return;
+            }
+            debug("fingerprints same -- same api");
+            fps.put(internalName, fp);
+            currentTopLevelName = fp.topLevelName();
+            return;
+        }
+        debug("%s is a resource", entryName);
+
+        main.error(Main.formatMsg("error.validator.resources.with.same.name", entryName));
+        fps.put(internalName, fp);
+        return;
+    }
+
+    private boolean checkInternalName(String entryName, String basename, String internalName) {
+        String className = className(basename);
+        if (internalName.equals(className)) {
+            return true;
+        }
+        main.error(Main.formatMsg2("error.validator.names.mismatch",
+                entryName, internalName.replace("/", ".")));
+        return false;
+    }
+
+    private boolean checkNestedClass(int version, String entryName, String internalName, FingerPrint fp) {
+        debug("%s is a nested class entry in top level class %s", entryName, fp.topLevelName());
+        if (fp.topLevelName().equals(currentTopLevelName)) {
+            debug("%s (top level class) was accepted", fp.topLevelName());
+            fps.put(internalName, fp);
+            return true;
+        }
+        debug("top level class was not accepted");
+        main.error(Main.formatMsg("error.validator.isolated.nested.class", entryName));
+        return false;
+    }
+
+    private String className(String entryName) {
+        return entryName.endsWith(".class") ? entryName.substring(0, entryName.length() - 6) : null;
+    }
+
+    private void debug(String fmt, Object... args) {
+        if (DEBUG) System.err.format(fmt, args);
+    }
+}
+
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties	Thu Aug 11 17:02:46 2016 +0000
@@ -85,6 +85,30 @@
         release {0} not valid
 error.release.value.toosmall=\
         release {0} not valid, must be >= 9
+error.validator.jarfile.exception=\
+        can not validate {0}: {1}
+error.validator.jarfile.invalid=\
+        invalid multi-release jar file {0} deleted
+error.validator.bad.entry.name=\
+        entry name malformed, {0}
+error.validator.version.notnumber=\
+        entry name: {0}, does not have a version number
+error.validator.entryname.tooshort=\
+        entry name: {0}, too short, not a directory
+error.validator.isolated.nested.class=\
+        entry: {0}, is an isolated nested class
+error.validator.new.public.class=\
+        entry: {0}, contains a new public class not found in base entries
+error.validator.identical.entry=\
+        warning - entry: {0} contains a class that is identical to an entry already in the jar
+error.validator.incompatible.class.version=\
+        entry: {0}, has a class version incompatible with an earlier version
+error.validator.different.api=\
+        entry: {0}, contains a class with different api from earlier version
+error.validator.resources.with.same.name=\
+         warning - entry: {0}, multiple resources with same name
+error.validator.names.mismatch=\
+         entry: {0}, contains a class with internal name {1}, names do not match
 out.added.manifest=\
         added manifest
 out.added.module-info=\
@@ -177,7 +201,7 @@
 main.help.opt.main.extract=\
 \  -x, --extract              Extract named (or all) files from the archive
 main.help.opt.main.print-module-descriptor=\
-\  -p, --print-module-descriptor  Print the module descriptor
+\  -d, --print-module-descriptor  Print the module descriptor
 main.help.opt.any=\
 \ Operation modifiers valid in any mode:\n\
 \n\
@@ -208,8 +232,8 @@
 \                             matched by the given pattern and that depend upon\n\
 \                             directly or indirectly on a modular jar being\n\
 \                             created or a non-modular jar being updated
-main.help.opt.create.update.modulepath=\
-\      --modulepath           Location of module dependence for generating
+main.help.opt.create.update.module-path=\
+\  -p, --module-path          Location of module dependence for generating\n\
 \                             the hash
 main.help.opt.create.update.index=\
 \ Operation modifiers valid only in create, update, and generate-index mode:\n
@@ -226,7 +250,7 @@
 \ located in the root of the given directories, or the root of the jar archive\n\
 \ itself. The following operations are only valid when creating a modular jar,\n\
 \ or updating an existing non-modular jar: '--module-version',\n\
-\ '--hash-modules', and '--modulepath'.\n\
+\ '--hash-modules', and '--module-path'.\n\
 \n\
 \ Mandatory or optional arguments to long options are also mandatory or optional\n\
-\ for any corresponding short options.
\ No newline at end of file
+\ for any corresponding short options.
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java	Thu Aug 11 17:02:46 2016 +0000
@@ -61,11 +61,11 @@
 
         new Option<JImageTask>(false, (task, option, arg) -> {
             task.options.fullVersion = true;
-        }, true, "--fullversion"),
+        }, true, "--full-version"),
 
         new Option<JImageTask>(false, (task, option, arg) -> {
             task.options.help = true;
-        }, "--help"),
+        }, "--help", "-h"),
 
         new Option<JImageTask>(false, (task, option, arg) -> {
             task.options.verbose = true;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties	Thu Aug 11 17:02:46 2016 +0000
@@ -25,7 +25,7 @@
 
 main.usage.summary=\
 Usage: {0} <extract | info | list | verify> <options> jimage...\n\
-use --help for a list of possible options.
+use -h or --help for a list of possible options.
 
 main.usage=\
 Usage: {0} <extract | info | list | verify> <options> jimage...\n\
@@ -76,11 +76,11 @@
 \ used, one pattern per line\n\
 
 
-main.opt.fullversion=\
-\  --fullversion                     Print full version information
+main.opt.full-version=\
+\  --full-version                    Print full version information
 
 main.opt.help=\
-\  --help                            Print usage message
+\  -h,  --help                       Print usage message
 
 main.opt.verbose=\
 \  --verbose                         Listing prints entry size and offset attributes
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Thu Aug 11 17:02:46 2016 +0000
@@ -84,31 +84,32 @@
     private static final Option<?>[] recognizedOptions = {
         new Option<JlinkTask>(false, (task, opt, arg) -> {
             task.options.help = true;
-        }, "--help"),
+        }, "--help", "-h"),
         new Option<JlinkTask>(true, (task, opt, arg) -> {
             String[] dirs = arg.split(File.pathSeparator);
+            int i = 0;
             Arrays.stream(dirs)
                   .map(Paths::get)
                   .forEach(task.options.modulePath::add);
-        }, "--modulepath", "--mp"),
+        }, "--module-path", "-p"),
         new Option<JlinkTask>(true, (task, opt, arg) -> {
             for (String mn : arg.split(",")) {
                 if (mn.isEmpty()) {
                     throw taskHelper.newBadArgs("err.mods.must.be.specified",
-                            "--limitmods");
+                            "--limit-modules");
                 }
                 task.options.limitMods.add(mn);
             }
-        }, "--limitmods"),
+        }, "--limit-modules"),
         new Option<JlinkTask>(true, (task, opt, arg) -> {
             for (String mn : arg.split(",")) {
                 if (mn.isEmpty()) {
                     throw taskHelper.newBadArgs("err.mods.must.be.specified",
-                            "--addmods");
+                            "--add-modules");
                 }
                 task.options.addMods.add(mn);
             }
-        }, "--addmods"),
+        }, "--add-modules"),
         new Option<JlinkTask>(true, (task, opt, arg) -> {
             Path path = Paths.get(arg);
             task.options.output = path;
@@ -134,10 +135,10 @@
         }, true, "--keep-packaged-modules"),
         new Option<JlinkTask>(true, (task, opt, arg) -> {
             task.options.saveoptsfile = arg;
-        }, "--saveopts"),
+        }, "--save-opts"),
         new Option<JlinkTask>(false, (task, opt, arg) -> {
             task.options.fullVersion = true;
-        }, true, "--fullversion"),};
+        }, true, "--full-version"),};
 
     private static final String PROGNAME = "jlink";
     private final OptionsValues options = new OptionsValues();
@@ -294,7 +295,7 @@
         try {
             options.addMods = checkAddMods(options.addMods);
         } catch (IllegalArgumentException ex) {
-            throw taskHelper.newBadArgs("err.mods.must.be.specified", "--addmods")
+            throw taskHelper.newBadArgs("err.mods.must.be.specified", "--add-modules")
                     .showUsage(true);
         }
         // First create the image provider
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Thu Aug 11 17:02:46 2016 +0000
@@ -196,7 +196,7 @@
                         // This option is handled prior
                         // to have the options parsed.
                     },
-                    "--plugins-modulepath"));
+                    "--plugin-module-path"));
             mainOptions.add(new PlugOption(true, (task, opt, arg) -> {
                 Path path = Paths.get(arg);
                 if (!Files.exists(path) || !Files.isDirectory(path)) {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java	Thu Aug 11 17:02:46 2016 +0000
@@ -25,7 +25,6 @@
 package jdk.tools.jlink.internal.plugins;
 
 import java.lang.invoke.MethodType;
-import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.EnumSet;
 import java.util.HashMap;
@@ -33,6 +32,8 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
+import jdk.internal.misc.SharedSecrets;
+import jdk.internal.misc.JavaLangInvokeAccess;
 import jdk.tools.jlink.plugin.ResourcePoolEntry;
 import jdk.tools.jlink.plugin.PluginException;
 import jdk.tools.jlink.plugin.ResourcePool;
@@ -54,9 +55,6 @@
 
     private static final String DESCRIPTION = PluginsResourceBundle.getDescription(NAME);
 
-    private static final String BMH = "java/lang/invoke/BoundMethodHandle";
-    private static final Method BMH_FACTORY_METHOD;
-
     private static final String DMH = "java/lang/invoke/DirectMethodHandle$Holder";
     private static final String DMH_INVOKE_VIRTUAL = "invokeVirtual";
     private static final String DMH_INVOKE_STATIC = "invokeStatic";
@@ -64,7 +62,9 @@
     private static final String DMH_NEW_INVOKE_SPECIAL = "newInvokeSpecial";
     private static final String DMH_INVOKE_INTERFACE = "invokeInterface";
     private static final String DMH_INVOKE_STATIC_INIT = "invokeStaticInit";
-    private static final Method DMH_FACTORY_METHOD;
+
+    private static final JavaLangInvokeAccess JLIA
+            = SharedSecrets.getJavaLangInvokeAccess();
 
     List<String> speciesTypes;
 
@@ -232,8 +232,8 @@
     private void generateBMHClass(String types, ResourcePoolBuilder out) {
         try {
             // Generate class
-            Map.Entry<String, byte[]> result = (Map.Entry<String, byte[]>)
-                    BMH_FACTORY_METHOD.invoke(null, types);
+            Map.Entry<String, byte[]> result =
+                    JLIA.generateConcreteBMHClassBytes(types);
             String className = result.getKey();
             byte[] bytes = result.getValue();
 
@@ -264,11 +264,8 @@
             }
         }
         try {
-            byte[] bytes = (byte[])DMH_FACTORY_METHOD
-                    .invoke(null,
-                            DMH,
-                            methodTypes,
-                            dmhTypes);
+            byte[] bytes =
+                    JLIA.generateDMHClassBytes(DMH, methodTypes, dmhTypes);
             ResourcePoolEntry ndata = ResourcePoolEntry.create(DMH_ENTRY, bytes);
             out.add(ndata);
         } catch (Exception ex) {
@@ -277,22 +274,6 @@
     }
     private static final String DMH_ENTRY = "/java.base/" + DMH + ".class";
 
-    static {
-        try {
-            Class<?> BMHFactory = Class.forName("java.lang.invoke.BoundMethodHandle$Factory");
-            BMH_FACTORY_METHOD = BMHFactory.getDeclaredMethod("generateConcreteBMHClassBytes",
-                    String.class);
-            BMH_FACTORY_METHOD.setAccessible(true);
-
-            Class<?> DMHFactory = Class.forName("java.lang.invoke.DirectMethodHandle");
-            DMH_FACTORY_METHOD = DMHFactory.getDeclaredMethod("generateDMHClassBytes",
-                    String.class, MethodType[].class, int[].class);
-            DMH_FACTORY_METHOD.setAccessible(true);
-        } catch (Exception e) {
-            throw new PluginException(e);
-        }
-    }
-
     // Convert LL -> LL, L3 -> LLL
     private static String expandSignature(String signature) {
         StringBuilder sb = new StringBuilder();
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Thu Aug 11 17:02:46 2016 +0000
@@ -24,30 +24,31 @@
 #
 
 main.usage.summary=\
-Usage: {0} <options> --modulepath <modulepath> --addmods <mods> --output <path>\n\
+Usage: {0} <options> --module-path <modulepath> --add-modules <mods> --output <path>\n\
 use --help for a list of possible options
 
 main.usage=\
-Usage: {0} <options> --modulepath <modulepath> --addmods <mods> --output <path>\n\
+Usage: {0} <options> --module-path <modulepath> --add-modules <mods> --output <path>\n\
 \Possible options include:
 
 error.prefix=Error:
 warn.prefix=Warning:
 
 main.opt.help=\
-\  --help                            Print this help message
+\  -h, --help                        Print this help message
 
 main.opt.version=\
 \  --version                         Version information
 
-main.opt.modulepath=\
-\  --modulepath <modulepath>         Module path
+main.opt.module-path=\
+\  -p <modulepath>\n\
+\  --module-path <modulepath>        Module path
 
-main.opt.addmods=\
-\  --addmods <mod>[,<mod>...]        Root modules to resolve
+main.opt.add-modules=\
+\  --add-modules <mod>[,<mod>...]    Root modules to resolve
 
-main.opt.limitmods=\
-\  --limitmods <mod>[,<mod>...]      Limit the universe of observable modules
+main.opt.limit-modules=\
+\  --limit-modules <mod>[,<mod>...]  Limit the universe of observable modules
 
 main.opt.output=\
 \  --output <path>                   Location of output path
@@ -58,8 +59,8 @@
 main.opt.endian=\
 \  --endian <little|big>             Byte order of generated jimage (default:native)
 
-main.opt.saveopts=\
-\  --saveopts <filename>             Save jlink options in the given file
+main.opt.save-opts=\
+\  --save-opts <filename>            Save jlink options in the given file
 
 main.msg.bug=\
 An exception has occurred in jlink. \
@@ -83,7 +84,7 @@
 
 err.unknown.byte.order:unknown byte order {0}
 err.output.must.be.specified:--output must be specified
-err.modulepath.must.be.specified:--modulepath must be specified
+err.modulepath.must.be.specified:--module-path must be specified
 err.mods.must.be.specified:no modules specified to {0}
 err.path.not.found=path not found: {0}
 err.path.not.valid=invalid path: {0}
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Thu Aug 11 17:02:46 2016 +0000
@@ -115,7 +115,7 @@
 Invalid language tag: %s
 
 include-locales.localedatanotfound=\
-jdk.localedata module was not specified with --addmods option
+jdk.localedata module was not specified with --add-modules option
 
 main.status.ok=Functional.
 
@@ -133,8 +133,8 @@
 plugin.opt.resources-last-sorter=\
 \  --resources-last-sorter <name>    The last plugin allowed to sort resources
 
-plugin.opt.plugins-modulepath=\
-\  --plugin-module-path <modulepath> Custom plugins module path
+plugin.opt.plugin-module-path=\
+\  --plugin-module-path <modulepath> Custom plugin module path
 
 plugin.opt.c=\
 \  -c, --compress=2                  Enable compression of resources (level 2)
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Thu Aug 11 17:02:46 2016 +0000
@@ -1181,7 +1181,7 @@
         }
     }
 
-    private final OptionParser parser = new OptionParser();
+    private final OptionParser parser = new OptionParser("hp");
 
     private void handleOptions(String[] args) {
         parser.formatHelpWith(new JmodHelpFormatter());
@@ -1218,7 +1218,7 @@
                         .withValuesConvertedBy(new PatternConverter());
 
         OptionSpec<Void> help
-                = parser.accepts("help", getMessage("main.opt.help"))
+                = parser.acceptsAll(Set.of("h", "help"), getMessage("main.opt.help"))
                         .forHelp();
 
         OptionSpec<Path> libs
@@ -1232,9 +1232,9 @@
                         .withRequiredArg()
                         .describedAs(getMessage("main.opt.main-class.arg"));
 
-        OptionSpec<Path> modulePath  // TODO: short version of --mp ??
-                = parser.acceptsAll(Arrays.asList("mp", "modulepath"),
-                                    getMessage("main.opt.modulepath"))
+        OptionSpec<Path> modulePath
+                = parser.acceptsAll(Set.of("p", "module-path"),
+                                    getMessage("main.opt.module-path"))
                         .withRequiredArg()
                         .withValuesSeparatedBy(File.pathSeparatorChar)
                         .withValuesConvertedBy(DirPathConverter.INSTANCE);
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties	Thu Aug 11 17:02:46 2016 +0000
@@ -63,7 +63,7 @@
 main.opt.os-arch.arg=os-arch
 main.opt.os-version=Operating system version
 main.opt.os-version.arg=os-version
-main.opt.modulepath=Module path
+main.opt.module-path=Module path
 main.opt.hash-modules=Compute and record hashes to tie a packaged module\
 \ with modules matching the given <regex-pattern> and depending upon it directly\
 \ or indirectly. The hashes are recorded in the JMOD file being created, or\
--- a/jdk/test/ProblemList.txt	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/ProblemList.txt	Thu Aug 11 17:02:46 2016 +0000
@@ -343,6 +343,9 @@
 
 com/sun/jdi/sde/SourceDebugExtensionTest.java                   8158066 windows-all
 
+com/sun/jdi/ClassesByName2Test.java				8160833 generic-all
+com/sun/jdi/RedefineCrossEvent.java				8160833 generic-all
+
 ############################################################################
 
 # jdk_time
--- a/jdk/test/TEST.ROOT	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/TEST.ROOT	Thu Aug 11 17:02:46 2016 +0000
@@ -26,12 +26,12 @@
 # Allow querying of various System properties in @requires clauses
 requires.properties=sun.arch.data.model java.runtime.name
 
-# Tests using jtreg 4.2 b02 features
-requiredVersion=4.2 b02
+# Tests using jtreg 4.2 b03 features
+requiredVersion=4.2 b03
 
 # Path to libraries in the topmost test directory. This is needed so @library
 # does not need ../../ notation to reach them
 external.lib.roots = ../../
 
-# Use new form of -Xpatch
-useNewXpatch=true
+# Use new module options
+useNewOptions=true
--- a/jdk/test/com/sun/corba/5036554/TestCorbaBug.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/com/sun/corba/5036554/TestCorbaBug.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -81,9 +81,9 @@
 
 chmod -fR 777 bug
 
-${COMPILEJAVA}${FS}bin${FS}javac -addmods java.corba -d . bug${FS}*.java
+${COMPILEJAVA}${FS}bin${FS}javac --add-modules java.corba -d . bug${FS}*.java
 
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -addmods java.corba -cp . bug/JavaBug > test.out 2>&1 
+${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} --add-modules java.corba -cp . bug/JavaBug > test.out 2>&1 
 
 grep "NullPointerException" test.out
 
--- a/jdk/test/com/sun/corba/7130985/CorbaExceptionsCompileTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/com/sun/corba/7130985/CorbaExceptionsCompileTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -27,8 +27,8 @@
  * @summary Four helper classes missing in Sun JDK
  * @library /lib/testlibrary
  * @build jdk.testlibrary.*
- * @compile -addmods java.corba CorbaExceptionsCompileTest.java
- * @run main/othervm -addmods java.corba CorbaExceptionsCompileTest
+ * @modules java.corba
+ * @run main CorbaExceptionsCompileTest
  */
 
 import java.io.*;
--- a/jdk/test/com/sun/corba/se/impl/io/HookPutFieldsTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/com/sun/corba/se/impl/io/HookPutFieldsTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -25,8 +25,8 @@
  * @test
  * @bug 7095856
  * @summary OutputStreamHook doesn't handle null values
- * @compile -addmods java.corba HookPutFieldsTest.java
- * @run main/othervm -addmods java.corba HookPutFieldsTest
+ * @modules java.corba
+ * @run main HookPutFieldsTest
  */
 
 import java.net.InetAddress;
--- a/jdk/test/com/sun/corba/se/impl/orb/SetDefaultORBTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/com/sun/corba/se/impl/orb/SetDefaultORBTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -25,8 +25,8 @@
  * @test
  * @bug 8028215
  * @summary SetDefaultORBTest setting ORB impl via properties test
- * @compile -addmods java.corba SetDefaultORBTest.java
- * @run main/othervm -addmods java.corba SetDefaultORBTest
+ * @modules java.corba
+ * @run main SetDefaultORBTest
  *
  */
 
--- a/jdk/test/com/sun/jdi/ImmutableResourceTest.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/com/sun/jdi/ImmutableResourceTest.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -99,11 +99,11 @@
 set -vx
 #
 # Compile test class
-${TESTJAVA}/bin/javac -XaddExports:jdk.jdi/com.sun.tools.example.debug.tty=ALL-UNNAMED \
+${TESTJAVA}/bin/javac --add-exports jdk.jdi/com.sun.tools.example.debug.tty=ALL-UNNAMED \
    -d "${TESTCLASSES}" ${CP} -g "${TESTSRC}"/"${TARGETCLASS}".java
 #
 # Run the test class, again with the classpath we need:
-${TESTJAVA}/bin/java -XaddExports:jdk.jdi/com.sun.tools.example.debug.tty=ALL-UNNAMED \
+${TESTJAVA}/bin/java --add-exports jdk.jdi/com.sun.tools.example.debug.tty=ALL-UNNAMED \
     ${CP} ${TARGETCLASS}
 status=$?
 echo "test status was: $status"
--- a/jdk/test/com/sun/jndi/cosnaming/CNNameParser.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/com/sun/jndi/cosnaming/CNNameParser.java	Thu Aug 11 17:02:46 2016 +0000
@@ -26,6 +26,7 @@
  * @summary Tests that JNDI/COS naming parser supports the syntax
  * defined in the new INS standard.
  * @modules java.corba/com.sun.jndi.cosnaming
+ * @run main/othervm CNNameParser
  */
 
 import javax.naming.*;
--- a/jdk/test/com/sun/jndi/cosnaming/IiopUrlIPv6.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/com/sun/jndi/cosnaming/IiopUrlIPv6.java	Thu Aug 11 17:02:46 2016 +0000
@@ -25,6 +25,7 @@
  * @bug 5042453
  * @summary Ipv6 address throws Non-numeric port number error
  * @modules java.corba/com.sun.jndi.cosnaming
+ * @run main/othervm IiopUrlIPv6
  */
 
 import com.sun.jndi.cosnaming.*;
--- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java	Thu Aug 11 17:02:46 2016 +0000
@@ -61,7 +61,7 @@
 
             ProcessBuilder pb = ProcessTools.
                 createJavaProcessBuilder(
-                    "-XaddExports:jdk.attach/sun.tools.attach=ALL-UNNAMED",
+                    "--add-exports", "jdk.attach/sun.tools.attach=ALL-UNNAMED",
                     "-XX:+UseConcMarkSweepGC",  // this will cause UseParNewGC to be FLAG_SET_ERGO
                     "-XX:+UseCodeAging",
                     "-XX:+UseCerealGC",         // Should be ignored.
--- a/jdk/test/java/awt/Gtk/GtkVersionTest/GtkVersionTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/awt/Gtk/GtkVersionTest/GtkVersionTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -55,7 +55,7 @@
                 "/bin/java " +
                 (version == null ? "" : "-Djdk.gtk.version=" + version) +
                 " -Djdk.gtk.verbose=true " +
-                "-XaddExports:java.desktop/sun.awt=ALL-UNNAMED " +
+                "--add-exports=java.desktop/sun.awt=ALL-UNNAMED " +
                 "-cp " + System.getProperty("java.class.path", ".") +
                 " GtkVersionTest$LoadGtk");
         p.waitFor();
--- a/jdk/test/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -113,8 +113,8 @@
 case "$OS" in
   Windows* | CYGWIN* )
     ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} \
-                         -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \
-                         -XaddExports:java.desktop/sun.awt.windows=ALL-UNNAMED ${CP} \
+                         --add-exports java.desktop/sun.awt=ALL-UNNAMED \
+                         --add-exports java.desktop/sun.awt.windows=ALL-UNNAMED ${CP} \
                          *.java
     status=$?
     if [ ! $status -eq "0" ]; then
@@ -124,8 +124,8 @@
 
   SunOS | Linux )
     ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} \
-                         -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \
-                         -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED ${CP} \
+                         --add-exports java.desktop/sun.awt=ALL-UNNAMED \
+                         --add-exports java.desktop/sun.awt.X11=ALL-UNNAMED ${CP} \
                          *.java
     status=$?
     if [ ! $status -eq "0" ]; then
@@ -135,8 +135,8 @@
 
   Darwin)
     ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} \
-                         -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \
-                         -XaddExports:java.desktop/sun.lwawt.macosx=ALL-UNNAMED ${CP} \
+                         --add-exports java.desktop/sun.awt=ALL-UNNAMED \
+                         --add-exports java.desktop/sun.lwawt.macosx=ALL-UNNAMED ${CP} \
                          *.java
     status=$?
     if [ ! $status -eq "0" ]; then
@@ -154,16 +154,16 @@
 case "$OS" in
   Windows* | CYGWIN* )
     ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \
-                         -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \
-                         -XaddExports:java.desktop/sun.awt.windows=ALL-UNNAMED ${CP} \
+                         --add-exports java.desktop/sun.awt=ALL-UNNAMED \
+                         --add-exports java.desktop/sun.awt.windows=ALL-UNNAMED ${CP} \
                          TestWrapped sun.awt.windows.WToolkit
     status=$?
     if [ ! $status -eq "0" ]; then
       fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.windows.WToolkit";
     fi
     ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \
-                         -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \
-                         -XaddExports:java.desktop/sun.awt.windows=ALL-UNNAMED ${CP} \
+                         --add-exports java.desktop/sun.awt=ALL-UNNAMED \
+                         --add-exports java.desktop/sun.awt.windows=ALL-UNNAMED ${CP} \
                          -Dawt.toolkit=sun.awt.windows.WToolkit \
                          TestWrapped sun.awt.windows.WToolkit
     status=$?
@@ -174,8 +174,8 @@
 
   SunOS | Linux )
     ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \
-                         -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \
-                         -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED ${CP} \
+                         --add-exports java.desktop/sun.awt=ALL-UNNAMED \
+                         --add-exports java.desktop/sun.awt.X11=ALL-UNNAMED ${CP} \
                          -Dawt.toolkit=sun.awt.X11.XToolkit \
                          TestWrapped sun.awt.X11.XToolkit
     status=$?
@@ -183,8 +183,8 @@
       fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.xawt.XToolkit";
     fi
     AWT_TOOLKIT=XToolkit ${TESTJAVA}/bin/java ${TESTVMOPTS} \
-                         -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \
-                         -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED ${CP} \
+                         --add-exports java.desktop/sun.awt=ALL-UNNAMED \
+                         --add-exports java.desktop/sun.awt.X11=ALL-UNNAMED ${CP} \
                                               -Djava.awt.headless=true \
                                               TestWrapped sun.awt.X11.XToolkit
     status=$?
@@ -195,16 +195,16 @@
 
   Darwin)
     ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \
-                         -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \
-                         -XaddExports:java.desktop/sun.lwawt.macosx=ALL-UNNAMED ${CP} \
+                         --add-exports java.desktop/sun.awt=ALL-UNNAMED \
+                         --add-exports java.desktop/sun.lwawt.macosx=ALL-UNNAMED ${CP} \
                          TestWrapped sun.lwawt.macosx.LWCToolkit
     status=$?
     if [ ! $status -eq "0" ]; then
       fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.lwawt.macosx.LWCToolkit";
     fi
     ${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.awt.headless=true \
-                         -XaddExports:java.desktop/sun.awt=ALL-UNNAMED \
-                         -XaddExports:java.desktop/sun.lwawt.macosx=ALL-UNNAMED ${CP} \
+                         --add-exports java.desktop/sun.awt=ALL-UNNAMED \
+                         --add-exports java.desktop/sun.lwawt.macosx=ALL-UNNAMED ${CP} \
                          -Dawt.toolkit=sun.lwawt.macosx.LWCToolkit \
                          TestWrapped sun.lwawt.macosx.LWCToolkit
     status=$?
--- a/jdk/test/java/awt/xembed/server/RunTestXEmbed.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/awt/xembed/server/RunTestXEmbed.java	Thu Aug 11 17:02:46 2016 +0000
@@ -73,10 +73,11 @@
                     enva[ind++] = "AWT_TOOLKIT=sun.awt.X11.XToolkit";
                 }
             }
-            Process proc = Runtime.getRuntime().exec(java_home +
-                                                     "/bin/java -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED -Dawt.toolkit=sun.awt.X11.XToolkit TesterClient "
-                                                     + test.getName() + " " + window + buf,
-                                                     enva);
+            Process proc = Runtime.getRuntime().
+                exec(java_home +
+                     "/bin/java --add-exports java.desktop/sun.awt.X11=ALL-UNNAMED -Dawt.toolkit=sun.awt.X11.XToolkit TesterClient "
+                     + test.getName() + " " + window + buf,
+                     enva);
             System.err.println("Test for " + test.getName() + " has started.");
             log.fine("Test for " + test.getName() + " has started.");
             new InputReader(proc.getInputStream());
--- a/jdk/test/java/awt/xembed/server/TestXEmbedServerJava.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/awt/xembed/server/TestXEmbedServerJava.java	Thu Aug 11 17:02:46 2016 +0000
@@ -84,11 +84,11 @@
             }
             if (hasModules) {
                 System.out.println(java_home +
-                               "/bin/java  -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED "+
-                               "-XaddExports:java.desktop/sun.awt=ALL-UNNAMED  JavaClient " + window);
+                               "/bin/java --add-exports java.desktop/sun.awt.X11=ALL-UNNAMED "+
+                               "--add-exports java.desktop/sun.awt=ALL-UNNAMED  JavaClient " + window);
                 return Runtime.getRuntime().exec(java_home +
-                               "/bin/java  -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED "+
-                               "-XaddExports:java.desktop/sun.awt=ALL-UNNAMED  JavaClient " + window);
+                               "/bin/java --add-exports java.desktop/sun.awt.X11=ALL-UNNAMED "+
+                               "--add-exports java.desktop/sun.awt=ALL-UNNAMED  JavaClient " + window);
             }else{
                 System.out.println(java_home + "/bin/java JavaClient " + window);
                 return Runtime.getRuntime().exec(java_home + "/bin/java JavaClient " + window);
--- a/jdk/test/java/beans/XMLDecoder/8028054/TestConstructorFinder.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/beans/XMLDecoder/8028054/TestConstructorFinder.java	Thu Aug 11 17:02:46 2016 +0000
@@ -39,7 +39,7 @@
  *          java.corba
  *          java.xml.bind
  * @compile -XDignore.symbol.file TestConstructorFinder.java
- * @run main/othervm -addmods java.activation -addmods java.transaction -addmods java.corba -addmods java.xml.bind TestConstructorFinder
+ * @run main/othervm --add-modules=java.activation,java.transaction,java.corba,java.xml.bind TestConstructorFinder
  */
 
 public class TestConstructorFinder {
--- a/jdk/test/java/beans/XMLDecoder/8028054/TestMethodFinder.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/beans/XMLDecoder/8028054/TestMethodFinder.java	Thu Aug 11 17:02:46 2016 +0000
@@ -39,7 +39,7 @@
  *          java.corba
  *          java.xml.bind
  * @compile -XDignore.symbol.file TestMethodFinder.java
- * @run main/othervm -addmods java.activation -addmods java.transaction -addmods java.corba -addmods java.xml.bind TestMethodFinder
+ * @run main/othervm --add-modules=java.activation,java.transaction,java.corba,java.xml.bind TestMethodFinder
  */
 
 public class TestMethodFinder {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/CharArrayReader/OverflowInRead.java	Thu Aug 11 17:02:46 2016 +0000
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8163518
+ * @summary Integer overflow when reading in large buffer
+ * @requires (os.simpleArch == "x64" & os.maxMemory > 8g)
+ * @run main/othervm -Xmx8g OverflowInRead
+ */
+
+import java.io.CharArrayReader;
+
+public class OverflowInRead {
+    public static void main(String[] args) throws Exception {
+        char[] a = "_123456789_123456789_123456789_123456789"
+                .toCharArray(); // a.length > 33
+        try (CharArrayReader car = new CharArrayReader(a)) {
+            int len1 = 33;
+            char[] buf1 = new char[len1];
+            if (car.read(buf1, 0, len1) != len1)
+                throw new Exception("Expected to read " + len1 + " chars");
+
+            int len2 = Integer.MAX_VALUE - 32;
+            char[] buf2 = new char[len2];
+            int expLen2 = a.length - len1;
+            if (car.read(buf2, 0, len2) != expLen2)
+                throw new Exception("Expected to read " + expLen2 + " chars");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/CharArrayReader/OverflowInSkip.java	Thu Aug 11 17:02:46 2016 +0000
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8163518
+ * @summary Integer overflow when skipping a lot
+ */
+
+import java.io.CharArrayReader;
+
+public class OverflowInSkip {
+    public static void main(String[] args) throws Exception {
+        char[] a = "_123456789_123456789_123456789_123456789"
+                .toCharArray(); // a.length > 33
+        try (CharArrayReader car = new CharArrayReader(a)) {
+            long small = 33;
+            long big = Long.MAX_VALUE;
+
+            long smallSkip = car.skip(small);
+            if (smallSkip != small)
+                throw new Exception("Expected to skip " + small
+                        + " chars, but skipped " + smallSkip);
+
+            long expSkip = a.length - small;
+            long bigSkip = car.skip(big);
+            if (bigSkip != expSkip)
+                throw new Exception("Expected to skip " + expSkip
+                        + " chars, but skipped " + bigSkip);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/StringBufferInputStream/OverflowInRead.java	Thu Aug 11 17:02:46 2016 +0000
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8163518
+ * @summary Integer overflow when reading in large buffer
+ * @requires (os.simpleArch == "x64" & os.maxMemory > 4g)
+ * @run main/othervm -Xmx4g OverflowInRead
+ */
+
+import java.io.StringBufferInputStream;
+
+public class OverflowInRead {
+    public static void main(String[] args) throws Exception {
+        String s = "_123456789_123456789_123456789_123456789"; // s.length() > 33
+        try (StringBufferInputStream sbis = new StringBufferInputStream(s)) {
+            int len1 = 33;
+            byte[] buf1 = new byte[len1];
+            if (sbis.read(buf1, 0, len1) != len1)
+                throw new Exception("Expected to read " + len1 + " bytes");
+
+            int len2 = Integer.MAX_VALUE - 32;
+            byte[] buf2 = new byte[len2];
+            int expLen2 = s.length() - len1;
+            if (sbis.read(buf2, 0, len2) != expLen2)
+                throw new Exception("Expected to read " + expLen2 + " bytes");
+        }
+    }
+}
--- a/jdk/test/java/lang/Class/forName/modules/TestDriver.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/Class/forName/modules/TestDriver.java	Thu Aug 11 17:02:46 2016 +0000
@@ -65,7 +65,7 @@
     public void setup() throws Exception {
         assertTrue(CompilerUtils.compile(
                         MOD_SRC_DIR, MOD_DEST_DIR,
-                        "-modulesourcepath",
+                        "--module-source-path",
                         MOD_SRC_DIR.toString()));
 
         copyDirectories(MOD_DEST_DIR.resolve("m1"), Paths.get("mods1"));
@@ -76,8 +76,8 @@
     public void test() throws Exception {
         String[] options = new String[] {
                 "-cp", TEST_CLASSES,
-                "-mp", MOD_DEST_DIR.toString(),
-                "-addmods", String.join(",", modules),
+                "--module-path", MOD_DEST_DIR.toString(),
+                "--add-modules", String.join(",", modules),
                 "-m", "m2/p2.test.Main"
         };
         runTest(options);
@@ -87,8 +87,8 @@
     public void testUnnamedModule() throws Exception {
         String[] options = new String[] {
                 "-cp", TEST_CLASSES,
-                "-mp", MOD_DEST_DIR.toString(),
-                "-addmods", String.join(",", modules),
+                "--module-path", MOD_DEST_DIR.toString(),
+                "--add-modules", String.join(",", modules),
                 "TestMain"
         };
         runTest(options);
@@ -107,8 +107,8 @@
     @Test
     public void testDeniedClassLoaderAccess() throws Exception {
         String[] options = new String[] {
-                "-mp", MOD_DEST_DIR.toString(),
-                "-addmods", String.join(",", modules),
+                "--module-path", MOD_DEST_DIR.toString(),
+                "--add-modules", String.join(",", modules),
                 "-m", "m3/p3.NoGetClassLoaderAccess"
         };
         assertTrue(executeTestJava(options)
@@ -124,8 +124,8 @@
         String[] options = new String[] {
                 "-Djava.security.manager",
                 "-Djava.security.policy=" + policyFile.toString(),
-                "-mp", MOD_DEST_DIR.toString(),
-                "-addmods", String.join(",", modules),
+                "--module-path", MOD_DEST_DIR.toString(),
+                "--add-modules", String.join(",", modules),
                 "-m", "m3/p3.NoAccess"
         };
         assertTrue(executeTestJava(options)
--- a/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -63,8 +63,8 @@
  *          loads all the classes in the BCL, get their declared fields,
  *          and call setAccessible(false) followed by setAccessible(true);
  * @modules java.base/jdk.internal.module
- * @run main/othervm -Djdk.launcher.addmods=ALL-SYSTEM FieldSetAccessibleTest UNSECURE
- * @run main/othervm -Djdk.launcher.addmods=ALL-SYSTEM FieldSetAccessibleTest SECURE
+ * @run main/othervm --add-modules=ALL-SYSTEM FieldSetAccessibleTest UNSECURE
+ * @run main/othervm --add-modules=ALL-SYSTEM FieldSetAccessibleTest SECURE
  *
  * @author danielfuchs
  */
--- a/jdk/test/java/lang/Class/getResource/ResourcesTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/Class/getResource/ResourcesTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -60,15 +60,15 @@
         compiled = CompilerUtils
             .compile(SRC_DIR,
                      MODS_DIR,
-                     "-modulesourcepath", SRC_DIR.toString());
+                     "--module-source-path", SRC_DIR.toString());
         assertTrue(compiled);
 
-        // javac -mp mods -d classes Main.java
+        // javac --module-path mods -d classes Main.java
         compiled = CompilerUtils
             .compile(Paths.get(TEST_SRC, "Main.java"),
                      CLASSES_DIR,
-                     "-mp", MODS_DIR.toString(),
-                     "-addmods", "m1,m2,m3");
+                     "--module-path", MODS_DIR.toString(),
+                     "--add-modules", "m1,m2,m3");
         assertTrue(compiled);
 
     }
@@ -79,8 +79,8 @@
     public void runTest() throws Exception {
 
         int exitValue
-            = executeTestJava("-mp", MODS_DIR.toString(),
-                              "-addmods", "m1,m2,m3",
+            = executeTestJava("--module-path", MODS_DIR.toString(),
+                              "--add-modules", "m1,m2,m3",
                                "-cp", CLASSES_DIR.toString(),
                               "Main")
                 .outputTo(System.out)
--- a/jdk/test/java/lang/ClassLoader/getResource/modules/ResourcesTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/ClassLoader/getResource/modules/ResourcesTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -56,19 +56,19 @@
     public void compileAll() throws Exception {
         boolean compiled;
 
-        // javac -modulesource mods -d mods src/**
+        // javac --module-source-path mods -d mods src/**
         compiled = CompilerUtils
             .compile(SRC_DIR,
                      MODS_DIR,
-                     "-modulesourcepath", SRC_DIR.toString());
+                     "--module-source-path", SRC_DIR.toString());
         assertTrue(compiled);
 
-        // javac -mp mods -d classes Main.java
+        // javac --module-path mods -d classes Main.java
         compiled = CompilerUtils
             .compile(Paths.get(TEST_SRC, "Main.java"),
                      CLASSES_DIR,
-                     "-mp", MODS_DIR.toString(),
-                     "-addmods", "m1,m2,m3");
+                     "--module-path", MODS_DIR.toString(),
+                     "--add-modules", "m1,m2,m3");
         assertTrue(compiled);
     }
 
@@ -77,8 +77,8 @@
      */
     public void runTest() throws Exception {
         int exitValue
-            = executeTestJava("-mp", MODS_DIR.toString(),
-                              "-addmods", "m1,m2,m3",
+            = executeTestJava("--module-path", MODS_DIR.toString(),
+                              "--add-modules", "m1,m2,m3",
                                "-cp", CLASSES_DIR.toString(),
                               "Main")
                 .outputTo(System.out)
--- a/jdk/test/java/lang/SecurityManager/modules/CustomSecurityManager.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/SecurityManager/modules/CustomSecurityManager.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -51,15 +51,15 @@
 JAVA="$TESTJAVA/bin/java ${TESTVMOPTS}"
 
 mkdir -p mods
-$JAVAC -d mods -modulesourcepath ${TESTSRC} `find ${TESTSRC}/m -name "*.java"`
+$JAVAC -d mods --module-source-path ${TESTSRC} `find ${TESTSRC}/m -name "*.java"`
 
 mkdir -p classes
 $JAVAC -d classes ${TESTSRC}/Test.java
 
-$JAVA -cp classes -mp mods -addmods m \
+$JAVA -cp classes --module-path mods --add-modules m \
     -Djava.security.manager \
     -Djava.security.policy=${TESTSRC}/test.policy Test
-$JAVA -cp classes -mp mods -addmods m \
+$JAVA -cp classes --module-path mods --add-modules m \
     -Djava.security.manager=p.CustomSecurityManager \
     -Djava.security.policy=${TESTSRC}/test.policy Test
 
--- a/jdk/test/java/lang/String/concat/WithSecurityManager.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/String/concat/WithSecurityManager.java	Thu Aug 11 17:02:46 2016 +0000
@@ -38,13 +38,13 @@
  * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=MH_SB_SIZED_EXACT      WithSecurityManager
  * @run main/othervm -Xverify:all -Djava.lang.invoke.stringConcat=MH_INLINE_SIZED_EXACT  WithSecurityManager
  *
- * @run main/othervm -Xverify:all -limitmods java.base WithSecurityManager
- * @run main/othervm -Xverify:all -limitmods java.base -Djava.lang.invoke.stringConcat=BC_SB                  WithSecurityManager
- * @run main/othervm -Xverify:all -limitmods java.base -Djava.lang.invoke.stringConcat=BC_SB_SIZED            WithSecurityManager
- * @run main/othervm -Xverify:all -limitmods java.base -Djava.lang.invoke.stringConcat=MH_SB_SIZED            WithSecurityManager
- * @run main/othervm -Xverify:all -limitmods java.base -Djava.lang.invoke.stringConcat=BC_SB_SIZED_EXACT      WithSecurityManager
- * @run main/othervm -Xverify:all -limitmods java.base -Djava.lang.invoke.stringConcat=MH_SB_SIZED_EXACT      WithSecurityManager
- * @run main/othervm -Xverify:all -limitmods java.base -Djava.lang.invoke.stringConcat=MH_INLINE_SIZED_EXACT  WithSecurityManager
+ * @run main/othervm -Xverify:all --limit-modules=java.base WithSecurityManager
+ * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=BC_SB                  WithSecurityManager
+ * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=BC_SB_SIZED            WithSecurityManager
+ * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=MH_SB_SIZED            WithSecurityManager
+ * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=BC_SB_SIZED_EXACT      WithSecurityManager
+ * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=MH_SB_SIZED_EXACT      WithSecurityManager
+ * @run main/othervm -Xverify:all --limit-modules=java.base -Djava.lang.invoke.stringConcat=MH_INLINE_SIZED_EXACT  WithSecurityManager
 */
 public class WithSecurityManager {
     public static void main(String[] args) throws Throwable {
--- a/jdk/test/java/lang/instrument/MakeJAR2.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/instrument/MakeJAR2.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -87,7 +87,7 @@
 cd ..
 
 ${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
-    -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED ${AGENT}.java asmlib/*.java
+    --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED ${AGENT}.java asmlib/*.java
 ${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -classpath .${PATHSEP}bootpath ${APP}.java
 
 echo "Manifest-Version: 1.0"    >  ${AGENT}.mf
--- a/jdk/test/java/lang/invoke/modules/ModuleAccessControlTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/invoke/modules/ModuleAccessControlTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -60,7 +60,7 @@
         for (String mn : modules) {
             Path msrc = SRC_DIR.resolve(mn);
             assertTrue(CompilerUtils
-                .compile(msrc, MODS_DIR, "-modulesourcepath", SRC_DIR.toString()));
+                .compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString()));
         }
     }
 
@@ -69,7 +69,7 @@
      */
     @Test
     public void runTest() throws Exception {
-        int exitValue = executeTestJava("-mp", MODS_DIR.toString(),
+        int exitValue = executeTestJava("--module-path", MODS_DIR.toString(),
                                         "-m", "m1/p1.Main")
                 .outputTo(System.out)
                 .errorTo(System.out)
--- a/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -63,9 +63,9 @@
     @BeforeTest
     public void setup() throws Exception {
 
-        // javac -d mods -modulesourcepath src src/**
+        // javac -d mods --module-source-path src src/**
         assertTrue(CompilerUtils.compile(SRC_DIR, MODS_DIR,
-                "-modulesourcepath", SRC_DIR.toString()));
+                "--module-source-path", SRC_DIR.toString()));
     }
 
 
--- a/jdk/test/java/lang/reflect/Layer/src/m1/module-info.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/reflect/Layer/src/m1/module-info.java	Thu Aug 11 17:02:46 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
--- a/jdk/test/java/lang/reflect/Module/AddExportsTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/reflect/Module/AddExportsTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -23,29 +23,44 @@
 
 /**
  * @test
- * @modules java.desktop
- * @run main/othervm -XaddExports:java.desktop/sun.awt=java.base AddExportsTest
- * @run main/othervm -XaddExports:java.desktop/sun.awt=ALL-UNNAMED AddExportsTest
+ * @modules java.base/jdk.internal.misc
+ *          java.desktop
+ * @run main/othervm --add-exports=java.desktop/sun.awt=java.base AddExportsTest
+ * @run main/othervm --add-exports=java.desktop/sun.awt=ALL-UNNAMED AddExportsTest
  * @summary Test Module isExported methods with exports changed by -AddExportsTest
  */
 
 import java.lang.reflect.Layer;
 import java.lang.reflect.Module;
 import java.util.Optional;
+import java.util.stream.Stream;
+
+import jdk.internal.misc.VM;
 
 public class AddExportsTest {
+    /*
+     * jtreg sets -Dtest.modules system property to the internal APIs
+     * specified at @modules tag.  The test will exclude --add-exports set
+     * for @modules.
+     */
+    private static final String TEST_MODULES = System.getProperty("test.modules");
 
     public static void main(String[] args) {
 
-        String addExports = System.getProperty("jdk.launcher.addexports.0");
-        assertTrue(addExports != null, "Expected to be run with -XaddExports");
+        Optional<String> oaddExports = Stream.of(VM.getRuntimeArguments())
+            .filter(arg -> arg.startsWith("--add-exports="))
+            .filter(arg -> !arg.equals("--add-exports=" + TEST_MODULES + "=ALL-UNNAMED"))
+            .map(arg -> arg.substring("--add-exports=".length(), arg.length()))
+            .findFirst();
+
+        assertTrue(oaddExports.isPresent());
 
         Layer bootLayer = Layer.boot();
 
         Module unnamedModule = AddExportsTest.class.getModule();
         assertFalse(unnamedModule.isNamed());
 
-        for (String expr : addExports.split(",")) {
+        for (String expr : oaddExports.get().split(",")) {
 
             String[] s = expr.split("=");
             assertTrue(s.length == 2);
--- a/jdk/test/java/lang/reflect/Module/access/AccessTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/reflect/Module/access/AccessTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -72,8 +72,8 @@
      */
     public void runTest() throws Exception {
         int exitValue
-            = executeTestJava("-mp", MODS_DIR.toString(),
-                              "-addmods", "target",
+            = executeTestJava("--module-path", MODS_DIR.toString(),
+                              "--add-modules", "target",
                               "-m", "test/test.Main")
                 .outputTo(System.out)
                 .errorTo(System.out)
--- a/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -64,7 +64,7 @@
     public void compileAll() throws Exception {
         for (String mn : modules) {
             Path msrc = SRC_DIR.resolve(mn);
-            assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "-modulesourcepath", SRC_DIR.toString()));
+            assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString()));
         }
     }
 
@@ -73,7 +73,7 @@
      */
     @Test
     public void runTest() throws Exception {
-        int exitValue = executeTestJava("-mp", MODS_DIR.toString(),
+        int exitValue = executeTestJava("--module-path", MODS_DIR.toString(),
                                         "-m", "test/jdk.test.ProxyClassAccess")
                             .outputTo(System.out)
                             .errorTo(System.out)
--- a/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -65,7 +65,7 @@
     public void compileAll() throws Exception {
         for (String mn : modules) {
             Path msrc = SRC_DIR.resolve(mn);
-            assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "-modulesourcepath", SRC_DIR.toString()));
+            assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString()));
         }
     }
 
--- a/jdk/test/java/lang/reflect/Proxy/ProxyModuleMapping.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyModuleMapping.java	Thu Aug 11 17:02:46 2016 +0000
@@ -38,7 +38,7 @@
         Module unnamed = ld.getUnnamedModule();
         new ProxyModuleMapping(unnamed, Runnable.class).test();
 
-        // unnamed module gets access to sun.invoke package (e.g. via -XaddExports)
+        // unnamed module gets access to sun.invoke package (e.g. via --add-exports)
         new ProxyModuleMapping(sun.invoke.WrapperInstance.class).test();
 
         Class<?> modulePrivateIntf = Class.forName("sun.net.ProgressListener");
--- a/jdk/test/java/lang/reflect/Proxy/ProxyTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -61,7 +61,7 @@
     public void compileAll() throws Exception {
         for (String mn : modules) {
             Path msrc = SRC_DIR.resolve(mn);
-            assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "-modulesourcepath", SRC_DIR.toString()));
+            assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString()));
         }
     }
 
@@ -71,7 +71,7 @@
     @Test
     public void runTest() throws Exception {
         int exitValue = executeTestJava("-cp", CPATH_DIR.toString(),
-                                        "-mp", MODS_DIR.toString(),
+                                        "--module-path", MODS_DIR.toString(),
                                         "-m", "test/jdk.test.Main")
                             .outputTo(System.out)
                             .errorTo(System.out)
--- a/jdk/test/java/net/Authenticator/B4933582.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/net/Authenticator/B4933582.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -44,7 +44,7 @@
     ;;
 esac
 
-EXTRAOPTS="-XaddExports:java.base/sun.net.www=ALL-UNNAMED -XaddExports:java.base/sun.net.www.protocol.http=ALL-UNNAMED"
+EXTRAOPTS="--add-exports java.base/sun.net.www=ALL-UNNAMED --add-exports java.base/sun.net.www.protocol.http=ALL-UNNAMED"
 export EXTRAOPTS
 
 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -d . \
--- a/jdk/test/java/net/SocketOption/OptionsTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/net/SocketOption/OptionsTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -26,7 +26,7 @@
  * @bug 8036979 8072384 8044773
  * @run main/othervm -Xcheck:jni OptionsTest
  * @run main/othervm -Xcheck:jni -Djava.net.preferIPv4Stack=true OptionsTest
- * @run main/othervm -limitmods java.base OptionsTest
+ * @run main/othervm --limit-modules=java.base OptionsTest
  */
 
 import java.lang.reflect.Method;
--- a/jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -33,7 +33,7 @@
  * @summary Test checks that UnsupportedOperationException for unsupported
  * SOCKET_OPTIONS is thrown by both getOption() and setOption() methods.
  * @run main UnsupportedOptionsTest
- * @run main/othervm -limitmods java.base UnsupportedOptionsTest
+ * @run main/othervm --limit-modules=java.base UnsupportedOptionsTest
  */
 
 public class UnsupportedOptionsTest {
--- a/jdk/test/java/net/httpclient/http2/HpackDriver.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/net/httpclient/http2/HpackDriver.java	Thu Aug 11 17:02:46 2016 +0000
@@ -29,12 +29,12 @@
  * @compile/module=java.httpclient sun/net/httpclient/hpack/SpecHelper.java
  * @compile/module=java.httpclient sun/net/httpclient/hpack/TestHelper.java
  * @compile/module=java.httpclient sun/net/httpclient/hpack/BuffersTestingKit.java
- * @run testng/othervm -XaddReads:java.httpclient=ALL-UNNAMED java.httpclient/sun.net.httpclient.hpack.BinaryPrimitivesTest
- * @run testng/othervm -XaddReads:java.httpclient=ALL-UNNAMED java.httpclient/sun.net.httpclient.hpack.CircularBufferTest
- * @run testng/othervm -XaddReads:java.httpclient=ALL-UNNAMED java.httpclient/sun.net.httpclient.hpack.DecoderTest
- * @run testng/othervm -XaddReads:java.httpclient=ALL-UNNAMED java.httpclient/sun.net.httpclient.hpack.EncoderTest
- * @run testng/othervm -XaddReads:java.httpclient=ALL-UNNAMED java.httpclient/sun.net.httpclient.hpack.HeaderTableTest
- * @run testng/othervm -XaddReads:java.httpclient=ALL-UNNAMED java.httpclient/sun.net.httpclient.hpack.HuffmanTest
- * @run testng/othervm -XaddReads:java.httpclient=ALL-UNNAMED java.httpclient/sun.net.httpclient.hpack.TestHelper
+ * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.BinaryPrimitivesTest
+ * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.CircularBufferTest
+ * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.DecoderTest
+ * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.EncoderTest
+ * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.HeaderTableTest
+ * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.HuffmanTest
+ * @run testng/othervm java.httpclient/sun.net.httpclient.hpack.TestHelper
  */
 public class HpackDriver { }
--- a/jdk/test/java/nio/channels/DatagramChannel/SocketOptionTests.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/nio/channels/DatagramChannel/SocketOptionTests.java	Thu Aug 11 17:02:46 2016 +0000
@@ -25,7 +25,7 @@
  * @bug 4640544 8044773
  * @summary Unit test for setOption/getOption/options methods
  * @run main SocketOptionTests
- * @run main/othervm -limitmods java.base SocketOptionTests
+ * @run main/othervm --limit-modules=java.base SocketOptionTests
  */
 
 import java.nio.*;
--- a/jdk/test/java/nio/channels/Selector/RacyDeregister.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/nio/channels/Selector/RacyDeregister.java	Thu Aug 11 17:02:46 2016 +0000
@@ -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
@@ -40,6 +40,11 @@
  */
 public class RacyDeregister {
 
+    // FIXME: numOuterLoopIterations should be reverted to the hard-coded value
+    // 15 when JDK-8161083 is resolved as either a bug or a non-issue.
+    static final int numOuterLoopIterations =
+        System.getProperty("os.name").startsWith("Windows") ? 150 : 15;
+
     static boolean notified;
     static final Object selectorLock = new Object();
     static final Object notifyLock = new Object();
@@ -77,7 +82,7 @@
 
             public void run() {
                 try {
-                    for (int k = 0; k < 15; k++) {
+                    for (int k = 0; k < numOuterLoopIterations; k++) {
                         for (int i = 0; i < 10000; i++) {
                             synchronized (notifyLock) {
                                 synchronized (selectorLock) {
@@ -94,6 +99,17 @@
                                     }
                                     long endTime = System.currentTimeMillis();
                                     if (endTime - beginTime > 5000) {
+                                        for (int j = 0; j < 60; j++) {
+                                            Thread.sleep(1000);
+                                            if (notified) {
+                                                long t =
+                                                    System.currentTimeMillis();
+                                                System.out.printf
+                                                    ("Notified after %d ms%n",
+                                                     t - beginTime);
+                                                break;
+                                            }
+                                        }
                                         succTermination = false;
                                         // wake up main thread doing select()
                                         sel.wakeup();
--- a/jdk/test/java/nio/channels/ServerSocketChannel/SocketOptionTests.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/nio/channels/ServerSocketChannel/SocketOptionTests.java	Thu Aug 11 17:02:46 2016 +0000
@@ -26,7 +26,7 @@
  * @summary Unit test for ServerSocketChannel setOption/getOption/options
  *          methods.
  * @run main SocketOptionTests
- * @run main/othervm -limitmods java.base SocketOptionTests
+ * @run main/othervm --limit-modules=java.base SocketOptionTests
  */
 
 import java.nio.*;
--- a/jdk/test/java/nio/channels/SocketChannel/SocketOptionTests.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/nio/channels/SocketChannel/SocketOptionTests.java	Thu Aug 11 17:02:46 2016 +0000
@@ -26,7 +26,7 @@
  * @summary Unit test to check SocketChannel setOption/getOption/options
  *          methods.
  * @run main SocketOptionTests
- * @run main/othervm -limitmods java.base SocketOptionTests
+ * @run main/othervm --limit-modules=java.base SocketOptionTests
  */
 
 import java.nio.*;
--- a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -109,7 +109,7 @@
 
 go() {
     echo ''
-    sh -xc "$JAVA ${TESTVMOPTS} -XaddExports:java.base/sun.nio.ch=ALL-UNNAMED $DFLAG \
+    sh -xc "$JAVA ${TESTVMOPTS} --add-exports java.base/sun.nio.ch=ALL-UNNAMED $DFLAG \
         $1 $2 $3 $4 $5 $6 $7 $8" 2>&1
     if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
 }
--- a/jdk/test/java/nio/file/Files/probeContentType/Basic.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/nio/file/Files/probeContentType/Basic.java	Thu Aug 11 17:02:46 2016 +0000
@@ -95,7 +95,7 @@
         return 0;
     }
 
-    static int checkContentTypes(String[] extensions, String[] expectedTypes)
+    static int checkContentTypes(String[] extensions, String[][] expectedTypes)
         throws IOException {
         if (extensions.length != expectedTypes.length) {
             System.err.println("Parameter array lengths differ");
@@ -113,9 +113,24 @@
                             + " cannot be determined");
                     failures++;
                 } else {
-                    if (!type.equals(expectedTypes[i])) {
-                        System.err.println("Content type: " + type
-                                + "; expected: " + expectedTypes[i]);
+                    boolean isTypeFound = false;
+                    for (String s : expectedTypes[i]) {
+                        if (type.equals(s)) {
+                            isTypeFound = true;
+                            break;
+                        }
+                    }
+                    if (!isTypeFound) {
+                        System.err.printf("Content type: %s; expected: ", type);
+                        int j = 0;
+                        for (String s : expectedTypes[i]) {
+                            if (j++ == 0) {
+                                System.err.printf("%s", s);
+                            } else {
+                                System.err.printf(", or %s", s);
+                            }
+                        }
+                        System.err.println();
                         failures++;
                     }
                 }
@@ -159,11 +174,24 @@
 
         // Verify that certain media extensions are mapped to the correct type.
         String[] extensions = new String[]{
-            "aac", "flac", "jpg", "mp3", "mp4", "pdf", "png", "webm"
+            "aac",
+            "flac",
+            "jpg",
+            "mp3",
+            "mp4",
+            "pdf",
+            "png",
+            "webm"
         };
-        String[] expectedTypes = new String[]{
-            "audio/aac", "audio/flac", "image/jpeg", "audio/mpeg",
-            "video/mp4", "application/pdf", "image/png", "video/webm"
+        String[][] expectedTypes = new String[][] {
+            {"audio/aac", "audio/x-aac"},
+            {"audio/flac", "audio/x-flac"},
+            {"image/jpeg"},
+            {"audio/mpeg"},
+            {"video/mp4"},
+            {"application/pdf"},
+            {"image/png"},
+            {"video/webm"}
         };
         failures += checkContentTypes(extensions, expectedTypes);
 
--- a/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ext.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ext.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -52,9 +52,9 @@
 $COMPILEJAVA/bin/jar ${TESTTOOLVMOPTS} cf ext/ext.jar -C $TESTCLASSES ExtLoadedImpl.class -C $TESTCLASSES ExtLoadedImpl_Stub.class -C $TESTCLASSES CheckLoader.class
 
 TESTVMOPTS="${TESTVMOPTS} \
- -XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED \
- -XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED \
- -XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED \
- -XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED"
+ --add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED \
+ --add-exports java.rmi/sun.rmi.server=ALL-UNNAMED \
+ --add-exports java.rmi/sun.rmi.transport=ALL-UNNAMED \
+ --add-exports java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED"
 $TESTJAVA/bin/java ${TESTVMOPTS} -cp classes -Dtest.src=$TESTSRC -Dtest.classes=$TESTCLASSES -Djava.security.policy=$TESTSRC/security.policy -Djava.ext.dirs=ext ExtLoadedImplTest
 
--- a/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java	Thu Aug 11 17:02:46 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,6 @@
 /*
  * @test
  * @bug 4510355
- * @key intermittent
  * @summary ActivationGroup implementations cannot be downloaded by default;
  * Creates a custom activation group without setting a security manager
  * in activation group's descriptor.  The custom activation group
@@ -140,10 +139,10 @@
             CommandEnvironment cmd = new ActivationGroupDesc.CommandEnvironment(
                     null,
                     new String[] {
-                        "-XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED",
-                        "-XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED",
-                        "-XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED",
-                        "-XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" });
+                        "--add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED",
+                        "--add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED",
+                        "--add-exports=java.rmi/sun.rmi.transport=ALL-UNNAMED",
+                        "--add-exports=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" });
 
             ActivationGroupDesc groupDesc =
                 new ActivationGroupDesc("MyActivationGroupImpl",
--- a/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java	Thu Aug 11 17:02:46 2016 +0000
@@ -121,11 +121,11 @@
             System.err.println("Create activation group, in a new VM");
             CommandEnvironment cmd = new ActivationGroupDesc.CommandEnvironment(null,
                     new String[] {
-                        "-XaddExports:java.base/sun.security.provider=ALL-UNNAMED",
-                        "-XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED",
-                        "-XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED",
-                        "-XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED",
-                        "-XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" });
+                        "--add-exports=java.base/sun.security.provider=ALL-UNNAMED",
+                        "--add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED",
+                        "--add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED",
+                        "--add-exports=java.rmi/sun.rmi.transport=ALL-UNNAMED",
+                        "--add-exports=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" });
 
             ActivationGroupDesc groupDesc =
                 new ActivationGroupDesc(p, cmd);
--- a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java	Thu Aug 11 17:02:46 2016 +0000
@@ -106,7 +106,7 @@
             rmid = RMID.createRMID(System.out, System.err, true, true,
                                    TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT);
             rmid.addOptions(
-                "-XaddExports:java.base/sun.nio.ch=ALL-UNNAMED",
+                "--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",
                 "-Djava.nio.channels.spi.SelectorProvider=InheritedChannelNotServerSocket$SP");
             rmid.start();
 
--- a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java	Thu Aug 11 17:02:46 2016 +0000
@@ -93,7 +93,7 @@
             rmid = RMID.createRMID(System.out, System.err, true, false,
                                    TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT);
             rmid.addOptions(
-                "-XaddExports:java.base/sun.nio.ch=ALL-UNNAMED",
+                "--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",
                 "-Djava.nio.channels.spi.SelectorProvider=RmidViaInheritedChannel$RmidSelectorProvider");
             if (System.getProperty("os.name").startsWith("Windows") &&
                 System.getProperty("os.version").startsWith("5."))
--- a/jdk/test/java/rmi/module/ModuleTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/rmi/module/ModuleTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -97,8 +97,8 @@
      */
     @Test
     public void testAllInModule() throws Exception {
-        assertEquals(executeTestJava("-mp", pathJoin(MTEST_JAR, CLIENT_JAR, SERVER_JAR),
-                "-addmods", "mclient,mserver",
+        assertEquals(executeTestJava("--module-path", pathJoin(MTEST_JAR, CLIENT_JAR, SERVER_JAR),
+                "--add-modules", "mclient,mserver",
                 "-m", "mtest/" + DUMMY_MAIN)
                 .outputTo(System.out)
                 .errorTo(System.out)
@@ -113,7 +113,7 @@
      */
     @Test
     public void testAppInModule() throws Exception {
-        assertEquals(executeTestJava("-mp", MTEST_JAR,
+        assertEquals(executeTestJava("--module-path", MTEST_JAR,
                 "-cp", pathJoin(CLIENT_JAR, SERVER_JAR),
                 "-m", "mtest/" + DUMMY_MAIN)
                 .outputTo(System.out)
@@ -129,8 +129,8 @@
      */
     @Test
     public void testAppInUnnamedModule() throws Exception {
-        assertEquals(executeTestJava("-mp", pathJoin(CLIENT_JAR, SERVER_JAR),
-                "-addmods", "mclient,mserver",
+        assertEquals(executeTestJava("--module-path", pathJoin(CLIENT_JAR, SERVER_JAR),
+                "--add-modules", "mclient,mserver",
                 "-cp", MTEST_JAR,
                 DUMMY_MAIN)
                 .outputTo(System.out)
@@ -146,8 +146,8 @@
      */
     @Test
     public void testClientInUnamedModule() throws Exception {
-        assertEquals(executeTestJava("-mp", pathJoin(MTEST_JAR, SERVER_JAR),
-                "-addmods", "mserver",
+        assertEquals(executeTestJava("--module-path", pathJoin(MTEST_JAR, SERVER_JAR),
+                "--add-modules", "mserver",
                 "-cp", CLIENT_JAR,
                 "-m", "mtest/" + DUMMY_MAIN)
                 .outputTo(System.out)
--- a/jdk/test/java/rmi/registry/readTest/readTest.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/rmi/registry/readTest/readTest.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -99,10 +99,10 @@
 esac
 # trailing / after code base is important for rmi codebase property.
 TESTVMOPTS="${TESTVMOPTS} \
- -XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED \
- -XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED \
- -XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED \
- -XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED"
+ --add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED \
+ --add-exports java.rmi/sun.rmi.server=ALL-UNNAMED \
+ --add-exports java.rmi/sun.rmi.transport=ALL-UNNAMED \
+ --add-exports java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED"
 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp $TEST_CLASSPATH ${ARGS} -Djava.rmi.server.codebase=${FILEURL}$CODEBASE/ readTest > OUT.TXT 2>&1 &
 TEST_PID=$!
 #bulk of testcase - let it run for a while
--- a/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java	Thu Aug 11 17:02:46 2016 +0000
@@ -123,10 +123,10 @@
                                     propOption + property +
                                     equal +
                                     propertyValue + extraProp +
-                                    " -XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED" +
-                                    " -XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED" +
-                                    " -XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED" +
-                                    " -XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" +
+                                    " --add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED" +
+                                    " --add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED" +
+                                    " --add-exports=java.rmi/sun.rmi.transport=ALL-UNNAMED" +
+                                    " --add-exports=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" +
                                     " -Drmi.registry.port=" +
                                     REGISTRY_PORT,
                                     "");
--- a/jdk/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java	Thu Aug 11 17:02:46 2016 +0000
@@ -75,10 +75,10 @@
         try {
             String options = " -Djava.security.policy=" +
                 TestParams.defaultPolicy +
-                " -XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED" +
-                " -XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED" +
-                " -XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED" +
-                " -XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" +
+                " --add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED" +
+                " --add-exports java.rmi/sun.rmi.server=ALL-UNNAMED" +
+                " --add-exports java.rmi/sun.rmi.transport=ALL-UNNAMED" +
+                " --add-exports java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" +
                 " -Djava.rmi.dgc.leaseValue=500000" +
                 "  -Dsun.rmi.dgc.checkInterval=" +
                 (HOLD_TARGET_TIME - 5000) +
--- a/jdk/test/java/security/Provider/SecurityProviderModularTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/security/Provider/SecurityProviderModularTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -317,7 +317,7 @@
         vmArgs.put("-Duser.language=", "en");
         vmArgs.put("-Duser.region=", "US");
         if (addModName != null && sModuletype == MODULE_TYPE.AUTO) {
-            vmArgs.put("-addmods ", addModName);
+            vmArgs.put("--add-modules=", addModName);
         }
         // If mechanism selected to find the provider through
         // Security.getProvider() then use providerName/ProviderClassName based
--- a/jdk/test/java/security/modules/ModularTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/security/modules/ModularTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -137,7 +137,7 @@
         final StringJoiner command = new StringJoiner(SPACE, SPACE, SPACE);
         vmArgs.forEach((key, value) -> command.add(key + value));
         if (modulePath != null) {
-            command.add("-mp").add(modulePath.toFile().getCanonicalPath());
+            command.add("--module-path").add(modulePath.toFile().getCanonicalPath());
         }
         if (classPath != null && classPath.length() > 0) {
             command.add("-cp").add(classPath);
--- a/jdk/test/java/security/testlibrary/Proc.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/security/testlibrary/Proc.java	Thu Aug 11 17:02:46 2016 +0000
@@ -25,19 +25,19 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLClassLoader;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.security.Permission;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Base64;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.stream.Stream;
 
 /**
  * This is a test library that makes writing a Java test that spawns multiple
@@ -184,12 +184,9 @@
                         "java").getPath());
         }
 
-        int n = 0;
-        String addexports;
-        while ((addexports = System.getProperty("jdk.launcher.addexports." + n)) != null) {
-            prop("jdk.launcher.addexports." + n, addexports);
-            n++;
-        }
+        Stream.of(jdk.internal.misc.VM.getRuntimeArguments())
+            .filter(arg -> arg.startsWith("--add-exports="))
+            .forEach(cmd::add);
 
         Collections.addAll(cmd, splitProperty("test.vm.opts"));
         Collections.addAll(cmd, splitProperty("test.java.opts"));
--- a/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/util/Calendar/GenericTimeZoneNamesTest.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -31,7 +31,7 @@
 # This test is locale data-dependent and assumes that both JRE and CLDR
 # have the same geneic time zone names in English.
 
-EXTRAOPTS="-XaddExports:java.base/sun.util.locale.provider=ALL-UNNAMED"
+EXTRAOPTS="--add-exports java.base/sun.util.locale.provider=ALL-UNNAMED"
 STATUS=0
 echo "Locale providers: default"
 if ! ${TESTJAVA}/bin/java -esa ${TESTVMOPTS} ${EXTRAOPTS} -cp "${TESTCLASSES}" GenericTimeZoneNamesTest en-US; then
--- a/jdk/test/java/util/Formatter/Basic.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/util/Formatter/Basic.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -23,7 +23,7 @@
 
 #
 
-EXTRAOPTS="-XaddExports:java.base/jdk.internal.math=ALL-UNNAMED"
+EXTRAOPTS="--add-exports java.base/jdk.internal.math=ALL-UNNAMED"
 ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -cp ${TESTSRC} -d . \
     ${TESTSRC}/Basic.java
 
--- a/jdk/test/java/util/Locale/LocaleProviders.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/util/Locale/LocaleProviders.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -122,8 +122,8 @@
 tznp8013086
 EOF
 
-EXTRAOPTS="-XaddExports:java.base/sun.util.locale=ALL-UNNAMED \
- -XaddExports:java.base/sun.util.locale.provider=ALL-UNNAMED"
+EXTRAOPTS="--add-exports java.base/sun.util.locale=ALL-UNNAMED \
+ --add-exports java.base/sun.util.locale.provider=ALL-UNNAMED"
 
 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${SPIDIR}${FS}dest \
     ${SPIDIR}${FS}src${FS}tznp.java \
--- a/jdk/test/java/util/PluggableLocale/ExecTest.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/util/PluggableLocale/ExecTest.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -93,8 +93,8 @@
 esac
 
 
-EXTRA_OPTS="-XaddExports:java.base/sun.util.locale.provider=ALL-UNNAMED \
- -XaddExports:java.base/sun.util.resources=ALL-UNNAMED"
+EXTRA_OPTS="--add-exports java.base/sun.util.locale.provider=ALL-UNNAMED \
+ --add-exports java.base/sun.util.resources=ALL-UNNAMED"
 
 # compile
 cp ${TESTSRC}${FS}ProviderTest.java .
--- a/jdk/test/java/util/ResourceBundle/Bug6299235Test.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/util/ResourceBundle/Bug6299235Test.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -68,7 +68,7 @@
 ${TESTJAVA}/bin/jar xf ${TESTSRC}/awtres.jar
 
 echo 
-${TESTJAVA}/bin/java ${TESTVMOPTS} -Xpatch:java.desktop=${PATCHDIR}/java.desktop \
+${TESTJAVA}/bin/java ${TESTVMOPTS} --patch-module java.desktop=${PATCHDIR}/java.desktop \
      -cp ${TESTCLASSES} Bug6299235Test
 
 if [ $? -ne 0 ]
--- a/jdk/test/java/util/ResourceBundle/modules/appbasic/appbasic.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/util/ResourceBundle/modules/appbasic/appbasic.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -47,7 +47,7 @@
   mkdir -p mods/$B
   CLASSES="`find $TESTSRC/src/$B -name '*.java'`"
   if [ "x$CLASSES" != x ]; then
-    $JAVAC -g -d mods -modulesourcepath $TESTSRC/src -cp mods/test $CLASSES
+    $JAVAC -g -d mods --module-source-path $TESTSRC/src -cp mods/test $CLASSES
   fi
   PROPS="`(cd $TESTSRC/src/$B; find . -name '*.properties')`"
   if [ "x$PROPS" != x ]; then
@@ -61,8 +61,8 @@
 done
 
 mkdir -p mods/test
-$JAVAC -g -d mods -modulesourcepath $TESTSRC/src `find $TESTSRC/src/test -name "*.java"`
+$JAVAC -g -d mods --module-source-path $TESTSRC/src `find $TESTSRC/src/test -name "*.java"`
 
-$JAVA -mp mods -m test/jdk.test.Main de fr ja zh-tw en de
+$JAVA -p mods -m test/jdk.test.Main de fr ja zh-tw en de
 
 exit $?
--- a/jdk/test/java/util/ResourceBundle/modules/appbasic2/appbasic2.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/util/ResourceBundle/modules/appbasic2/appbasic2.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -47,7 +47,7 @@
   mkdir -p mods/$B
   CLASSES="`find $TESTSRC/src/$B -name '*.java'`"
   if [ "x$CLASSES" != x ]; then
-    $JAVAC -g -d mods -modulesourcepath $TESTSRC/src -cp mods/test $CLASSES
+    $JAVAC -g -d mods --module-source-path $TESTSRC/src -cp mods/test $CLASSES
   fi
   PROPS="`(cd $TESTSRC/src/$B; find . -name '*.properties')`"
   if [ "x$PROPS" != x ]; then
@@ -61,8 +61,8 @@
 done
 
 mkdir -p mods/test
-$JAVAC -g -d mods -modulesourcepath $TESTSRC/src `find $TESTSRC/src/test -name "*.java"`
+$JAVAC -g -d mods --module-source-path $TESTSRC/src `find $TESTSRC/src/test -name "*.java"`
 
-$JAVA -mp mods -m test/jdk.test.Main de fr ja zh-tw en de
+$JAVA -p mods -m test/jdk.test.Main de fr ja zh-tw en de
 
 exit $?
--- a/jdk/test/java/util/ResourceBundle/modules/basic/basic.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/util/ResourceBundle/modules/basic/basic.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -52,7 +52,7 @@
   mkdir -p mods/$B
   CLASSES="`find $TESTSRC/src/$B -name '*.java'`"
   if [ "x$CLASSES" != x ]; then
-    $JAVAC -g -d mods -modulesourcepath $TESTSRC/src $CP $CLASSES
+    $JAVAC -g -d mods --module-source-path $TESTSRC/src $CP $CLASSES
   fi
   PROPS="`(cd $TESTSRC/src/$B; find . -name '*.properties')`"
   if [ "x$PROPS" != x ]; then
@@ -67,7 +67,7 @@
 done
 
 mkdir -p mods/test
-$JAVAC -g -cp mods/mainbundles -d mods -modulesourcepath $TESTSRC/src \
+$JAVAC -g -cp mods/mainbundles -d mods --module-source-path $TESTSRC/src \
     `find $TESTSRC/src/test -name "*.java"`
 
 # Create a jar to be added to the class path. Expected only properties files are
@@ -81,9 +81,9 @@
 STATUS=0
 
 echo "jdk.test.Main should load bundles using ResourceBundleProviders."
-$JAVA -mp mods -m test/jdk.test.Main de fr ja ja-jp zh-tw en de ja-jp || STATUS=1
+$JAVA -p mods -m test/jdk.test.Main de fr ja ja-jp zh-tw en de ja-jp || STATUS=1
 
 echo "jdk.test.Main should NOT load bundles from the jar file specified by the class-path."
-$JAVA -cp extra.jar -mp mods -m test/jdk.test.Main es vi && STATUS=1
+$JAVA -cp extra.jar -p mods -m test/jdk.test.Main es vi && STATUS=1
 
 exit $STATUS
--- a/jdk/test/java/util/ResourceBundle/modules/modlocal/modlocal.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/util/ResourceBundle/modules/modlocal/modlocal.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -57,7 +57,7 @@
     done
 fi
 
-$JAVAC -g -d mods -modulesourcepath $TESTSRC/src \
+$JAVAC -g -d mods --module-source-path $TESTSRC/src \
        -cp mods/bundles `find $TESTSRC/src/test -name "*.java"`
 
 # Create a jar to be added to the class path. Expected properties files are
@@ -69,9 +69,9 @@
 STATUS=0
 
 echo 'jdk.test.Main should load bundles local to named module "test".'
-$JAVA -mp mods -m test/jdk.test.Main de fr ja zh-tw en de || STATUS=1
+$JAVA -p mods -m test/jdk.test.Main de fr ja zh-tw en de || STATUS=1
 
 echo "jdk.test.Main should NOT load bundles from the jar file specified by the class-path."
-$JAVA -cp extra.jar -mp mods -m test/jdk.test.Main vi && STATUS=1
+$JAVA -cp extra.jar -p mods -m test/jdk.test.Main vi && STATUS=1
 
 exit $STATUS
--- a/jdk/test/java/util/ResourceBundle/modules/security/TestPermission.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/util/ResourceBundle/modules/security/TestPermission.java	Thu Aug 11 17:02:46 2016 +0000
@@ -59,7 +59,7 @@
     public void compileAll() throws Exception {
         for (String mn : modules) {
             Path msrc = SRC_DIR.resolve(mn);
-            assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "-modulesourcepath", SRC_DIR.toString()));
+            assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString()));
         }
     }
 
@@ -68,7 +68,7 @@
      */
     @Test
     public void runTest() throws Exception {
-        int exitValue = executeTestJava("-mp", MODS_DIR.toString(),
+        int exitValue = executeTestJava("--module-path", MODS_DIR.toString(),
                                         "-m", "test/jdk.test.Main")
                             .outputTo(System.out)
                             .errorTo(System.out)
--- a/jdk/test/java/util/ResourceBundle/modules/simple/simple.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/util/ResourceBundle/modules/simple/simple.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -50,7 +50,7 @@
 mkdir -p mods/$B
 CLASSES="`find $TESTSRC/src/$B -name '*.java'`"
 if [ "x$CLASSES" != x ]; then
-    $JAVAC -g -d mods -modulesourcepath $TESTSRC/src $CLASSES
+    $JAVAC -g -d mods --module-source-path $TESTSRC/src $CLASSES
 fi
 PROPS="`(cd $TESTSRC/src/$B; find . -name '*.properties')`"
 if [ "x$PROPS" != x ]; then
@@ -62,9 +62,9 @@
     done
 fi
 
-$JAVAC -g -d mods -modulesourcepath $TESTSRC/src \
+$JAVAC -g -d mods --module-source-path $TESTSRC/src \
        -cp mods/bundles `find $TESTSRC/src/test -name "*.java"`
 
-$JAVA -mp mods -m test/jdk.test.Main de fr ja zh-tw en de
+$JAVA -p mods -m test/jdk.test.Main de fr ja zh-tw en de
 
 exit $?
--- a/jdk/test/java/util/ResourceBundle/modules/visibility/visibility.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/util/ResourceBundle/modules/visibility/visibility.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -57,7 +57,7 @@
     mkdir -p mods/$M
     CLASSES="`find $TESTSRC/src/$M -name '*.java'`"
     if [ "x$CLASSES" != x ]; then
-        $JAVAC -g -d mods -modulesourcepath $TESTSRC/src $CLASSES
+        $JAVAC -g -d mods --module-source-path $TESTSRC/src $CLASSES
     fi
     PROPS="`(cd $TESTSRC/src/$M; find . -name '*.properties')`"
     if [ "x$PROPS" != x ]; then
@@ -96,23 +96,23 @@
 
 # jdk.test.resources.{classes,props}.* are available only to named module "test"
 # by ResourceBundleProvider.
-runJava -mp mods -m test/jdk.test.TestWithNoModuleArg \
+runJava -p mods -m test/jdk.test.TestWithNoModuleArg \
     jdk.test.resources.classes.MyResources true
-runJava -mp mods -m test/jdk.test.TestWithNoModuleArg \
+runJava -p mods -m test/jdk.test.TestWithNoModuleArg \
     jdk.test.resources.props.MyResources true
-runJava -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \
+runJava -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \
     jdk.test.resources.classes.MyResources false
-runJava -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \
+runJava -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \
     jdk.test.resources.props.MyResources false
 
 # Add mods/named.bundles to the class path.
-runJava -cp mods/named.bundles -mp mods -m test/jdk.test.TestWithNoModuleArg \
+runJava -cp mods/named.bundles -p mods -m test/jdk.test.TestWithNoModuleArg \
     jdk.test.resources.classes.MyResources true
-runJava -cp mods/named.bundles -mp mods -m test/jdk.test.TestWithNoModuleArg \
+runJava -cp mods/named.bundles -p mods -m test/jdk.test.TestWithNoModuleArg \
     jdk.test.resources.props.MyResources true
-runJava -cp mods/named.bundles -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \
+runJava -cp mods/named.bundles -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \
     jdk.test.resources.classes.MyResources false
-runJava -cp mods/named.bundles -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \
+runJava -cp mods/named.bundles -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \
     jdk.test.resources.props.MyResources false
 
 # Tests using jdk.test.TestWithUnnamedModuleArg and jdk.embargo.TestWithUnnamedModuleArg
@@ -120,37 +120,37 @@
 
 # jdk.test.resources.classes is exported to named module "test".
 # IllegalAccessException is thrown in ResourceBundle.Control.newBundle().
-runJava -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \
+runJava -p mods -m test/jdk.test.TestWithUnnamedModuleArg \
     jdk.test.resources.classes.MyResources false
 
 # jdk.test.resources.props is exported to named module "test".
 # loader.getResource() doesn't find jdk.test.resources.props.MyResources.
-runJava -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \
+runJava -p mods -m test/jdk.test.TestWithUnnamedModuleArg \
     jdk.test.resources.props.MyResources false
 
 # IllegalAccessException is thrown in ResourceBundle.Control.newBundle().
-runJava -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
+runJava -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
     jdk.test.resources.classes.MyResources false
 # jdk.test.resources.props is exported to named module "test".
 # loader.getResource() doesn't find jdk.test.resources.props.MyResources.
-runJava -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
+runJava -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
     jdk.test.resources.props.MyResources false
 
 # Add mods/named.bundles to the class path
 
 # IllegalAccessException is thrown in ResourceBundle.Control.newBundle().
-runJava -cp mods/named.bundles -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \
+runJava -cp mods/named.bundles -p mods -m test/jdk.test.TestWithUnnamedModuleArg \
         jdk.test.resources.classes.MyResources false
 # loader.getResource() finds jdk.test.resources.exported.props.MyResources.
-runJava -cp mods/named.bundles -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \
+runJava -cp mods/named.bundles -p mods -m test/jdk.test.TestWithUnnamedModuleArg \
         jdk.test.resources.props.MyResources true
 
 # jdk.test.resources.exported.classes.MyResources is treated
 # as if the class is in an unnamed module.
-runJava -cp mods/named.bundles -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
+runJava -cp mods/named.bundles -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
         jdk.test.resources.classes.MyResources true
 # loader.getResource() finds jdk.test.resources.exported.props.MyResources.
-runJava -cp mods/named.bundles -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
+runJava -cp mods/named.bundles -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
         jdk.test.resources.props.MyResources true
 
 #################################################
@@ -160,23 +160,23 @@
 # neither of which specifies an unnamed module with ResourceBundle.getBundle.
 
 # None of jdk.test.resources.exported.** is available to the named modules.
-runJava -mp mods -m test/jdk.test.TestWithNoModuleArg \
+runJava -p mods -m test/jdk.test.TestWithNoModuleArg \
     jdk.test.resources.exported.classes.MyResources false
-runJava -mp mods -m test/jdk.test.TestWithNoModuleArg \
+runJava -p mods -m test/jdk.test.TestWithNoModuleArg \
     jdk.test.resources.exported.props.MyResources false
-runJava -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \
+runJava -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \
     jdk.test.resources.exported.classes.MyResources false
-runJava -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \
+runJava -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \
     jdk.test.resources.exported.props.MyResources false
 
 # Add mods/exported.named.bundles to the class path.
-runJava -cp mods/exported.named.bundles -mp mods -m test/jdk.test.TestWithNoModuleArg \
+runJava -cp mods/exported.named.bundles -p mods -m test/jdk.test.TestWithNoModuleArg \
     jdk.test.resources.exported.classes.MyResources false
-runJava -cp mods/exported.named.bundles -mp mods -m test/jdk.test.TestWithNoModuleArg \
+runJava -cp mods/exported.named.bundles -p mods -m test/jdk.test.TestWithNoModuleArg \
     jdk.test.resources.exported.props.MyResources false
-runJava -cp mods/exported.named.bundles -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \
+runJava -cp mods/exported.named.bundles -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \
     jdk.test.resources.exported.classes.MyResources false
-runJava -cp mods/exported.named.bundles -mp mods -m embargo/jdk.embargo.TestWithNoModuleArg \
+runJava -cp mods/exported.named.bundles -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \
     jdk.test.resources.exported.props.MyResources false
 
 # Tests using jdk.test.TestWithUnnamedModuleArg and jdk.embargo.TestWithUnnamedModuleArg
@@ -184,36 +184,36 @@
 
 # loader.loadClass() doesn't find jdk.test.resources.exported.classes.MyResources
 # and throws a ClassNotFoundException.
-runJava -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \
+runJava -p mods -m test/jdk.test.TestWithUnnamedModuleArg \
         jdk.test.resources.exported.classes.MyResources false
 # The properties files in jdk.test.resources.exported.props are not found with loader.getResource().
-runJava -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \
+runJava -p mods -m test/jdk.test.TestWithUnnamedModuleArg \
         jdk.test.resources.exported.props.MyResources false
 
 
 # loader.loadClass() doesn't find jdk.test.resources.exported.classes.MyResources
 # and throws a ClassNotFoundException.
-runJava -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
+runJava -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
         jdk.test.resources.exported.classes.MyResources false
 # The properties files in jdk.test.resources.exported.props are not found
 # with loader.getResource().
-runJava -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
+runJava -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
         jdk.test.resources.exported.props.MyResources false
 
 # Add mods/exported.named.bundles to the class path.
 
 # jdk.test.resources.exported.classes.MyResources.getModule().isNamed() returns false.
-runJava -cp mods/exported.named.bundles -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \
+runJava -cp mods/exported.named.bundles -p mods -m test/jdk.test.TestWithUnnamedModuleArg \
         jdk.test.resources.exported.classes.MyResources true
 # loader.getResource() finds jdk.test.resources.exported.props.MyResources.
-runJava -cp mods/exported.named.bundles -mp mods -m test/jdk.test.TestWithUnnamedModuleArg \
+runJava -cp mods/exported.named.bundles -p mods -m test/jdk.test.TestWithUnnamedModuleArg \
         jdk.test.resources.exported.props.MyResources true
 
 # jdk.test.resources.exported.classes.MyResources.getModule().isNamed() returns false.
-runJava -cp mods/exported.named.bundles -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
+runJava -cp mods/exported.named.bundles -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
         jdk.test.resources.exported.classes.MyResources true
 # loader.getResource() finds jdk.test.resources.exported.props.MyResources.
-runJava -cp mods/exported.named.bundles -mp mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
+runJava -cp mods/exported.named.bundles -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \
         jdk.test.resources.exported.props.MyResources true
 
 #######################################
--- a/jdk/test/java/util/ResourceBundle/modules/xmlformat/xmlformat.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/util/ResourceBundle/modules/xmlformat/xmlformat.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -48,7 +48,7 @@
 mkdir -p mods/$B
 CLASSES="`find $TESTSRC/src/$B -name '*.java'`"
 if [ "x$CLASSES" != x ]; then
-    $JAVAC -g -d mods -modulesourcepath $TESTSRC/src $CLASSES
+    $JAVAC -g -d mods --module-source-path $TESTSRC/src $CLASSES
 fi
 PROPS="`(cd $TESTSRC/src/$B; find . -name '*.xml')`"
 if [ "x$PROPS" != x ]; then
@@ -60,9 +60,9 @@
     done
 fi
 
-$JAVAC -g -d mods -modulesourcepath $TESTSRC/src \
+$JAVAC -g -d mods --module-source-path $TESTSRC/src \
        -cp mods/bundles `find $TESTSRC/src/test -name "*.java"`
 
-$JAVA -mp mods -m test/jdk.test.Main de fr ja zh-tw en de
+$JAVA -p mods -m test/jdk.test.Main de fr ja zh-tw en de
 
 exit $?
--- a/jdk/test/java/util/ServiceLoader/modules/ServicesTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/util/ServiceLoader/modules/ServicesTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -105,13 +105,13 @@
 
 
     /**
-     * Run test with -modulepath.
+     * Run test with --module-path.
      *
      * BananaScriptEngine should be found.
      */
     public void runWithModulePath() throws Exception {
         int exitValue
-            = executeTestJava("-mp", MODS_DIR.toString(),
+            = executeTestJava("--module-path", MODS_DIR.toString(),
                               "-m", "test/test.Main",
                               "BananaScriptEngine")
                 .outputTo(System.out)
@@ -123,13 +123,13 @@
 
 
     /**
-     * Run test with -modulepath and -classpath.
+     * Run test with --module-path and -classpath.
      *
      * Both BananaScriptEngine and PearScriptEngine should be found
      */
     public void runWithModulePathAndClassPath() throws Exception {
         int exitValue
-            = executeTestJava("-mp", MODS_DIR.toString(),
+            = executeTestJava("--module-path", MODS_DIR.toString(),
                               "-cp", CLASSES_DIR.toString(),
                               "-m", "test/test.Main",
                               "BananaScriptEngine", "PearScriptEngine")
--- a/jdk/test/java/util/logging/modules/GetResourceBundleTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/java/util/logging/modules/GetResourceBundleTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -66,10 +66,10 @@
         for (String mn : modules) {
             Path msrc = MOD_SRC_DIR.resolve(mn);
             assertTrue(CompilerUtils.compile(msrc, MOD_DEST_DIR,
-                    "-modulesourcepath", MOD_SRC_DIR.toString()));
+                    "--module-source-path", MOD_SRC_DIR.toString()));
         }
         assertTrue(CompilerUtils.compile(PKG_SRC_DIR, PKG_DEST_DIR,
-                "-modulepath", MOD_DEST_DIR.toString(), "-addmods", String.join(",", modules)));
+                "--module-path", MOD_DEST_DIR.toString(), "--add-modules", String.join(",", modules)));
 
         // copy resource files
         String[] files = { "m1/p1/resource/p.properties", "m2/p2/resource/p.properties" };
@@ -84,8 +84,8 @@
     public void runWithoutSecurityManager() throws Exception {
         int exitValue = executeTestJava(
                 "-cp", PKG_DEST_DIR.toString(),
-                "-mp", MOD_DEST_DIR.toString(),
-                "-addmods", String.join(",", modules),
+                "--module-path", MOD_DEST_DIR.toString(),
+                "--add-modules", String.join(",", modules),
                 "p3.test.ResourceBundleTest")
                 .outputTo(System.out)
                 .errorTo(System.err)
@@ -98,8 +98,8 @@
         int exitValue = executeTestJava(
                 "-Djava.security.manager",
                 "-cp", PKG_DEST_DIR.toString(),
-                "-mp", MOD_DEST_DIR.toString(),
-                "-addmods", String.join(",", modules),
+                "--module-path", MOD_DEST_DIR.toString(),
+                "--add-modules", String.join(",", modules),
                 "p3.test.ResourceBundleTest")
                 .outputTo(System.out)
                 .errorTo(System.err)
--- a/jdk/test/javax/crypto/Cipher/CipherStreamClose.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/crypto/Cipher/CipherStreamClose.java	Thu Aug 11 17:02:46 2016 +0000
@@ -27,8 +27,8 @@
  * @summary Make sure Cipher IO streams doesn't call extra doFinal if close()
  * is called multiple times.  Additionally, verify the input and output streams
  * match with encryption and decryption with non-stream crypto.
- * @compile -addmods java.xml.bind CipherStreamClose.java
- * @run main/othervm -addmods java.xml.bind CipherStreamClose
+ * @modules java.xml.bind
+ * @run main CipherStreamClose
  */
 
 import java.io.*;
--- a/jdk/test/javax/imageio/plugins/external_plugin_tests/TestClassPathPlugin.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/imageio/plugins/external_plugin_tests/TestClassPathPlugin.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -86,7 +86,7 @@
 
 # expect to find SimpReader on module path
 echo "Test modular jar .. "
-$JAVA -mp $PLUGINDIR -cp $TESTDIR simptest.TestSIMPPlugin
+$JAVA --module-path $PLUGINDIR -cp $TESTDIR simptest.TestSIMPPlugin
 
 if [ $? -ne 0 ]; then
     exception=1
@@ -94,7 +94,7 @@
 fi
 
 echo "Test modular jar with security manager .."
-$JAVA -Djava.security.manager -mp $PLUGINDIR -cp $TESTDIR simptest.TestSIMPPlugin
+$JAVA -Djava.security.manager --module-path $PLUGINDIR -cp $TESTDIR simptest.TestSIMPPlugin
 if [ $? -ne 0 ]; then
     exception=1
     echo "modular jar with security manager test failed: exception thrown!"
--- a/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -199,14 +199,14 @@
 fi
 
 # Verify that all classloaders are destroyed
-${TESTJAVA}/bin/java -XaddExports:java.desktop/sun.awt=ALL-UNNAMED ${TESTVMOPTS} -cp Test.jar test.Main
+${TESTJAVA}/bin/java --add-exports java.desktop/sun.awt=ALL-UNNAMED ${TESTVMOPTS} -cp Test.jar test.Main
 if [ $? -ne 0 ] ; then
     fail "Test FAILED: some classloaders weren't destroyed."
 fi
 
 
 # Verify that ImageIO shutdown hook works correcly
-${TESTJAVA}/bin/java -XaddExports:java.desktop/sun.awt=ALL-UNNAMED ${TESTVMOPTS} \
+${TESTJAVA}/bin/java --add-exports java.desktop/sun.awt=ALL-UNNAMED ${TESTVMOPTS} \
     -cp Test.jar -DforgetSomeStreams=true test.Main
 if [ $? -ne 0 ] ; then
     fail "Test FAILED: some classloaders weren't destroyed of shutdown hook failed."
--- a/jdk/test/javax/naming/module/basic.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/naming/module/basic.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -78,27 +78,27 @@
 
 echo "\nPreparing the 'test' module..."
 mkdir -p mods/test
-$JAVAC -d mods -modulesourcepath $TESTSRC/src `find $TESTSRC/src/test -name "*.java"`
+$JAVAC -d mods --module-source-path $TESTSRC/src `find $TESTSRC/src/test -name "*.java"`
 
 
 echo "\nRunning with the 'java.desktop' module..."
-$JAVA -Dtest.src=${TESTSRC} -mp mods -m test/test.StoreObject ldap://localhost/dc=ie,dc=oracle,dc=com
+$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.StoreObject ldap://localhost/dc=ie,dc=oracle,dc=com
 
 echo "\nRunning with the 'person' module..."
-$JAVA -Dtest.src=${TESTSRC} -mp mods -m test/test.StorePerson ldap://localhost/dc=ie,dc=oracle,dc=com
+$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.StorePerson ldap://localhost/dc=ie,dc=oracle,dc=com
 
 echo "\nRunning with the 'fruit' module..."
-$JAVA -Dtest.src=${TESTSRC} -mp mods -m test/test.StoreFruit ldap://localhost/dc=ie,dc=oracle,dc=com
+$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.StoreFruit ldap://localhost/dc=ie,dc=oracle,dc=com
 
 echo "\nRunning with the 'hello' module..."
-$JAVA -Dtest.src=${TESTSRC} -mp mods -m test/test.StoreRemote ldap://localhost/dc=ie,dc=oracle,dc=com
+$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.StoreRemote ldap://localhost/dc=ie,dc=oracle,dc=com
 
 echo "\nRunning with the 'foo' module..."
-$JAVA -Dtest.src=${TESTSRC} -mp mods -m test/test.ConnectWithFoo ldap://localhost/dc=ie,dc=oracle,dc=com
+$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.ConnectWithFoo ldap://localhost/dc=ie,dc=oracle,dc=com
 
 echo "\nRunning with the 'authz' module..."
-$JAVA -Dtest.src=${TESTSRC} -mp mods -m test/test.ConnectWithAuthzId ldap://localhost/dc=ie,dc=oracle,dc=com
+$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.ConnectWithAuthzId ldap://localhost/dc=ie,dc=oracle,dc=com
 
 echo "\nRunning with the 'ldapv4' module..."
-$JAVA -Dtest.src=${TESTSRC} -mp mods -m test/test.ReadByUrl ldap://localhost/dc=ie,dc=oracle,dc=com
+$JAVA -Dtest.src=${TESTSRC} -p mods -m test/test.ReadByUrl ldap://localhost/dc=ie,dc=oracle,dc=com
 
--- a/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -25,18 +25,19 @@
  * @test
  * @bug 8146975
  * @summary test RMI-IIOP with value object return
+ * @modules java.corba
  * @library /lib/testlibrary
  * @build jdk.testlibrary.*
- * @compile -addmods java.corba Test.java Test3.java Test4.java
+ * @compile Test.java Test3.java Test4.java
  *    HelloInterface.java HelloServer.java
  *    HelloClient.java HelloImpl.java _HelloImpl_Tie.java _HelloInterface_Stub.java
  *    RmiIiopReturnValueTest.java
- * @run main/othervm -addmods java.corba
+ * @run main/othervm
  *    -Djava.naming.provider.url=iiop://localhost:5050
  *    -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory
  *    RmiIiopReturnValueTest -port 5049
  * @run main/othervm/secure=java.lang.SecurityManager/policy=jtreg.test.policy
- *    -addmods java.corba -Djava.naming.provider.url=iiop://localhost:5050
+ *    -Djava.naming.provider.url=iiop://localhost:5050
  *    -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory
  *    RmiIiopReturnValueTest -port 5049
  */
@@ -102,12 +103,12 @@
 
     static void startRmiIiopServer() throws Exception {
         System.out.println("\nStarting RmiIiopServer");
-        // java -addmods java.corba -cp .
+        // java --add-modules java.corba -cp .
         // -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory
         // -Djava.naming.provider.url=iiop://localhost:5050 HelloServer -port 5049
         List<String> commands = new ArrayList<>();
         commands.add(RmiIiopReturnValueTest.JAVA);
-        commands.add("-addmods");
+        commands.add("--add-modules");
         commands.add("java.corba");
         commands.add("-Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory");
         commands.add("-Djava.naming.provider.url=iiop://localhost:5050");
--- a/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -28,12 +28,12 @@
  * @library /lib/testlibrary
  * @modules java.corba
  * @build jdk.testlibrary.*
- * @compile -addmods java.corba Test.java HelloInterface.java HelloServer.java HelloClient.java
+ * @compile Test.java HelloInterface.java HelloServer.java HelloClient.java
  *    HelloImpl.java _HelloImpl_Tie.java _HelloInterface_Stub.java ConcurrentHashMapTest.java
- * @run main/othervm -addmods java.corba -Djava.naming.provider.url=iiop://localhost:1050
+ * @run main/othervm -Djava.naming.provider.url=iiop://localhost:1050
  *    -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory ConcurrentHashMapTest
  * @run main/othervm/secure=java.lang.SecurityManager/policy=jtreg.test.policy
- *    -addmods java.corba -Djava.naming.provider.url=iiop://localhost:1050
+ *    -Djava.naming.provider.url=iiop://localhost:1050
  *    -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory ConcurrentHashMapTest
  * @key intermittent
  */
@@ -98,12 +98,12 @@
 
     static void startRmiIiopServer() throws Exception {
         System.out.println("\nStarting RmiServer");
-        // java -cp . -addmods java.corba
+        // java -cp . --add-modules java.corba
         // -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory
         // -Djava.naming.provider.url=iiop://localhost:1050 HelloServer
         List<String> commands = new ArrayList<>();
         commands.add(ConcurrentHashMapTest.JAVA);
-        commands.add("-addmods");
+        commands.add("--add-modules");
         commands.add("java.corba");
         commands.add("-Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory");
         commands.add("-Djava.naming.provider.url=iiop://localhost:1050");
--- a/jdk/test/javax/security/auth/login/modules/JaasModularClientTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/security/auth/login/modules/JaasModularClientTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -291,7 +291,7 @@
         vmArgs.put("-Djava.security.auth.login.config=", SRC.resolve(
                 "jaas.conf").toFile().getCanonicalPath());
         if (addModName != null && sModuletype == MODULE_TYPE.AUTO) {
-            vmArgs.put("-addmods ", addModName);
+            vmArgs.put("--add-modules ", addModName);
         }
         return vmArgs;
     }
--- a/jdk/test/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -247,7 +247,7 @@
         if (addModName != null
                 && !(cModuleType == MODULE_TYPE.EXPLICIT
                 && sModuletype == MODULE_TYPE.EXPLICIT)) {
-            vmArgs.put("-addmods ", addModName);
+            vmArgs.put("--add-modules=", addModName);
         }
         return vmArgs;
     }
--- a/jdk/test/javax/smartcardio/CommandAPDUTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/smartcardio/CommandAPDUTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -26,8 +26,8 @@
  * @bug 8049021
  * @summary Test different constructors for CommandAPDU and check CLA,INS,NC,NE,
  * P1,and P2
- * @compile -addmods java.smartcardio CommandAPDUTest.java
- * @run testng/othervm -addmods java.smartcardio CommandAPDUTest
+ * @compile --add-modules=java.smartcardio CommandAPDUTest.java
+ * @run testng/othervm --add-modules=java.smartcardio CommandAPDUTest
  */
 import java.nio.ByteBuffer;
 import javax.smartcardio.CommandAPDU;
--- a/jdk/test/javax/smartcardio/HistoricalBytes.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/smartcardio/HistoricalBytes.java	Thu Aug 11 17:02:46 2016 +0000
@@ -26,8 +26,8 @@
  * @bug 6445367
  * @summary Verify that ATR.getHistoricalBytes() works
  * @author Andreas Sterbenz
- * @compile -addmods java.smartcardio HistoricalBytes.java
- * @run main/othervm -addmods java.smartcardio HistoricalBytes
+ * @compile --add-modules=java.smartcardio HistoricalBytes.java
+ * @run main/othervm --add-modules=java.smartcardio HistoricalBytes
  */
 
 import java.util.Arrays;
--- a/jdk/test/javax/smartcardio/ResponseAPDUTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/smartcardio/ResponseAPDUTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -25,8 +25,8 @@
  * @test
  * @bug 8049021
  * @summary Construct ResponseAPDU from byte array and check NR< SW, SW1 and SW2
- * @compile -addmods java.smartcardio ResponseAPDUTest.java
- * @run testng/othervm -addmods java.smartcardio ResponseAPDUTest
+ * @compile --add-modules=java.smartcardio ResponseAPDUTest.java
+ * @run testng/othervm --add-modules=java.smartcardio ResponseAPDUTest
  */
 import javax.smartcardio.ResponseAPDU;
 import static org.testng.Assert.*;
--- a/jdk/test/javax/smartcardio/Serialize.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/smartcardio/Serialize.java	Thu Aug 11 17:02:46 2016 +0000
@@ -26,8 +26,8 @@
  * @bug 6445367
  * @summary make sure serialization works
  * @author Andreas Sterbenz
- * @compile -addmods java.smartcardio Serialize.java
- * @run main/othervm -addmods java.smartcardio Serialize
+ * @compile --add-modules=java.smartcardio Serialize.java
+ * @run main/othervm --add-modules=java.smartcardio Serialize
  */
 
 import java.io.*;
--- a/jdk/test/javax/smartcardio/TerminalFactorySpiTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/smartcardio/TerminalFactorySpiTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -25,8 +25,8 @@
  * @test
  * @bug 8049021
  * @summary Test if we can write new provider for smart card
- * @compile -addmods java.smartcardio TerminalFactorySpiTest.java
- * @run main/othervm/java.security.policy=policy -addmods java.smartcardio TerminalFactorySpiTest
+ * @compile --add-modules=java.smartcardio TerminalFactorySpiTest.java
+ * @run main/othervm/java.security.policy=policy --add-modules=java.smartcardio TerminalFactorySpiTest
  */
 import java.security.Provider;
 import java.security.Security;
--- a/jdk/test/javax/smartcardio/TestCardPermission.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/smartcardio/TestCardPermission.java	Thu Aug 11 17:02:46 2016 +0000
@@ -26,8 +26,8 @@
  * @bug 6293767
  * @summary Test for the CardPermission class
  * @author Andreas Sterbenz
- * @compile -addmods java.smartcardio TestCardPermission.java
- * @run main/othervm -addmods java.smartcardio TestCardPermission
+ * @compile --add-modules=java.smartcardio TestCardPermission.java
+ * @run main/othervm --add-modules=java.smartcardio TestCardPermission
  */
 
 import javax.smartcardio.*;
--- a/jdk/test/javax/smartcardio/TestCommandAPDU.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/smartcardio/TestCommandAPDU.java	Thu Aug 11 17:02:46 2016 +0000
@@ -27,8 +27,8 @@
  * @summary Test for the CommandAPDU class
  * @author Andreas Sterbenz
  * @key randomness
- * @compile -addmods java.smartcardio TestCommandAPDU.java
- * @run main/othervm -addmods java.smartcardio TestCommandAPDU
+ * @compile --add-modules=java.smartcardio TestCommandAPDU.java
+ * @run main/othervm --add-modules=java.smartcardio TestCommandAPDU
  */
 
 import java.util.*;
--- a/jdk/test/javax/transaction/testng/Driver.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/transaction/testng/Driver.java	Thu Aug 11 17:02:46 2016 +0000
@@ -24,14 +24,14 @@
 /**
  * @test
  * @modules java.sql java.transaction
- * @compile -addmods java.transaction
+ * @compile
  *   test/transaction/InvalidTransactionExceptionTests.java
  *   test/transaction/TransactionRequiredExceptionTests.java
  *   test/transaction/TransactionRolledbackExceptionTests.java
  *   test/transaction/XAExceptionTests.java
  *   util/SerializedTransactionExceptions.java
- * @run testng/othervm -addmods java.transaction test.transaction.InvalidTransactionExceptionTests
- * @run testng/othervm -addmods java.transaction test.transaction.TransactionRequiredExceptionTests
- * @run testng/othervm -addmods java.transaction test.transaction.TransactionRolledbackExceptionTests
- * @run testng/othervm -addmods java.transaction util.SerializedTransactionExceptions
+ * @run testng/othervm test.transaction.InvalidTransactionExceptionTests
+ * @run testng/othervm test.transaction.TransactionRequiredExceptionTests
+ * @run testng/othervm test.transaction.TransactionRolledbackExceptionTests
+ * @run testng/othervm util.SerializedTransactionExceptions
  */
--- a/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithAbstractFactory.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithAbstractFactory.java	Thu Aug 11 17:02:46 2016 +0000
@@ -33,8 +33,8 @@
  * @bug 8150173
  * @summary Verifies that a factory which inherit its createContext method
  *          from an abstract subclass of JAXBContextFactory can be instantiated.
- * @compile -addmods java.xml.bind JAXBContextWithAbstractFactory.java
- * @run main/othervm -addmods java.xml.bind JAXBContextWithAbstractFactory
+ * @modules java.xml.bind
+ * @run main/othervm JAXBContextWithAbstractFactory
  */
 public class JAXBContextWithAbstractFactory {
     private static JAXBContext tmp;
--- a/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithLegacyFactory.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithLegacyFactory.java	Thu Aug 11 17:02:46 2016 +0000
@@ -35,8 +35,8 @@
  * @bug 8150173
  * @summary Verifies that a JAXBContext can be created with a legacy
  *          factory class that has static createContext methods.
- * @compile -addmods java.xml.bind JAXBContextWithLegacyFactory.java
- * @run main/othervm -addmods java.xml.bind JAXBContextWithLegacyFactory
+ * @modules java.xml.bind
+ * @run main/othervm JAXBContextWithLegacyFactory
  */
 public class JAXBContextWithLegacyFactory {
     private static JAXBContext tmp;
--- a/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithSubclassedFactory.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/xml/bind/JAXBContext/JAXBContextWithSubclassedFactory.java	Thu Aug 11 17:02:46 2016 +0000
@@ -36,8 +36,8 @@
  * @bug 8150173
  * @summary Verifies that a factory which inherit its createContext method
  *          from a concrete subclass of JAXBContextFactory is be instantiated.
- * @compile -addmods java.xml.bind JAXBContextWithSubclassedFactory.java
- * @run main/othervm -addmods java.xml.bind JAXBContextWithSubclassedFactory
+ * @modules java.xml.bind
+ * @run main/othervm JAXBContextWithSubclassedFactory
  */
 public class JAXBContextWithSubclassedFactory {
     static JAXBContext tmp;
--- a/jdk/test/javax/xml/bind/jxc/8073872/SchemagenStackOverflow.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/xml/bind/jxc/8073872/SchemagenStackOverflow.java	Thu Aug 11 17:02:46 2016 +0000
@@ -26,9 +26,8 @@
  * @bug 8073872
  * @summary test that stackoverflow is not observable when element
  *          references containing class
- * @modules java.xml
  * @modules java.xml.bind
- * @compile Foo.java
+ * @compile SchemagenStackOverflow.java Foo.java
  * @run testng/othervm SchemagenStackOverflow
  */
 
--- a/jdk/test/javax/xml/bind/marshal/8134111/UnmarshalTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/xml/bind/marshal/8134111/UnmarshalTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -26,9 +26,10 @@
  * @bug 8134111
  * @summary test that elements without namespace is ignored by unmarshaller
  *          when elementFormDefault is set to QUALIFIED.
- * @compile testTypes/package-info.java testTypes/Root.java
+ * @modules java.xml.bind
+ * @compile UnmarshalTest.java
+ *          testTypes/package-info.java testTypes/Root.java
  *          testTypes/WhenType.java testTypes/ObjectFactory.java
- * @modules java.xml.bind
  * @run testng/othervm UnmarshalTest
  */
 
--- a/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -100,7 +100,7 @@
     // Compile java classes with javac tool
     void compileXjcGeneratedClasses() throws Exception {
         JDKToolLauncher javacLauncher = JDKToolLauncher.createUsingTestJDK("javac");
-        javacLauncher.addToolArg("-addmods");
+        javacLauncher.addToolArg("--add-modules");
         javacLauncher.addToolArg("java.xml.bind");
         javacLauncher.addToolArg(xjcResultDir.resolve("Foo.java").toString());
         System.out.println("Compiling xjc generated class: " + Arrays.asList(javacLauncher.getCommand()));
--- a/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -127,7 +127,7 @@
     // Compile java classes with javac tool
     void compileXjcGeneratedClasses() throws Exception {
         JDKToolLauncher javacLauncher = JDKToolLauncher.createUsingTestJDK("javac");
-        javacLauncher.addToolArg("-addmods");
+        javacLauncher.addToolArg("--add-modules");
         javacLauncher.addToolArg("java.xml.bind");
         javacLauncher.addToolArg(xjcResultDir.resolve("ObjectFactory.java").toString());
         javacLauncher.addToolArg(xjcResultDir.resolve("TypesLongList.java").toString());
--- a/jdk/test/javax/xml/jaxp/common/8035437/run.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/xml/jaxp/common/8035437/run.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -34,12 +34,12 @@
    -d compile/java.xml -Xmodule:java.xml $TESTSRC/Document.java $TESTSRC/Node.java || exit 1
 
 $COMPILEJAVA/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
-   -d exec/java.xml -Xpatch:java.xml=compile/java.xml -Xmodule:java.xml $TESTSRC/DocumentImpl.java || exit 2
+   -d exec/java.xml --patch-module java.xml=compile/java.xml -Xmodule:java.xml $TESTSRC/DocumentImpl.java || exit 2
 
 $COMPILEJAVA/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
    $TESTSRC/AbstractMethodErrorTest.java -d exec || exit 3
 
-$TESTJAVA/bin/java ${TESTVMOPTS} -Xpatch:java.xml=exec -cp exec AbstractMethodErrorTest || exit 4
+$TESTJAVA/bin/java ${TESTVMOPTS} --patch-module java.xml=exec -cp exec AbstractMethodErrorTest || exit 4
 
 exit 0
 
--- a/jdk/test/javax/xml/soap/XmlTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/xml/soap/XmlTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -38,8 +38,8 @@
 
 /*
  * @test
- * @compile -addmods java.xml.ws XmlTest.java
- * @run main/othervm -addmods java.xml.ws XmlTest
+ * @modules java.xml.ws
+ * @run main XmlTest
  * @summary tests JAF DataHandler can be instantiated; test serialize and
  *   deserialize SOAP message containing xml attachment
  */
--- a/jdk/test/javax/xml/soap/spi/SAAJFactoryTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/xml/soap/spi/SAAJFactoryTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -50,28 +50,28 @@
  *      scenario14 javax.xml.soap.MessageFactory=saaj.factory.Valid saaj.factory.Valid2 -
  *
  * @modules java.xml.ws
- * @compile -addmods java.xml.ws saaj/factory/Invalid.java saaj/factory/Valid.java
+ * @compile saaj/factory/Invalid.java saaj/factory/Valid.java
  *     saaj/factory/Valid2.java saaj/factory/Valid3.java SAAJFactoryTest.java
  *
- * @run main/othervm -addmods java.xml.ws
+ * @run main/othervm
  *      SAAJFactoryTest com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl - scenario2 - -
- * @run main/othervm -addmods java.xml.ws -Djavax.xml.soap.MessageFactory=saaj.factory.Valid
+ * @run main/othervm -Djavax.xml.soap.MessageFactory=saaj.factory.Valid
  *      SAAJFactoryTest saaj.factory.Valid - scenario5 - -
- * @run main/othervm -addmods java.xml.ws -Djavax.xml.soap.MessageFactory=saaj.factory.NonExisting
+ * @run main/othervm -Djavax.xml.soap.MessageFactory=saaj.factory.NonExisting
  *      SAAJFactoryTest - javax.xml.soap.SOAPException scenario6 - -
- * @run main/othervm -addmods java.xml.ws -Djavax.xml.soap.MessageFactory=saaj.factory.Invalid
+ * @run main/othervm -Djavax.xml.soap.MessageFactory=saaj.factory.Invalid
  *      SAAJFactoryTest - javax.xml.soap.SOAPException scenario7 - -
- * @run main/othervm  -addmods java.xml.ws
+ * @run main/othervm
  *      SAAJFactoryTest saaj.factory.Valid - scenario8 - saaj.factory.Valid
- * @run main/othervm -addmods java.xml.ws
+ * @run main/othervm
  *      SAAJFactoryTest saaj.factory.Valid - scenario9 - saaj.factory.Valid
- * @run main/othervm -addmods java.xml.ws
+ * @run main/othervm
  *      SAAJFactoryTest - javax.xml.soap.SOAPException scenario10 - saaj.factory.NonExisting
- * @run main/othervm -addmods java.xml.ws
+ * @run main/othervm
  *      SAAJFactoryTest - javax.xml.soap.SOAPException scenario11 - saaj.factory.Invalid scenario11 - saaj.factory.Invalid
- * @run main/othervm  -addmods java.xml.ws
+ * @run main/othervm
  *      SAAJFactoryTest com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl - scenario12 - -
- * @run main/othervm -addmods java.xml.ws
+ * @run main/othervm
  *      SAAJFactoryTest saaj.factory.Valid - scenario15 - saaj.factory.Valid
  */
 public class SAAJFactoryTest {
@@ -207,4 +207,3 @@
     }
 
 }
-
--- a/jdk/test/javax/xml/ws/8043129/MailTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/xml/ws/8043129/MailTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -28,8 +28,7 @@
  * @author mkos
  * @library javax.mail.jar
  * @modules java.xml.ws
- * @compile -addmods java.xml.ws MailTest.java
- * @run main/othervm -addmods java.xml.ws MailTest
+ * @run main MailTest
  */
 
 import javax.activation.CommandMap;
--- a/jdk/test/javax/xml/ws/clientjar/TestWsImport.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/xml/ws/clientjar/TestWsImport.java	Thu Aug 11 17:02:46 2016 +0000
@@ -25,8 +25,8 @@
  * @test
  * @bug 8016271 8026405
  * @summary wsimport -clientjar does not create portable jar on windows due to hardcoded '\'
- * @compile -addmods java.xml.ws TestWsImport.java
- * @run main/othervm -addmods java.xml.ws TestWsImport
+ * @modules java.xml.ws
+ * @run main TestWsImport
  */
 
 import javax.xml.namespace.QName;
--- a/jdk/test/javax/xml/ws/publish/WSTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/xml/ws/publish/WSTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -26,8 +26,7 @@
  * @bug 8146086
  * @summary Publishing two webservices on same port fails with "java.net.BindException: Address already in use"
  * @modules java.xml.ws
- * @compile -addmods java.xml.ws WSTest.java
- * @run main/othervm -addmods java.xml.ws WSTest
+ * @run main/othervm WSTest
  */
 import javax.jws.WebMethod;
 import javax.jws.WebService;
--- a/jdk/test/javax/xml/ws/xsanymixed/Test.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/javax/xml/ws/xsanymixed/Test.java	Thu Aug 11 17:02:46 2016 +0000
@@ -28,8 +28,7 @@
  *          no white space changes and no changes to namespace prefixes
  * @modules java.xml.ws
  * @run shell compile-wsdl.sh
- * @compile -addmods java.xml.ws Test.java
- * @run main/othervm -addmods java.xml.ws Test
+ * @run main/othervm Test
  */
 
 import com.sun.net.httpserver.HttpServer;
--- a/jdk/test/jdk/internal/misc/VM/RuntimeArguments.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/jdk/internal/misc/VM/RuntimeArguments.java	Thu Aug 11 17:02:46 2016 +0000
@@ -26,6 +26,8 @@
  * @summary Basic test of VM::getRuntimeArguments
  * @library /lib/testlibrary
  * @modules java.base/jdk.internal.misc
+ *          java.compact3
+ *          jdk.zipfs
  * @run testng RuntimeArguments
  */
 
@@ -45,21 +47,28 @@
     public Object[][] options() {
         return new Object[][] {
             { // CLI options
-              List.of("-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED",
-                      "-XaddExports:java.base/jdk.internal.perf=ALL-UNNAMED",
-                      "-addmods", "jdk.zipfs"),
+              List.of("--add-exports",
+                      "java.base/jdk.internal.misc=ALL-UNNAMED",
+                      "--add-exports",
+                      "java.base/jdk.internal.perf=ALL-UNNAMED",
+                      "--add-modules",
+                      "jdk.zipfs"),
               // expected runtime arguments
-              List.of("-Djdk.launcher.addexports.0=java.base/jdk.internal.misc=ALL-UNNAMED",
-                      "-Djdk.launcher.addexports.1=java.base/jdk.internal.perf=ALL-UNNAMED",
-                      "-Djdk.launcher.addmods=jdk.zipfs")
+              List.of("--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
+                      "--add-exports=java.base/jdk.internal.perf=ALL-UNNAMED",
+                      "--add-modules=jdk.zipfs")
             },
             { // CLI options
-              List.of("-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED",
-                      "-addmods", "jdk.zipfs",
-                      "-limitmods", "java.compact3"),
+              List.of("--add-exports",
+                      "java.base/jdk.internal.misc=ALL-UNNAMED",
+                      "--add-modules",
+                      "jdk.zipfs",
+                      "--limit-modules",
+                      "java.compact3"),
               // expected runtime arguments
-              List.of("-Djdk.launcher.addexports.0=java.base/jdk.internal.misc=ALL-UNNAMED",
-                      "-Djdk.launcher.addmods=jdk.zipfs", "-Djdk.launcher.limitmods=java.compact3")
+              List.of("--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
+                      "--add-modules=jdk.zipfs",
+                      "--limit-modules=java.compact3"),
             },
         };
     };
--- a/jdk/test/jdk/internal/reflect/Reflection/GetCallerClassTest.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/jdk/internal/reflect/Reflection/GetCallerClassTest.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -55,7 +55,7 @@
 rm -rf ${BCP}
 mkdir ${BCP}
 
-EXTRAOPTS="-XaddExports:java.base/jdk.internal.reflect=ALL-UNNAMED"
+EXTRAOPTS="--add-exports java.base/jdk.internal.reflect=ALL-UNNAMED"
 
 # Compile GetCallerClass in bootclasspath
 ${COMPILEJAVA}/bin/javac ${TESTTOOLVMOPTS} ${EXTRAOPTS} \
--- a/jdk/test/jdk/modules/etc/VerifyModuleDelegation.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/jdk/modules/etc/VerifyModuleDelegation.java	Thu Aug 11 17:02:46 2016 +0000
@@ -26,7 +26,7 @@
  * @summary Verify the defining class loader of each module never delegates
  *          to its child class loader. Also sanity check java.compact2
  *          requires.
- * @run testng/othervm -Djdk.launcher.addmods=ALL-SYSTEM VerifyModuleDelegation
+ * @run testng/othervm --add-modules=ALL-SYSTEM VerifyModuleDelegation
  */
 
 import java.lang.module.ModuleDescriptor;
@@ -51,11 +51,11 @@
 
     private static final ModuleDescriptor COMPACT2
         = new ModuleDescriptor.Builder(JAVA_COMPACT2)
-            .requires(MANDATED, JAVA_BASE)
-            .requires(PUBLIC, JAVA_COMPACT1)
-            .requires(PUBLIC, "java.rmi")
-            .requires(PUBLIC, "java.sql")
-            .requires(PUBLIC, "java.xml")
+            .requires(Set.of(MANDATED), JAVA_BASE)
+            .requires(Set.of(PUBLIC), JAVA_COMPACT1)
+            .requires(Set.of(PUBLIC), "java.rmi")
+            .requires(Set.of(PUBLIC), "java.sql")
+            .requires(Set.of(PUBLIC), "java.xml")
             .build();
 
     private static final Set<ModuleReference> MREFS
--- a/jdk/test/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java	Thu Aug 11 17:02:46 2016 +0000
@@ -100,15 +100,15 @@
         compiled = CompilerUtils
             .compile(SRC_DIR.resolve(testModule),
                     MODS_DIR.resolve(testModule),
-                    "-mp", MODS_DIR.toString());
+                    "--module-path", MODS_DIR.toString());
         assertTrue(compiled);
 
 
-        // launch the test. Need -addmods because nothing explicitly depends on logging
+        // launch the test. Need --add-mdoules because nothing explicitly depends on logging
 
         int exitValue
-            = executeTestJava("-mp", MODS_DIR.toString(),
-                              "-addmods", "logging",
+            = executeTestJava("--module-path", MODS_DIR.toString(),
+                              "--add-modules", "logging",
                               "-m", testModule + "/" + mainClass)
                 .outputTo(System.out)
                 .errorTo(System.out)
@@ -159,7 +159,7 @@
         compiled = CompilerUtils
                 .compile(SRC_DIR.resolve(testModule),
                         MODS_DIR.resolve(testModule),
-                        "-mp", MODS_DIR.toString());
+                        "--module-path", MODS_DIR.toString());
 
         assertTrue(compiled);
 
@@ -167,7 +167,7 @@
         // launch the test
 
         int exitValue
-            = executeTestJava("-mp", MODS_DIR.toString(),
+            = executeTestJava("--module-path", MODS_DIR.toString(),
                               "-m", testModule + "/" + mainClass)
                 .outputTo(System.out)
                 .errorTo(System.out)
--- a/jdk/test/jdk/modules/scenarios/container/ContainerTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/jdk/modules/scenarios/container/ContainerTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -98,7 +98,7 @@
 
         compiled = CompilerUtils.compile(SRC_DIR.resolve("app1"),
                                          dir.resolve("app1"),
-                                         "-upgrademodulepath", dir.toString());
+                                         "--upgrade-module-path", dir.toString());
         assertTrue(compiled);
     }
 
@@ -116,7 +116,7 @@
 
         compiled = CompilerUtils.compile(SRC_DIR.resolve("app2"),
                                          dir.resolve("app2"),
-                                         "-mp", dir.toString());
+                                         "--module-path", dir.toString());
         assertTrue(compiled);
     }
 
@@ -134,7 +134,7 @@
     public void testContainer() throws Exception {
 
         int exitValue
-            = executeTestJava("-mp", MLIB_DIR.toString(),
+            = executeTestJava("--module-path", MLIB_DIR.toString(),
                               "-m", CONTAINER_MODULE)
                 .outputTo(System.out)
                 .errorTo(System.err)
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -74,7 +74,7 @@
      */
     public void testNoOverlappingPackages() throws Exception {
         int exitValue
-            = executeTestJava("-mp", MODS_DIR.toString(),
+            = executeTestJava("--module-path", MODS_DIR.toString(),
                               "-m", "test/test.Main")
                 .outputTo(System.out)
                 .errorTo(System.err)
@@ -85,13 +85,13 @@
 
 
     /**
-     * Run the test with "-addmods misc", the misc module has package
+     * Run the test with "--add-modules misc", the misc module has package
      * jdk.internal.misc and so should overlap with the base module.
      */
     public void testOverlapWithBaseModule() throws Exception {
         int exitValue
-            = executeTestJava("-mp", MODS_DIR.toString(),
-                              "-addmods", "misc",
+            = executeTestJava("--module-path", MODS_DIR.toString(),
+                              "-add-modules", "misc",
                               "-m", "test/test.Main")
                 .outputTo(System.out)
                 .errorTo(System.err)
@@ -101,12 +101,12 @@
     }
 
     /**
-     * Run the test with "-addmods m1,m2". Both modules have package p.
+     * Run the test with "--add-modules m1,m2". Both modules have package p.
      */
     public void testOverlap() throws Exception {
         int exitValue
-            = executeTestJava("-mp", MODS_DIR.toString(),
-                              "-addmods", "m1,m2",
+            = executeTestJava("--module-path", MODS_DIR.toString(),
+                              "--add-modules", "m1,m2",
                               "-m", "test/test.Main")
                 .outputTo(System.out)
                 .errorTo(System.err)
--- a/jdk/test/sun/awt/shell/ShellFolderMemoryLeak.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/awt/shell/ShellFolderMemoryLeak.java	Thu Aug 11 17:02:46 2016 +0000
@@ -93,7 +93,7 @@
         String command = javaPath + File.separator + "bin" + File.separator
                 + "java -Xmx256M" + arg1 + " -cp "
                 + classPathDir
-                + " -XaddExports:java.desktop/sun.awt.shell=ALL-UNNAMED"
+                + " --add-exports=java.desktop/sun.awt.shell=ALL-UNNAMED"
                 + " ShellFolderMemoryLeak " + arg2;
         process = Runtime.getRuntime().exec(command);
         BufferedReader input = null;
--- a/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -150,7 +150,7 @@
             ProcessBuilder client = ProcessTools.createJavaProcessBuilder(
                 "-cp",
                 TEST_CLASSPATH,
-                "-XaddExports:java.management/sun.management=ALL-UNNAMED",
+                "--add-exports", "java.management/sun.management=ALL-UNNAMED",
                 "TestManager",
                 String.valueOf(serverPrc.getPid()),
                 port.get(),
--- a/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -131,7 +131,7 @@
             ProcessBuilder client = ProcessTools.createJavaProcessBuilder(
                 "-cp",
                 TEST_CLASSPATH,
-                "-XaddExports:java.management/sun.management=ALL-UNNAMED",
+                "--add-exports", "java.management/sun.management=ALL-UNNAMED",
                 "TestManager",
                 String.valueOf(serverPrc.getPid()),
                 port.get(),
--- a/jdk/test/sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -51,8 +51,8 @@
 DEBUGOPTIONS=""
 export DEBUGOPTIONS
 
-EXTRAOPTIONS="-XaddExports:java.management/sun.management=ALL-UNNAMED \
- -XaddExports:java.management/sun.management.jmxremote=ALL-UNNAMED"
+EXTRAOPTIONS="--add-exports java.management/sun.management=ALL-UNNAMED \
+ --add-exports java.management/sun.management.jmxremote=ALL-UNNAMED"
 export EXTRAOPTIONS
 
 # Call the common generic test
--- a/jdk/test/sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -49,8 +49,8 @@
 DEBUGOPTIONS=""
 export DEBUGOPTIONS
 
-EXTRAOPTIONS="-XaddExports:java.management/sun.management=ALL-UNNAMED \
- -XaddExports:java.management/sun.management.jmxremote=ALL-UNNAMED"
+EXTRAOPTIONS="--add-exports java.management/sun.management=ALL-UNNAMED \
+ --add-exports java.management/sun.management.jmxremote=ALL-UNNAMED"
 export EXTRAOPTIONS
 
 # Call the common generic test
--- a/jdk/test/sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -48,8 +48,8 @@
 DEBUGOPTIONS=""
 export DEBUGOPTIONS
 
-EXTRAOPTIONS="-XaddExports:java.management/sun.management=ALL-UNNAMED \
- -XaddExports:java.management/sun.management.jmxremote=ALL-UNNAMED"
+EXTRAOPTIONS="--add-exports java.management/sun.management=ALL-UNNAMED \
+ --add-exports java.management/sun.management.jmxremote=ALL-UNNAMED"
 export EXTRAOPTIONS
 
 # Call the common generic test
--- a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -51,7 +51,7 @@
     ;;
 esac
 
-EXTRAOPTS="-XaddExports:java.base/sun.net.www=ALL-UNNAMED"
+EXTRAOPTS="--add-exports java.base/sun.net.www=ALL-UNNAMED"
 
 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} -d . \
     ${TESTSRC}${FS}OriginServer.java \
--- a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -51,7 +51,7 @@
     ;;
 esac
 
-EXTRAOPTS="-XaddExports:java.base/sun.net.www=ALL-UNNAMED"
+EXTRAOPTS="--add-exports java.base/sun.net.www=ALL-UNNAMED"
 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} ${EXTRAOPTS} \
     -d . ${TESTSRC}${FS}OriginServer.java \
     ${TESTSRC}${FS}ProxyTunnelServer.java \
--- a/jdk/test/sun/net/www/protocol/jrt/OtherResources.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/net/www/protocol/jrt/OtherResources.java	Thu Aug 11 17:02:46 2016 +0000
@@ -36,7 +36,7 @@
         // check that java.desktop is not in the set of readable modules
         try {
             Class.forName("java.awt.Component");
-            throw new RuntimeException("Need to run with -limitmods java.base");
+            throw new RuntimeException("Need to run with --limit-modules java.base");
         } catch (ClassNotFoundException expected) { }
 
         // access resource in the java.desktop module
--- a/jdk/test/sun/net/www/protocol/jrt/other_resources.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/net/www/protocol/jrt/other_resources.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -26,7 +26,7 @@
 # @run shell other_resources.sh
 # @summary Access a jrt:/ resource in an observable module that is not in
 #  the boot layer and hence not known to the built-in class loaders. This
-#  test is a shell test because the run tag doesn't support -limitmods.
+#  test is a shell test because the run tag doesn't support --limit-modules.
 
 set -e
 
@@ -39,7 +39,7 @@
 fi
 
 JAVA="$TESTJAVA/bin/java ${TESTVMOPTS}"
-$JAVA -limitmods java.base -cp $TESTCLASSES OtherResources
+$JAVA --limit-modules java.base -cp $TESTCLASSES OtherResources
 
 exit 0
 
--- a/jdk/test/sun/rmi/rmic/iiopCompilation/IIOPCompilation.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/rmi/rmic/iiopCompilation/IIOPCompilation.java	Thu Aug 11 17:02:46 2016 +0000
@@ -30,8 +30,9 @@
  *          java.rmi/sun.rmi.transport
  *          java.rmi/sun.rmi.transport.tcp
  * @build TestLibrary
+ * @run main IIOPCompilation
+ *
  * @summary Compiles a PortableRemoteObject with rmic -iiop and ensures that stub and tie classes are generated.
- * @run main IIOPCompilation
  * @author Felix Yang
  *
  */
--- a/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java	Thu Aug 11 17:02:46 2016 +0000
@@ -68,10 +68,10 @@
         // (neither on standard output, nor on standard err streams).
         JavaVM vm = new JavaVM(
                 DoRMIStuff.class.getName(),
-                "-XaddExports:java.rmi/sun.rmi.registry=ALL-UNNAMED"
-                + " -XaddExports:java.rmi/sun.rmi.server=ALL-UNNAMED"
-                + " -XaddExports:java.rmi/sun.rmi.transport=ALL-UNNAMED"
-                + " -XaddExports:java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED"
+                "--add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED"
+                + " --add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED"
+                + " --add-exports=java.rmi/sun.rmi.transport=ALL-UNNAMED"
+                + " --add-exports=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED"
                 + " -Djava.util.logging.config.file="
                 + loggingPropertiesFile, "", out, err);
         vm.execute();
--- a/jdk/test/sun/security/krb5/ccache/EmptyCC.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/krb5/ccache/EmptyCC.java	Thu Aug 11 17:02:46 2016 +0000
@@ -27,7 +27,8 @@
  * @bug 8001208
  * @summary NPE in sun.security.krb5.Credentials.acquireDefaultCreds()
  * @library ../../../../java/security/testlibrary/
- * @modules java.security.jgss/sun.security.krb5
+ * @modules java.base/jdk.internal.misc
+ *          java.security.jgss/sun.security.krb5
  *          java.security.jgss/sun.security.krb5.internal.ccache
  * @compile -XDignore.symbol.file EmptyCC.java
  * @run main EmptyCC tmpcc
--- a/jdk/test/sun/security/krb5/tools/ktcheck.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/krb5/tools/ktcheck.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -61,8 +61,8 @@
 EXTRA_OPTIONS="-Djava.security.krb5.conf=${TESTSRC}${FS}onlythree.conf"
 KTAB="${TESTJAVA}${FS}bin${FS}ktab -J${EXTRA_OPTIONS} -k $KEYTAB -f"
 CHECK="${TESTJAVA}${FS}bin${FS}java -cp ${TESTCLASSES} ${TESTVMOPTS} ${EXTRA_OPTIONS} \
-        -XaddExports:java.security.jgss/sun.security.krb5.internal.ktab=ALL-UNNAMED \
-        -XaddExports:java.security.jgss/sun.security.krb5=ALL-UNNAMED \
+        --add-exports java.security.jgss/sun.security.krb5.internal.ktab=ALL-UNNAMED \
+        --add-exports java.security.jgss/sun.security.krb5=ALL-UNNAMED \
         KtabCheck $KEYTAB"
 
 echo ${EXTRA_OPTIONS}
--- a/jdk/test/sun/security/mscapi/PublicKeyInterop.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/mscapi/PublicKeyInterop.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -62,9 +62,9 @@
 
         echo
         echo "Running the test..."
-        ${TESTJAVA}/bin/javac -XaddExports:java.base/sun.security.util=ALL-UNNAMED \
+        ${TESTJAVA}/bin/javac --add-exports java.base/sun.security.util=ALL-UNNAMED \
             ${TESTTOOLVMOPTS} ${TESTJAVACOPTS} -d . ${TESTSRC}\\PublicKeyInterop.java
-        ${TESTJAVA}/bin/java -XaddExports:java.base/sun.security.util=ALL-UNNAMED \
+        ${TESTJAVA}/bin/java --add-exports java.base/sun.security.util=ALL-UNNAMED \
             ${TESTVMOPTS} PublicKeyInterop
 
         rc=$?
--- a/jdk/test/sun/security/mscapi/ShortRSAKey1024.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/mscapi/ShortRSAKey1024.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -88,10 +88,10 @@
 
         echo
         echo "Running the test..."
-        ${TESTJAVA}${FS}bin${FS}javac -XaddExports:java.base/sun.security.util=ALL-UNNAMED \
+        ${TESTJAVA}${FS}bin${FS}javac --add-exports java.base/sun.security.util=ALL-UNNAMED \
             ${TESTTOOLVMOPTS} ${TESTJAVACOPTS} -d . \
             ${TESTSRC}${FS}ShortRSAKeyWithinTLS.java
-        ${TESTJAVA}${FS}bin${FS}java -XaddExports:java.base/sun.security.util=ALL-UNNAMED \
+        ${TESTJAVA}${FS}bin${FS}java --add-exports java.base/sun.security.util=ALL-UNNAMED \
             ${TESTVMOPTS} ShortRSAKeyWithinTLS 7106773.$BITS $BITS \
             TLSv1.2 TLS_DHE_RSA_WITH_AES_128_CBC_SHA
 
--- a/jdk/test/sun/security/provider/PolicyFile/Modules.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/provider/PolicyFile/Modules.java	Thu Aug 11 17:02:46 2016 +0000
@@ -33,14 +33,14 @@
  *          java.sql
  *          java.xml
  *          java.xml.bind
+ *          java.xml.ws
  *          jdk.attach
  *          jdk.jdi
  *          jdk.net
  *          jdk.security.auth
  *          jdk.security.jgss
- * @compile -addmods java.xml.ws,java.smartcardio Modules.java
- * @run main/othervm/java.security.policy==modules.policy
- *     -addmods java.xml.ws,java.smartcardio Modules
+ * @compile --add-modules=java.xml.ws,java.smartcardio Modules.java
+ * @run main/othervm/java.security.policy==modules.policy Modules
  */
 
 import java.security.AccessController;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/StatusStapling/RunStatReqSelect.java	Thu Aug 11 17:02:46 2016 +0000
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8132943
+ * @library ../../../../java/security/testlibrary
+ * @build CertificateBuilder SimpleOCSPServer
+ * @run main/othervm java.base/sun.security.ssl.StatusReqSelection
+ * @summary ServerHandshaker may select non-empty OCSPStatusRequest
+ *          structures when Responder ID selection is not supported
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/StatusStapling/java.base/sun/security/ssl/StatusReqSelection.java	Thu Aug 11 17:02:46 2016 +0000
@@ -0,0 +1,899 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+
+// See ../../../../RunStatReqSelect.java for the jtreg header
+
+package sun.security.ssl;
+
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+import javax.security.auth.x500.X500Principal;
+import java.io.*;
+import java.math.BigInteger;
+import java.security.*;
+import java.nio.*;
+import java.security.cert.X509Certificate;
+import java.security.cert.Extension;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+import sun.security.provider.certpath.OCSPNonceExtension;
+import sun.security.provider.certpath.ResponderId;
+import sun.security.testlibrary.SimpleOCSPServer;
+import sun.security.testlibrary.CertificateBuilder;
+
+public class StatusReqSelection {
+
+    /*
+     * Enables logging of the SSLEngine operations.
+     */
+    private static final boolean logging = true;
+
+    /*
+     * Enables the JSSE system debugging system property:
+     *
+     *     -Djavax.net.debug=all
+     *
+     * This gives a lot of low-level information about operations underway,
+     * including specific handshake messages, and might be best examined
+     * after gaining some familiarity with this application.
+     */
+    private static final boolean debug = false;
+
+    // The following items are used to set up the keystores.
+    private static final String passwd = "passphrase";
+    private static final String ROOT_ALIAS = "root";
+    private static final String INT_ALIAS = "intermediate";
+    private static final String SSL_ALIAS = "ssl";
+
+    // PKI and server components we will need for this test
+    private static KeyManagerFactory kmf;
+    private static TrustManagerFactory tmf;
+    private static KeyStore rootKeystore;       // Root CA Keystore
+    private static KeyStore intKeystore;        // Intermediate CA Keystore
+    private static KeyStore serverKeystore;     // SSL Server Keystore
+    private static KeyStore trustStore;         // SSL Client trust store
+    private static SimpleOCSPServer rootOcsp;   // Root CA OCSP Responder
+    private static int rootOcspPort;            // Port for root OCSP
+    private static SimpleOCSPServer intOcsp;    // Intermediate CA OCSP server
+    private static int intOcspPort;             // Port for intermediate OCSP
+    private static SSLContext ctxStaple;        // SSLContext for all tests
+
+    // Some useful objects we will need for test purposes
+    private static final SecureRandom RNG = new SecureRandom();
+
+    // We'll be using these objects repeatedly to make hello messages
+    private static final ProtocolVersion VER_1_0 = ProtocolVersion.TLS10;
+    private static final ProtocolVersion VER_1_2 = ProtocolVersion.TLS12;
+    private static final CipherSuiteList SUITES = new CipherSuiteList(
+            CipherSuite.valueOf("TLS_RSA_WITH_AES_128_GCM_SHA256"));
+    private static final SessionId SID = new SessionId(new byte[0]);
+    private static final HelloExtension RNIEXT =
+            new RenegotiationInfoExtension(new byte[0], new byte[0]);
+    private static final List<SignatureAndHashAlgorithm> algList =
+            new ArrayList<SignatureAndHashAlgorithm>() {{
+               add(SignatureAndHashAlgorithm.valueOf(4, 1, 0));
+            }};         // List with only SHA256withRSA
+    private static final SignatureAlgorithmsExtension SIGALGEXT =
+            new SignatureAlgorithmsExtension(algList);
+
+    /*
+     * Main entry point for this test.
+     */
+    public static void main(String args[]) throws Exception {
+        int testsPassed = 0;
+
+        if (debug) {
+            System.setProperty("javax.net.debug", "ssl");
+        }
+
+        // All tests will have stapling enabled on the server side
+        System.setProperty("jdk.tls.server.enableStatusRequestExtension",
+                "true");
+
+        // Create a single SSLContext that we can use for all tests
+        ctxStaple = SSLContext.getInstance("TLS");
+
+        // Create the PKI we will use for the test and start the OCSP servers
+        createPKI();
+
+        // Set up the KeyManagerFactory and TrustManagerFactory
+        kmf = KeyManagerFactory.getInstance("PKIX");
+        kmf.init(serverKeystore, passwd.toCharArray());
+        tmf = TrustManagerFactory.getInstance("PKIX");
+        tmf.init(trustStore);
+
+        List<TestCase> testList = new ArrayList<TestCase>() {{
+            add(new TestCase("ClientHello: No stapling extensions",
+                    makeHelloNoStaplingExts(), false, false));
+            add(new TestCase("ClientHello: Default status_request only",
+                    makeDefaultStatReqOnly(), true, false));
+            add(new TestCase("ClientHello: Default status_request_v2 only",
+                    makeDefaultStatReqV2Only(), false, true));
+            add(new TestCase("ClientHello: Both status_request exts, default",
+                    makeDefaultStatReqBoth(), false, true));
+            add(new TestCase(
+                    "ClientHello: Hello with status_request and responder IDs",
+                    makeStatReqWithRid(), false, false));
+            add(new TestCase(
+                    "ClientHello: Hello with status_request using no " +
+                    "responder IDs but provides the OCSP nonce extension",
+                    makeStatReqNoRidNonce(), true, false));
+            add(new TestCase("ClientHello with default status_request and " +
+                    "status_request_v2 with ResponderIds",
+                    makeStatReqDefV2WithRid(), true, false));
+            add(new TestCase("ClientHello with default status_request and " +
+                    "status_request_v2 (OCSP_MULTI with ResponderId, " +
+                    "OCSP as a default request)",
+                    makeStatReqDefV2MultiWithRidSingleDef(), false, true));
+            add(new TestCase("ClientHello with status_request and " +
+                    "status_request_v2 and all OCSPStatusRequests use " +
+                    "Responder IDs",
+                    makeStatReqAllWithRid(), false, false));
+            add(new TestCase("ClientHello with default status_request and " +
+                    "status_request_v2 that has a default OCSP item and " +
+                    "multiple OCSP_MULTI items, only one is default",
+                    makeHelloMultiV2andSingle(), false, true));
+        }};
+
+        // Run the client and server property tests
+        for (TestCase test : testList) {
+            try {
+                log("*** Test: " + test.testName);
+                if (runTest(test)) {
+                    log("PASS: status_request: " + test.statReqEnabled +
+                            ", status_request_v2: " + test.statReqV2Enabled);
+                    testsPassed++;
+                }
+            } catch (Exception e) {
+                // If we get an exception, we'll count it as a failure
+                log("Test failure due to exception: " + e);
+            }
+            log("");
+        }
+
+        // Summary
+        if (testsPassed != testList.size()) {
+            throw new RuntimeException(testList.size() - testsPassed +
+                    " tests failed out of " + testList.size() + " total.");
+        } else {
+            log("Total tests: " + testList.size() + ", all passed");
+        }
+    }
+
+    private static boolean runTest(TestCase test) throws Exception {
+        SSLEngineResult serverResult;
+
+        // Create a Server SSLEngine to receive our customized ClientHello
+        ctxStaple.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+        SSLEngine engine = ctxStaple.createSSLEngine();
+        engine.setUseClientMode(false);
+        engine.setNeedClientAuth(false);
+
+        SSLSession session = engine.getSession();
+        ByteBuffer serverOut = ByteBuffer.wrap("I'm a Server".getBytes());
+        ByteBuffer serverIn =
+                ByteBuffer.allocate(session.getApplicationBufferSize() + 50);
+        ByteBuffer sTOc =
+                ByteBuffer.allocateDirect(session.getPacketBufferSize());
+
+        // Send the ClientHello ByteBuffer in the test case
+        if (debug) {
+            System.out.println("Sending Client Hello:\n" +
+                    dumpHexBytes(test.data));
+        }
+
+        // Consume the client hello
+        serverResult = engine.unwrap(test.data, serverIn);
+        if (debug) {
+            log("server unwrap: ", serverResult);
+        }
+        if (serverResult.getStatus() != SSLEngineResult.Status.OK) {
+            throw new SSLException("Server unwrap got status: " +
+                    serverResult.getStatus());
+        } else if (serverResult.getHandshakeStatus() !=
+                SSLEngineResult.HandshakeStatus.NEED_TASK) {
+             throw new SSLException("Server unwrap expected NEED_TASK, got: " +
+                    serverResult.getHandshakeStatus());
+        }
+        runDelegatedTasks(serverResult, engine);
+        if (engine.getHandshakeStatus() !=
+                SSLEngineResult.HandshakeStatus.NEED_WRAP) {
+            throw new SSLException("Expected NEED_WRAP, got: " +
+                    engine.getHandshakeStatus());
+        }
+
+        // Generate a TLS record with the ServerHello
+        serverResult = engine.wrap(serverOut, sTOc);
+        if (debug) {
+            log("client wrap: ", serverResult);
+        }
+        if (serverResult.getStatus() != SSLEngineResult.Status.OK) {
+            throw new SSLException("Client wrap got status: " +
+                    serverResult.getStatus());
+        }
+        sTOc.flip();
+
+        if (debug) {
+            log("Server Response:\n" + dumpHexBytes(sTOc));
+        }
+
+        return checkServerHello(sTOc, test.statReqEnabled,
+                test.statReqV2Enabled);
+    }
+
+    /**
+     * Make a TLSv1.2 ClientHello with only RNI and no stapling extensions
+     */
+    private static ByteBuffer makeHelloNoStaplingExts() throws IOException {
+        // Craft the ClientHello byte buffer
+        HelloExtensions exts = new HelloExtensions();
+        exts.add(RNIEXT);
+        exts.add(SIGALGEXT);
+        return createTlsRecord(Record.ct_handshake, VER_1_2,
+                createClientHelloMsg(VER_1_2, SID, SUITES, exts));
+    }
+
+    /**
+     * Make a TLSv1.2 ClientHello with the RNI and Status Request extensions
+     */
+    private static ByteBuffer makeDefaultStatReqOnly() throws IOException {
+        // Craft the ClientHello byte buffer
+        HelloExtensions exts = new HelloExtensions();
+        exts.add(RNIEXT);
+        exts.add(SIGALGEXT);
+        exts.add(new CertStatusReqExtension(StatusRequestType.OCSP,
+                new OCSPStatusRequest(null, null)));
+        return createTlsRecord(Record.ct_handshake, VER_1_2,
+                createClientHelloMsg(VER_1_2, SID, SUITES, exts));
+    }
+
+    /**
+     * Make a TLSv1.2 ClientHello with the RNI and Status Request V2 extension
+     */
+    private static ByteBuffer makeDefaultStatReqV2Only() throws IOException {
+        // Craft the ClientHello byte buffer
+        HelloExtensions exts = new HelloExtensions();
+        OCSPStatusRequest osr = new OCSPStatusRequest();
+        List<CertStatusReqItemV2> itemList = new ArrayList<>(2);
+        itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI,
+                osr));
+        itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP, osr));
+
+        exts.add(RNIEXT);
+        exts.add(SIGALGEXT);
+        exts.add(new CertStatusReqListV2Extension(itemList));
+        return createTlsRecord(Record.ct_handshake, VER_1_2,
+                createClientHelloMsg(VER_1_2, SID, SUITES, exts));
+    }
+    /**
+     * Make a TLSv1.2 ClientHello with Status Request and Status Request V2
+     * extensions.
+     */
+    private static ByteBuffer makeDefaultStatReqBoth() throws IOException {
+        // Craft the ClientHello byte buffer
+        HelloExtensions exts = new HelloExtensions();
+        OCSPStatusRequest osr = new OCSPStatusRequest();
+        List<CertStatusReqItemV2> itemList = new ArrayList<>(2);
+        itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI,
+                osr));
+        itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP, osr));
+
+        exts.add(RNIEXT);
+        exts.add(SIGALGEXT);
+        exts.add(new CertStatusReqExtension(StatusRequestType.OCSP,
+                new OCSPStatusRequest(null, null)));
+        exts.add(new CertStatusReqListV2Extension(itemList));
+        return createTlsRecord(Record.ct_handshake, VER_1_2,
+                createClientHelloMsg(VER_1_2, SID, SUITES, exts));
+    }
+
+    /**
+     * Make a ClientHello using a status_request that has a single
+     * responder ID in it.
+     */
+    private static ByteBuffer makeStatReqWithRid() throws IOException {
+        HelloExtensions exts = new HelloExtensions();
+        exts.add(RNIEXT);
+        exts.add(SIGALGEXT);
+        List<ResponderId> rids = new ArrayList<ResponderId>() {{
+            add(new ResponderId(new X500Principal("CN=Foo")));
+        }};
+        exts.add(new CertStatusReqExtension(StatusRequestType.OCSP,
+                new OCSPStatusRequest(rids, null)));
+        return createTlsRecord(Record.ct_handshake, VER_1_2,
+                createClientHelloMsg(VER_1_2, SID, SUITES, exts));
+    }
+
+    /**
+     * Make a ClientHello using a status_request that has no
+     * responder IDs but does provide the nonce extension.
+     */
+    private static ByteBuffer makeStatReqNoRidNonce() throws IOException {
+        HelloExtensions exts = new HelloExtensions();
+        exts.add(RNIEXT);
+        exts.add(SIGALGEXT);
+        List<Extension> ocspExts = new ArrayList<Extension>() {{
+            add(new OCSPNonceExtension(16));
+        }};
+        exts.add(new CertStatusReqExtension(StatusRequestType.OCSP,
+                new OCSPStatusRequest(null, ocspExts)));
+        return createTlsRecord(Record.ct_handshake, VER_1_2,
+                createClientHelloMsg(VER_1_2, SID, SUITES, exts));
+    }
+
+    /**
+     * Make a ClientHello using a default status_request and a
+     * status_request_v2 that has a single responder ID in it.
+     */
+    private static ByteBuffer makeStatReqDefV2WithRid() throws IOException {
+        HelloExtensions exts = new HelloExtensions();
+        List<ResponderId> rids = new ArrayList<ResponderId>() {{
+            add(new ResponderId(new X500Principal("CN=Foo")));
+        }};
+        List<CertStatusReqItemV2> itemList = new ArrayList<>(2);
+        itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI,
+                new OCSPStatusRequest(rids, null)));
+        itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP,
+                new OCSPStatusRequest(rids, null)));
+
+        exts.add(RNIEXT);
+        exts.add(SIGALGEXT);
+        exts.add(new CertStatusReqExtension(StatusRequestType.OCSP,
+                new OCSPStatusRequest(null, null)));
+        exts.add(new CertStatusReqListV2Extension(itemList));
+        return createTlsRecord(Record.ct_handshake, VER_1_2,
+                createClientHelloMsg(VER_1_2, SID, SUITES, exts));
+    }
+
+    /**
+     * Make a ClientHello using a default status_request and a
+     * status_request_v2 that has a single responder ID in it for the
+     * OCSP_MULTI request item and a default OCSP request item.
+     */
+    private static ByteBuffer makeStatReqDefV2MultiWithRidSingleDef()
+            throws IOException {
+        HelloExtensions exts = new HelloExtensions();
+        List<ResponderId> rids = new ArrayList<ResponderId>() {{
+            add(new ResponderId(new X500Principal("CN=Foo")));
+        }};
+        List<CertStatusReqItemV2> itemList = new ArrayList<>(2);
+        itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI,
+                new OCSPStatusRequest(rids, null)));
+        itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP,
+                new OCSPStatusRequest(null, null)));
+
+        exts.add(RNIEXT);
+        exts.add(SIGALGEXT);
+        exts.add(new CertStatusReqExtension(StatusRequestType.OCSP,
+                new OCSPStatusRequest(null, null)));
+        exts.add(new CertStatusReqListV2Extension(itemList));
+        return createTlsRecord(Record.ct_handshake, VER_1_2,
+                createClientHelloMsg(VER_1_2, SID, SUITES, exts));
+    }
+
+    /**
+     * Make a ClientHello using status_request and status_request_v2 where
+     * all underlying OCSPStatusRequests use responder IDs.
+     */
+    private static ByteBuffer makeStatReqAllWithRid() throws IOException {
+        HelloExtensions exts = new HelloExtensions();
+        List<ResponderId> rids = new ArrayList<ResponderId>() {{
+            add(new ResponderId(new X500Principal("CN=Foo")));
+        }};
+        List<CertStatusReqItemV2> itemList = new ArrayList<>(2);
+        itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI,
+                new OCSPStatusRequest(rids, null)));
+        itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP,
+                new OCSPStatusRequest(rids, null)));
+
+        exts.add(RNIEXT);
+        exts.add(SIGALGEXT);
+        exts.add(new CertStatusReqExtension(StatusRequestType.OCSP,
+                new OCSPStatusRequest(rids, null)));
+        exts.add(new CertStatusReqListV2Extension(itemList));
+        return createTlsRecord(Record.ct_handshake, VER_1_2,
+                createClientHelloMsg(VER_1_2, SID, SUITES, exts));
+    }
+
+    /**
+     * Make a TLSv1.2 ClientHello multiple CertStatusReqItemV2s of different
+     * types.  One of the middle items should be acceptable while the others
+     * have responder IDs.  The status_request (v1) should also be acceptable
+     * but should be overridden in favor of the status_request_v2.
+     */
+    private static ByteBuffer makeHelloMultiV2andSingle() throws IOException {
+        // Craft the ClientHello byte buffer
+        HelloExtensions exts = new HelloExtensions();
+        List<ResponderId> fooRid = Collections.singletonList(
+                new ResponderId(new X500Principal("CN=Foo")));
+        List<ResponderId> barRid = Collections.singletonList(
+                new ResponderId(new X500Principal("CN=Bar")));
+        List<CertStatusReqItemV2> itemList = new ArrayList<>();
+        itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP,
+                new OCSPStatusRequest(null, null)));
+        itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI,
+                new OCSPStatusRequest(fooRid, null)));
+        itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI,
+                new OCSPStatusRequest(null, null)));
+        itemList.add(new CertStatusReqItemV2(StatusRequestType.OCSP_MULTI,
+                new OCSPStatusRequest(barRid, null)));
+
+        exts.add(RNIEXT);
+        exts.add(SIGALGEXT);
+        exts.add(new CertStatusReqExtension(StatusRequestType.OCSP,
+                new OCSPStatusRequest(null, null)));
+        exts.add(new CertStatusReqListV2Extension(itemList));
+        return createTlsRecord(Record.ct_handshake, VER_1_2,
+                createClientHelloMsg(VER_1_2, SID, SUITES, exts));
+    }
+
+    /**
+     * Wrap a TLS content message into a TLS record header
+     *
+     * @param contentType a byte containing the content type value
+     * @param pv the protocol version for this record
+     * @param data a byte buffer containing the message data
+     * @return
+     */
+    private static ByteBuffer createTlsRecord(byte contentType,
+            ProtocolVersion pv, ByteBuffer data) {
+        int msgLen = (data != null) ? data.limit() : 0;
+
+        // Allocate enough space to hold the TLS record header + the message
+        ByteBuffer recordBuf = ByteBuffer.allocate(msgLen + 5);
+        recordBuf.put(contentType);
+        recordBuf.putShort((short)pv.v);
+        recordBuf.putShort((short)msgLen);
+        if (msgLen > 0) {
+            recordBuf.put(data);
+        }
+
+        recordBuf.flip();
+        return recordBuf;
+    }
+
+    /**
+     * Craft and encode a ClientHello message as a byte array.
+     *
+     * @param pv the protocol version asserted in the hello message.
+     * @param sessId the session ID for this hello message.
+     * @param suites a list consisting of one or more cipher suite objects
+     * @param extensions a list of HelloExtension objects
+     *
+     * @return a byte array containing the encoded ClientHello message.
+     */
+    private static ByteBuffer createClientHelloMsg(ProtocolVersion pv,
+            SessionId sessId, CipherSuiteList suites,
+            HelloExtensions extensions) throws IOException {
+        ByteBuffer msgBuf;
+
+        HandshakeOutStream hsos =
+                new HandshakeOutStream(new SSLEngineOutputRecord());
+
+        // Construct the client hello object from the first 3 parameters
+        HandshakeMessage.ClientHello cHello =
+                new HandshakeMessage.ClientHello(RNG, pv, sessId, suites,
+                        false);
+
+        // Use the HelloExtensions provided by the caller
+        if (extensions != null) {
+            cHello.extensions = extensions;
+        }
+
+        cHello.send(hsos);
+        msgBuf = ByteBuffer.allocate(hsos.size() + 4);
+
+        // Combine the handshake type with the length
+        msgBuf.putInt((HandshakeMessage.ht_client_hello << 24) |
+                (hsos.size() & 0x00FFFFFF));
+        msgBuf.put(hsos.toByteArray());
+        msgBuf.flip();
+        return msgBuf;
+    }
+
+    /*
+     * If the result indicates that we have outstanding tasks to do,
+     * go ahead and run them in this thread.
+     */
+    private static void runDelegatedTasks(SSLEngineResult result,
+            SSLEngine engine) throws Exception {
+
+        if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
+            Runnable runnable;
+            while ((runnable = engine.getDelegatedTask()) != null) {
+                if (debug) {
+                    log("\trunning delegated task...");
+                }
+                runnable.run();
+            }
+            HandshakeStatus hsStatus = engine.getHandshakeStatus();
+            if (hsStatus == HandshakeStatus.NEED_TASK) {
+                throw new Exception(
+                    "handshake shouldn't need additional tasks");
+            }
+            if (debug) {
+                log("\tnew HandshakeStatus: " + hsStatus);
+            }
+        }
+    }
+
+    private static void log(String str, SSLEngineResult result) {
+        if (!logging) {
+            return;
+        }
+        HandshakeStatus hsStatus = result.getHandshakeStatus();
+        log(str +
+            result.getStatus() + "/" + hsStatus + ", " +
+            result.bytesConsumed() + "/" + result.bytesProduced() +
+            " bytes");
+        if (hsStatus == HandshakeStatus.FINISHED) {
+            log("\t...ready for application data");
+        }
+    }
+
+    private static void log(String str) {
+        if (logging) {
+            System.out.println(str);
+        }
+    }
+
+    /**
+     * Dump a ByteBuffer as a hexdump to stdout.  The dumping routine will
+     * start at the current position of the buffer and run to its limit.
+     * After completing the dump, the position will be returned to its
+     * starting point.
+     *
+     * @param data the ByteBuffer to dump to stdout.
+     *
+     * @return the hexdump of the byte array.
+     */
+    private static String dumpHexBytes(ByteBuffer data) {
+        StringBuilder sb = new StringBuilder();
+        if (data != null) {
+            int i = 0;
+            data.mark();
+            while (data.hasRemaining()) {
+                if (i % 16 == 0 && i != 0) {
+                    sb.append("\n");
+                }
+                sb.append(String.format("%02X ", data.get()));
+                i++;
+            }
+            data.reset();
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * Tests the ServerHello for the presence (or not) of the status_request
+     * or status_request_v2 hello extension.  It is assumed that the provided
+     * ByteBuffer has its position set at the first byte of the TLS record
+     * containing the ServerHello and contains the entire hello message.  Upon
+     * successful completion of this method the ByteBuffer will have its
+     * position reset to the initial offset in the buffer.  If an exception is
+     * thrown the position at the time of the exception will be preserved.
+     *
+     * @param statReqPresent true if the status_request hello extension should
+     * be present.
+     * @param statReqV2Present true if the status_request_v2 hello extension
+     * should be present.
+     *
+     * @return true if the ServerHello's extension set matches the presence
+     *      booleans for status_request and status_request_v2.  False if
+     *      not, or if the TLS record or message is of the wrong type.
+     */
+    private static boolean checkServerHello(ByteBuffer data,
+            boolean statReqPresent, boolean statReqV2Present) {
+        boolean hasV1 = false;
+        boolean hasV2 = false;
+        Objects.requireNonNull(data);
+        int startPos = data.position();
+        data.mark();
+
+        // Process the TLS record header
+        int type = Byte.toUnsignedInt(data.get());
+        int ver_major = Byte.toUnsignedInt(data.get());
+        int ver_minor = Byte.toUnsignedInt(data.get());
+        int recLen = Short.toUnsignedInt(data.getShort());
+
+        // Simple sanity checks
+        if (type != 22) {
+            log("Not a handshake: Type = " + type);
+            return false;
+        } else if (recLen > data.remaining()) {
+            log("Incomplete record in buffer: Record length = " + recLen +
+                    ", Remaining = " + data.remaining());
+            return false;
+        }
+
+        // Grab the handshake message header.
+        int msgHdr = data.getInt();
+        int msgType = (msgHdr >> 24) & 0x000000FF;
+        int msgLen = msgHdr & 0x00FFFFFF;
+
+        // More simple sanity checks
+        if (msgType != 2) {
+            log("Not a ServerHello: Type = " + msgType);
+            return false;
+        }
+
+        // Skip over the protocol version and server random
+        data.position(data.position() + 34);
+
+        // Jump past the session ID
+        int sessLen = Byte.toUnsignedInt(data.get());
+        if (sessLen != 0) {
+            data.position(data.position() + sessLen);
+        }
+
+        // Skip the cipher suite and compression method
+        data.position(data.position() + 3);
+
+        // Go through the extensions and look for the request extension
+        // expected by the caller.
+        int extsLen = Short.toUnsignedInt(data.getShort());
+        while (data.position() < recLen + startPos + 5) {
+            int extType = Short.toUnsignedInt(data.getShort());
+            int extLen = Short.toUnsignedInt(data.getShort());
+            hasV1 |= (extType == ExtensionType.EXT_STATUS_REQUEST.id);
+            hasV2 |= (extType == ExtensionType.EXT_STATUS_REQUEST_V2.id);
+            data.position(data.position() + extLen);
+        }
+
+        if (hasV1 != statReqPresent) {
+            log("The status_request extension is " +
+                    "inconsistent with the expected result: expected = " +
+                    statReqPresent + ", actual = " + hasV1);
+        }
+        if (hasV2 != statReqV2Present) {
+            log("The status_request_v2 extension is " +
+                    "inconsistent with the expected result: expected = " +
+                    statReqV2Present + ", actual = " + hasV2);
+        }
+
+        // Reset the position to the initial spot at the start of this method.
+        data.reset();
+
+        return ((hasV1 == statReqPresent) && (hasV2 == statReqV2Present));
+    }
+
+    /**
+     * Creates the PKI components necessary for this test, including
+     * Root CA, Intermediate CA and SSL server certificates, the keystores
+     * for each entity, a client trust store, and starts the OCSP responders.
+     */
+    private static void createPKI() throws Exception {
+        CertificateBuilder cbld = new CertificateBuilder();
+        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
+        keyGen.initialize(2048);
+        KeyStore.Builder keyStoreBuilder =
+                KeyStore.Builder.newInstance("PKCS12", null,
+                        new KeyStore.PasswordProtection(passwd.toCharArray()));
+
+        // Generate Root, IntCA, EE keys
+        KeyPair rootCaKP = keyGen.genKeyPair();
+        log("Generated Root CA KeyPair");
+        KeyPair intCaKP = keyGen.genKeyPair();
+        log("Generated Intermediate CA KeyPair");
+        KeyPair sslKP = keyGen.genKeyPair();
+        log("Generated SSL Cert KeyPair");
+
+        // Set up the Root CA Cert
+        cbld.setSubjectName("CN=Root CA Cert, O=SomeCompany");
+        cbld.setPublicKey(rootCaKP.getPublic());
+        cbld.setSerialNumber(new BigInteger("1"));
+        // Make a 3 year validity starting from 60 days ago
+        long start = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(60);
+        long end = start + TimeUnit.DAYS.toMillis(1085);
+        cbld.setValidity(new Date(start), new Date(end));
+        addCommonExts(cbld, rootCaKP.getPublic(), rootCaKP.getPublic());
+        addCommonCAExts(cbld);
+        // Make our Root CA Cert!
+        X509Certificate rootCert = cbld.build(null, rootCaKP.getPrivate(),
+                "SHA256withRSA");
+        log("Root CA Created:\n" + certInfo(rootCert));
+
+        // Now build a keystore and add the keys and cert
+        rootKeystore = keyStoreBuilder.getKeyStore();
+        java.security.cert.Certificate[] rootChain = {rootCert};
+        rootKeystore.setKeyEntry(ROOT_ALIAS, rootCaKP.getPrivate(),
+                passwd.toCharArray(), rootChain);
+
+        // Now fire up the OCSP responder
+        rootOcsp = new SimpleOCSPServer(rootKeystore, passwd, ROOT_ALIAS, null);
+        rootOcsp.enableLog(debug);
+        rootOcsp.setNextUpdateInterval(3600);
+        rootOcsp.start();
+
+        // Wait 5 seconds for server ready
+        for (int i = 0; (i < 100 && !rootOcsp.isServerReady()); i++) {
+            Thread.sleep(50);
+        }
+        if (!rootOcsp.isServerReady()) {
+            throw new RuntimeException("Server not ready yet");
+        }
+
+        rootOcspPort = rootOcsp.getPort();
+        String rootRespURI = "http://localhost:" + rootOcspPort;
+        log("Root OCSP Responder URI is " + rootRespURI);
+
+        // Now that we have the root keystore and OCSP responder we can
+        // create our intermediate CA.
+        cbld.reset();
+        cbld.setSubjectName("CN=Intermediate CA Cert, O=SomeCompany");
+        cbld.setPublicKey(intCaKP.getPublic());
+        cbld.setSerialNumber(new BigInteger("100"));
+        // Make a 2 year validity starting from 30 days ago
+        start = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(30);
+        end = start + TimeUnit.DAYS.toMillis(730);
+        cbld.setValidity(new Date(start), new Date(end));
+        addCommonExts(cbld, intCaKP.getPublic(), rootCaKP.getPublic());
+        addCommonCAExts(cbld);
+        cbld.addAIAExt(Collections.singletonList(rootRespURI));
+        // Make our Intermediate CA Cert!
+        X509Certificate intCaCert = cbld.build(rootCert, rootCaKP.getPrivate(),
+                "SHA256withRSA");
+        log("Intermediate CA Created:\n" + certInfo(intCaCert));
+
+        // Provide intermediate CA cert revocation info to the Root CA
+        // OCSP responder.
+        Map<BigInteger, SimpleOCSPServer.CertStatusInfo> revInfo =
+            new HashMap<>();
+        revInfo.put(intCaCert.getSerialNumber(),
+                new SimpleOCSPServer.CertStatusInfo(
+                        SimpleOCSPServer.CertStatus.CERT_STATUS_GOOD));
+        rootOcsp.updateStatusDb(revInfo);
+
+        // Now build a keystore and add the keys, chain and root cert as a TA
+        intKeystore = keyStoreBuilder.getKeyStore();
+        java.security.cert.Certificate[] intChain = {intCaCert, rootCert};
+        intKeystore.setKeyEntry(INT_ALIAS, intCaKP.getPrivate(),
+                passwd.toCharArray(), intChain);
+        intKeystore.setCertificateEntry(ROOT_ALIAS, rootCert);
+
+        // Now fire up the Intermediate CA OCSP responder
+        intOcsp = new SimpleOCSPServer(intKeystore, passwd,
+                INT_ALIAS, null);
+        intOcsp.enableLog(debug);
+        intOcsp.setNextUpdateInterval(3600);
+        intOcsp.start();
+
+        // Wait 5 seconds for server ready
+        for (int i = 0; (i < 100 && !intOcsp.isServerReady()); i++) {
+            Thread.sleep(50);
+        }
+        if (!intOcsp.isServerReady()) {
+            throw new RuntimeException("Server not ready yet");
+        }
+
+        intOcspPort = intOcsp.getPort();
+        String intCaRespURI = "http://localhost:" + intOcspPort;
+        log("Intermediate CA OCSP Responder URI is " + intCaRespURI);
+
+        // Last but not least, let's make our SSLCert and add it to its own
+        // Keystore
+        cbld.reset();
+        cbld.setSubjectName("CN=SSLCertificate, O=SomeCompany");
+        cbld.setPublicKey(sslKP.getPublic());
+        cbld.setSerialNumber(new BigInteger("4096"));
+        // Make a 1 year validity starting from 7 days ago
+        start = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(7);
+        end = start + TimeUnit.DAYS.toMillis(365);
+        cbld.setValidity(new Date(start), new Date(end));
+
+        // Add extensions
+        addCommonExts(cbld, sslKP.getPublic(), intCaKP.getPublic());
+        boolean[] kuBits = {true, false, true, false, false, false,
+            false, false, false};
+        cbld.addKeyUsageExt(kuBits);
+        List<String> ekuOids = new ArrayList<>();
+        ekuOids.add("1.3.6.1.5.5.7.3.1");
+        ekuOids.add("1.3.6.1.5.5.7.3.2");
+        cbld.addExtendedKeyUsageExt(ekuOids);
+        cbld.addSubjectAltNameDNSExt(Collections.singletonList("localhost"));
+        cbld.addAIAExt(Collections.singletonList(intCaRespURI));
+        // Make our SSL Server Cert!
+        X509Certificate sslCert = cbld.build(intCaCert, intCaKP.getPrivate(),
+                "SHA256withRSA");
+        log("SSL Certificate Created:\n" + certInfo(sslCert));
+
+        // Provide SSL server cert revocation info to the Intermeidate CA
+        // OCSP responder.
+        revInfo = new HashMap<>();
+        revInfo.put(sslCert.getSerialNumber(),
+                new SimpleOCSPServer.CertStatusInfo(
+                        SimpleOCSPServer.CertStatus.CERT_STATUS_GOOD));
+        intOcsp.updateStatusDb(revInfo);
+
+        // Now build a keystore and add the keys, chain and root cert as a TA
+        serverKeystore = keyStoreBuilder.getKeyStore();
+        java.security.cert.Certificate[] sslChain = {sslCert, intCaCert, rootCert};
+        serverKeystore.setKeyEntry(SSL_ALIAS, sslKP.getPrivate(),
+                passwd.toCharArray(), sslChain);
+        serverKeystore.setCertificateEntry(ROOT_ALIAS, rootCert);
+
+        // And finally a Trust Store for the client
+        trustStore = keyStoreBuilder.getKeyStore();
+        trustStore.setCertificateEntry(ROOT_ALIAS, rootCert);
+    }
+
+    private static void addCommonExts(CertificateBuilder cbld,
+            PublicKey subjKey, PublicKey authKey) throws IOException {
+        cbld.addSubjectKeyIdExt(subjKey);
+        cbld.addAuthorityKeyIdExt(authKey);
+    }
+
+    private static void addCommonCAExts(CertificateBuilder cbld)
+            throws IOException {
+        cbld.addBasicConstraintsExt(true, true, -1);
+        // Set key usage bits for digitalSignature, keyCertSign and cRLSign
+        boolean[] kuBitSettings = {true, false, false, false, false, true,
+            true, false, false};
+        cbld.addKeyUsageExt(kuBitSettings);
+    }
+
+    /**
+     * Helper routine that dumps only a few cert fields rather than
+     * the whole toString() output.
+     *
+     * @param cert an X509Certificate to be displayed
+     *
+     * @return the String output of the issuer, subject and
+     * serial number
+     */
+    private static String certInfo(X509Certificate cert) {
+        StringBuilder sb = new StringBuilder();
+        sb.append("Issuer: ").append(cert.getIssuerX500Principal()).
+                append("\n");
+        sb.append("Subject: ").append(cert.getSubjectX500Principal()).
+                append("\n");
+        sb.append("Serial: ").append(cert.getSerialNumber()).append("\n");
+        return sb.toString();
+    }
+
+    private static class TestCase {
+        public final String testName;
+        public final ByteBuffer data;
+        public final boolean statReqEnabled;
+        public final boolean statReqV2Enabled;
+
+        TestCase(String name, ByteBuffer buffer, boolean srEn, boolean srv2En) {
+            testName = (name != null) ? name : "";
+            data = Objects.requireNonNull(buffer,
+                    "TestCase requires a non-null ByteBuffer");
+            statReqEnabled = srEn;
+            statReqV2Enabled = srv2En;
+        }
+    }
+}
--- a/jdk/test/sun/security/tools/jarsigner/AltProvider.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/AltProvider.java	Thu Aug 11 17:02:46 2016 +0000
@@ -55,7 +55,7 @@
         // Compile the provider
         CompilerUtils.compile(
                 MOD_SRC_DIR, MOD_DEST_DIR,
-                "-modulesourcepath",
+                "--module-source-path",
                 MOD_SRC_DIR.toString());
 
         // Create a keystore
@@ -102,22 +102,22 @@
                 0, "loadProviderByClass: org.test.dummy.DummyProvider");
 
         // name in a module
-        testBoth("-J-mp -Jmods " +
+        testBoth("-J--module-path=mods " +
                 "-addprovider Dummy -providerArg full",
                 0, "loadProviderByName: Dummy");
 
         // -providerClass does not work
-        testBoth("-J-mp -Jmods " +
+        testBoth("-J--module-path=mods " +
                 "-providerClass org.test.dummy.DummyProvider -providerArg full",
                 1, "Provider \"org.test.dummy.DummyProvider\" not found");
 
         // -addprovider with class does not work
-        testBoth("-J-mp -Jmods " +
+        testBoth("-J--module-path=mods " +
                 "-addprovider org.test.dummy.DummyProvider -providerArg full",
                 1, "Provider named \"org.test.dummy.DummyProvider\" not found");
 
         // -addprovider without arg does not work
-        testBoth("-J-mp -Jmods " +
+        testBoth("-J--module-path=mods " +
                 "-addprovider Dummy",
                 1, "DUMMYKS not found");
     }
--- a/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java	Thu Aug 11 17:02:46 2016 +0000
@@ -311,6 +311,7 @@
 
             cmd += " " + System.getProperty("test.tool.vm.opts")
                     + " -J-Djava.security.egd=file:/dev/./urandom"
+                    + " -J-Duser.language=en -J-Duser.country=US"
                     + " -debug -keystore " + TSKS + " -storepass changeit"
                     + " -tsa http://localhost:" + port + "/%d"
                     + " -signedjar new_%d.jar " + JAR + " old";
--- a/jdk/test/sun/security/tools/jarsigner/TsacertOptionTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/TsacertOptionTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -22,14 +22,13 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary The test signs and verifies a jar file with -tsacert option
- * @library /lib/testlibrary
+ * @library /lib/testlibrary warnings
  * @modules java.base/sun.security.pkcs
  *          java.base/sun.security.timestamp
  *          java.base/sun.security.util
@@ -37,29 +36,14 @@
  *          java.management
  * @run main TsacertOptionTest
  */
-public class TsacertOptionTest {
+public class TsacertOptionTest extends Test {
 
-    private static final String FS = System.getProperty("file.separator");
-    private static final String JAVA_HOME = System.getProperty("java.home");
-    private static final String KEYTOOL = JAVA_HOME + FS + "bin" + FS
-            + "keytool";
-    private static final String JARSIGNER = JAVA_HOME + FS + "bin" + FS
-            + "jarsigner";
-    private static final String UNSIGNED_JARFILE = "unsigned.jar";
-    private static final String SIGNED_JARFILE = "signed.jar";
     private static final String FILENAME = TsacertOptionTest.class.getName()
             + ".txt";
-    private static final String PASSWORD = "changeit";
-    private static final String KEYSTORE = "ks.jks";
-    private static final String CA_KEY_ALIAS = "ca";
     private static final String SIGNING_KEY_ALIAS = "sign_alias";
     private static final String TSA_KEY_ALIAS = "ts";
-    private static final String KEY_ALG = "RSA";
-    private static final int KEY_SIZE = 2048;
-    private static final int VALIDITY = 365;
-    private static final String WARNING = "Warning:";
-    private static final String JAR_SIGNED = "jar signed.";
-    private static final String JAR_VERIFIED = "jar verified.";
+
+    private static final String PASSWORD = "changeit";
 
     /**
      * The test signs and verifies a jar file with -tsacert option,
@@ -77,13 +61,8 @@
         Utils.createFiles(FILENAME);
         JarUtils.createJar(UNSIGNED_JARFILE, FILENAME);
 
-        // look for free network port for TSA service
-        int port = jdk.testlibrary.Utils.getFreePort();
-        String host = "127.0.0.1";
-        String tsaUrl = "http://" + host + ":" + port;
-
         // create key pair for jar signing
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkey",
                 "-alias", CA_KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -93,7 +72,7 @@
                 "-keypass", PASSWORD,
                 "-dname", "CN=CA",
                 "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0);
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkey",
                 "-alias", SIGNING_KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -102,14 +81,14 @@
                 "-storepass", PASSWORD,
                 "-keypass", PASSWORD,
                 "-dname", "CN=Test").shouldHaveExitValue(0);
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-certreq",
                 "-alias", SIGNING_KEY_ALIAS,
                 "-keystore", KEYSTORE,
                 "-storepass", PASSWORD,
                 "-keypass", PASSWORD,
                 "-file", "certreq").shouldHaveExitValue(0);
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-gencert",
                 "-alias", CA_KEY_ALIAS,
                 "-keystore", KEYSTORE,
@@ -118,7 +97,7 @@
                 "-validity", Integer.toString(VALIDITY),
                 "-infile", "certreq",
                 "-outfile", "cert").shouldHaveExitValue(0);
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-importcert",
                 "-alias", SIGNING_KEY_ALIAS,
                 "-keystore", KEYSTORE,
@@ -126,24 +105,30 @@
                 "-keypass", PASSWORD,
                 "-file", "cert").shouldHaveExitValue(0);
 
-        // create key pair for TSA service
-        // SubjectInfoAccess extension contains URL to TSA service
-        ProcessTools.executeCommand(KEYTOOL,
-                "-genkey",
-                "-v",
-                "-alias", TSA_KEY_ALIAS,
-                "-keyalg", KEY_ALG,
-                "-keysize", Integer.toString(KEY_SIZE),
-                "-keystore", KEYSTORE,
-                "-storepass", PASSWORD,
-                "-keypass", PASSWORD,
-                "-dname", "CN=TSA",
-                "-ext", "ExtendedkeyUsage:critical=timeStamping",
-                "-ext", "SubjectInfoAccess=timeStamping:URI:" + tsaUrl,
-                "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0);
 
-        try (TimestampCheck.Handler tsa = TimestampCheck.Handler.init(port,
-                KEYSTORE);) {
+        try (TimestampCheck.Handler tsa = TimestampCheck.Handler.init(0,
+                KEYSTORE)) {
+
+            // look for free network port for TSA service
+            int port = tsa.getPort();
+            String host = "127.0.0.1";
+            String tsaUrl = "http://" + host + ":" + port;
+
+            // create key pair for TSA service
+            // SubjectInfoAccess extension contains URL to TSA service
+            keytool(
+                    "-genkey",
+                    "-v",
+                    "-alias", TSA_KEY_ALIAS,
+                    "-keyalg", KEY_ALG,
+                    "-keysize", Integer.toString(KEY_SIZE),
+                    "-keystore", KEYSTORE,
+                    "-storepass", PASSWORD,
+                    "-keypass", PASSWORD,
+                    "-dname", "CN=TSA",
+                    "-ext", "ExtendedkeyUsage:critical=timeStamping",
+                    "-ext", "SubjectInfoAccess=timeStamping:URI:" + tsaUrl,
+                    "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0);
 
             // start TSA
             tsa.start();
@@ -151,7 +136,7 @@
             // sign jar file
             // specify -tsadigestalg option because
             // TSA server uses SHA-1 digest algorithm
-             OutputAnalyzer analyzer = ProcessTools.executeCommand(JARSIGNER,
+             OutputAnalyzer analyzer = jarsigner(
                     "-J-Dhttp.proxyHost=",
                     "-J-Dhttp.proxyPort=",
                     "-J-Djava.net.useSystemProxies=",
@@ -170,7 +155,7 @@
             analyzer.shouldContain(JAR_SIGNED);
 
             // verify signed jar
-            analyzer = ProcessTools.executeCommand(JARSIGNER,
+            analyzer = jarsigner(
                     "-verbose",
                     "-verify",
                     "-keystore", KEYSTORE,
--- a/jdk/test/sun/security/tools/jarsigner/concise_jarsigner.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/concise_jarsigner.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -47,6 +47,8 @@
 # Choose 1024-bit RSA to make sure it runs fine and fast on all platforms. In
 # fact, every keyalg/keysize combination is OK for this test.
 
+TESTTOOLVMOPTS="$TESTTOOLVMOPTS -J-Duser.language=en -J-Duser.country=US"
+
 KS=js.ks
 KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS -keyalg rsa -keysize 1024"
 JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
--- a/jdk/test/sun/security/tools/jarsigner/default_options.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/default_options.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -34,6 +34,8 @@
 PASS=changeit
 export PASS
 
+TESTTOOLVMOPTS="$TESTTOOLVMOPTS -J-Duser.language=en -J-Duser.country=US"
+
 KS=ks
 KEYTOOL="$TESTJAVA/bin/keytool ${TESTTOOLVMOPTS} -storepass:env PASS -keypass:env PASS -keystore $KS"
 JAR="$TESTJAVA/bin/jar ${TESTTOOLVMOPTS}"
--- a/jdk/test/sun/security/tools/jarsigner/ts.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/ts.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -94,10 +94,10 @@
         $KT -alias ca -gencert -ext eku:critical=cs | \
         $KT -alias tsbad3 -importcert
 
-EXTRAOPTS="-XaddExports:java.base/sun.security.pkcs=ALL-UNNAMED \
- -XaddExports:java.base/sun.security.timestamp=ALL-UNNAMED \
- -XaddExports:java.base/sun.security.x509=ALL-UNNAMED \
- -XaddExports:java.base/sun.security.util=ALL-UNNAMED"
+EXTRAOPTS="--add-exports java.base/sun.security.pkcs=ALL-UNNAMED \
+ --add-exports java.base/sun.security.timestamp=ALL-UNNAMED \
+ --add-exports java.base/sun.security.x509=ALL-UNNAMED \
+ --add-exports java.base/sun.security.util=ALL-UNNAMED"
 $JAVAC ${EXTRAOPTS} -d . ${TESTSRC}/TimestampCheck.java
 $JAVA ${TESTVMOPTS} ${EXTRAOPTS} "-Dtest.tool.vm.opts=${TESTTOOLVMOPTS}" TimestampCheck
 
--- a/jdk/test/sun/security/tools/jarsigner/warnings/AliasNotInStoreTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/AliasNotInStoreTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -22,7 +22,6 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.JarUtils;
 
 /**
@@ -51,7 +50,7 @@
         JarUtils.createJar(UNSIGNED_JARFILE, FIRST_FILE);
 
         // create first key pair for signing
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkey",
                 "-alias", FIRST_KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -63,7 +62,7 @@
                 "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0);
 
         // create second key pair for signing
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkey",
                 "-alias", SECOND_KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -75,7 +74,7 @@
                 "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0);
 
         // sign jar with first key
-        OutputAnalyzer analyzer = ProcessTools.executeCommand(JARSIGNER,
+        OutputAnalyzer analyzer = jarsigner(
                 "-keystore", BOTH_KEYS_KEYSTORE,
                 "-storepass", PASSWORD,
                 "-keypass", PASSWORD,
@@ -92,7 +91,7 @@
         JarUtils.updateJar(SIGNED_JARFILE, UPDATED_SIGNED_JARFILE, SECOND_FILE);
 
         // sign jar with second key
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-keystore", BOTH_KEYS_KEYSTORE,
                 "-storepass", PASSWORD,
                 "-keypass", PASSWORD,
@@ -102,7 +101,7 @@
         checkSigning(analyzer);
 
         // create keystore that contains only first key
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-importkeystore",
                 "-srckeystore", BOTH_KEYS_KEYSTORE,
                 "-srcalias", FIRST_KEY_ALIAS,
@@ -116,7 +115,7 @@
         // verify jar with keystore that contains only first key in strict mode,
         // so there is signed entry (FirstClass.class) that is not signed
         // by any alias in the keystore
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-keystore", FIRST_KEY_KEYSTORE,
@@ -128,7 +127,7 @@
                 ALIAS_NOT_IN_STORE_VERIFYING_WARNING);
 
         // verify jar with keystore that contains only first key in strict mode
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-strict",
--- a/jdk/test/sun/security/tools/jarsigner/warnings/BadExtendedKeyUsageTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/BadExtendedKeyUsageTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -22,7 +22,6 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.JarUtils;
 
 /**
@@ -52,7 +51,7 @@
 
         // create a certificate whose signer certificate's
         // ExtendedKeyUsage extension doesn't allow code signing
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkey",
                 "-alias", KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -65,7 +64,7 @@
                 "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0);
 
         // sign jar
-        OutputAnalyzer analyzer = ProcessTools.executeCommand(JARSIGNER,
+        OutputAnalyzer analyzer = jarsigner(
                 "-verbose",
                 "-keystore", KEYSTORE,
                 "-storepass", PASSWORD,
@@ -77,7 +76,7 @@
         checkSigning(analyzer, BAD_EXTENDED_KEY_USAGE_SIGNING_WARNING);
 
         // verify signed jar
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-keystore", KEYSTORE,
@@ -88,7 +87,7 @@
         checkVerifying(analyzer, 0, BAD_EXTENDED_KEY_USAGE_VERIFYING_WARNING);
 
         // verity signed jar in strict mode
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-strict",
--- a/jdk/test/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -22,7 +22,6 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.JarUtils;
 
 /**
@@ -53,7 +52,7 @@
 
         // create a certificate whose signer certificate's KeyUsage extension
         // doesn't allow code signing
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkey",
                 "-alias", KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -66,7 +65,7 @@
                 "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0);
 
         // sign jar
-        OutputAnalyzer analyzer = ProcessTools.executeCommand(JARSIGNER,
+        OutputAnalyzer analyzer = jarsigner(
                 "-verbose",
                 "-keystore", KEYSTORE,
                 "-storepass", PASSWORD,
@@ -78,7 +77,7 @@
         checkSigning(analyzer, BAD_KEY_USAGE_SIGNING_WARNING);
 
         // verify signed jar
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-keystore", KEYSTORE,
@@ -89,7 +88,7 @@
         checkVerifying(analyzer, 0, BAD_KEY_USAGE_VERIFYING_WARNING);
 
         // verify signed jar in strict mode
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-strict",
--- a/jdk/test/sun/security/tools/jarsigner/warnings/BadNetscapeCertTypeTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/BadNetscapeCertTypeTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -22,7 +22,6 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.JarUtils;
 
 import java.nio.file.Files;
@@ -67,7 +66,7 @@
         JarUtils.createJar(UNSIGNED_JARFILE, FIRST_FILE);
 
         // sign jar
-        OutputAnalyzer analyzer = ProcessTools.executeCommand(JARSIGNER,
+        OutputAnalyzer analyzer = jarsigner(
                 "-verbose",
                 "-keystore", NETSCAPE_KEYSTORE,
                 "-storepass", PASSWORD,
@@ -79,7 +78,7 @@
         checkSigning(analyzer, BAD_NETSCAPE_CERT_TYPE_SIGNING_WARNING);
 
         // verify signed jar
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-keystore", NETSCAPE_KEYSTORE,
@@ -90,7 +89,7 @@
         checkVerifying(analyzer, 0, BAD_NETSCAPE_CERT_TYPE_VERIFYING_WARNING);
 
         // verify signed jar in strict mode
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-strict",
--- a/jdk/test/sun/security/tools/jarsigner/warnings/ChainNotValidatedTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/ChainNotValidatedTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -55,7 +55,7 @@
         // create self-signed certificate whose BasicConstraints extension
         // is set to false, so the certificate may not be used
         // as a parent certificate (certpath validation should fail)
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkeypair",
                 "-alias", CA_KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -70,7 +70,7 @@
         // create a certificate that is signed by self-signed certificate
         // despite of it may not be used as a parent certificate
         // (certpath validation should fail)
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkeypair",
                 "-alias", KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -82,7 +82,7 @@
                 "-ext", "BasicConstraints:critical=ca:false",
                 "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0);
 
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-certreq",
                 "-alias", KEY_ALIAS,
                 "-keystore", KEYSTORE,
@@ -90,7 +90,7 @@
                 "-keypass", PASSWORD,
                 "-file", CERT_REQUEST_FILENAME).shouldHaveExitValue(0);
 
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-gencert",
                 "-alias", CA_KEY_ALIAS,
                 "-keystore", KEYSTORE,
@@ -100,7 +100,7 @@
                 "-validity", Integer.toString(VALIDITY),
                 "-outfile", CERT_FILENAME).shouldHaveExitValue(0);
 
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-importcert",
                 "-alias", KEY_ALIAS,
                 "-keystore", KEYSTORE,
@@ -129,7 +129,7 @@
         ProcessTools.executeCommand(pb).shouldHaveExitValue(0);
 
         // remove CA certificate
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-delete",
                 "-alias", CA_KEY_ALIAS,
                 "-keystore", KEYSTORE,
@@ -137,7 +137,7 @@
                 "-keypass", PASSWORD).shouldHaveExitValue(0);
 
         // sign jar
-        OutputAnalyzer analyzer = ProcessTools.executeCommand(JARSIGNER,
+        OutputAnalyzer analyzer = jarsigner(
                 "-keystore", KEYSTORE,
                 "-storepass", PASSWORD,
                 "-keypass", PASSWORD,
@@ -149,7 +149,7 @@
         checkSigning(analyzer, CHAIN_NOT_VALIDATED_SIGNING_WARNING);
 
         // verify signed jar
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-keystore", KEYSTORE,
@@ -161,7 +161,7 @@
         checkVerifying(analyzer, 0, CHAIN_NOT_VALIDATED_VERIFYING_WARNING);
 
         // verify signed jar in strict mode
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-strict",
--- a/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiredCertTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiredCertTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -22,7 +22,6 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.JarUtils;
 
 /**
@@ -52,7 +51,7 @@
         JarUtils.createJar(UNSIGNED_JARFILE, FIRST_FILE);
 
         // create key pair for jar signing
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkey",
                 "-alias", KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -66,7 +65,7 @@
                 .shouldHaveExitValue(0);
 
         // sign jar
-        OutputAnalyzer analyzer = ProcessTools.executeCommand(JARSIGNER,
+        OutputAnalyzer analyzer = jarsigner(
                 "-keystore", KEYSTORE,
                 "-storepass", PASSWORD,
                 "-keypass", PASSWORD,
@@ -77,7 +76,7 @@
         checkSigning(analyzer, HAS_EXPIRED_CERT_SIGNING_WARNING);
 
         // verify signed jar
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-keystore", KEYSTORE,
@@ -87,7 +86,7 @@
 
         checkVerifying(analyzer, 0, HAS_EXPIRED_CERT_VERIFYING_WARNING);
 
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-strict",
                 "-keystore", KEYSTORE,
--- a/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiringCertTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiringCertTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -22,7 +22,6 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.JarUtils;
 
 /**
@@ -52,7 +51,7 @@
         JarUtils.createJar(UNSIGNED_JARFILE, FIRST_FILE);
 
         // create key pair for jar signing
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkey",
                 "-alias", KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -65,7 +64,7 @@
                 .shouldHaveExitValue(0);
 
         // sign jar
-        OutputAnalyzer analyzer = ProcessTools.executeCommand(JARSIGNER,
+        OutputAnalyzer analyzer = jarsigner(
                 "-keystore", KEYSTORE,
                 "-verbose",
                 "-storepass", PASSWORD,
@@ -77,7 +76,7 @@
         checkSigning(analyzer, HAS_EXPIRING_CERT_SIGNING_WARNING);
 
         // verify signed jar
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-keystore", KEYSTORE,
@@ -89,7 +88,7 @@
         checkVerifying(analyzer, 0, HAS_EXPIRING_CERT_VERIFYING_WARNING);
 
         // verify signed jar in strict mode
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-strict",
--- a/jdk/test/sun/security/tools/jarsigner/warnings/HasUnsignedEntryTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/HasUnsignedEntryTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -22,7 +22,6 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.JarUtils;
 
 /**
@@ -51,7 +50,7 @@
         JarUtils.createJar(UNSIGNED_JARFILE, FIRST_FILE);
 
         // create key pair for signing
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkey",
                 "-alias", KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -63,7 +62,7 @@
                 "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0);
 
         // sign jar
-        OutputAnalyzer analyzer = ProcessTools.executeCommand(JARSIGNER,
+        OutputAnalyzer analyzer = jarsigner(
                 "-verbose",
                 "-keystore", KEYSTORE,
                 "-storepass", PASSWORD,
@@ -82,7 +81,7 @@
         JarUtils.updateJar(SIGNED_JARFILE, UPDATED_SIGNED_JARFILE, SECOND_FILE);
 
         // verify jar
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-keystore", KEYSTORE,
@@ -93,7 +92,7 @@
         checkVerifying(analyzer, 0, HAS_UNSIGNED_ENTRY_VERIFYING_WARNING);
 
         // verify jar in strict mode
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-strict",
--- a/jdk/test/sun/security/tools/jarsigner/warnings/MultipleWarningsTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/MultipleWarningsTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -22,7 +22,6 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.JarUtils;
 
 /**
@@ -56,7 +55,7 @@
 
         // create first expired certificate
         // whose ExtendedKeyUsage extension does not allow code signing
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkey",
                 "-alias", FIRST_KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -71,7 +70,7 @@
 
         // create second expired certificate
         // whose KeyUsage extension does not allow code signing
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkey",
                 "-alias", SECOND_KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -85,7 +84,7 @@
                 "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0);
 
         // sign jar with first key
-        OutputAnalyzer analyzer = ProcessTools.executeCommand(JARSIGNER,
+        OutputAnalyzer analyzer = jarsigner(
                 "-keystore", KEYSTORE,
                 "-storepass", PASSWORD,
                 "-keypass", PASSWORD,
@@ -100,7 +99,7 @@
         JarUtils.updateJar(SIGNED_JARFILE, UPDATED_SIGNED_JARFILE, SECOND_FILE);
 
         // verify jar with second key
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-keystore", KEYSTORE,
                 "-storepass", PASSWORD,
@@ -114,7 +113,7 @@
                 NOT_SIGNED_BY_ALIAS_VERIFYING_WARNING);
 
         // verify jar with second key in strict mode
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-strict",
                 "-keystore", KEYSTORE,
@@ -134,7 +133,7 @@
                 NOT_SIGNED_BY_ALIAS_VERIFYING_WARNING);
 
         // verify jar with non-exisiting alias
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-keystore", KEYSTORE,
                 "-storepass", PASSWORD,
@@ -148,7 +147,7 @@
                 NOT_SIGNED_BY_ALIAS_VERIFYING_WARNING);
 
         // verify jar with non-exisiting alias in strict mode
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-strict",
                 "-keystore", KEYSTORE,
--- a/jdk/test/sun/security/tools/jarsigner/warnings/NoTimestampTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/NoTimestampTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -23,7 +23,6 @@
 
 import java.util.Date;
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.JarUtils;
 
 /**
@@ -57,7 +56,7 @@
                 * 24 * 60 * 60 * 1000L);
 
         // create key pair
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkey",
                 "-alias", KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -69,7 +68,7 @@
                 "-validity", Integer.toString(VALIDITY));
 
         // sign jar file
-        OutputAnalyzer analyzer = ProcessTools.executeCommand(JARSIGNER,
+        OutputAnalyzer analyzer = jarsigner(
                 "-J-Duser.timezone=" + timezone,
                 "-keystore", KEYSTORE,
                 "-storepass", PASSWORD,
@@ -83,7 +82,7 @@
         checkSigning(analyzer, warning);
 
         // verify signed jar
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-J-Duser.timezone=" + timezone,
                 "-verify",
                 "-keystore", KEYSTORE,
@@ -96,7 +95,7 @@
         checkVerifying(analyzer, 0, warning);
 
         // verify signed jar in strict mode
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-J-Duser.timezone=" + timezone,
                 "-verify",
                 "-strict",
--- a/jdk/test/sun/security/tools/jarsigner/warnings/NotSignedByAliasTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/NotSignedByAliasTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -22,7 +22,6 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.JarUtils;
 
 /**
@@ -50,7 +49,7 @@
         JarUtils.createJar(UNSIGNED_JARFILE, FIRST_FILE);
 
         // create first key pair for signing
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkey",
                 "-alias", FIRST_KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -62,7 +61,7 @@
                 "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0);
 
         // create first key pair for signing
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkey",
                 "-alias", SECOND_KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -74,7 +73,7 @@
                 "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0);
 
         // sign jar with first key
-        OutputAnalyzer analyzer = ProcessTools.executeCommand(JARSIGNER,
+        OutputAnalyzer analyzer = jarsigner(
                 "-keystore", KEYSTORE,
                 "-storepass", PASSWORD,
                 "-keypass", PASSWORD,
@@ -85,7 +84,7 @@
         checkSigning(analyzer);
 
         // verify jar with second key
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-keystore", KEYSTORE,
                 "-storepass", PASSWORD,
@@ -96,7 +95,7 @@
         checkVerifying(analyzer, 0, NOT_SIGNED_BY_ALIAS_VERIFYING_WARNING);
 
         // verify jar with second key in strict mode
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-strict",
                 "-keystore", KEYSTORE,
@@ -109,7 +108,7 @@
                 NOT_SIGNED_BY_ALIAS_VERIFYING_WARNING);
 
         // verify jar with non-existing alias
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-keystore", KEYSTORE,
                 "-storepass", PASSWORD,
@@ -120,7 +119,7 @@
         checkVerifying(analyzer, 0, NOT_SIGNED_BY_ALIAS_VERIFYING_WARNING);
 
         // verify jar with non-existing alias in strict mode
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-strict",
                 "-keystore", KEYSTORE,
--- a/jdk/test/sun/security/tools/jarsigner/warnings/NotYetValidCertTest.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/NotYetValidCertTest.java	Thu Aug 11 17:02:46 2016 +0000
@@ -22,7 +22,6 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.JarUtils;
 
 /**
@@ -50,7 +49,7 @@
         JarUtils.createJar(UNSIGNED_JARFILE, FIRST_FILE);
 
         // create certificate that will be valid only tomorrow
-        ProcessTools.executeCommand(KEYTOOL,
+        keytool(
                 "-genkey",
                 "-alias", KEY_ALIAS,
                 "-keyalg", KEY_ALG,
@@ -63,7 +62,7 @@
                 "-validity", Integer.toString(VALIDITY));
 
         // sign jar
-        OutputAnalyzer analyzer = ProcessTools.executeCommand(JARSIGNER,
+        OutputAnalyzer analyzer = jarsigner(
                 "-keystore", KEYSTORE,
                 "-storepass", PASSWORD,
                 "-keypass", PASSWORD,
@@ -74,7 +73,7 @@
         checkSigning(analyzer, NOT_YET_VALID_CERT_SIGNING_WARNING);
 
         // verify signed jar
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-keystore", KEYSTORE,
@@ -86,7 +85,7 @@
         checkVerifying(analyzer, 0, NOT_YET_VALID_CERT_VERIFYING_WARNING);
 
         // verify jar in strict mode
-        analyzer = ProcessTools.executeCommand(JARSIGNER,
+        analyzer = jarsigner(
                 "-verify",
                 "-verbose",
                 "-strict",
--- a/jdk/test/sun/security/tools/jarsigner/warnings/Test.java	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/Test.java	Thu Aug 11 17:02:46 2016 +0000
@@ -22,6 +22,11 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.ProcessTools;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
 /**
  * Base class.
@@ -175,4 +180,21 @@
         }
         analyzer.shouldContain(JAR_SIGNED);
     }
+
+    protected OutputAnalyzer keytool(String... cmd) throws Throwable {
+        return tool(KEYTOOL, cmd);
+    }
+
+    protected OutputAnalyzer jarsigner(String... cmd) throws Throwable {
+        return tool(JARSIGNER, cmd);
+    }
+
+    private OutputAnalyzer tool(String tool, String... args) throws Throwable {
+        List<String> cmd = new ArrayList<>();
+        cmd.add(tool);
+        cmd.add("-J-Duser.language=en");
+        cmd.add("-J-Duser.country=US");
+        cmd.addAll(Arrays.asList(args));
+        return ProcessTools.executeCommand(cmd.toArray(new String[cmd.size()]));
+    }
 }
--- a/jdk/test/sun/security/tools/jarsigner/weaksize.sh	Thu Aug 11 15:47:09 2016 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/weaksize.sh	Thu Aug 11 17:02:46 2016 +0000
@@ -31,6 +31,8 @@
   TESTJAVA=`dirname $JAVAC_CMD`/..
 fi
 
+TESTTOOLVMOPTS="$TESTTOOLVMOPTS -J-Duser.language=en -J-Duser.country=US"
+
 # The sigalg used is MD2withRSA, which is obsolete.
 
 KT="$TESTJAVA/bin/keytool ${TESTTOOLVMOPTS} -keystore ks
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/tools/keytool/CacertsOption.java	Thu Aug 11 17:02:46 2016 +0000
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8162739
+ * @summary Create new keytool option to access cacerts file
+ * @modules java.base/sun.security.tools.keytool
+ *          java.base/sun.security.tools
+ * @run main/othervm -Duser.language=en -Duser.country=US CacertsOption
+ */
+
+import sun.security.tools.KeyStoreUtil;
+import sun.security.tools.keytool.Main;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.PrintStream;
+import java.security.KeyStore;
+import java.util.Collections;
+
+public class CacertsOption {
+
+    public static void main(String[] args) throws Exception {
+
+        run("-help -list");
+        if (!msg.contains("-cacerts")) {
+            throw new Exception("No cacerts in help:\n" + msg);
+        }
+
+        String cacerts = KeyStoreUtil.getCacerts();
+
+        run("-list -keystore " + cacerts);
+        if (!msg.contains("Warning:")) {
+            throw new Exception("No warning in output:\n" + msg);
+        }
+
+        run("-list -cacerts");
+        KeyStore ks = KeyStore.getInstance(new File(cacerts), (char[])null);
+        for (String alias: Collections.list(ks.aliases())) {
+            if (!msg.contains(alias)) {
+                throw new Exception(alias + " not found in\n" + msg);
+            }
+        }
+
+        try {
+            run("-list -cacerts -storetype jks");
+            throw new Exception("Should fail");
+        } catch (IllegalArgumentException iae) {
+            if (!msg.contains("cannot be used with")) {
+                throw new Exception("Bad error msg\n" + msg);
+            }
+        }
+    }
+
+    private static String msg = null;
+
+    private static void run(String cmd) throws Exception {
+        msg = null;
+        cmd += " -storepass changeit -debug";
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        PrintStream ps = new PrintStream(bout);
+        PrintStream oldOut = System.out;
+        PrintStream oldErr = System.err;
+        try {
+            System.setOut(ps);
+            System.setErr(ps);
+            Main.main(cmd.split(" "));