changeset 9992:a0fcf95f8143

Merge
author prr
date Mon, 12 May 2014 09:38:27 -0700
parents 1a6c78863ead 013ac43d9800
children 30544a627823
files src/solaris/classes/java/lang/UNIXProcess.java.aix src/solaris/classes/java/lang/UNIXProcess.java.bsd src/solaris/classes/java/lang/UNIXProcess.java.linux src/solaris/classes/java/lang/UNIXProcess.java.solaris
diffstat 125 files changed, 2930 insertions(+), 2254 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon May 12 09:32:23 2014 -0700
+++ b/.hgtags	Mon May 12 09:38:27 2014 -0700
@@ -254,3 +254,4 @@
 2cef452ba711b17950da275fd15931925799f07c jdk9-b09
 ab06ba2894313a47e4969ca37792ff119c49e711 jdk9-b10
 47feccd164b7187a0147693a922ee47c6629643c jdk9-b11
+83d9bc20973de232cae45b139fdff8a4549c130f jdk9-b12
--- a/make/CompileJavaClasses.gmk	Mon May 12 09:32:23 2014 -0700
+++ b/make/CompileJavaClasses.gmk	Mon May 12 09:38:27 2014 -0700
@@ -84,8 +84,6 @@
       SolarisUserDefinedFileAttributeView.java \
       SolarisWatchService.java \
       SolarisAclFileAttributeView.java \
-      SolarisLoginModule.java \
-      SolarisSystem.java \
       sun/nio/ch/DevPollArrayWrapper.java \
       sun/nio/ch/DevPollSelectorImpl.java \
       sun/nio/ch/DevPollSelectorProvider.java \
@@ -100,15 +98,6 @@
   EXCLUDES += com/oracle/security
 endif
 
-ifneq ($(OPENJDK_TARGET_OS), windows)
-  # Exclude Window security related files in src/share/classes
-  EXFILES += NTLoginModule.java \
-      NTSystem.java
-else
-  EXFILES += UnixLoginModule.java \
-      UnixSystem.java
-endif
-
 ifeq ($(OPENJDK_TARGET_OS), windows)
   # Don't build GTK L&F on Windows
   EXCLUDES += com/sun/java/swing/plaf/gtk
--- a/make/CopyFiles.gmk	Mon May 12 09:32:23 2014 -0700
+++ b/make/CopyFiles.gmk	Mon May 12 09:38:27 2014 -0700
@@ -367,8 +367,24 @@
 POLICY_SRC := $(JDK_TOPDIR)/src/share/lib/security/java.policy
 POLICY_DST := $(JDK_OUTPUTDIR)/lib/security/java.policy
 
-$(POLICY_DST): $(POLICY_SRC)
-	$(call install-file)
+POLICY_SRC_LIST :=
+
+ifeq ($(OPENJDK_TARGET_OS), windows)
+  POLICY_SRC_LIST += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS)/lib/security/java.policy
+endif
+ifndef OPENJDK
+  ifneq (, $(filter $(OPENJDK_TARGET_OS), windows solaris))
+    POLICY_SRC_LIST += $(JDK_TOPDIR)/src/closed/$(OPENJDK_TARGET_OS)/lib/security/java.policy
+  endif
+endif
+
+POLICY_SRC_LIST += $(POLICY_SRC)
+
+$(POLICY_DST): $(POLICY_SRC_LIST)
+	$(MKDIR) -p $(@D)
+	$(RM) $@ $@.tmp
+	$(foreach f,$(POLICY_SRC_LIST),$(CAT) $(f) >> $@.tmp;)
+	$(MV) $@.tmp $@
 
 COPY_FILES += $(POLICY_DST)
 
--- a/make/gensrc/GensrcMisc.gmk	Mon May 12 09:32:23 2014 -0700
+++ b/make/gensrc/GensrcMisc.gmk	Mon May 12 09:38:27 2014 -0700
@@ -62,25 +62,6 @@
 
 ##########################################################################################
 
-ifeq ($(OPENJDK_TARGET_OS_API), posix)
-  UPSUFFIX := $(OPENJDK_TARGET_OS)
-  ifeq ($(OPENJDK_TARGET_OS), macosx)
-    UPSUFFIX := bsd
-  endif
-  # UNIXProcess.java is different for solaris and linux. We need to copy
-  # the correct UNIXProcess.java over to $(JDK_OUTPUTDIR)/gensrc/java/lang/.
-
-  $(JDK_OUTPUTDIR)/gensrc/java/lang/UNIXProcess.java: \
-      $(JDK_TOPDIR)/src/solaris/classes/java/lang/UNIXProcess.java.$(UPSUFFIX)
-	$(ECHO) $(LOG_INFO) Copying UNIXProcess.java.$(OPENJDK_TARGET_OS) to java/lang/UNIXProcess.java
-	$(call install-file)
-	$(CHMOD) u+rw $@
-
-  GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc/java/lang/UNIXProcess.java
-endif
-
-##########################################################################################
-
 GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc/sun/nio/ch/SocketOptionRegistry.java
 
 GENSRC_SOR_SRC := $(JDK_TOPDIR)/make/src/native/genconstants/ch
--- a/make/mapfiles/libjava/mapfile-vers	Mon May 12 09:32:23 2014 -0700
+++ b/make/mapfiles/libjava/mapfile-vers	Mon May 12 09:38:27 2014 -0700
@@ -273,7 +273,8 @@
                 Java_sun_misc_VM_isSetUID;
                 Java_sun_misc_VM_initialize;
 		Java_sun_misc_VMSupport_initAgentProperties;
-
+		Java_sun_misc_VMSupport_getVMTemporaryDirectory;
+		
                 # ZipFile.c needs this one
 		throwFileNotFoundException;
 
--- a/src/share/classes/com/sun/security/auth/module/NTLoginModule.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/com/sun/security/auth/module/NTLoginModule.java	Mon May 12 09:38:27 2014 -0700
@@ -139,15 +139,17 @@
 
         succeeded = false; // Indicate not yet successful
 
-        ntSystem = new NTSystem(debugNative);
-        if (ntSystem == null) {
+        try {
+            ntSystem = new NTSystem(debugNative);
+        } catch (UnsatisfiedLinkError ule) {
             if (debug) {
                 System.out.println("\t\t[NTLoginModule] " +
                                    "Failed in NT login");
             }
             throw new FailedLoginException
                 ("Failed in attempt to import the " +
-                 "underlying NT system identity information");
+                 "underlying NT system identity information" +
+                 " on " + System.getProperty("os.name"));
         }
 
         if (ntSystem.getName() == null) {
--- a/src/share/classes/com/sun/security/auth/module/SolarisLoginModule.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/com/sun/security/auth/module/SolarisLoginModule.java	Mon May 12 09:38:27 2014 -0700
@@ -129,39 +129,39 @@
 
         long[] solarisGroups = null;
 
-        ss = new SolarisSystem();
-
-        if (ss == null) {
+        try {
+            ss = new SolarisSystem();
+        } catch (UnsatisfiedLinkError ule) {
             succeeded = false;
             throw new FailedLoginException
                                 ("Failed in attempt to import " +
-                                "the underlying system identity information");
-        } else {
-            userPrincipal = new SolarisPrincipal(ss.getUsername());
-            UIDPrincipal = new SolarisNumericUserPrincipal(ss.getUid());
-            GIDPrincipal = new SolarisNumericGroupPrincipal(ss.getGid(), true);
-            if (ss.getGroups() != null && ss.getGroups().length > 0)
-                solarisGroups = ss.getGroups();
-                for (int i = 0; i < solarisGroups.length; i++) {
-                    SolarisNumericGroupPrincipal ngp =
-                        new SolarisNumericGroupPrincipal
-                        (solarisGroups[i], false);
-                    if (!ngp.getName().equals(GIDPrincipal.getName()))
-                        supplementaryGroups.add(ngp);
-                }
-            if (debug) {
-                System.out.println("\t\t[SolarisLoginModule]: " +
-                        "succeeded importing info: ");
-                System.out.println("\t\t\tuid = " + ss.getUid());
-                System.out.println("\t\t\tgid = " + ss.getGid());
-                solarisGroups = ss.getGroups();
-                for (int i = 0; i < solarisGroups.length; i++) {
-                    System.out.println("\t\t\tsupp gid = " + solarisGroups[i]);
-                }
+                                "the underlying system identity information" +
+                                " on " + System.getProperty("os.name"));
+        }
+        userPrincipal = new SolarisPrincipal(ss.getUsername());
+        UIDPrincipal = new SolarisNumericUserPrincipal(ss.getUid());
+        GIDPrincipal = new SolarisNumericGroupPrincipal(ss.getGid(), true);
+        if (ss.getGroups() != null && ss.getGroups().length > 0)
+            solarisGroups = ss.getGroups();
+            for (int i = 0; i < solarisGroups.length; i++) {
+                SolarisNumericGroupPrincipal ngp =
+                    new SolarisNumericGroupPrincipal
+                    (solarisGroups[i], false);
+                if (!ngp.getName().equals(GIDPrincipal.getName()))
+                    supplementaryGroups.add(ngp);
             }
-            succeeded = true;
-            return true;
+        if (debug) {
+            System.out.println("\t\t[SolarisLoginModule]: " +
+                    "succeeded importing info: ");
+            System.out.println("\t\t\tuid = " + ss.getUid());
+            System.out.println("\t\t\tgid = " + ss.getGid());
+            solarisGroups = ss.getGroups();
+            for (int i = 0; i < solarisGroups.length; i++) {
+                System.out.println("\t\t\tsupp gid = " + solarisGroups[i]);
+            }
         }
+        succeeded = true;
+        return true;
     }
 
     /**
--- a/src/share/classes/com/sun/security/auth/module/SolarisSystem.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/com/sun/security/auth/module/SolarisSystem.java	Mon May 12 09:38:27 2014 -0700
@@ -29,8 +29,10 @@
  * <p> This class implementation retrieves and makes available Solaris
  * UID/GID/groups information for the current user.
  *
+ * @deprecated replaced by {@link UnixSystem}.
  */
-@jdk.Exported
+@jdk.Exported(false)
+@Deprecated
 public class SolarisSystem {
 
     private native void getSolarisInfo();
--- a/src/share/classes/com/sun/security/auth/module/UnixLoginModule.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/com/sun/security/auth/module/UnixLoginModule.java	Mon May 12 09:38:27 2014 -0700
@@ -122,40 +122,40 @@
 
         long[] unixGroups = null;
 
-        ss = new UnixSystem();
-
-        if (ss == null) {
+        try {
+            ss = new UnixSystem();
+        } catch (UnsatisfiedLinkError ule) {
             succeeded = false;
             throw new FailedLoginException
                                 ("Failed in attempt to import " +
-                                "the underlying system identity information");
-        } else {
-            userPrincipal = new UnixPrincipal(ss.getUsername());
-            UIDPrincipal = new UnixNumericUserPrincipal(ss.getUid());
-            GIDPrincipal = new UnixNumericGroupPrincipal(ss.getGid(), true);
-            if (ss.getGroups() != null && ss.getGroups().length > 0) {
-                unixGroups = ss.getGroups();
-                for (int i = 0; i < unixGroups.length; i++) {
-                    UnixNumericGroupPrincipal ngp =
-                        new UnixNumericGroupPrincipal
-                        (unixGroups[i], false);
-                    if (!ngp.getName().equals(GIDPrincipal.getName()))
-                        supplementaryGroups.add(ngp);
-                }
+                                "the underlying system identity information" +
+                                " on " + System.getProperty("os.name"));
+        }
+        userPrincipal = new UnixPrincipal(ss.getUsername());
+        UIDPrincipal = new UnixNumericUserPrincipal(ss.getUid());
+        GIDPrincipal = new UnixNumericGroupPrincipal(ss.getGid(), true);
+        if (ss.getGroups() != null && ss.getGroups().length > 0) {
+            unixGroups = ss.getGroups();
+            for (int i = 0; i < unixGroups.length; i++) {
+                UnixNumericGroupPrincipal ngp =
+                    new UnixNumericGroupPrincipal
+                    (unixGroups[i], false);
+                if (!ngp.getName().equals(GIDPrincipal.getName()))
+                    supplementaryGroups.add(ngp);
             }
-            if (debug) {
-                System.out.println("\t\t[UnixLoginModule]: " +
-                        "succeeded importing info: ");
-                System.out.println("\t\t\tuid = " + ss.getUid());
-                System.out.println("\t\t\tgid = " + ss.getGid());
-                unixGroups = ss.getGroups();
-                for (int i = 0; i < unixGroups.length; i++) {
-                    System.out.println("\t\t\tsupp gid = " + unixGroups[i]);
-                }
+        }
+        if (debug) {
+            System.out.println("\t\t[UnixLoginModule]: " +
+                    "succeeded importing info: ");
+            System.out.println("\t\t\tuid = " + ss.getUid());
+            System.out.println("\t\t\tgid = " + ss.getGid());
+            unixGroups = ss.getGroups();
+            for (int i = 0; i < unixGroups.length; i++) {
+                System.out.println("\t\t\tsupp gid = " + unixGroups[i]);
             }
-            succeeded = true;
-            return true;
         }
+        succeeded = true;
+        return true;
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/attach/AttachOperationFailedException.java	Mon May 12 09:38:27 2014 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.attach;
+
+import java.io.IOException;
+
+/**
+ * Exception type to signal that an attach operation failed in the target VM.
+ *
+ * <p> This exception can be thrown by the various operations of
+ * {@link com.sun.tools.attach.VirtualMachine} when the operation
+ * fails in the target VM. If there is a communication error,
+ * a regular IOException will be thrown.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public class AttachOperationFailedException extends IOException {
+
+    private static final long serialVersionUID = 2140308168167478043L;
+
+    /**
+     * Constructs an <code>AttachOperationFailedException</code> with
+     * the specified detail message.
+     *
+     * @param   s   the detail message.
+     */
+    public AttachOperationFailedException(String message) {
+        super(message);
+    }
+}
--- a/src/share/classes/com/sun/tools/attach/VirtualMachine.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/com/sun/tools/attach/VirtualMachine.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -564,8 +564,15 @@
      *
      * @return  The system properties
      *
+     * @throws  AttachOperationFailedException
+     *          If the target virtual machine is unable to complete the
+     *          attach operation. A more specific error message will be
+     *          given by {@link AttachOperationFailedException#getMessage()}.
+     *
      * @throws  IOException
-     *          If an I/O error occurs
+     *          If an I/O error occurs, a communication error for example,
+     *          that cannot be identified as an error to indicate that the
+     *          operation failed in the target VM.
      *
      * @see     java.lang.System#getProperties
      * @see     #loadAgentLibrary
@@ -591,8 +598,15 @@
      *
      * @return       The agent properties
      *
+     * @throws       AttachOperationFailedException
+     *               If the target virtual machine is unable to complete the
+     *               attach operation. A more specific error message will be
+     *               given by {@link AttachOperationFailedException#getMessage()}.
+     *
      * @throws       IOException
-     *               If an I/O error occurs
+     *               If an I/O error occurs, a communication error for example,
+     *               that cannot be identified as an error to indicate that the
+     *               operation failed in the target VM.
      */
     public abstract Properties getAgentProperties() throws IOException;
 
--- a/src/share/classes/java/lang/Character.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/lang/Character.java	Mon May 12 09:38:27 2014 -0700
@@ -4498,7 +4498,6 @@
          * Character case is ignored for all of the valid script names.
          * The en_US locale's case mapping rules are used to provide
          * case-insensitive string comparisons for script name validation.
-         * <p>
          *
          * @param scriptName A {@code UnicodeScript} name.
          * @return The {@code UnicodeScript} constant identified
@@ -5503,7 +5502,7 @@
      * '&#92;u00D0' '&#92;u00D1' '&#92;u00D2' '&#92;u00D3' '&#92;u00D4' '&#92;u00D5' '&#92;u00D6' '&#92;u00D8'
      * '&#92;u00D9' '&#92;u00DA' '&#92;u00DB' '&#92;u00DC' '&#92;u00DD' '&#92;u00DE'
      * </pre></blockquote>
-     * <p> Many other Unicode characters are uppercase too.<p>
+     * <p> Many other Unicode characters are uppercase too.
      *
      * @param   codePoint the character (Unicode code point) to be tested.
      * @return  {@code true} if the character is uppercase;
@@ -5581,7 +5580,7 @@
      * <li>{@code LATIN CAPITAL LETTER N WITH SMALL LETTER J}
      * <li>{@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z}
      * </ul>
-     * <p> Many other Unicode characters are titlecase too.<p>
+     * <p> Many other Unicode characters are titlecase too.
      *
      * @param   codePoint the character (Unicode code point) to be tested.
      * @return  {@code true} if the character is titlecase;
@@ -6777,7 +6776,6 @@
      * <li> It is {@code '\u005Cu001E'}, U+001E RECORD SEPARATOR.
      * <li> It is {@code '\u005Cu001F'}, U+001F UNIT SEPARATOR.
      * </ul>
-     * <p>
      *
      * @param   codePoint the character (Unicode code point) to be tested.
      * @return  {@code true} if the character is a Java whitespace
@@ -7121,7 +7119,6 @@
     /**
      * Converts the character (Unicode code point) argument to uppercase using
      * information from the UnicodeData file.
-     * <p>
      *
      * @param   codePoint   the character (Unicode code point) to be converted.
      * @return  either the uppercase equivalent of the character, if
--- a/src/share/classes/java/lang/Math.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/lang/Math.java	Mon May 12 09:38:27 2014 -0700
@@ -1048,7 +1048,6 @@
      *       whereas {@code (-4 / 3) == -1}.
      *   </li>
      * </ul>
-     * <p>
      *
      * @param x the dividend
      * @param y the divisor
--- a/src/share/classes/java/lang/Runtime.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/lang/Runtime.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -83,7 +83,7 @@
      * blocks indefinitely.
      *
      * <p> The <tt>{@link System#exit(int) System.exit}</tt> method is the
-     * conventional and convenient means of invoking this method. <p>
+     * conventional and convenient means of invoking this method.
      *
      * @param  status
      *         Termination status.  By convention, a nonzero status code
@@ -180,7 +180,7 @@
      * method goes awry by, for example, corrupting internal data structures or
      * attempting to access nonexistent memory.  If the virtual machine aborts
      * then no guarantee can be made about whether or not any shutdown hooks
-     * will be run. <p>
+     * will be run.
      *
      * @param   hook
      *          An initialized but unstarted <tt>{@link Thread}</tt> object
@@ -248,7 +248,7 @@
      * hooks to be started and does not run uninvoked finalizers if
      * finalization-on-exit has been enabled.  If the shutdown sequence has
      * already been initiated then this method does not wait for any running
-     * shutdown hooks or finalizers to finish their work. <p>
+     * shutdown hooks or finalizers to finish their work.
      *
      * @param  status
      *         Termination status.  By convention, a nonzero status code
--- a/src/share/classes/java/lang/SecurityManager.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/lang/SecurityManager.java	Mon May 12 09:38:27 2014 -0700
@@ -1242,7 +1242,6 @@
      * <code>super.checkPropertiesAccess</code>
      * at the point the overridden method would normally throw an
      * exception.
-     * <p>
      *
      * @exception  SecurityException  if the calling thread does not have
      *             permission to access or modify the system properties.
@@ -1320,7 +1319,6 @@
      * <code>super.checkPrintJobAccess</code>
      * at the point the overridden method would normally throw an
      * exception.
-     * <p>
      *
      * @exception  SecurityException  if the calling thread does not have
      *             permission to initiate a print job request.
@@ -1566,7 +1564,6 @@
      * <code>super.checkSetFactory</code>
      * at the point the overridden method would normally throw an
      * exception.
-     * <p>
      *
      * @exception  SecurityException  if the calling thread does not have
      *             permission to specify a socket factory or a stream
--- a/src/share/classes/java/lang/String.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/lang/String.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2650,7 +2650,7 @@
      * LATIN SMALL LETTER DOTLESS I character.
      * To obtain correct results for locale insensitive strings, use
      * {@code toLowerCase(Locale.ROOT)}.
-     * <p>
+     *
      * @return  the {@code String}, converted to lowercase.
      * @see     java.lang.String#toLowerCase(Locale)
      */
@@ -2812,7 +2812,7 @@
      * LATIN CAPITAL LETTER I WITH DOT ABOVE character.
      * To obtain correct results for locale insensitive strings, use
      * {@code toUpperCase(Locale.ROOT)}.
-     * <p>
+     *
      * @return  the {@code String}, converted to uppercase.
      * @see     java.lang.String#toUpperCase(Locale)
      */
--- a/src/share/classes/java/lang/System.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/lang/System.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -133,7 +133,6 @@
      * <p>First, if there is a security manager, its <code>checkPermission</code>
      * method is called with a <code>RuntimePermission("setIO")</code> permission
      *  to see if it's ok to reassign the "standard" input stream.
-     * <p>
      *
      * @param in the new standard input stream.
      *
@@ -762,7 +761,6 @@
      * permission. This may result in a SecurityException being thrown.
      * If no exception is thrown, the specified property is set to the given
      * value.
-     * <p>
      *
      * @param      key   the name of the system property.
      * @param      value the value of the system property.
@@ -801,7 +799,6 @@
      * is called with a <code>PropertyPermission(key, "write")</code>
      * permission. This may result in a SecurityException being thrown.
      * If no exception is thrown, the specified property is removed.
-     * <p>
      *
      * @param      key   the name of the system property to be removed.
      * @return     the previous string value of the system property,
--- a/src/share/classes/java/lang/instrument/package.html	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/lang/instrument/package.html	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 <!--
- Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -140,7 +140,7 @@
 
   <li><p>The system class loader (
       {@link java.lang.ClassLoader#getSystemClassLoader ClassLoader.getSystemClassLoader}) must
-      support a mechanism to add an agent JAR file to the system class path. <p></li>
+      support a mechanism to add an agent JAR file to the system class path.</li>
 </ol>  
 
 <P>
--- a/src/share/classes/java/lang/invoke/MethodHandles.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/lang/invoke/MethodHandles.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,7 @@
  * <li>Combinator methods, which combine or transform pre-existing method handles into new ones.
  * <li>Other factory methods to create method handles that emulate other common JVM operations or control flow patterns.
  * </ul>
- * <p>
+ *
  * @author John Rose, JSR 292 EG
  * @since 1.7
  */
--- a/src/share/classes/java/lang/management/MemoryNotificationInfo.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/lang/management/MemoryNotificationInfo.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -89,7 +89,7 @@
  *       Subsequent crossing of the usage threshold value does not cause
  *       further notification until the memory usage has returned
  *       to become less than the usage threshold value.
- *       <p></li>
+ *       </li>
  *   <li>A {@link #MEMORY_COLLECTION_THRESHOLD_EXCEEDED
  *       collection usage threshold exceeded notification}.
  *       <br>This notification will be emitted when
--- a/src/share/classes/java/lang/management/ThreadInfo.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/lang/management/ThreadInfo.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -429,12 +429,12 @@
      *     <br>The thread is in the {@link java.lang.Thread.State#BLOCKED BLOCKED}
      *     state waiting to enter the <tt>synchronized</tt> statement
      *     or method.
-     *     <p></li>
+     *     </li>
      * <li>an object monitor to be notified by another thread.
      *     <br>The thread is in the {@link java.lang.Thread.State#WAITING WAITING}
      *     or {@link java.lang.Thread.State#TIMED_WAITING TIMED_WAITING} state
      *     due to a call to the {@link Object#wait Object.wait} method.
-     *     <p></li>
+     *     </li>
      * <li>a synchronization object responsible for the thread parking.
      *     <br>The thread is in the {@link java.lang.Thread.State#WAITING WAITING}
      *     or {@link java.lang.Thread.State#TIMED_WAITING TIMED_WAITING} state
--- a/src/share/classes/java/lang/management/package.html	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/lang/management/package.html	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 <!--
- Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,6 @@
 Java virtual machine and other components in the Java runtime.
 It allows both local and remote
 monitoring and management of the running Java virtual machine.
-<p>
 
 <h4><a name="MXBean">Platform MXBean</a></h4>
 <p>
@@ -41,7 +40,6 @@
 Each platform MXBean is a {@link java.lang.management.PlatformManagedObject}
 with a unique
 {@linkplain java.lang.management.PlatformManagedObject#getObjectName name}.
-<p>
 <h4>ManagementFactory</h4>
 
 <p>The {@link java.lang.management.ManagementFactory} class is the management
@@ -80,7 +78,6 @@
 Java virtual machine and the runtime in the following ways:
 <p>
 <b>1. Direct access to an MXBean interface</b>
-<p>
 <ul>
 <li>Get an MXBean instance locally in the running Java virtual machine:
 <pre>
@@ -100,7 +97,6 @@
    // Get the standard attribute "VmVendor"
    String vendor = mxbean.getVmVendor();
 </pre>
-<p>
 </li>
 <li>Construct an MXBean proxy instance that forwards the
     method calls to a given MBeanServer:
@@ -132,7 +128,7 @@
 </li>
 </ul>
 <p>
-<b>2. Indirect access to an MXBean interface via MBeanServer</b><p>
+<b>2. Indirect access to an MXBean interface via MBeanServer</b>
 <ul>
 <li>Go through the
     {@link java.lang.management.ManagementFactory#getPlatformMBeanServer
@@ -143,7 +139,7 @@
     <em>JMX open types</em> which include basic data types,
     {@link javax.management.openmbean.CompositeData CompositeData},
     and {@link javax.management.openmbean.TabularData TabularData}
-    defined in {@link javax.management.openmbean.OpenType OpenType}.<p>
+    defined in {@link javax.management.openmbean.OpenType OpenType}.
 <pre>
    MBeanServerConnection mbs;
 
--- a/src/share/classes/java/math/BigInteger.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/math/BigInteger.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3597,7 +3597,7 @@
      * Converts the specified BigInteger to a string and appends to
      * {@code sb}.  This implements the recursive Schoenhage algorithm
      * for base conversions.
-     * <p/>
+     * <p>
      * See Knuth, Donald,  _The Art of Computer Programming_, Vol. 2,
      * Answers to Exercises (4.4) Question 14.
      *
@@ -3646,7 +3646,7 @@
     /**
      * Returns the value radix^(2^exponent) from the cache.
      * If this value doesn't already exist in the cache, it is added.
-     * <p/>
+     * <p>
      * This could be changed to a more complicated caching method using
      * {@code Future}.
      */
--- a/src/share/classes/java/net/ContentHandler.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/net/ContentHandler.java	Mon May 12 09:38:27 2014 -0700
@@ -46,15 +46,28 @@
  * <p>
  * If no content handler could be found, URLConnection will
  * look for a content handler in a user-defineable set of places.
- * By default it looks in sun.net.www.content, but users can define a
- * vertical-bar delimited set of class prefixes to search through in
- * addition by defining the java.content.handler.pkgs property.
- * The class name must be of the form:
- * <pre>
- *     {package-prefix}.{major}.{minor}
- * e.g.
+ * Users can define a vertical-bar delimited set of class prefixes
+ * to search through by defining the <i>java.content.handler.pkgs</i>
+ * property. The class name must be of the form:
+ * <blockquote>
+ *     <i>{package-prefix}.{major}.{minor}</i>
+ *     <P>
+ *     where <i>{major}.{minor}</i> is formed by taking the
+ *     content-type string, replacing all slash characters with a
+ *     {@code period} ('.'), and all other non-alphanumeric characters
+ *     with the underscore character '{@code _}'. The alphanumeric
+ *     characters are specifically the 26 uppercase ASCII letters
+ *     '{@code A}' through '{@code Z}', the 26 lowercase ASCII
+ *     letters '{@code a}' through '{@code z}', and the 10 ASCII
+ *     digits '{@code 0}' through '{@code 9}'.
+ *     <p>
+ *     e.g.
  *     YoyoDyne.experimental.text.plain
- * </pre>
+ * </blockquote>
+ * If no user-defined content handler is found, then the system
+ * tries to load a specific <i>content-type</i> handler from one
+ * of the built-in handlers, if one exists.
+ * <p>
  * If the loading of the content handler class would be performed by
  * a classloader that is outside of the delegation chain of the caller,
  * the JVM will need the RuntimePermission "getClassLoader".
--- a/src/share/classes/java/net/URL.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/net/URL.java	Mon May 12 09:38:27 2014 -0700
@@ -266,10 +266,7 @@
      *     a subclass of {@code URLStreamHandler}, then the next package
      *     in the list is tried.
      * <li>If the previous step fails to find a protocol handler, then the
-     *     constructor tries to load from a system default package.
-     *     <blockquote><pre>
-     *         &lt;<i>system default package</i>&gt;.&lt;<i>protocol</i>&gt;.Handler
-     *     </pre></blockquote>
+     *     constructor tries to load a built-in protocol handler.
      *     If this class does not exist, or if the class exists but it is not a
      *     subclass of {@code URLStreamHandler}, then a
      *     {@code MalformedURLException} is thrown.
--- a/src/share/classes/java/net/URLConnection.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/net/URLConnection.java	Mon May 12 09:38:27 2014 -0700
@@ -704,21 +704,10 @@
      *     handler for that content type.
      * <li>If no content handler factory has yet been set up, or if the
      *     factory's {@code createContentHandler} method returns
-     *     {@code null}, then the application loads the class named:
-     *     <blockquote><pre>
-     *         sun.net.www.content.&lt;<i>contentType</i>&gt;
-     *     </pre></blockquote>
-     *     where &lt;<i>contentType</i>&gt; is formed by taking the
-     *     content-type string, replacing all slash characters with a
-     *     {@code period} ('.'), and all other non-alphanumeric characters
-     *     with the underscore character '{@code _}'. The alphanumeric
-     *     characters are specifically the 26 uppercase ASCII letters
-     *     '{@code A}' through '{@code Z}', the 26 lowercase ASCII
-     *     letters '{@code a}' through '{@code z}', and the 10 ASCII
-     *     digits '{@code 0}' through '{@code 9}'. If the specified
-     *     class does not exist, or is not a subclass of
-     *     {@code ContentHandler}, then an
-     *     {@code UnknownServiceException} is thrown.
+     *     {@code null}, then this method tries to load a content handler
+     *     class as defined by {@link java.net.ContentHandler ContentHandler}.
+     *     If the class does not exist, or is not a subclass of {@code
+     *     ContentHandler}, then an {@code UnknownServiceException} is thrown.
      * </ol>
      *
      * @return     the object fetched. The {@code instanceof} operator
--- a/src/share/classes/java/util/BitSet.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/util/BitSet.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -696,6 +696,9 @@
      *  <pre> {@code
      * for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1)) {
      *     // operate on index i here
+     *     if (i == Integer.MAX_VALUE) {
+     *         break; // or (i+1) would overflow
+     *     }
      * }}</pre>
      *
      * @param  fromIndex the index to start checking from (inclusive)
@@ -1186,10 +1189,12 @@
         int i = nextSetBit(0);
         if (i != -1) {
             b.append(i);
-            for (i = nextSetBit(i+1); i >= 0; i = nextSetBit(i+1)) {
+            while (true) {
+                if (++i < 0) break;
+                if ((i = nextSetBit(i)) < 0) break;
                 int endOfRun = nextClearBit(i);
                 do { b.append(", ").append(i); }
-                while (++i < endOfRun);
+                while (++i != endOfRun);
             }
         }
 
--- a/src/share/classes/java/util/Locale.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/util/Locale.java	Mon May 12 09:38:27 2014 -0700
@@ -2904,8 +2904,8 @@
                 for (int i = 1; i < subtags.length; i++) {
                     if (isSubtagIllFormed(subtags[i], false)) {
                         isIllFormed = true;
+                        break;
                     }
-                    break;
                 }
             }
             if (isIllFormed) {
--- a/src/share/classes/java/util/stream/SortedOps.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/java/util/stream/SortedOps.java	Mon May 12 09:38:27 2014 -0700
@@ -279,16 +279,60 @@
     }
 
     /**
+     * Abstract {@link Sink} for implementing sort on reference streams.
+     *
+     * <p>
+     * Note: documentation below applies to reference and all primitive sinks.
+     * <p>
+     * Sorting sinks first accept all elements, buffering then into an array
+     * or a re-sizable data structure, if the size of the pipeline is known or
+     * unknown respectively.  At the end of the sink protocol those elements are
+     * sorted and then pushed downstream.
+     * This class records if {@link #cancellationRequested} is called.  If so it
+     * can be inferred that the source pushing source elements into the pipeline
+     * knows that the pipeline is short-circuiting.  In such cases sub-classes
+     * pushing elements downstream will preserve the short-circuiting protocol
+     * by calling {@code downstream.cancellationRequested()} and checking the
+     * result is {@code false} before an element is pushed.
+     * <p>
+     * Note that the above behaviour is an optimization for sorting with
+     * sequential streams.  It is not an error that more elements, than strictly
+     * required to produce a result, may flow through the pipeline.  This can
+     * occur, in general (not restricted to just sorting), for short-circuiting
+     * parallel pipelines.
+     */
+    private static abstract class AbstractRefSortingSink<T> extends Sink.ChainedReference<T, T> {
+        protected final Comparator<? super T> comparator;
+        // @@@ could be a lazy final value, if/when support is added
+        protected boolean cancellationWasRequested;
+
+        AbstractRefSortingSink(Sink<? super T> downstream, Comparator<? super T> comparator) {
+            super(downstream);
+            this.comparator = comparator;
+        }
+
+        /**
+         * Records is cancellation is requested so short-circuiting behaviour
+         * can be preserved when the sorted elements are pushed downstream.
+         *
+         * @return false, as this sink never short-circuits.
+         */
+        @Override
+        public final boolean cancellationRequested() {
+            cancellationWasRequested = true;
+            return false;
+        }
+    }
+
+    /**
      * {@link Sink} for implementing sort on SIZED reference streams.
      */
-    private static final class SizedRefSortingSink<T> extends Sink.ChainedReference<T, T> {
-        private final Comparator<? super T> comparator;
+    private static final class SizedRefSortingSink<T> extends AbstractRefSortingSink<T> {
         private T[] array;
         private int offset;
 
         SizedRefSortingSink(Sink<? super T> sink, Comparator<? super T> comparator) {
-            super(sink);
-            this.comparator = comparator;
+            super(sink, comparator);
         }
 
         @Override
@@ -303,8 +347,14 @@
         public void end() {
             Arrays.sort(array, 0, offset, comparator);
             downstream.begin(offset);
-            for (int i = 0; i < offset; i++)
-                downstream.accept(array[i]);
+            if (!cancellationWasRequested) {
+                for (int i = 0; i < offset; i++)
+                    downstream.accept(array[i]);
+            }
+            else {
+                for (int i = 0; i < offset && !downstream.cancellationRequested(); i++)
+                    downstream.accept(array[i]);
+            }
             downstream.end();
             array = null;
         }
@@ -318,13 +368,11 @@
     /**
      * {@link Sink} for implementing sort on reference streams.
      */
-    private static final class RefSortingSink<T> extends Sink.ChainedReference<T, T> {
-        private final Comparator<? super T> comparator;
+    private static final class RefSortingSink<T> extends AbstractRefSortingSink<T> {
         private ArrayList<T> list;
 
         RefSortingSink(Sink<? super T> sink, Comparator<? super T> comparator) {
-            super(sink);
-            this.comparator = comparator;
+            super(sink, comparator);
         }
 
         @Override
@@ -338,7 +386,15 @@
         public void end() {
             list.sort(comparator);
             downstream.begin(list.size());
-            list.forEach(downstream::accept);
+            if (!cancellationWasRequested) {
+                list.forEach(downstream::accept);
+            }
+            else {
+                for (T t : list) {
+                    if (downstream.cancellationRequested()) break;
+                    downstream.accept(t);
+                }
+            }
             downstream.end();
             list = null;
         }
@@ -350,9 +406,26 @@
     }
 
     /**
+     * Abstract {@link Sink} for implementing sort on int streams.
+     */
+    private static abstract class AbstractIntSortingSink extends Sink.ChainedInt<Integer> {
+        protected boolean cancellationWasRequested;
+
+        AbstractIntSortingSink(Sink<? super Integer> downstream) {
+            super(downstream);
+        }
+
+        @Override
+        public final boolean cancellationRequested() {
+            cancellationWasRequested = true;
+            return false;
+        }
+    }
+
+    /**
      * {@link Sink} for implementing sort on SIZED int streams.
      */
-    private static final class SizedIntSortingSink extends Sink.ChainedInt<Integer> {
+    private static final class SizedIntSortingSink extends AbstractIntSortingSink {
         private int[] array;
         private int offset;
 
@@ -371,8 +444,14 @@
         public void end() {
             Arrays.sort(array, 0, offset);
             downstream.begin(offset);
-            for (int i = 0; i < offset; i++)
-                downstream.accept(array[i]);
+            if (!cancellationWasRequested) {
+                for (int i = 0; i < offset; i++)
+                    downstream.accept(array[i]);
+            }
+            else {
+                for (int i = 0; i < offset && !downstream.cancellationRequested(); i++)
+                    downstream.accept(array[i]);
+            }
             downstream.end();
             array = null;
         }
@@ -386,7 +465,7 @@
     /**
      * {@link Sink} for implementing sort on int streams.
      */
-    private static final class IntSortingSink extends Sink.ChainedInt<Integer> {
+    private static final class IntSortingSink extends AbstractIntSortingSink {
         private SpinedBuffer.OfInt b;
 
         IntSortingSink(Sink<? super Integer> sink) {
@@ -405,8 +484,16 @@
             int[] ints = b.asPrimitiveArray();
             Arrays.sort(ints);
             downstream.begin(ints.length);
-            for (int anInt : ints)
-                downstream.accept(anInt);
+            if (!cancellationWasRequested) {
+                for (int anInt : ints)
+                    downstream.accept(anInt);
+            }
+            else {
+                for (int anInt : ints) {
+                    if (downstream.cancellationRequested()) break;
+                    downstream.accept(anInt);
+                }
+            }
             downstream.end();
         }
 
@@ -417,9 +504,26 @@
     }
 
     /**
+     * Abstract {@link Sink} for implementing sort on long streams.
+     */
+    private static abstract class AbstractLongSortingSink extends Sink.ChainedLong<Long> {
+        protected boolean cancellationWasRequested;
+
+        AbstractLongSortingSink(Sink<? super Long> downstream) {
+            super(downstream);
+        }
+
+        @Override
+        public final boolean cancellationRequested() {
+            cancellationWasRequested = true;
+            return false;
+        }
+    }
+
+    /**
      * {@link Sink} for implementing sort on SIZED long streams.
      */
-    private static final class SizedLongSortingSink extends Sink.ChainedLong<Long> {
+    private static final class SizedLongSortingSink extends AbstractLongSortingSink {
         private long[] array;
         private int offset;
 
@@ -438,8 +542,14 @@
         public void end() {
             Arrays.sort(array, 0, offset);
             downstream.begin(offset);
-            for (int i = 0; i < offset; i++)
-                downstream.accept(array[i]);
+            if (!cancellationWasRequested) {
+                for (int i = 0; i < offset; i++)
+                    downstream.accept(array[i]);
+            }
+            else {
+                for (int i = 0; i < offset && !downstream.cancellationRequested(); i++)
+                    downstream.accept(array[i]);
+            }
             downstream.end();
             array = null;
         }
@@ -453,7 +563,7 @@
     /**
      * {@link Sink} for implementing sort on long streams.
      */
-    private static final class LongSortingSink extends Sink.ChainedLong<Long> {
+    private static final class LongSortingSink extends AbstractLongSortingSink {
         private SpinedBuffer.OfLong b;
 
         LongSortingSink(Sink<? super Long> sink) {
@@ -472,8 +582,16 @@
             long[] longs = b.asPrimitiveArray();
             Arrays.sort(longs);
             downstream.begin(longs.length);
-            for (long aLong : longs)
-                downstream.accept(aLong);
+            if (!cancellationWasRequested) {
+                for (long aLong : longs)
+                    downstream.accept(aLong);
+            }
+            else {
+                for (long aLong : longs) {
+                    if (downstream.cancellationRequested()) break;
+                    downstream.accept(aLong);
+                }
+            }
             downstream.end();
         }
 
@@ -484,9 +602,26 @@
     }
 
     /**
+     * Abstract {@link Sink} for implementing sort on long streams.
+     */
+    private static abstract class AbstractDoubleSortingSink extends Sink.ChainedDouble<Double> {
+        protected boolean cancellationWasRequested;
+
+        AbstractDoubleSortingSink(Sink<? super Double> downstream) {
+            super(downstream);
+        }
+
+        @Override
+        public final boolean cancellationRequested() {
+            cancellationWasRequested = true;
+            return false;
+        }
+    }
+
+    /**
      * {@link Sink} for implementing sort on SIZED double streams.
      */
-    private static final class SizedDoubleSortingSink extends Sink.ChainedDouble<Double> {
+    private static final class SizedDoubleSortingSink extends AbstractDoubleSortingSink {
         private double[] array;
         private int offset;
 
@@ -505,8 +640,14 @@
         public void end() {
             Arrays.sort(array, 0, offset);
             downstream.begin(offset);
-            for (int i = 0; i < offset; i++)
-                downstream.accept(array[i]);
+            if (!cancellationWasRequested) {
+                for (int i = 0; i < offset; i++)
+                    downstream.accept(array[i]);
+            }
+            else {
+                for (int i = 0; i < offset && !downstream.cancellationRequested(); i++)
+                    downstream.accept(array[i]);
+            }
             downstream.end();
             array = null;
         }
@@ -520,7 +661,7 @@
     /**
      * {@link Sink} for implementing sort on double streams.
      */
-    private static final class DoubleSortingSink extends Sink.ChainedDouble<Double> {
+    private static final class DoubleSortingSink extends AbstractDoubleSortingSink {
         private SpinedBuffer.OfDouble b;
 
         DoubleSortingSink(Sink<? super Double> sink) {
@@ -539,8 +680,16 @@
             double[] doubles = b.asPrimitiveArray();
             Arrays.sort(doubles);
             downstream.begin(doubles.length);
-            for (double aDouble : doubles)
-                downstream.accept(aDouble);
+            if (!cancellationWasRequested) {
+                for (double aDouble : doubles)
+                    downstream.accept(aDouble);
+            }
+            else {
+                for (double aDouble : doubles) {
+                    if (downstream.cancellationRequested()) break;
+                    downstream.accept(aDouble);
+                }
+            }
             downstream.end();
         }
 
--- a/src/share/classes/javax/management/MBeanPermission.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/management/MBeanPermission.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -156,7 +156,7 @@
  * </ul>
  *
  * <p>In a comma-separated list of actions, spaces are allowed before
- * and after each action.</p>
+ * and after each action.
  *
  * @since 1.5
  */
@@ -1129,7 +1129,7 @@
      * Checks two MBeanPermission objects for equality. Checks
      * that <i>obj</i> is an MBeanPermission, and has the same
      * name and actions as this object.
-     * <P>
+     *
      * @param obj the object we are testing for equality with this object.
      * @return true if obj is an MBeanPermission, and has the
      * same name and actions as this MBeanPermission object.
--- a/src/share/classes/javax/management/MBeanServerPermission.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/management/MBeanServerPermission.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -285,7 +285,7 @@
      * Checks two MBeanServerPermission objects for equality. Checks that
      * <i>obj</i> is an MBeanServerPermission, and represents the same
      * list of allowable actions as this object.
-     * <P>
+     *
      * @param obj the object we are testing for equality with this object.
      * @return true if the objects are equal.
      */
--- a/src/share/classes/javax/management/modelmbean/ModelMBeanNotificationBroadcaster.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/management/modelmbean/ModelMBeanNotificationBroadcaster.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -124,7 +124,7 @@
         /**
          * Sends an attributeChangeNotification which contains the old value and new value for the
          * attribute to the registered AttributeChangeNotification listeners on the ModelMBean.
-         * <P>
+         *
          * @param oldValue The original value for the Attribute
          * @param newValue The current value for the Attribute
          * <PRE>
--- a/src/share/classes/javax/management/openmbean/CompositeType.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/management/openmbean/CompositeType.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -81,29 +81,29 @@
      * The Java class name of composite data values this composite type represents
      * (ie the class name returned by the {@link OpenType#getClassName() getClassName} method)
      * is set to the string value returned by <code>CompositeData.class.getName()</code>.
-     * <p>
+     *
      * @param  typeName  The name given to the composite type this instance represents; cannot be a null or empty string.
-     * <br>&nbsp;
+     *
      * @param  description  The human readable description of the composite type this instance represents;
      *                      cannot be a null or empty string.
-     * <br>&nbsp;
+     *
      * @param  itemNames  The names of the items contained in the
      *                    composite data values described by this <code>CompositeType</code> instance;
      *                    cannot be null and should contain at least one element; no element can be a null or empty string.
      *                    Note that the order in which the item names are given is not important to differentiate a
      *                    <code>CompositeType</code> instance from another;
      *                    the item names are internally stored sorted in ascending alphanumeric order.
-     * <br>&nbsp;
+     *
      * @param  itemDescriptions  The descriptions, in the same order as <var>itemNames</var>, of the items contained in the
      *                           composite data values described by this <code>CompositeType</code> instance;
      *                           should be of the same size as <var>itemNames</var>;
      *                           no element can be null or an empty string.
-     * <br>&nbsp;
+     *
      * @param  itemTypes  The open type instances, in the same order as <var>itemNames</var>, describing the items contained
      *                    in the composite data values described by this <code>CompositeType</code> instance;
      *                    should be of the same size as <var>itemNames</var>;
      *                    no element can be null.
-     * <br>&nbsp;
+     *
      * @throws IllegalArgumentException  If <var>typeName</var> or <var>description</var> is a null or empty string,
      *                                   or <var>itemNames</var> or <var>itemDescriptions</var> or <var>itemTypes</var> is null,
      *                                   or any element of <var>itemNames</var> or <var>itemDescriptions</var>
@@ -111,7 +111,7 @@
      *                                   or any element of <var>itemTypes</var> is null,
      *                                   or <var>itemNames</var> or <var>itemDescriptions</var> or <var>itemTypes</var>
      *                                   are not of the same size.
-     * <br>&nbsp;
+     *
      * @throws OpenDataException  If <var>itemNames</var> contains duplicate item names
      *                            (case sensitive, but leading and trailing whitespaces removed).
      */
@@ -356,7 +356,7 @@
      * <li>their type names are equal</li>
      * <li>their items' names and types are equal</li>
      * </ul>
-     * <br>&nbsp;
+     *
      * @param  obj  the object to be compared for equality with this <code>CompositeType</code> instance;
      *              if <var>obj</var> is <code>null</code>, <code>equals</code> returns <code>false</code>.
      *
--- a/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfo.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfo.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -113,7 +113,6 @@
      * for any two <code>OpenMBeanAttributeInfo</code> instances <code>t1</code> and <code>t2</code>,
      * as required by the general contract of the method
      * {@link Object#hashCode() Object.hashCode()}.
-     * <p>
      *
      * @return  the hash code value for this <code>OpenMBeanAttributeInfo</code> instance
      */
--- a/src/share/classes/javax/management/openmbean/OpenMBeanConstructorInfo.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/management/openmbean/OpenMBeanConstructorInfo.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -118,7 +118,6 @@
      * for any two <code>OpenMBeanConstructorInfo</code> instances <code>t1</code> and <code>t2</code>,
      * as required by the general contract of the method
      * {@link Object#hashCode() Object.hashCode()}.
-     * <p>
      *
      * @return  the hash code value for this <code>OpenMBeanConstructorInfo</code> instance
      */
--- a/src/share/classes/javax/management/openmbean/OpenMBeanInfo.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/management/openmbean/OpenMBeanInfo.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -168,7 +168,6 @@
      * for any two <code>OpenMBeanInfo</code> instances <code>t1</code> and <code>t2</code>,
      * as required by the general contract of the method
      * {@link Object#hashCode() Object.hashCode()}.
-     * <p>
      *
      * @return  the hash code value for this <code>OpenMBeanInfo</code> instance
      */
--- a/src/share/classes/javax/management/openmbean/OpenMBeanOperationInfo.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/management/openmbean/OpenMBeanOperationInfo.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -161,7 +161,7 @@
      * for any two <code>OpenMBeanOperationInfo</code> instances <code>t1</code> and <code>t2</code>,
      * as required by the general contract of the method
      * {@link Object#hashCode() Object.hashCode()}.
-     * <p>
+     *
      *
      * @return  the hash code value for this <code>OpenMBeanOperationInfo</code> instance
      */
--- a/src/share/classes/javax/management/openmbean/OpenMBeanParameterInfo.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/management/openmbean/OpenMBeanParameterInfo.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -192,7 +192,6 @@
      * for any two <code>OpenMBeanParameterInfo</code> instances <code>t1</code> and <code>t2</code>,
      * as required by the general contract of the method
      * {@link Object#hashCode() Object.hashCode()}.
-     * <p>
      *
      * @return  the hash code value for this <code>OpenMBeanParameterInfo</code> instance
      */
--- a/src/share/classes/javax/management/openmbean/TabularType.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/management/openmbean/TabularType.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -75,7 +75,7 @@
      * The Java class name of tabular data values this tabular type represents
      * (ie the class name returned by the {@link OpenType#getClassName() getClassName} method)
      * is set to the string value returned by <code>TabularData.class.getName()</code>.
-     * <p>
+     *
      * @param  typeName  The name given to the tabular type this instance represents; cannot be a null or empty string.
      * <br>&nbsp;
      * @param  description  The human readable description of the tabular type this instance represents;
--- a/src/share/classes/javax/management/remote/JMXConnectorFactory.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/management/remote/JMXConnectorFactory.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -134,7 +134,7 @@
  * <code>MalformedURLException</code> if there is none.  An
  * implementation may choose to find providers by other means.  For
  * example, it may support the <a
- * href="{@docRoot}/../technotes/guides/jar/jar.html#Service Provider">
+ * href="{@docRoot}/../technotes/guides/jar/jar.html#Service%20Provider">
  * JAR conventions for service providers</a>, where the service
  * interface is <code>JMXConnectorProvider</code>.</p>
  *
--- a/src/share/classes/javax/management/remote/JMXConnectorServerFactory.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/management/remote/JMXConnectorServerFactory.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -125,7 +125,7 @@
  * <code>MalformedURLException</code> if there is none.  An
  * implementation may choose to find providers by other means.  For
  * example, it may support the <a
- * href="{@docRoot}/../technotes/guides/jar/jar.html#Service Provider">
+ * href="{@docRoot}/../technotes/guides/jar/jar.html#Service%20Provider">
  * JAR conventions for service providers</a>, where the service
  * interface is <code>JMXConnectorServerProvider</code>.</p>
  *
--- a/src/share/classes/javax/management/remote/JMXPrincipal.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/management/remote/JMXPrincipal.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,7 +59,7 @@
     private String name;
 
     /**
-     * <p>Creates a JMXPrincipal for a given identity.</p>
+     * Creates a JMXPrincipal for a given identity.
      *
      * @param name the JMX Remote API name for this identity.
      *
@@ -74,8 +74,6 @@
     /**
      * Returns the name of this principal.
      *
-     * <p>
-     *
      * @return the name of this <code>JMXPrincipal</code>.
      */
     public String getName() {
@@ -85,8 +83,6 @@
     /**
      * Returns a string representation of this <code>JMXPrincipal</code>.
      *
-     * <p>
-     *
      * @return a string representation of this <code>JMXPrincipal</code>.
      */
     public String toString() {
@@ -99,8 +95,6 @@
      * <code>JMXPrincipal</code> and the two JMXPrincipals
      * have the same name.
      *
-     * <p>
-     *
      * @param o Object to be compared for equality with this
      * <code>JMXPrincipal</code>.
      *
@@ -124,8 +118,6 @@
     /**
      * Returns a hash code for this <code>JMXPrincipal</code>.
      *
-     * <p>
-     *
      * @return a hash code for this <code>JMXPrincipal</code>.
      */
     public int hashCode() {
--- a/src/share/classes/javax/management/remote/package.html	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/management/remote/package.html	Mon May 12 09:38:27 2014 -0700
@@ -2,7 +2,7 @@
 <head>
     <title>JMX<sup><font size="-2">TM</font></sup> Remote API.</title>
 <!--
-Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
 This code is free software; you can redistribute it and/or modify it
@@ -60,7 +60,7 @@
        <li>User-defined connector protocols are also possible using the 
 	{@link javax.management.remote.JMXConnectorFactory
 	JMXConnectorFactory} and, optionally, the Generic Connector
-	(not part of this bundle, see note below).</p>
+	(not part of this bundle, see note below).
       </ul>
 
       <p><u>Note</u>: the optional packages implementing
--- a/src/share/classes/javax/management/remote/rmi/package.html	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/management/remote/rmi/package.html	Mon May 12 09:38:27 2014 -0700
@@ -2,7 +2,7 @@
 <head>
     <title>RMI connector</title>
 <!--
-Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
 This code is free software; you can redistribute it and/or modify it
@@ -240,12 +240,12 @@
       that the RMI registry only allows registration from the local
       host.  So, in this case, <code>myhost</code> must be the name
       (or a name) of the host that the connector server is running
-      on.</p>
+      on.
 
     <p>In this <code>JMXServiceURL</code>, the first <code>rmi:</code>
       specifies the RMI
       connector, while the second <code>rmi:</code> specifies the RMI
-      registry.</p>
+      registry.
 
     <p>As another example, if the <code>JMXServiceURL</code> is:
 
@@ -262,7 +262,7 @@
       </pre>
 
       which means entry <code>cn=this,ou=that</code> in the LDAP
-      directory running on port 9999 of host <code>dirhost</code>.</p>
+      directory running on port 9999 of host <code>dirhost</code>.
 
     <p>If the <code>JMXServiceURL</code> is:
 
@@ -280,7 +280,7 @@
 
       For this case to work, the JNDI API must have been configured
       appropriately to supply the information about what directory to
-      use.</p>
+      use.
 
     <p>In these examples, the host name <code>ignoredhost</code> is
       not used by the connector server or its clients.  It can be
--- a/src/share/classes/javax/script/ScriptEngineFactory.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/script/ScriptEngineFactory.java	Mon May 12 09:38:27 2014 -0700
@@ -160,7 +160,6 @@
      *      return ret;
      * }
      * } </pre>
-     * <p>
      *
      * @param obj The name representing the object whose method is to be invoked. The
      * name is the one used to create bindings using the <code>put</code> method of
--- a/src/share/classes/javax/swing/text/html/CSS.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/swing/text/html/CSS.java	Mon May 12 09:38:27 2014 -0700
@@ -153,6 +153,8 @@
          * Fetch the default value for the attribute.
          * If there is no default value (such as for
          * composite attributes), null will be returned.
+         *
+         * @return default value for the attribute
          */
         public String getDefaultValue() {
             return defaultValue;
@@ -161,6 +163,8 @@
         /**
          * Indicates if the attribute should be inherited
          * from the parent or not.
+         *
+         * @return true if the attribute should be inherited from the parent
          */
         public boolean isInherited() {
             return inherited;
@@ -1036,6 +1040,8 @@
 
     /**
      * Return the set of all possible CSS attribute keys.
+     *
+     * @return the set of all possible CSS attribute keys
      */
     public static Attribute[] getAllAttributeKeys() {
         Attribute[] keys = new Attribute[Attribute.allAttributes.length];
--- a/src/share/classes/javax/swing/text/html/FormView.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/swing/text/html/FormView.java	Mon May 12 09:38:27 2014 -0700
@@ -448,6 +448,8 @@
     /**
      * This method is responsible for submitting the form data.
      * A thread is forked to undertake the submission.
+     *
+     * @param data data to submit
      */
     protected void submitData(String data) {
         Element form = getFormElement();
--- a/src/share/classes/javax/swing/text/html/HTML.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/swing/text/html/HTML.java	Mon May 12 09:38:27 2014 -0700
@@ -571,6 +571,9 @@
      * are recognized by the default HTML reader.
      * This set does not include tags that are
      * manufactured by the reader.
+     *
+     * @return the set of actual HTML tags that
+     * are recognized by the default HTML reader
      */
     public static Tag[] getAllTags() {
         Tag[] tags = new Tag[Tag.allTags.length];
@@ -626,6 +629,7 @@
      * @param key the key to use to fetch the value
      * @param def the default value to use if the attribute isn't
      *  defined or there is an error converting to an integer
+     * @return an attribute value
      */
     public static int getIntegerAttributeValue(AttributeSet attr,
                                                Attribute key, int def) {
--- a/src/share/classes/javax/swing/text/html/HTMLDocument.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/swing/text/html/HTMLDocument.java	Mon May 12 09:38:27 2014 -0700
@@ -339,6 +339,7 @@
      * <p>This is a convenience method for
      * <code>getReader(int, int, int, HTML.Tag, TRUE)</code>.
      *
+     * @param pos the starting position
      * @param popDepth   the number of <code>ElementSpec.EndTagTypes</code>
      *          to generate before inserting
      * @param pushDepth  the number of <code>ElementSpec.StartTagTypes</code>
@@ -1022,6 +1023,9 @@
      * @throws IllegalArgumentException if <code>elem</code> is a leaf
      * @throws IllegalStateException if an <code>HTMLEditorKit.Parser</code>
      *         has not been defined
+     * @throws BadLocationException if replacement is impossible because of
+     *         a structural issue
+     * @throws IOException if an I/O exception occurs
      * @since 1.3
      */
     public void setInnerHTML(Element elem, String htmlText) throws
@@ -1099,6 +1103,9 @@
      * @param htmlText the string to be parsed and inserted in place of <code>elem</code>
      * @throws IllegalStateException if an HTMLEditorKit.Parser has not
      *         been set
+     * @throws BadLocationException if replacement is impossible because of
+     *         a structural issue
+     * @throws IOException if an I/O exception occurs
      * @since 1.3
      */
     public void setOuterHTML(Element elem, String htmlText) throws
@@ -1177,6 +1184,9 @@
      * @throws IllegalArgumentException if <code>elem</code> is a leaf
      * @throws IllegalStateException if an HTMLEditorKit.Parser has not
      *         been set on the document
+     * @throws BadLocationException if insertion is impossible because of
+     *         a structural issue
+     * @throws IOException if an I/O exception occurs
      * @since 1.3
      */
     public void insertAfterStart(Element elem, String htmlText) throws
@@ -1247,6 +1257,9 @@
      * @throws IllegalArgumentException if <code>elem</code> is a leaf
      * @throws IllegalStateException if an HTMLEditorKit.Parser has not
      *         been set on the document
+     * @throws BadLocationException if insertion is impossible because of
+     *         a structural issue
+     * @throws IOException if an I/O exception occurs
      * @since 1.3
      */
     public void insertBeforeEnd(Element elem, String htmlText) throws
@@ -1310,6 +1323,9 @@
      * @param htmlText the string to be parsed and inserted before <code>elem</code>
      * @throws IllegalStateException if an HTMLEditorKit.Parser has not
      *         been set on the document
+     * @throws BadLocationException if insertion is impossible because of
+     *         a structural issue
+     * @throws IOException if an I/O exception occurs
      * @since 1.3
      */
     public void insertBeforeStart(Element elem, String htmlText) throws
@@ -1368,6 +1384,9 @@
      * @param htmlText the string to be parsed and inserted after <code>elem</code>
      * @throws IllegalStateException if an HTMLEditorKit.Parser has not
      *         been set on the document
+     * @throws BadLocationException if insertion is impossible because of
+     *         a structural issue
+     * @throws IOException if an I/O exception occurs
      * @since 1.3
      */
     public void insertAfterEnd(Element elem, String htmlText) throws
@@ -1890,6 +1909,7 @@
 
         /**
          * Type of tag this iterator represents.
+         * @return the tag
          */
         public abstract HTML.Tag getTag();
     }
@@ -2171,10 +2191,24 @@
      */
     public class HTMLReader extends HTMLEditorKit.ParserCallback {
 
+        /**
+         * Constructs an HTMLReader using default pop and push depth and no tag to insert.
+         *
+         * @param offset the starting offset
+         */
         public HTMLReader(int offset) {
             this(offset, 0, 0, null);
         }
 
+        /**
+         * Constructs an HTMLReader.
+         *
+         * @param offset the starting offset
+         * @param popDepth how many parents to ascend before insert new element
+         * @param pushDepth how many parents to descend (relative to popDepth) before
+         *                  inserting
+         * @param insertTag a tag to insert (may be null)
+         */
         public HTMLReader(int offset, int popDepth, int pushDepth,
                           HTML.Tag insertTag) {
             this(offset, popDepth, pushDepth, insertTag, true, false, true);
@@ -2742,6 +2776,9 @@
          * all of the well-known tags will have been registered.
          * This can be used to change the handling of a particular
          * tag or to add support for custom tags.
+         *
+         * @param t an HTML tag
+         * @param a tag action handler
          */
         protected void registerTag(HTML.Tag t, TagAction a) {
             tagMap.put(t, a);
@@ -2762,6 +2799,9 @@
              * tag for those actions that are shared across
              * many tags.  By default this does nothing and
              * completely ignores the tag.
+             *
+             * @param t the HTML tag
+             * @param a the attributes
              */
             public void start(HTML.Tag t, MutableAttributeSet a) {
             }
@@ -2773,12 +2813,17 @@
              * tag for those actions that are shared across
              * many tags.  By default this does nothing and
              * completely ignores the tag.
+             *
+             * @param t the HTML tag
              */
             public void end(HTML.Tag t) {
             }
 
         }
 
+        /**
+         * Action assigned by default to handle the Block task of the reader.
+         */
         public class BlockAction extends TagAction {
 
             public void start(HTML.Tag t, MutableAttributeSet attr) {
@@ -2816,6 +2861,9 @@
         }
 
 
+        /**
+         * Action assigned by default to handle the Paragraph task of the reader.
+         */
         public class ParagraphAction extends BlockAction {
 
             public void start(HTML.Tag t, MutableAttributeSet a) {
@@ -2829,6 +2877,9 @@
             }
         }
 
+        /**
+         * Action assigned by default to handle the Special task of the reader.
+         */
         public class SpecialAction extends TagAction {
 
             public void start(HTML.Tag t, MutableAttributeSet a) {
@@ -2848,6 +2899,9 @@
         }
 
 
+        /**
+         * Action assigned by default to handle the Hidden task of the reader.
+         */
         public class HiddenAction extends TagAction {
 
             public void start(HTML.Tag t, MutableAttributeSet a) {
@@ -3093,6 +3147,9 @@
             }
         }
 
+        /**
+         * Action assigned by default to handle the Character task of the reader.
+         */
         public class CharacterAction extends TagAction {
 
             public void start(HTML.Tag t, MutableAttributeSet attr) {
@@ -3515,6 +3572,8 @@
          * context.  Therefore all text that is seen belongs
          * to the text area and is hence added to the
          * TextAreaDocument associated with the text area.
+         *
+         * @param data the given content
          */
         protected void textAreaContent(char[] data) {
             try {
@@ -3529,6 +3588,8 @@
          * PRE element.  This synthesizes lines to hold the
          * runs of text, and makes calls to addContent to
          * actually add the text.
+         *
+         * @param data the given content
          */
         protected void preContent(char[] data) {
             int last = 0;
@@ -3550,6 +3611,9 @@
         /**
          * Adds an instruction to the parse buffer to create a
          * block element with the given attributes.
+         *
+         * @param t an HTML tag
+         * @param attr the attribute set
          */
         protected void blockOpen(HTML.Tag t, MutableAttributeSet attr) {
             if (impliedP) {
@@ -3574,6 +3638,8 @@
         /**
          * Adds an instruction to the parse buffer to close out
          * a block element of the given type.
+         *
+         * @param t the HTML tag
          */
         protected void blockClose(HTML.Tag t) {
             inBlock--;
@@ -3672,6 +3738,9 @@
         /**
          * Adds content that is basically specified entirely
          * in the attribute set.
+         *
+         * @param t an HTML tag
+         * @param a the attribute set
          */
         protected void addSpecialElement(HTML.Tag t, MutableAttributeSet a) {
             if ((t != HTML.Tag.FRAME) && (! inParagraph) && (! inPre)) {
@@ -4049,7 +4118,13 @@
          */
         Option option;
 
+        /**
+         * Buffer to keep building elements.
+         */
         protected Vector<ElementSpec> parseBuffer = new Vector<ElementSpec>();
+        /**
+         * Current character attribute set.
+         */
         protected MutableAttributeSet charAttr = new TaggedAttributeSet();
         Stack<AttributeSet> charAttrStack = new Stack<AttributeSet>();
         Hashtable<HTML.Tag, TagAction> tagMap;
--- a/src/share/classes/javax/swing/text/html/HTMLEditorKit.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/swing/text/html/HTMLEditorKit.java	Mon May 12 09:38:27 2014 -0700
@@ -971,6 +971,8 @@
          * Parse the given stream and drive the given callback
          * with the results of the parse.  This method should
          * be implemented to be thread-safe.
+         *
+         * @throws IOException if an I/O exception occurs
          */
         public abstract void parse(Reader r, ParserCallback cb, boolean ignoreCharSet) throws IOException;
 
@@ -1026,6 +1028,8 @@
          * or \r\n, which ever is encountered the most in parsing the
          * stream.
          *
+         * @param eol value of eol
+         *
          * @since 1.3
          */
         public void handleEndOfLineString(String eol) {
@@ -1490,6 +1494,7 @@
         }
 
         /**
+         * @param e the JEditorPane
          * @return HTMLDocument of <code>e</code>.
          */
         protected HTMLDocument getHTMLDocument(JEditorPane e) {
@@ -1501,6 +1506,7 @@
         }
 
         /**
+         * @param e the JEditorPane
          * @return HTMLEditorKit for <code>e</code>.
          */
         protected HTMLEditorKit getHTMLEditorKit(JEditorPane e) {
@@ -1514,6 +1520,10 @@
         /**
          * Returns an array of the Elements that contain <code>offset</code>.
          * The first elements corresponds to the root.
+         *
+         * @param doc an instance of HTMLDocument
+         * @param offset value of offset
+         * @return an array of the Elements that contain <code>offset</code>
          */
         protected Element[] getElementsAt(HTMLDocument doc, int offset) {
             return getElementsAt(doc.getDefaultRootElement(), offset, 0);
@@ -1541,6 +1551,11 @@
          * return -1 if no elements is found representing <code>tag</code>,
          * or 0 if the parent of the leaf at <code>offset</code> represents
          * <code>tag</code>.
+         *
+         * @param doc an instance of HTMLDocument
+         * @param offset an offset to start from
+         * @param tag tag to represent
+         * @return number of elements
          */
         protected int elementCountToTag(HTMLDocument doc, int offset,
                                         HTML.Tag tag) {
--- a/src/share/classes/javax/swing/text/html/HTMLFrameHyperlinkEvent.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/javax/swing/text/html/HTMLFrameHyperlinkEvent.java	Mon May 12 09:38:27 2014 -0700
@@ -125,6 +125,8 @@
 
     /**
      * returns the target for the link.
+     *
+     * @return the target for the link
      */
     public String getTarget() {
         return targetFrame;
--- a/src/share/classes/jdk/nio/zipfs/ZipFileSystem.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/jdk/nio/zipfs/ZipFileSystem.java	Mon May 12 09:38:27 2014 -0700
@@ -41,6 +41,8 @@
 import java.nio.file.spi.*;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.*;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -110,7 +112,9 @@
         }
         // sm and existence check
         zfpath.getFileSystem().provider().checkAccess(zfpath, AccessMode.READ);
-        if (!Files.isWritable(zfpath))
+        boolean writeable = AccessController.doPrivileged(
+            (PrivilegedAction<Boolean>) () ->  Files.isWritable(zfpath));
+        if (!writeable)
             this.readOnly = true;
         this.zc = ZipCoder.get(nameEncoding);
         this.defaultdir = new ZipPath(this, getBytes(defaultDir));
@@ -262,9 +266,13 @@
         }
         beginWrite();                   // lock and sync
         try {
-            sync();
-            ch.close();                 // close the ch just in case no update
-        } finally {                     // and sync dose not close the ch
+            AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+                sync(); return null;
+            });
+            ch.close();                          // close the ch just in case no update
+        } catch (PrivilegedActionException e) {  // and sync dose not close the ch
+            throw (IOException)e.getException();
+        } finally {
             endWrite();
         }
 
@@ -281,8 +289,10 @@
         synchronized (tmppaths) {
             for (Path p: tmppaths) {
                 try {
-                    Files.deleteIfExists(p);
-                } catch (IOException x) {
+                    AccessController.doPrivileged(
+                        (PrivilegedExceptionAction<Boolean>)() -> Files.deleteIfExists(p));
+                } catch (PrivilegedActionException e) {
+                    IOException x = (IOException)e.getException();
                     if (ioe == null)
                         ioe = x;
                     else
--- a/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataFile.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataFile.java	Mon May 12 09:38:27 2014 -0700
@@ -233,8 +233,6 @@
      *               does not conform to the expected pattern
      */
     public static int getLocalVmId(File file) {
-        int lvmid = 0;
-
         try {
             // try 1.4.2 and later format first
             return Integer.parseInt(file.getName());
@@ -287,31 +285,13 @@
         return tmpDirName + dirNamePrefix + user + File.separator;
     }
 
-    /*
-     * this static initializer would not be necessary if the
-     * Solaris java.io.tmpdir property were set to /tmp by default
-     */
     static {
         /*
-         * Why is java.io.tmpdir on Solaris set to "/var/tmp/" when the
-         * HotSpot JVM os:get_temp_path() method returns "/tmp/"
-         *
-         * Why do Solaris and Windows return a string with a trailing
-         * file separator character where as Linix does not? (this change
-         * seems to have occurred sometime during hopper beta)
+         * For this to work, the target VM and this code need to use
+         * the same directory. Instead of guessing which directory the
+         * VM is using, we will ask.
          */
-        String tmpdir = System.getProperty("java.io.tmpdir");
-
-        if (tmpdir.compareTo("/var/tmp/") == 0) {
-             /*
-              * shared memory files are created in /tmp. Interestingly,
-              * java.io.tmpdir is set to "/var/tmp/" on Solaris and Linux,
-              * but os::get_temp_directory() is set to "/tmp/" on these
-              * platforms. the java.io.logging packages also makes reference
-              * to java.io.tmpdir.
-              */
-             tmpdir = "/tmp/";
-        }
+        String tmpdir = sun.misc.VMSupport.getVMTemporaryDirectory();
 
         /*
          * Assure that the string returned has a trailing File.separator
--- a/src/share/classes/sun/misc/VMSupport.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/sun/misc/VMSupport.java	Mon May 12 09:38:27 2014 -0700
@@ -97,4 +97,14 @@
             throw new RuntimeException(ioe.getMessage());
         }
     }
+
+    /*
+     * Return the temporary directory that the VM uses for the attach
+     * and perf data files.
+     *
+     * It is important that this directory is well-known and the
+     * same for all VM instances. It cannot be affected by configuration
+     * variables such as java.io.tmpdir.
+     */
+    public static native String getVMTemporaryDirectory();
 }
--- a/src/share/classes/sun/nio/fs/AbstractPoller.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/sun/nio/fs/AbstractPoller.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -100,8 +100,6 @@
         // validate arguments before request to poller
         if (dir == null)
             throw new NullPointerException();
-        if (events.length == 0)
-            throw new IllegalArgumentException("No events to register");
         Set<WatchEvent.Kind<?>> eventSet = new HashSet<>(events.length);
         for (WatchEvent.Kind<?> event: events) {
             // standard events
@@ -114,17 +112,16 @@
             }
 
             // OVERFLOW is ignored
-            if (event == StandardWatchEventKinds.OVERFLOW) {
-                if (events.length == 1)
-                    throw new IllegalArgumentException("No events to register");
+            if (event == StandardWatchEventKinds.OVERFLOW)
                 continue;
-            }
 
             // null/unsupported
             if (event == null)
                 throw new NullPointerException("An element in event set is 'null'");
             throw new UnsupportedOperationException(event.name());
         }
+        if (eventSet.isEmpty())
+            throw new IllegalArgumentException("No events to register");
         return (WatchKey)invoke(RequestType.REGISTER, dir, eventSet, modifiers);
     }
 
@@ -192,14 +189,17 @@
          * the request.
          */
         Object awaitResult() {
+            boolean interrupted = false;
             synchronized (this) {
                 while (!completed) {
                     try {
                         wait();
                     } catch (InterruptedException x) {
-                        // ignore
+                        interrupted = true;
                     }
                 }
+                if (interrupted)
+                    Thread.currentThread().interrupt();
                 return result;
             }
         }
--- a/src/share/classes/sun/nio/fs/PollingWatchService.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/sun/nio/fs/PollingWatchService.java	Mon May 12 09:38:27 2014 -0700
@@ -74,8 +74,6 @@
          throws IOException
     {
         // check events - CCE will be thrown if there are invalid elements
-        if (events.length == 0)
-            throw new IllegalArgumentException("No events to register");
         final Set<WatchEvent.Kind<?>> eventSet =
             new HashSet<WatchEvent.Kind<?>>(events.length);
         for (WatchEvent.Kind<?> event: events) {
@@ -90,8 +88,6 @@
 
             // OVERFLOW is ignored
             if (event == StandardWatchEventKinds.OVERFLOW) {
-                if (events.length == 1)
-                    throw new IllegalArgumentException("No events to register");
                 continue;
             }
 
@@ -100,6 +96,8 @@
                 throw new NullPointerException("An element in event set is 'null'");
             throw new UnsupportedOperationException(event.name());
         }
+        if (eventSet.isEmpty())
+            throw new IllegalArgumentException("No events to register");
 
         // A modifier may be used to specify the sensitivity level
         SensitivityWatchEventModifier sensivity = SensitivityWatchEventModifier.MEDIUM;
--- a/src/share/classes/sun/security/krb5/internal/rcache/DflCache.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/sun/security/krb5/internal/rcache/DflCache.java	Mon May 12 09:38:27 2014 -0700
@@ -39,6 +39,7 @@
 import java.security.AccessController;
 import java.util.*;
 
+import com.sun.security.auth.module.UnixSystem;
 import sun.security.action.GetPropertyAction;
 import sun.security.krb5.internal.KerberosTime;
 import sun.security.krb5.internal.Krb5;
@@ -105,14 +106,14 @@
 
     private final String source;
 
-    private static int uid;
+    private static long uid;
     static {
         try {
             // Available on Solaris, Linux and Mac. Otherwise, no _euid suffix
-            Class<?> clazz = Class.forName("com.sun.security.auth.module.UnixSystem");
-            uid = (int)(long)(Long)
-                    clazz.getMethod("getUid").invoke(clazz.newInstance());
-        } catch (Exception e) {
+            UnixSystem us = new com.sun.security.auth.module.UnixSystem();
+            uid = us.getUid();
+        } catch (Throwable e) {
+            // Cannot be only Exception, might be UnsatisfiedLinkError
             uid = -1;
         }
     }
--- a/src/share/classes/sun/security/ssl/ByteBufferInputStream.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/sun/security/ssl/ByteBufferInputStream.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,7 +60,8 @@
         if (bb.remaining() == 0) {
             return -1;
         }
-        return bb.get();
+
+        return (bb.get() & 0xFF);   // need to be in the range 0 to 255
     }
 
     /**
--- a/src/share/classes/sun/security/ssl/EngineInputRecord.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/sun/security/ssl/EngineInputRecord.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -109,14 +109,8 @@
             ProtocolVersion recordVersion =
                 ProtocolVersion.valueOf(buf.get(pos + 1), buf.get(pos + 2));
 
-            // Check if too old (currently not possible)
-            // or if the major version does not match.
-            // The actual version negotiation is in the handshaker classes
-            if ((recordVersion.v < ProtocolVersion.MIN.v)
-                    || (recordVersion.major > ProtocolVersion.MAX.major)) {
-                throw new SSLException(
-                    "Unsupported record version " + recordVersion);
-            }
+            // check the record version
+            checkRecordVersion(recordVersion, false);
 
             /*
              * Reasonably sure this is a V3, disable further checks.
@@ -147,18 +141,8 @@
                 ProtocolVersion recordVersion =
                     ProtocolVersion.valueOf(buf.get(pos + 3), buf.get(pos + 4));
 
-                // Check if too old (currently not possible)
-                // or if the major version does not match.
-                // The actual version negotiation is in the handshaker classes
-                if ((recordVersion.v < ProtocolVersion.MIN.v)
-                        || (recordVersion.major > ProtocolVersion.MAX.major)) {
-
-                    // if it's not SSLv2, we're out of here.
-                    if (recordVersion.v != ProtocolVersion.SSL20Hello.v) {
-                        throw new SSLException(
-                            "Unsupported record version " + recordVersion);
-                    }
-                }
+                // check the record version
+                checkRecordVersion(recordVersion, true);
 
                 /*
                  * Client or Server Hello
@@ -406,14 +390,9 @@
 
         ProtocolVersion recordVersion = ProtocolVersion.valueOf(
                 srcBB.get(srcPos + 1), srcBB.get(srcPos + 2));
-        // Check if too old (currently not possible)
-        // or if the major version does not match.
-        // The actual version negotiation is in the handshaker classes
-        if ((recordVersion.v < ProtocolVersion.MIN.v)
-                || (recordVersion.major > ProtocolVersion.MAX.major)) {
-            throw new SSLException(
-                "Unsupported record version " + recordVersion);
-        }
+
+        // check the record version
+        checkRecordVersion(recordVersion, false);
 
         /*
          * It's really application data.  How much to consume?
--- a/src/share/classes/sun/security/ssl/InputRecord.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/sun/security/ssl/InputRecord.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -534,19 +534,35 @@
     }
 
     /**
+     * Return true if the specified record protocol version is out of the
+     * range of the possible supported versions.
+     */
+    static void checkRecordVersion(ProtocolVersion version,
+            boolean allowSSL20Hello) throws SSLException {
+        // Check if the record version is too old (currently not possible)
+        // or if the major version does not match.
+        //
+        // The actual version negotiation is in the handshaker classes
+        if ((version.v < ProtocolVersion.MIN.v) ||
+            ((version.major & 0xFF) > (ProtocolVersion.MAX.major & 0xFF))) {
+
+            // if it's not SSLv2, we're out of here.
+            if (!allowSSL20Hello ||
+                    (version.v != ProtocolVersion.SSL20Hello.v)) {
+                throw new SSLException("Unsupported record version " + version);
+            }
+        }
+    }
+
+    /**
      * Read a SSL/TLS record. Throw an IOException if the format is invalid.
      */
     private void readV3Record(InputStream s, OutputStream o)
             throws IOException {
         ProtocolVersion recordVersion = ProtocolVersion.valueOf(buf[1], buf[2]);
-        // Check if too old (currently not possible)
-        // or if the major version does not match.
-        // The actual version negotiation is in the handshaker classes
-        if ((recordVersion.v < ProtocolVersion.MIN.v)
-                || (recordVersion.major > ProtocolVersion.MAX.major)) {
-            throw new SSLException(
-                "Unsupported record version " + recordVersion);
-        }
+
+        // check the record version
+        checkRecordVersion(recordVersion, false);
 
         /*
          * Get and check length, then the data.
--- a/src/share/classes/sun/security/ssl/ProtocolVersion.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/sun/security/ssl/ProtocolVersion.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -101,7 +101,7 @@
         this.v = v;
         this.name = name;
         major = (byte)(v >>> 8);
-        minor = (byte)(v & 0xff);
+        minor = (byte)(v & 0xFF);
     }
 
     // private
@@ -117,8 +117,8 @@
         } else if (v == SSL20Hello.v) {
             return SSL20Hello;
         } else {
-            int major = (v >>> 8) & 0xff;
-            int minor = v & 0xff;
+            int major = (v >>> 8) & 0xFF;
+            int minor = v & 0xFF;
             return new ProtocolVersion(v, "Unknown-" + major + "." + minor);
         }
     }
@@ -128,10 +128,7 @@
      * numbers. Never throws exceptions.
      */
     public static ProtocolVersion valueOf(int major, int minor) {
-        major &= 0xff;
-        minor &= 0xff;
-        int v = (major << 8) | minor;
-        return valueOf(v);
+        return valueOf(((major & 0xFF) << 8) | (minor & 0xFF));
     }
 
     /**
--- a/src/share/classes/sun/security/validator/PKIXValidator.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/sun/security/validator/PKIXValidator.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,9 +60,6 @@
         AccessController.doPrivileged
             (new GetBooleanAction("com.sun.net.ssl.checkRevocation"));
 
-    // enable use of the validator if possible
-    private final static boolean TRY_VALIDATOR = true;
-
     private final Set<X509Certificate> trustedCerts;
     private final PKIXBuilderParameters parameterTemplate;
     private int certPathLength = -1;
@@ -75,48 +72,28 @@
 
     PKIXValidator(String variant, Collection<X509Certificate> trustedCerts) {
         super(TYPE_PKIX, variant);
-        if (trustedCerts instanceof Set) {
-            this.trustedCerts = (Set<X509Certificate>)trustedCerts;
-        } else {
-            this.trustedCerts = new HashSet<X509Certificate>(trustedCerts);
-        }
-        Set<TrustAnchor> trustAnchors = new HashSet<TrustAnchor>();
+        this.trustedCerts = (trustedCerts instanceof Set) ?
+                            (Set<X509Certificate>)trustedCerts :
+                            new HashSet<X509Certificate>(trustedCerts);
+
+        Set<TrustAnchor> trustAnchors = new HashSet<>();
         for (X509Certificate cert : trustedCerts) {
             trustAnchors.add(new TrustAnchor(cert, null));
         }
+
         try {
             parameterTemplate = new PKIXBuilderParameters(trustAnchors, null);
+            factory = CertificateFactory.getInstance("X.509");
         } catch (InvalidAlgorithmParameterException e) {
             throw new RuntimeException("Unexpected error: " + e.toString(), e);
-        }
-        setDefaultParameters(variant);
-
-        // initCommon();
-        if (TRY_VALIDATOR) {
-            if (TRY_VALIDATOR == false) {
-                return;
-            }
-            trustedSubjects = new HashMap<X500Principal, List<PublicKey>>();
-            for (X509Certificate cert : trustedCerts) {
-                X500Principal dn = cert.getSubjectX500Principal();
-                List<PublicKey> keys;
-                if (trustedSubjects.containsKey(dn)) {
-                    keys = trustedSubjects.get(dn);
-                } else {
-                    keys = new ArrayList<PublicKey>();
-                    trustedSubjects.put(dn, keys);
-                }
-                keys.add(cert.getPublicKey());
-            }
-            try {
-                factory = CertificateFactory.getInstance("X.509");
             } catch (CertificateException e) {
                 throw new RuntimeException("Internal error", e);
             }
+
+        setDefaultParameters(variant);
             plugin = variant.equals(VAR_PLUGIN_CODE_SIGNING);
-        } else {
-            plugin = false;
-        }
+
+        trustedSubjects = setTrustedSubjects();
     }
 
     PKIXValidator(String variant, PKIXBuilderParameters params) {
@@ -130,32 +107,40 @@
         }
         parameterTemplate = params;
 
-        // initCommon();
-        if (TRY_VALIDATOR) {
-            if (TRY_VALIDATOR == false) {
-                return;
-            }
-            trustedSubjects = new HashMap<X500Principal, List<PublicKey>>();
-            for (X509Certificate cert : trustedCerts) {
-                X500Principal dn = cert.getSubjectX500Principal();
-                List<PublicKey> keys;
-                if (trustedSubjects.containsKey(dn)) {
-                    keys = trustedSubjects.get(dn);
-                } else {
-                    keys = new ArrayList<PublicKey>();
-                    trustedSubjects.put(dn, keys);
-                }
-                keys.add(cert.getPublicKey());
-            }
             try {
                 factory = CertificateFactory.getInstance("X.509");
             } catch (CertificateException e) {
                 throw new RuntimeException("Internal error", e);
             }
+
             plugin = variant.equals(VAR_PLUGIN_CODE_SIGNING);
+
+        trustedSubjects = setTrustedSubjects();
+    }
+
+    /**
+     * Populate the trustedSubjects Map using the DN and public keys from
+     * the list of trusted certificates
+     *
+     * @return Map containing each subject DN and one or more public keys
+     *    tied to those DNs.
+     */
+    private Map<X500Principal, List<PublicKey>> setTrustedSubjects() {
+        Map<X500Principal, List<PublicKey>> subjectMap = new HashMap<>();
+
+        for (X509Certificate cert : trustedCerts) {
+            X500Principal dn = cert.getSubjectX500Principal();
+            List<PublicKey> keys;
+            if (subjectMap.containsKey(dn)) {
+                keys = subjectMap.get(dn);
         } else {
-            plugin = false;
+                keys = new ArrayList<PublicKey>();
+                subjectMap.put(dn, keys);
         }
+            keys.add(cert.getPublicKey());
+        }
+
+        return subjectMap;
     }
 
     public Collection<X509Certificate> getTrustedCertificates() {
@@ -217,7 +202,6 @@
             pkixParameters.addCertPathChecker(algorithmChecker);
         }
 
-        if (TRY_VALIDATOR) {
             // check that chain is in correct order and check if chain contains
             // trust anchor
             X500Principal prevIssuer = null;
@@ -287,7 +271,6 @@
                     (ValidatorException.T_NO_TRUST_ANCHOR);
             }
             // otherwise, fall back to builder
-        }
 
         return doBuild(chain, otherCerts, pkixParameters);
     }
--- a/src/share/classes/sun/tools/attach/HotSpotVirtualMachine.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/sun/tools/attach/HotSpotVirtualMachine.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -257,6 +257,20 @@
         return value;
     }
 
+    /*
+     * Utility method to read data into a String.
+     */
+    String readErrorMessage(InputStream sis) throws IOException {
+        byte b[] = new byte[1024];
+        int n;
+        StringBuffer message = new StringBuffer();
+        while ((n = sis.read(b)) != -1) {
+            message.append(new String(b, 0, n, "UTF-8"));
+        }
+        return message.toString();
+    }
+
+
     // -- attach timeout support
 
     private static long defaultAttachTimeout = 5000;
--- a/src/share/classes/sun/tools/jcmd/JCmd.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/classes/sun/tools/jcmd/JCmd.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,10 +33,12 @@
 import java.util.Comparator;
 import java.net.URISyntaxException;
 
+import com.sun.tools.attach.AttachOperationFailedException;
 import com.sun.tools.attach.VirtualMachine;
 import com.sun.tools.attach.VirtualMachineDescriptor;
 import com.sun.tools.attach.AgentLoadException;
 import com.sun.tools.attach.AttachNotSupportedException;
+
 import sun.tools.attach.HotSpotVirtualMachine;
 import sun.tools.jstat.JStatLogger;
 import sun.jvmstat.monitor.Monitor;
@@ -119,6 +121,7 @@
             pids.add(arg.getPid() + "");
         }
 
+        boolean success = true;
         for (String pid : pids) {
             System.out.println(pid + ":");
             if (arg.isListCounters()) {
@@ -126,11 +129,16 @@
             } else {
                 try {
                     executeCommandForPid(pid, arg.getCommand());
+                } catch(AttachOperationFailedException ex) {
+                    System.err.println(ex.getMessage());
+                    success = false;
                 } catch(Exception ex) {
                     ex.printStackTrace();
+                    success = false;
                 }
             }
         }
+        System.exit(success ? 0 : 1);
     }
 
     private static void executeCommandForPid(String pid, String command)
@@ -150,13 +158,18 @@
                 // read to EOF and just print output
                 byte b[] = new byte[256];
                 int n;
+                boolean messagePrinted = false;
                 do {
                     n = in.read(b);
                     if (n > 0) {
                         String s = new String(b, 0, n, "UTF-8");
                         System.out.print(s);
+                        messagePrinted = true;
                     }
                 } while (n > 0);
+                if (!messagePrinted) {
+                    System.out.println("Command executed successfully");
+                }
             }
         }
         vm.detach();
--- a/src/share/javavm/export/jvm.h	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/javavm/export/jvm.h	Mon May 12 09:38:27 2014 -0700
@@ -1331,6 +1331,9 @@
 JNIEXPORT jobject JNICALL
 JVM_InitAgentProperties(JNIEnv *env, jobject agent_props);
 
+JNIEXPORT jstring JNICALL
+JVM_GetTemporaryDirectory(JNIEnv *env);
+
 /* Generics reflection support.
  *
  * Returns information about the given class's EnclosingMethod
--- a/src/share/lib/security/java.policy	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/lib/security/java.policy	Mon May 12 09:38:27 2014 -0700
@@ -1,7 +1,39 @@
+// permissions required by each component
+grant codeBase "file:${java.home}/lib/ext/zipfs.jar" {
+        permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
+        permission java.lang.RuntimePermission "fileSystemProvider";
+        permission java.util.PropertyPermission "*", "read";
+};
 
-// Standard extensions get all permissions by default
+grant codeBase "file:${java.home}/lib/ext/cldrdata.jar" {
+        permission java.lang.RuntimePermission "accessClassInPackage.sun.text.*";
+        permission java.lang.RuntimePermission "accessClassInPackage.sun.util.*";
+        permission java.util.PropertyPermission "*", "read";
+};
 
-grant codeBase "file:${{java.ext.dirs}}/*" {
+grant codeBase "file:${java.home}/lib/ext/localedata.jar" {
+        permission java.lang.RuntimePermission "accessClassInPackage.sun.text.*";
+        permission java.lang.RuntimePermission "accessClassInPackage.sun.util.*";
+        permission java.util.PropertyPermission "*", "read";
+};
+
+grant codeBase "file:${java.home}/lib/ext/dnsns.jar" {
+        permission java.security.AllPermission;
+};
+
+grant codeBase "file:${java.home}/lib/ext/nashorn.jar" {
+        permission java.security.AllPermission;
+};
+
+grant codeBase "file:${java.home}/lib/ext/sunec.jar" {
+        permission java.security.AllPermission;
+};
+
+grant codeBase "file:${java.home}/lib/ext/sunjce_provider.jar" {
+        permission java.security.AllPermission;
+};
+
+grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
         permission java.security.AllPermission;
 };
 
--- a/src/share/native/sun/misc/VMSupport.c	Mon May 12 09:32:23 2014 -0700
+++ b/src/share/native/sun/misc/VMSupport.c	Mon May 12 09:38:27 2014 -0700
@@ -53,3 +53,9 @@
     }
     return (*InitAgentProperties_fp)(env, props);
 }
+
+JNIEXPORT jstring JNICALL
+Java_sun_misc_VMSupport_getVMTemporaryDirectory(JNIEnv *env, jclass cls)
+{
+    return JVM_GetTemporaryDirectory(env);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/solaris/classes/java/lang/UNIXProcess.java	Mon May 12 09:38:27 2014 -0700
@@ -0,0 +1,827 @@
+/*
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.Locale;
+import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.security.AccessController;
+import static java.security.AccessController.doPrivileged;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * java.lang.Process subclass in the UNIX environment.
+ *
+ * @author Mario Wolczko and Ross Knippel.
+ * @author Konstantin Kladko (ported to Linux and Bsd)
+ * @author Martin Buchholz
+ * @author Volker Simonis (ported to AIX)
+ */
+final class UNIXProcess extends Process {
+    private static final sun.misc.JavaIOFileDescriptorAccess fdAccess
+        = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess();
+
+    private final int pid;
+    private int exitcode;
+    private boolean hasExited;
+
+    private /* final */ OutputStream stdin;
+    private /* final */ InputStream  stdout;
+    private /* final */ InputStream  stderr;
+
+    // only used on Solaris
+    private /* final */ DeferredCloseInputStream stdout_inner_stream;
+
+    private static enum LaunchMechanism {
+        // order IS important!
+        FORK,
+        POSIX_SPAWN,
+        VFORK
+    }
+
+    private static enum Platform {
+
+        LINUX(LaunchMechanism.VFORK, LaunchMechanism.FORK),
+
+        BSD(LaunchMechanism.POSIX_SPAWN, LaunchMechanism.FORK),
+
+        SOLARIS(LaunchMechanism.POSIX_SPAWN, LaunchMechanism.FORK),
+
+        AIX(LaunchMechanism.POSIX_SPAWN, LaunchMechanism.FORK);
+
+        final LaunchMechanism defaultLaunchMechanism;
+        final Set<LaunchMechanism> validLaunchMechanisms;
+
+        Platform(LaunchMechanism ... launchMechanisms) {
+            this.defaultLaunchMechanism = launchMechanisms[0];
+            this.validLaunchMechanisms =
+                EnumSet.copyOf(Arrays.asList(launchMechanisms));
+        }
+
+        private String helperPath(String javahome, String osArch) {
+            switch (this) {
+                case SOLARIS:
+                    if (osArch.equals("x86")) { osArch = "i386"; }
+                    else if (osArch.equals("x86_64")) { osArch = "amd64"; }
+                    // fall through...
+                case LINUX:
+                case AIX:
+                    return javahome + "/lib/" + osArch + "/jspawnhelper";
+
+                case BSD:
+                    return javahome + "/lib/jspawnhelper";
+
+                default:
+                    throw new AssertionError("Unsupported platform: " + this);
+            }
+        }
+
+        String helperPath() {
+            return AccessController.doPrivileged(
+                (PrivilegedAction<String>) () ->
+                    helperPath(System.getProperty("java.home"),
+                               System.getProperty("os.arch"))
+            );
+        }
+
+        LaunchMechanism launchMechanism() {
+            return AccessController.doPrivileged(
+                (PrivilegedAction<LaunchMechanism>) () -> {
+                    String s = System.getProperty(
+                        "jdk.lang.Process.launchMechanism");
+                    LaunchMechanism lm;
+                    if (s == null) {
+                        lm = defaultLaunchMechanism;
+                        s = lm.name().toLowerCase(Locale.ENGLISH);
+                    } else {
+                        try {
+                            lm = LaunchMechanism.valueOf(
+                                s.toUpperCase(Locale.ENGLISH));
+                        } catch (IllegalArgumentException e) {
+                            lm = null;
+                        }
+                    }
+                    if (lm == null || !validLaunchMechanisms.contains(lm)) {
+                        throw new Error(
+                            s + " is not a supported " +
+                            "process launch mechanism on this platform."
+                        );
+                    }
+                    return lm;
+                }
+            );
+        }
+
+        static Platform get() {
+            String osName = AccessController.doPrivileged(
+                (PrivilegedAction<String>) () -> System.getProperty("os.name")
+            );
+
+            if (osName.equals("Linux")) { return LINUX; }
+            if (osName.contains("OS X")) { return BSD; }
+            if (osName.equals("SunOS")) { return SOLARIS; }
+            if (osName.equals("AIX")) { return AIX; }
+
+            throw new Error(osName + " is not a supported OS platform.");
+        }
+    }
+
+    private static final Platform platform = Platform.get();
+    private static final LaunchMechanism launchMechanism = platform.launchMechanism();
+    private static final byte[] helperpath = toCString(platform.helperPath());
+
+    private static byte[] toCString(String s) {
+        if (s == null)
+            return null;
+        byte[] bytes = s.getBytes();
+        byte[] result = new byte[bytes.length + 1];
+        System.arraycopy(bytes, 0,
+                         result, 0,
+                         bytes.length);
+        result[result.length-1] = (byte)0;
+        return result;
+    }
+
+    /* this is for the reaping thread */
+    private native int waitForProcessExit(int pid);
+
+    /**
+     * Creates a process. Depending on the {@code mode} flag, this is done by
+     * one of the following mechanisms:
+     * <pre>
+     *   1 - fork(2) and exec(2)
+     *   2 - posix_spawn(3P)
+     *   3 - vfork(2) and exec(2)
+     *
+     *  (4 - clone(2) and exec(2) - obsolete and currently disabled in native code)
+     * </pre>
+     * @param fds an array of three file descriptors.
+     *        Indexes 0, 1, and 2 correspond to standard input,
+     *        standard output and standard error, respectively.  On
+     *        input, a value of -1 means to create a pipe to connect
+     *        child and parent processes.  On output, a value which
+     *        is not -1 is the parent pipe fd corresponding to the
+     *        pipe which has been created.  An element of this array
+     *        is -1 on input if and only if it is <em>not</em> -1 on
+     *        output.
+     * @return the pid of the subprocess
+     */
+    private native int forkAndExec(int mode, byte[] helperpath,
+                                   byte[] prog,
+                                   byte[] argBlock, int argc,
+                                   byte[] envBlock, int envc,
+                                   byte[] dir,
+                                   int[] fds,
+                                   boolean redirectErrorStream)
+        throws IOException;
+
+    /**
+     * The thread pool of "process reaper" daemon threads.
+     */
+    private static final Executor processReaperExecutor =
+        doPrivileged((PrivilegedAction<Executor>) () -> {
+
+            ThreadGroup tg = Thread.currentThread().getThreadGroup();
+            while (tg.getParent() != null) tg = tg.getParent();
+            ThreadGroup systemThreadGroup = tg;
+
+            ThreadFactory threadFactory = grimReaper -> {
+                // Our thread stack requirement is quite modest.
+                Thread t = new Thread(systemThreadGroup, grimReaper,
+                                      "process reaper", 32768);
+                t.setDaemon(true);
+                // A small attempt (probably futile) to avoid priority inversion
+                t.setPriority(Thread.MAX_PRIORITY);
+                return t;
+            };
+
+            return Executors.newCachedThreadPool(threadFactory);
+        });
+
+    UNIXProcess(final byte[] prog,
+                final byte[] argBlock, final int argc,
+                final byte[] envBlock, final int envc,
+                final byte[] dir,
+                final int[] fds,
+                final boolean redirectErrorStream)
+            throws IOException {
+
+        pid = forkAndExec(launchMechanism.ordinal() + 1,
+                          helperpath,
+                          prog,
+                          argBlock, argc,
+                          envBlock, envc,
+                          dir,
+                          fds,
+                          redirectErrorStream);
+
+        try {
+            doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+                initStreams(fds);
+                return null;
+            });
+        } catch (PrivilegedActionException ex) {
+            throw (IOException) ex.getException();
+        }
+    }
+
+    static FileDescriptor newFileDescriptor(int fd) {
+        FileDescriptor fileDescriptor = new FileDescriptor();
+        fdAccess.set(fileDescriptor, fd);
+        return fileDescriptor;
+    }
+
+    void initStreams(int[] fds) throws IOException {
+        switch (platform) {
+            case LINUX:
+            case BSD:
+                stdin = (fds[0] == -1) ?
+                        ProcessBuilder.NullOutputStream.INSTANCE :
+                        new ProcessPipeOutputStream(fds[0]);
+
+                stdout = (fds[1] == -1) ?
+                         ProcessBuilder.NullInputStream.INSTANCE :
+                         new ProcessPipeInputStream(fds[1]);
+
+                stderr = (fds[2] == -1) ?
+                         ProcessBuilder.NullInputStream.INSTANCE :
+                         new ProcessPipeInputStream(fds[2]);
+
+                processReaperExecutor.execute(() -> {
+                    int exitcode = waitForProcessExit(pid);
+
+                    synchronized (this) {
+                        this.exitcode = exitcode;
+                        this.hasExited = true;
+                        this.notifyAll();
+                    }
+
+                    if (stdout instanceof ProcessPipeInputStream)
+                        ((ProcessPipeInputStream) stdout).processExited();
+
+                    if (stderr instanceof ProcessPipeInputStream)
+                        ((ProcessPipeInputStream) stderr).processExited();
+
+                    if (stdin instanceof ProcessPipeOutputStream)
+                        ((ProcessPipeOutputStream) stdin).processExited();
+                });
+                break;
+
+            case SOLARIS:
+                stdin = (fds[0] == -1) ?
+                        ProcessBuilder.NullOutputStream.INSTANCE :
+                        new BufferedOutputStream(
+                            new FileOutputStream(newFileDescriptor(fds[0])));
+
+                stdout = (fds[1] == -1) ?
+                         ProcessBuilder.NullInputStream.INSTANCE :
+                         new BufferedInputStream(
+                             stdout_inner_stream =
+                                 new DeferredCloseInputStream(
+                                     newFileDescriptor(fds[1])));
+
+                stderr = (fds[2] == -1) ?
+                         ProcessBuilder.NullInputStream.INSTANCE :
+                         new DeferredCloseInputStream(newFileDescriptor(fds[2]));
+
+                /*
+                 * For each subprocess forked a corresponding reaper task
+                 * is submitted.  That task is the only thread which waits
+                 * for the subprocess to terminate and it doesn't hold any
+                 * locks while doing so.  This design allows waitFor() and
+                 * exitStatus() to be safely executed in parallel (and they
+                 * need no native code).
+                 */
+                processReaperExecutor.execute(() -> {
+                    int exitcode = waitForProcessExit(pid);
+
+                    synchronized (this) {
+                        this.exitcode = exitcode;
+                        this.hasExited = true;
+                        this.notifyAll();
+                    }
+                });
+                break;
+
+            case AIX:
+                stdin = (fds[0] == -1) ?
+                        ProcessBuilder.NullOutputStream.INSTANCE :
+                        new ProcessPipeOutputStream(fds[0]);
+
+                stdout = (fds[1] == -1) ?
+                         ProcessBuilder.NullInputStream.INSTANCE :
+                         new DeferredCloseProcessPipeInputStream(fds[1]);
+
+                stderr = (fds[2] == -1) ?
+                         ProcessBuilder.NullInputStream.INSTANCE :
+                         new DeferredCloseProcessPipeInputStream(fds[2]);
+
+                processReaperExecutor.execute(() -> {
+                    int exitcode = waitForProcessExit(pid);
+
+                    synchronized (this) {
+                        this.exitcode = exitcode;
+                        this.hasExited = true;
+                        this.notifyAll();
+                    }
+
+                    if (stdout instanceof DeferredCloseProcessPipeInputStream)
+                        ((DeferredCloseProcessPipeInputStream) stdout).processExited();
+
+                    if (stderr instanceof DeferredCloseProcessPipeInputStream)
+                        ((DeferredCloseProcessPipeInputStream) stderr).processExited();
+
+                    if (stdin instanceof ProcessPipeOutputStream)
+                        ((ProcessPipeOutputStream) stdin).processExited();
+                });
+                break;
+
+            default: throw new AssertionError("Unsupported platform: " + platform);
+        }
+    }
+
+    public OutputStream getOutputStream() {
+        return stdin;
+    }
+
+    public InputStream getInputStream() {
+        return stdout;
+    }
+
+    public InputStream getErrorStream() {
+        return stderr;
+    }
+
+    public synchronized int waitFor() throws InterruptedException {
+        while (!hasExited) {
+            wait();
+        }
+        return exitcode;
+    }
+
+    @Override
+    public synchronized boolean waitFor(long timeout, TimeUnit unit)
+        throws InterruptedException
+    {
+        if (hasExited) return true;
+        if (timeout <= 0) return false;
+
+        long timeoutAsNanos = unit.toNanos(timeout);
+        long startTime = System.nanoTime();
+        long rem = timeoutAsNanos;
+
+        while (!hasExited && (rem > 0)) {
+            wait(Math.max(TimeUnit.NANOSECONDS.toMillis(rem), 1));
+            rem = timeoutAsNanos - (System.nanoTime() - startTime);
+        }
+        return hasExited;
+    }
+
+    public synchronized int exitValue() {
+        if (!hasExited) {
+            throw new IllegalThreadStateException("process hasn't exited");
+        }
+        return exitcode;
+    }
+
+    private static native void destroyProcess(int pid, boolean force);
+
+    private void destroy(boolean force) {
+        switch (platform) {
+            case LINUX:
+            case BSD:
+            case AIX:
+                // There is a risk that pid will be recycled, causing us to
+                // kill the wrong process!  So we only terminate processes
+                // that appear to still be running.  Even with this check,
+                // there is an unavoidable race condition here, but the window
+                // is very small, and OSes try hard to not recycle pids too
+                // soon, so this is quite safe.
+                synchronized (this) {
+                    if (!hasExited)
+                        destroyProcess(pid, force);
+                }
+                try { stdin.close();  } catch (IOException ignored) {}
+                try { stdout.close(); } catch (IOException ignored) {}
+                try { stderr.close(); } catch (IOException ignored) {}
+                break;
+
+            case SOLARIS:
+                // There is a risk that pid will be recycled, causing us to
+                // kill the wrong process!  So we only terminate processes
+                // that appear to still be running.  Even with this check,
+                // there is an unavoidable race condition here, but the window
+                // is very small, and OSes try hard to not recycle pids too
+                // soon, so this is quite safe.
+                synchronized (this) {
+                    if (!hasExited)
+                        destroyProcess(pid, force);
+                    try {
+                        stdin.close();
+                        if (stdout_inner_stream != null)
+                            stdout_inner_stream.closeDeferred(stdout);
+                        if (stderr instanceof DeferredCloseInputStream)
+                            ((DeferredCloseInputStream) stderr)
+                                .closeDeferred(stderr);
+                    } catch (IOException e) {
+                        // ignore
+                    }
+                }
+                break;
+
+            default: throw new AssertionError("Unsupported platform: " + platform);
+        }
+    }
+
+    public void destroy() {
+        destroy(false);
+    }
+
+    @Override
+    public Process destroyForcibly() {
+        destroy(true);
+        return this;
+    }
+
+    @Override
+    public synchronized boolean isAlive() {
+        return !hasExited;
+    }
+
+    private static native void init();
+
+    static {
+        init();
+    }
+
+    /**
+     * A buffered input stream for a subprocess pipe file descriptor
+     * that allows the underlying file descriptor to be reclaimed when
+     * the process exits, via the processExited hook.
+     *
+     * This is tricky because we do not want the user-level InputStream to be
+     * closed until the user invokes close(), and we need to continue to be
+     * able to read any buffered data lingering in the OS pipe buffer.
+     */
+    private static class ProcessPipeInputStream extends BufferedInputStream {
+        private final Object closeLock = new Object();
+
+        ProcessPipeInputStream(int fd) {
+            super(new FileInputStream(newFileDescriptor(fd)));
+        }
+        private static byte[] drainInputStream(InputStream in)
+                throws IOException {
+            int n = 0;
+            int j;
+            byte[] a = null;
+            while ((j = in.available()) > 0) {
+                a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j);
+                n += in.read(a, n, j);
+            }
+            return (a == null || n == a.length) ? a : Arrays.copyOf(a, n);
+        }
+
+        /** Called by the process reaper thread when the process exits. */
+        synchronized void processExited() {
+            synchronized (closeLock) {
+                try {
+                    InputStream in = this.in;
+                    // this stream is closed if and only if: in == null
+                    if (in != null) {
+                        byte[] stragglers = drainInputStream(in);
+                        in.close();
+                        this.in = (stragglers == null) ?
+                            ProcessBuilder.NullInputStream.INSTANCE :
+                            new ByteArrayInputStream(stragglers);
+                    }
+                } catch (IOException ignored) {}
+            }
+        }
+
+        @Override
+        public void close() throws IOException {
+            // BufferedInputStream#close() is not synchronized unlike most other
+            // methods. Synchronizing helps avoid race with processExited().
+            synchronized (closeLock) {
+                super.close();
+            }
+        }
+    }
+
+    /**
+     * A buffered output stream for a subprocess pipe file descriptor
+     * that allows the underlying file descriptor to be reclaimed when
+     * the process exits, via the processExited hook.
+     */
+    private static class ProcessPipeOutputStream extends BufferedOutputStream {
+        ProcessPipeOutputStream(int fd) {
+            super(new FileOutputStream(newFileDescriptor(fd)));
+        }
+
+        /** Called by the process reaper thread when the process exits. */
+        synchronized void processExited() {
+            OutputStream out = this.out;
+            if (out != null) {
+                try {
+                    out.close();
+                } catch (IOException ignored) {
+                    // We know of no reason to get an IOException, but if
+                    // we do, there's nothing else to do but carry on.
+                }
+                this.out = ProcessBuilder.NullOutputStream.INSTANCE;
+            }
+        }
+    }
+
+    // A FileInputStream that supports the deferment of the actual close
+    // operation until the last pending I/O operation on the stream has
+    // finished.  This is required on Solaris because we must close the stdin
+    // and stdout streams in the destroy method in order to reclaim the
+    // underlying file descriptors.  Doing so, however, causes any thread
+    // currently blocked in a read on one of those streams to receive an
+    // IOException("Bad file number"), which is incompatible with historical
+    // behavior.  By deferring the close we allow any pending reads to see -1
+    // (EOF) as they did before.
+    //
+    private static class DeferredCloseInputStream extends FileInputStream
+    {
+        DeferredCloseInputStream(FileDescriptor fd) {
+            super(fd);
+        }
+
+        private Object lock = new Object();     // For the following fields
+        private boolean closePending = false;
+        private int useCount = 0;
+        private InputStream streamToClose;
+
+        private void raise() {
+            synchronized (lock) {
+                useCount++;
+            }
+        }
+
+        private void lower() throws IOException {
+            synchronized (lock) {
+                useCount--;
+                if (useCount == 0 && closePending) {
+                    streamToClose.close();
+                }
+            }
+        }
+
+        // stc is the actual stream to be closed; it might be this object, or
+        // it might be an upstream object for which this object is downstream.
+        //
+        private void closeDeferred(InputStream stc) throws IOException {
+            synchronized (lock) {
+                if (useCount == 0) {
+                    stc.close();
+                } else {
+                    closePending = true;
+                    streamToClose = stc;
+                }
+            }
+        }
+
+        public void close() throws IOException {
+            synchronized (lock) {
+                useCount = 0;
+                closePending = false;
+            }
+            super.close();
+        }
+
+        public int read() throws IOException {
+            raise();
+            try {
+                return super.read();
+            } finally {
+                lower();
+            }
+        }
+
+        public int read(byte[] b) throws IOException {
+            raise();
+            try {
+                return super.read(b);
+            } finally {
+                lower();
+            }
+        }
+
+        public int read(byte[] b, int off, int len) throws IOException {
+            raise();
+            try {
+                return super.read(b, off, len);
+            } finally {
+                lower();
+            }
+        }
+
+        public long skip(long n) throws IOException {
+            raise();
+            try {
+                return super.skip(n);
+            } finally {
+                lower();
+            }
+        }
+
+        public int available() throws IOException {
+            raise();
+            try {
+                return super.available();
+            } finally {
+                lower();
+            }
+        }
+    }
+
+    /**
+     * A buffered input stream for a subprocess pipe file descriptor
+     * that allows the underlying file descriptor to be reclaimed when
+     * the process exits, via the processExited hook.
+     *
+     * This is tricky because we do not want the user-level InputStream to be
+     * closed until the user invokes close(), and we need to continue to be
+     * able to read any buffered data lingering in the OS pipe buffer.
+     *
+     * On AIX this is especially tricky, because the 'close()' system call
+     * will block if another thread is at the same time blocked in a file
+     * operation (e.g. 'read()') on the same file descriptor. We therefore
+     * combine 'ProcessPipeInputStream' approach used on Linux and Bsd
+     * with the DeferredCloseInputStream approach used on Solaris. This means
+     * that every potentially blocking operation on the file descriptor
+     * increments a counter before it is executed and decrements it once it
+     * finishes. The 'close()' operation will only be executed if there are
+     * no pending operations. Otherwise it is deferred after the last pending
+     * operation has finished.
+     *
+     */
+    private static class DeferredCloseProcessPipeInputStream
+        extends BufferedInputStream {
+
+        private final Object closeLock = new Object();
+        private int useCount = 0;
+        private boolean closePending = false;
+
+        DeferredCloseProcessPipeInputStream(int fd) {
+            super(new FileInputStream(newFileDescriptor(fd)));
+        }
+
+        private InputStream drainInputStream(InputStream in)
+                throws IOException {
+            int n = 0;
+            int j;
+            byte[] a = null;
+            synchronized (closeLock) {
+                if (buf == null) // asynchronous close()?
+                    return null; // discard
+                j = in.available();
+            }
+            while (j > 0) {
+                a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j);
+                synchronized (closeLock) {
+                    if (buf == null) // asynchronous close()?
+                        return null; // discard
+                    n += in.read(a, n, j);
+                    j = in.available();
+                }
+            }
+            return (a == null) ?
+                    ProcessBuilder.NullInputStream.INSTANCE :
+                    new ByteArrayInputStream(n == a.length ? a : Arrays.copyOf(a, n));
+        }
+
+        /** Called by the process reaper thread when the process exits. */
+        synchronized void processExited() {
+            try {
+                InputStream in = this.in;
+                if (in != null) {
+                    InputStream stragglers = drainInputStream(in);
+                    in.close();
+                    this.in = stragglers;
+                }
+            } catch (IOException ignored) { }
+        }
+
+        private void raise() {
+            synchronized (closeLock) {
+                useCount++;
+            }
+        }
+
+        private void lower() throws IOException {
+            synchronized (closeLock) {
+                useCount--;
+                if (useCount == 0 && closePending) {
+                    closePending = false;
+                    super.close();
+                }
+            }
+        }
+
+        @Override
+        public int read() throws IOException {
+            raise();
+            try {
+                return super.read();
+            } finally {
+                lower();
+            }
+        }
+
+        @Override
+        public int read(byte[] b) throws IOException {
+            raise();
+            try {
+                return super.read(b);
+            } finally {
+                lower();
+            }
+        }
+
+        @Override
+        public int read(byte[] b, int off, int len) throws IOException {
+            raise();
+            try {
+                return super.read(b, off, len);
+            } finally {
+                lower();
+            }
+        }
+
+        @Override
+        public long skip(long n) throws IOException {
+            raise();
+            try {
+                return super.skip(n);
+            } finally {
+                lower();
+            }
+        }
+
+        @Override
+        public int available() throws IOException {
+            raise();
+            try {
+                return super.available();
+            } finally {
+                lower();
+            }
+        }
+
+        @Override
+        public void close() throws IOException {
+            // BufferedInputStream#close() is not synchronized unlike most other
+            // methods. Synchronizing helps avoid racing with drainInputStream().
+            synchronized (closeLock) {
+                if (useCount == 0) {
+                    super.close();
+                }
+                else {
+                    closePending = true;
+                }
+            }
+        }
+    }
+}
--- a/src/solaris/classes/java/lang/UNIXProcess.java.aix	Mon May 12 09:32:23 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,504 +0,0 @@
-/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.lang;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Arrays;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-import java.security.AccessController;
-import static java.security.AccessController.doPrivileged;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * java.lang.Process subclass in the UNIX environment.
- *
- * @author Mario Wolczko and Ross Knippel.
- * @author Konstantin Kladko (ported to Linux)
- * @author Martin Buchholz
- * @author Volker Simonis (ported to AIX)
- */
-final class UNIXProcess extends Process {
-    private static final sun.misc.JavaIOFileDescriptorAccess fdAccess
-        = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess();
-
-    private final int pid;
-    private int exitcode;
-    private boolean hasExited;
-
-    private /* final */ OutputStream stdin;
-    private /* final */ InputStream  stdout;
-    private /* final */ InputStream  stderr;
-
-    private static enum LaunchMechanism {
-        FORK(1),
-        POSIX_SPAWN(2);
-
-        private int value;
-        LaunchMechanism(int x) {value = x;}
-    };
-
-    /* On AIX, the default is to spawn */
-    private static final LaunchMechanism launchMechanism;
-    private static byte[] helperpath;
-
-    private static byte[] toCString(String s) {
-        if (s == null)
-            return null;
-        byte[] bytes = s.getBytes();
-        byte[] result = new byte[bytes.length + 1];
-        System.arraycopy(bytes, 0,
-                         result, 0,
-                         bytes.length);
-        result[result.length-1] = (byte)0;
-        return result;
-    }
-
-    static {
-        launchMechanism = AccessController.doPrivileged(
-                new PrivilegedAction<LaunchMechanism>()
-        {
-            public LaunchMechanism run() {
-                String javahome = System.getProperty("java.home");
-                String osArch = System.getProperty("os.arch");
-
-                helperpath = toCString(javahome + "/lib/" + osArch + "/jspawnhelper");
-                String s = System.getProperty(
-                    "jdk.lang.Process.launchMechanism", "posix_spawn");
-
-                try {
-                    return LaunchMechanism.valueOf(s.toUpperCase());
-                } catch (IllegalArgumentException e) {
-                    throw new Error(s + " is not a supported " +
-                        "process launch mechanism on this platform.");
-                }
-            }
-        });
-    }
-
-    /* this is for the reaping thread */
-    private native int waitForProcessExit(int pid);
-
-    /**
-     * Create a process. Depending on the mode flag, this is done by
-     * one of the following mechanisms.
-     * - fork(2) and exec(2)
-     * - clone(2) and exec(2)
-     * - vfork(2) and exec(2)
-     *
-     * @param fds an array of three file descriptors.
-     *        Indexes 0, 1, and 2 correspond to standard input,
-     *        standard output and standard error, respectively.  On
-     *        input, a value of -1 means to create a pipe to connect
-     *        child and parent processes.  On output, a value which
-     *        is not -1 is the parent pipe fd corresponding to the
-     *        pipe which has been created.  An element of this array
-     *        is -1 on input if and only if it is <em>not</em> -1 on
-     *        output.
-     * @return the pid of the subprocess
-     */
-    private native int forkAndExec(int mode, byte[] helperpath,
-                                   byte[] prog,
-                                   byte[] argBlock, int argc,
-                                   byte[] envBlock, int envc,
-                                   byte[] dir,
-                                   int[] fds,
-                                   boolean redirectErrorStream)
-        throws IOException;
-
-    /**
-     * The thread factory used to create "process reaper" daemon threads.
-     */
-    private static class ProcessReaperThreadFactory implements ThreadFactory {
-        private final static ThreadGroup group = getRootThreadGroup();
-
-        private static ThreadGroup getRootThreadGroup() {
-            return doPrivileged(new PrivilegedAction<ThreadGroup> () {
-                public ThreadGroup run() {
-                    ThreadGroup root = Thread.currentThread().getThreadGroup();
-                    while (root.getParent() != null)
-                        root = root.getParent();
-                    return root;
-                }});
-        }
-
-        public Thread newThread(Runnable grimReaper) {
-            // Our thread stack requirement is quite modest.
-            Thread t = new Thread(group, grimReaper, "process reaper", 32768);
-            t.setDaemon(true);
-            // A small attempt (probably futile) to avoid priority inversion
-            t.setPriority(Thread.MAX_PRIORITY);
-            return t;
-        }
-    }
-
-    /**
-     * The thread pool of "process reaper" daemon threads.
-     */
-    private static final Executor processReaperExecutor =
-        doPrivileged(new PrivilegedAction<Executor>() {
-            public Executor run() {
-                return Executors.newCachedThreadPool
-                    (new ProcessReaperThreadFactory());
-            }});
-
-    UNIXProcess(final byte[] prog,
-                final byte[] argBlock, final int argc,
-                final byte[] envBlock, final int envc,
-                final byte[] dir,
-                final int[] fds,
-                final boolean redirectErrorStream)
-            throws IOException {
-
-        pid = forkAndExec(launchMechanism.value,
-                          helperpath,
-                          prog,
-                          argBlock, argc,
-                          envBlock, envc,
-                          dir,
-                          fds,
-                          redirectErrorStream);
-
-        try {
-            doPrivileged(new PrivilegedExceptionAction<Void>() {
-                public Void run() throws IOException {
-                    initStreams(fds);
-                    return null;
-                }});
-        } catch (PrivilegedActionException ex) {
-            throw (IOException) ex.getException();
-        }
-    }
-
-    static FileDescriptor newFileDescriptor(int fd) {
-        FileDescriptor fileDescriptor = new FileDescriptor();
-        fdAccess.set(fileDescriptor, fd);
-        return fileDescriptor;
-    }
-
-    void initStreams(int[] fds) throws IOException {
-        stdin = (fds[0] == -1) ?
-            ProcessBuilder.NullOutputStream.INSTANCE :
-            new ProcessPipeOutputStream(fds[0]);
-
-        stdout = (fds[1] == -1) ?
-            ProcessBuilder.NullInputStream.INSTANCE :
-            new ProcessPipeInputStream(fds[1]);
-
-        stderr = (fds[2] == -1) ?
-            ProcessBuilder.NullInputStream.INSTANCE :
-            new ProcessPipeInputStream(fds[2]);
-
-        processReaperExecutor.execute(new Runnable() {
-            public void run() {
-                int exitcode = waitForProcessExit(pid);
-                UNIXProcess.this.processExited(exitcode);
-            }});
-    }
-
-    void processExited(int exitcode) {
-        synchronized (this) {
-            this.exitcode = exitcode;
-            hasExited = true;
-            notifyAll();
-        }
-
-        if (stdout instanceof ProcessPipeInputStream)
-            ((ProcessPipeInputStream) stdout).processExited();
-
-        if (stderr instanceof ProcessPipeInputStream)
-            ((ProcessPipeInputStream) stderr).processExited();
-
-        if (stdin instanceof ProcessPipeOutputStream)
-            ((ProcessPipeOutputStream) stdin).processExited();
-    }
-
-    public OutputStream getOutputStream() {
-        return stdin;
-    }
-
-    public InputStream getInputStream() {
-        return stdout;
-    }
-
-    public InputStream getErrorStream() {
-        return stderr;
-    }
-
-    public synchronized int waitFor() throws InterruptedException {
-        while (!hasExited) {
-            wait();
-        }
-        return exitcode;
-    }
-
-    @Override
-    public synchronized boolean waitFor(long timeout, TimeUnit unit)
-        throws InterruptedException
-    {
-        if (hasExited) return true;
-        if (timeout <= 0) return false;
-
-        long timeoutAsNanos = unit.toNanos(timeout);
-        long startTime = System.nanoTime();
-        long rem = timeoutAsNanos;
-
-        while (!hasExited && (rem > 0)) {
-            wait(Math.max(TimeUnit.NANOSECONDS.toMillis(rem), 1));
-            rem = timeoutAsNanos - (System.nanoTime() - startTime);
-        }
-        return hasExited;
-    }
-
-    public synchronized int exitValue() {
-        if (!hasExited) {
-            throw new IllegalThreadStateException("process hasn't exited");
-        }
-        return exitcode;
-    }
-
-    private static native void destroyProcess(int pid, boolean force);
-    private void destroy(boolean force) {
-        // There is a risk that pid will be recycled, causing us to
-        // kill the wrong process!  So we only terminate processes
-        // that appear to still be running.  Even with this check,
-        // there is an unavoidable race condition here, but the window
-        // is very small, and OSes try hard to not recycle pids too
-        // soon, so this is quite safe.
-        synchronized (this) {
-            if (!hasExited)
-                destroyProcess(pid, force);
-        }
-        try { stdin.close();  } catch (IOException ignored) {}
-        try { stdout.close(); } catch (IOException ignored) {}
-        try { stderr.close(); } catch (IOException ignored) {}
-    }
-
-    public void destroy() {
-        destroy(false);
-    }
-
-    @Override
-    public Process destroyForcibly() {
-        destroy(true);
-        return this;
-    }
-
-    @Override
-    public synchronized boolean isAlive() {
-        return !hasExited;
-    }
-
-    private static native void init();
-
-    static {
-        init();
-    }
-
-    /**
-     * A buffered input stream for a subprocess pipe file descriptor
-     * that allows the underlying file descriptor to be reclaimed when
-     * the process exits, via the processExited hook.
-     *
-     * This is tricky because we do not want the user-level InputStream to be
-     * closed until the user invokes close(), and we need to continue to be
-     * able to read any buffered data lingering in the OS pipe buffer.
-     *
-     * On AIX this is especially tricky, because the 'close()' system call
-     * will block if another thread is at the same time blocked in a file
-     * operation (e.g. 'read()') on the same file descriptor. We therefore
-     * combine this 'ProcessPipeInputStream' with the DeferredCloseInputStream
-     * approach used on Solaris (see "UNIXProcess.java.solaris"). This means
-     * that every potentially blocking operation on the file descriptor
-     * increments a counter before it is executed and decrements it once it
-     * finishes. The 'close()' operation will only be executed if there are
-     * no pending operations. Otherwise it is deferred after the last pending
-     * operation has finished.
-     *
-     */
-    static class ProcessPipeInputStream extends BufferedInputStream {
-        private final Object closeLock = new Object();
-        private int useCount = 0;
-        private boolean closePending = false;
-
-        ProcessPipeInputStream(int fd) {
-            super(new FileInputStream(newFileDescriptor(fd)));
-        }
-
-        private InputStream drainInputStream(InputStream in)
-                throws IOException {
-            int n = 0;
-            int j;
-            byte[] a = null;
-            synchronized (closeLock) {
-                if (buf == null) // asynchronous close()?
-                    return null; // discard
-                j = in.available();
-            }
-            while (j > 0) {
-                a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j);
-                synchronized (closeLock) {
-                    if (buf == null) // asynchronous close()?
-                        return null; // discard
-                    n += in.read(a, n, j);
-                    j = in.available();
-                }
-            }
-            return (a == null) ?
-                    ProcessBuilder.NullInputStream.INSTANCE :
-                    new ByteArrayInputStream(n == a.length ? a : Arrays.copyOf(a, n));
-        }
-
-        /** Called by the process reaper thread when the process exits. */
-        synchronized void processExited() {
-            try {
-                InputStream in = this.in;
-                if (in != null) {
-                    InputStream stragglers = drainInputStream(in);
-                    in.close();
-                    this.in = stragglers;
-                }
-            } catch (IOException ignored) { }
-        }
-
-        private void raise() {
-            synchronized (closeLock) {
-                useCount++;
-            }
-        }
-
-        private void lower() throws IOException {
-            synchronized (closeLock) {
-                useCount--;
-                if (useCount == 0 && closePending) {
-                    closePending = false;
-                    super.close();
-                }
-            }
-        }
-
-        @Override
-        public int read() throws IOException {
-            raise();
-            try {
-                return super.read();
-            } finally {
-                lower();
-            }
-        }
-
-        @Override
-        public int read(byte[] b) throws IOException {
-            raise();
-            try {
-                return super.read(b);
-            } finally {
-                lower();
-            }
-        }
-
-        @Override
-        public int read(byte[] b, int off, int len) throws IOException {
-            raise();
-            try {
-                return super.read(b, off, len);
-            } finally {
-                lower();
-            }
-        }
-
-        @Override
-        public long skip(long n) throws IOException {
-            raise();
-            try {
-                return super.skip(n);
-            } finally {
-                lower();
-            }
-        }
-
-        @Override
-        public int available() throws IOException {
-            raise();
-            try {
-                return super.available();
-            } finally {
-                lower();
-            }
-        }
-
-        @Override
-        public void close() throws IOException {
-            // BufferedInputStream#close() is not synchronized unlike most other methods.
-            // Synchronizing helps avoid racing with drainInputStream().
-            synchronized (closeLock) {
-                if (useCount == 0) {
-                    super.close();
-                }
-                else {
-                    closePending = true;
-                }
-            }
-        }
-    }
-
-    /**
-     * A buffered output stream for a subprocess pipe file descriptor
-     * that allows the underlying file descriptor to be reclaimed when
-     * the process exits, via the processExited hook.
-     */
-    static class ProcessPipeOutputStream extends BufferedOutputStream {
-        ProcessPipeOutputStream(int fd) {
-            super(new FileOutputStream(newFileDescriptor(fd)));
-        }
-
-        /** Called by the process reaper thread when the process exits. */
-        synchronized void processExited() {
-            OutputStream out = this.out;
-            if (out != null) {
-                try {
-                    out.close();
-                } catch (IOException ignored) {
-                    // We know of no reason to get an IOException, but if
-                    // we do, there's nothing else to do but carry on.
-                }
-                this.out = ProcessBuilder.NullOutputStream.INSTANCE;
-            }
-        }
-    }
-}
--- a/src/solaris/classes/java/lang/UNIXProcess.java.bsd	Mon May 12 09:32:23 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,408 +0,0 @@
-/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.lang;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Arrays;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-import java.security.AccessController;
-import static java.security.AccessController.doPrivileged;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * java.lang.Process subclass in the UNIX environment.
- *
- * @author Mario Wolczko and Ross Knippel.
- * @author Konstantin Kladko (ported to Bsd)
- * @author Martin Buchholz
- */
-final class UNIXProcess extends Process {
-    private static final sun.misc.JavaIOFileDescriptorAccess fdAccess
-        = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess();
-
-    private final int pid;
-    private int exitcode;
-    private boolean hasExited;
-
-    private /* final */ OutputStream stdin;
-    private /* final */ InputStream  stdout;
-    private /* final */ InputStream  stderr;
-
-    private static enum LaunchMechanism {
-        FORK(1),
-        POSIX_SPAWN(2);
-
-        private int value;
-        LaunchMechanism(int x) {value = x;}
-    };
-
-    /* On BSD, the default is to spawn */
-    private static final LaunchMechanism launchMechanism;
-    private static byte[] helperpath;
-
-    private static byte[] toCString(String s) {
-        if (s == null)
-            return null;
-        byte[] bytes = s.getBytes();
-        byte[] result = new byte[bytes.length + 1];
-        System.arraycopy(bytes, 0,
-                         result, 0,
-                         bytes.length);
-        result[result.length-1] = (byte)0;
-        return result;
-    }
-
-    static {
-        launchMechanism = AccessController.doPrivileged(
-                new PrivilegedAction<LaunchMechanism>()
-        {
-            public LaunchMechanism run() {
-                String javahome = System.getProperty("java.home");
-
-                helperpath = toCString(javahome + "/lib/jspawnhelper");
-                String s = System.getProperty(
-                    "jdk.lang.Process.launchMechanism", "posix_spawn");
-
-                try {
-                    return LaunchMechanism.valueOf(s.toUpperCase());
-                } catch (IllegalArgumentException e) {
-                    throw new Error(s + " is not a supported " +
-                        "process launch mechanism on this platform.");
-                }
-            }
-        });
-    }
-
-    /* this is for the reaping thread */
-    private native int waitForProcessExit(int pid);
-
-    /**
-     * Create a process. Depending on the mode flag, this is done by
-     * one of the following mechanisms.
-     * - fork(2) and exec(2)
-     * - posix_spawn(2)
-     *
-     * @param fds an array of three file descriptors.
-     *        Indexes 0, 1, and 2 correspond to standard input,
-     *        standard output and standard error, respectively.  On
-     *        input, a value of -1 means to create a pipe to connect
-     *        child and parent processes.  On output, a value which
-     *        is not -1 is the parent pipe fd corresponding to the
-     *        pipe which has been created.  An element of this array
-     *        is -1 on input if and only if it is <em>not</em> -1 on
-     *        output.
-     * @return the pid of the subprocess
-     */
-    private native int forkAndExec(int mode, byte[] helperpath,
-                                   byte[] prog,
-                                   byte[] argBlock, int argc,
-                                   byte[] envBlock, int envc,
-                                   byte[] dir,
-                                   int[] fds,
-                                   boolean redirectErrorStream)
-        throws IOException;
-
-    /**
-     * The thread factory used to create "process reaper" daemon threads.
-     */
-    private static class ProcessReaperThreadFactory implements ThreadFactory {
-        private final static ThreadGroup group = getRootThreadGroup();
-
-        private static ThreadGroup getRootThreadGroup() {
-            return doPrivileged(new PrivilegedAction<ThreadGroup> () {
-                public ThreadGroup run() {
-                    ThreadGroup root = Thread.currentThread().getThreadGroup();
-                    while (root.getParent() != null)
-                        root = root.getParent();
-                    return root;
-                }});
-        }
-
-        public Thread newThread(Runnable grimReaper) {
-            // Our thread stack requirement is quite modest.
-            Thread t = new Thread(group, grimReaper, "process reaper", 32768);
-            t.setDaemon(true);
-            // A small attempt (probably futile) to avoid priority inversion
-            t.setPriority(Thread.MAX_PRIORITY);
-            return t;
-        }
-    }
-
-    /**
-     * The thread pool of "process reaper" daemon threads.
-     */
-    private static final Executor processReaperExecutor =
-        doPrivileged(new PrivilegedAction<Executor>() {
-            public Executor run() {
-                return Executors.newCachedThreadPool
-                    (new ProcessReaperThreadFactory());
-            }});
-
-    UNIXProcess(final byte[] prog,
-                final byte[] argBlock, final int argc,
-                final byte[] envBlock, final int envc,
-                final byte[] dir,
-                final int[] fds,
-                final boolean redirectErrorStream)
-            throws IOException {
-
-        pid = forkAndExec(launchMechanism.value,
-                          helperpath,
-                          prog,
-                          argBlock, argc,
-                          envBlock, envc,
-                          dir,
-                          fds,
-                          redirectErrorStream);
-
-        try {
-            doPrivileged(new PrivilegedExceptionAction<Void>() {
-                public Void run() throws IOException {
-                    initStreams(fds);
-                    return null;
-                }});
-        } catch (PrivilegedActionException ex) {
-            throw (IOException) ex.getException();
-        }
-    }
-
-    static FileDescriptor newFileDescriptor(int fd) {
-        FileDescriptor fileDescriptor = new FileDescriptor();
-        fdAccess.set(fileDescriptor, fd);
-        return fileDescriptor;
-    }
-
-    void initStreams(int[] fds) throws IOException {
-        stdin = (fds[0] == -1) ?
-            ProcessBuilder.NullOutputStream.INSTANCE :
-            new ProcessPipeOutputStream(fds[0]);
-
-        stdout = (fds[1] == -1) ?
-            ProcessBuilder.NullInputStream.INSTANCE :
-            new ProcessPipeInputStream(fds[1]);
-
-        stderr = (fds[2] == -1) ?
-            ProcessBuilder.NullInputStream.INSTANCE :
-            new ProcessPipeInputStream(fds[2]);
-
-        processReaperExecutor.execute(new Runnable() {
-            public void run() {
-                int exitcode = waitForProcessExit(pid);
-                UNIXProcess.this.processExited(exitcode);
-            }});
-    }
-
-    void processExited(int exitcode) {
-        synchronized (this) {
-            this.exitcode = exitcode;
-            hasExited = true;
-            notifyAll();
-        }
-
-        if (stdout instanceof ProcessPipeInputStream)
-            ((ProcessPipeInputStream) stdout).processExited();
-
-        if (stderr instanceof ProcessPipeInputStream)
-            ((ProcessPipeInputStream) stderr).processExited();
-
-        if (stdin instanceof ProcessPipeOutputStream)
-            ((ProcessPipeOutputStream) stdin).processExited();
-    }
-
-    public OutputStream getOutputStream() {
-        return stdin;
-    }
-
-    public InputStream getInputStream() {
-        return stdout;
-    }
-
-    public InputStream getErrorStream() {
-        return stderr;
-    }
-
-    public synchronized int waitFor() throws InterruptedException {
-        while (!hasExited) {
-            wait();
-        }
-        return exitcode;
-    }
-
-    @Override
-    public synchronized boolean waitFor(long timeout, TimeUnit unit)
-        throws InterruptedException
-    {
-        if (hasExited) return true;
-        if (timeout <= 0) return false;
-
-        long timeoutAsNanos = unit.toNanos(timeout);
-        long startTime = System.nanoTime();
-        long rem = timeoutAsNanos;
-
-        while (!hasExited && (rem > 0)) {
-            wait(Math.max(TimeUnit.NANOSECONDS.toMillis(rem), 1));
-            rem = timeoutAsNanos - (System.nanoTime() - startTime);
-        }
-        return hasExited;
-    }
-
-    public synchronized int exitValue() {
-        if (!hasExited) {
-            throw new IllegalThreadStateException("process hasn't exited");
-        }
-        return exitcode;
-    }
-
-    private static native void destroyProcess(int pid, boolean force);
-    private void destroy(boolean force) {
-        // There is a risk that pid will be recycled, causing us to
-        // kill the wrong process!  So we only terminate processes
-        // that appear to still be running.  Even with this check,
-        // there is an unavoidable race condition here, but the window
-        // is very small, and OSes try hard to not recycle pids too
-        // soon, so this is quite safe.
-        synchronized (this) {
-            if (!hasExited)
-                destroyProcess(pid, force);
-        }
-        try { stdin.close();  } catch (IOException ignored) {}
-        try { stdout.close(); } catch (IOException ignored) {}
-        try { stderr.close(); } catch (IOException ignored) {}
-    }
-
-    public void destroy() {
-        destroy(false);
-    }
-
-    @Override
-    public Process destroyForcibly() {
-        destroy(true);
-        return this;
-    }
-
-    @Override
-    public synchronized boolean isAlive() {
-        return !hasExited;
-    }
-
-    private static native void init();
-
-    static {
-        init();
-    }
-
-    /**
-     * A buffered input stream for a subprocess pipe file descriptor
-     * that allows the underlying file descriptor to be reclaimed when
-     * the process exits, via the processExited hook.
-     *
-     * This is tricky because we do not want the user-level InputStream to be
-     * closed until the user invokes close(), and we need to continue to be
-     * able to read any buffered data lingering in the OS pipe buffer.
-     */
-    static class ProcessPipeInputStream extends BufferedInputStream {
-        private final Object closeLock = new Object();
-
-        ProcessPipeInputStream(int fd) {
-            super(new FileInputStream(newFileDescriptor(fd)));
-        }
-        private static byte[] drainInputStream(InputStream in)
-                throws IOException {
-            int n = 0;
-            int j;
-            byte[] a = null;
-            while ((j = in.available()) > 0) {
-                a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j);
-                n += in.read(a, n, j);
-            }
-            return (a == null || n == a.length) ? a : Arrays.copyOf(a, n);
-        }
-
-        /** Called by the process reaper thread when the process exits. */
-        synchronized void processExited() {
-            synchronized (closeLock) {
-                try {
-                    InputStream in = this.in;
-                    // this stream is closed if and only if: in == null
-                    if (in != null) {
-                        byte[] stragglers = drainInputStream(in);
-                        in.close();
-                        this.in = (stragglers == null) ?
-                            ProcessBuilder.NullInputStream.INSTANCE :
-                            new ByteArrayInputStream(stragglers);
-                    }
-                } catch (IOException ignored) {}
-            }
-        }
-
-        @Override
-        public void close() throws IOException {
-            // BufferedInputStream#close() is not synchronized unlike most other methods.
-            // Synchronizing helps avoid race with processExited().
-            synchronized (closeLock) {
-                super.close();
-            }
-        }
-    }
-
-    /**
-     * A buffered output stream for a subprocess pipe file descriptor
-     * that allows the underlying file descriptor to be reclaimed when
-     * the process exits, via the processExited hook.
-     */
-    static class ProcessPipeOutputStream extends BufferedOutputStream {
-        ProcessPipeOutputStream(int fd) {
-            super(new FileOutputStream(newFileDescriptor(fd)));
-        }
-
-        /** Called by the process reaper thread when the process exits. */
-        synchronized void processExited() {
-            OutputStream out = this.out;
-            if (out != null) {
-                try {
-                    out.close();
-                } catch (IOException ignored) {
-                    // We know of no reason to get an IOException, but if
-                    // we do, there's nothing else to do but carry on.
-                }
-                this.out = ProcessBuilder.NullOutputStream.INSTANCE;
-            }
-        }
-    }
-}
--- a/src/solaris/classes/java/lang/UNIXProcess.java.linux	Mon May 12 09:32:23 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,410 +0,0 @@
-/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.lang;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Arrays;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-import java.security.AccessController;
-import static java.security.AccessController.doPrivileged;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * java.lang.Process subclass in the UNIX environment.
- *
- * @author Mario Wolczko and Ross Knippel.
- * @author Konstantin Kladko (ported to Linux)
- * @author Martin Buchholz
- */
-final class UNIXProcess extends Process {
-    private static final sun.misc.JavaIOFileDescriptorAccess fdAccess
-        = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess();
-
-    private final int pid;
-    private int exitcode;
-    private boolean hasExited;
-
-    private /* final */ OutputStream stdin;
-    private /* final */ InputStream  stdout;
-    private /* final */ InputStream  stderr;
-
-    private static enum LaunchMechanism {
-        FORK(1),
-        VFORK(3);
-
-        private int value;
-        LaunchMechanism(int x) {value = x;}
-    };
-
-    /* default is VFORK on Linux */
-    private static final LaunchMechanism launchMechanism;
-    private static byte[] helperpath;
-
-    private static byte[] toCString(String s) {
-        if (s == null)
-            return null;
-        byte[] bytes = s.getBytes();
-        byte[] result = new byte[bytes.length + 1];
-        System.arraycopy(bytes, 0,
-                         result, 0,
-                         bytes.length);
-        result[result.length-1] = (byte)0;
-        return result;
-    }
-
-    static {
-        launchMechanism = AccessController.doPrivileged(
-                new PrivilegedAction<LaunchMechanism>()
-        {
-            public LaunchMechanism run() {
-                String javahome = System.getProperty("java.home");
-                String osArch = System.getProperty("os.arch");
-
-                helperpath = toCString(javahome + "/lib/" + osArch + "/jspawnhelper");
-                String s = System.getProperty(
-                    "jdk.lang.Process.launchMechanism", "vfork");
-
-                try {
-                    return LaunchMechanism.valueOf(s.toUpperCase());
-                } catch (IllegalArgumentException e) {
-                    throw new Error(s + " is not a supported " +
-                        "process launch mechanism on this platform.");
-                }
-            }
-        });
-    }
-
-    /* this is for the reaping thread */
-    private native int waitForProcessExit(int pid);
-
-    /**
-     * Create a process. Depending on the mode flag, this is done by
-     * one of the following mechanisms.
-     * - fork(2) and exec(2)
-     * - clone(2) and exec(2)
-     * - vfork(2) and exec(2)
-     *
-     * @param fds an array of three file descriptors.
-     *        Indexes 0, 1, and 2 correspond to standard input,
-     *        standard output and standard error, respectively.  On
-     *        input, a value of -1 means to create a pipe to connect
-     *        child and parent processes.  On output, a value which
-     *        is not -1 is the parent pipe fd corresponding to the
-     *        pipe which has been created.  An element of this array
-     *        is -1 on input if and only if it is <em>not</em> -1 on
-     *        output.
-     * @return the pid of the subprocess
-     */
-    private native int forkAndExec(int mode, byte[] helperpath,
-                                   byte[] prog,
-                                   byte[] argBlock, int argc,
-                                   byte[] envBlock, int envc,
-                                   byte[] dir,
-                                   int[] fds,
-                                   boolean redirectErrorStream)
-        throws IOException;
-
-    /**
-     * The thread factory used to create "process reaper" daemon threads.
-     */
-    private static class ProcessReaperThreadFactory implements ThreadFactory {
-        private final static ThreadGroup group = getRootThreadGroup();
-
-        private static ThreadGroup getRootThreadGroup() {
-            return doPrivileged(new PrivilegedAction<ThreadGroup> () {
-                public ThreadGroup run() {
-                    ThreadGroup root = Thread.currentThread().getThreadGroup();
-                    while (root.getParent() != null)
-                        root = root.getParent();
-                    return root;
-                }});
-        }
-
-        public Thread newThread(Runnable grimReaper) {
-            // Our thread stack requirement is quite modest.
-            Thread t = new Thread(group, grimReaper, "process reaper", 32768);
-            t.setDaemon(true);
-            // A small attempt (probably futile) to avoid priority inversion
-            t.setPriority(Thread.MAX_PRIORITY);
-            return t;
-        }
-    }
-
-    /**
-     * The thread pool of "process reaper" daemon threads.
-     */
-    private static final Executor processReaperExecutor =
-        doPrivileged(new PrivilegedAction<Executor>() {
-            public Executor run() {
-                return Executors.newCachedThreadPool
-                    (new ProcessReaperThreadFactory());
-            }});
-
-    UNIXProcess(final byte[] prog,
-                final byte[] argBlock, final int argc,
-                final byte[] envBlock, final int envc,
-                final byte[] dir,
-                final int[] fds,
-                final boolean redirectErrorStream)
-            throws IOException {
-
-        pid = forkAndExec(launchMechanism.value,
-                          helperpath,
-                          prog,
-                          argBlock, argc,
-                          envBlock, envc,
-                          dir,
-                          fds,
-                          redirectErrorStream);
-
-        try {
-            doPrivileged(new PrivilegedExceptionAction<Void>() {
-                public Void run() throws IOException {
-                    initStreams(fds);
-                    return null;
-                }});
-        } catch (PrivilegedActionException ex) {
-            throw (IOException) ex.getException();
-        }
-    }
-
-    static FileDescriptor newFileDescriptor(int fd) {
-        FileDescriptor fileDescriptor = new FileDescriptor();
-        fdAccess.set(fileDescriptor, fd);
-        return fileDescriptor;
-    }
-
-    void initStreams(int[] fds) throws IOException {
-        stdin = (fds[0] == -1) ?
-            ProcessBuilder.NullOutputStream.INSTANCE :
-            new ProcessPipeOutputStream(fds[0]);
-
-        stdout = (fds[1] == -1) ?
-            ProcessBuilder.NullInputStream.INSTANCE :
-            new ProcessPipeInputStream(fds[1]);
-
-        stderr = (fds[2] == -1) ?
-            ProcessBuilder.NullInputStream.INSTANCE :
-            new ProcessPipeInputStream(fds[2]);
-
-        processReaperExecutor.execute(new Runnable() {
-            public void run() {
-                int exitcode = waitForProcessExit(pid);
-                UNIXProcess.this.processExited(exitcode);
-            }});
-    }
-
-    void processExited(int exitcode) {
-        synchronized (this) {
-            this.exitcode = exitcode;
-            hasExited = true;
-            notifyAll();
-        }
-
-        if (stdout instanceof ProcessPipeInputStream)
-            ((ProcessPipeInputStream) stdout).processExited();
-
-        if (stderr instanceof ProcessPipeInputStream)
-            ((ProcessPipeInputStream) stderr).processExited();
-
-        if (stdin instanceof ProcessPipeOutputStream)
-            ((ProcessPipeOutputStream) stdin).processExited();
-    }
-
-    public OutputStream getOutputStream() {
-        return stdin;
-    }
-
-    public InputStream getInputStream() {
-        return stdout;
-    }
-
-    public InputStream getErrorStream() {
-        return stderr;
-    }
-
-    public synchronized int waitFor() throws InterruptedException {
-        while (!hasExited) {
-            wait();
-        }
-        return exitcode;
-    }
-
-    @Override
-    public synchronized boolean waitFor(long timeout, TimeUnit unit)
-        throws InterruptedException
-    {
-        if (hasExited) return true;
-        if (timeout <= 0) return false;
-
-        long timeoutAsNanos = unit.toNanos(timeout);
-        long startTime = System.nanoTime();
-        long rem = timeoutAsNanos;
-
-        while (!hasExited && (rem > 0)) {
-            wait(Math.max(TimeUnit.NANOSECONDS.toMillis(rem), 1));
-            rem = timeoutAsNanos - (System.nanoTime() - startTime);
-        }
-        return hasExited;
-    }
-
-    public synchronized int exitValue() {
-        if (!hasExited) {
-            throw new IllegalThreadStateException("process hasn't exited");
-        }
-        return exitcode;
-    }
-
-    private static native void destroyProcess(int pid, boolean force);
-    private void destroy(boolean force) {
-        // There is a risk that pid will be recycled, causing us to
-        // kill the wrong process!  So we only terminate processes
-        // that appear to still be running.  Even with this check,
-        // there is an unavoidable race condition here, but the window
-        // is very small, and OSes try hard to not recycle pids too
-        // soon, so this is quite safe.
-        synchronized (this) {
-            if (!hasExited)
-                destroyProcess(pid, force);
-        }
-        try { stdin.close();  } catch (IOException ignored) {}
-        try { stdout.close(); } catch (IOException ignored) {}
-        try { stderr.close(); } catch (IOException ignored) {}
-    }
-
-    public void destroy() {
-        destroy(false);
-    }
-
-    @Override
-    public Process destroyForcibly() {
-        destroy(true);
-        return this;
-    }
-
-    @Override
-    public synchronized boolean isAlive() {
-        return !hasExited;
-    }
-
-    private static native void init();
-
-    static {
-        init();
-    }
-
-    /**
-     * A buffered input stream for a subprocess pipe file descriptor
-     * that allows the underlying file descriptor to be reclaimed when
-     * the process exits, via the processExited hook.
-     *
-     * This is tricky because we do not want the user-level InputStream to be
-     * closed until the user invokes close(), and we need to continue to be
-     * able to read any buffered data lingering in the OS pipe buffer.
-     */
-    static class ProcessPipeInputStream extends BufferedInputStream {
-        private final Object closeLock = new Object();
-
-        ProcessPipeInputStream(int fd) {
-            super(new FileInputStream(newFileDescriptor(fd)));
-        }
-        private static byte[] drainInputStream(InputStream in)
-                throws IOException {
-            int n = 0;
-            int j;
-            byte[] a = null;
-            while ((j = in.available()) > 0) {
-                a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j);
-                n += in.read(a, n, j);
-            }
-            return (a == null || n == a.length) ? a : Arrays.copyOf(a, n);
-        }
-
-        /** Called by the process reaper thread when the process exits. */
-        synchronized void processExited() {
-            synchronized (closeLock) {
-                try {
-                    InputStream in = this.in;
-                    // this stream is closed if and only if: in == null
-                    if (in != null) {
-                        byte[] stragglers = drainInputStream(in);
-                        in.close();
-                        this.in = (stragglers == null) ?
-                            ProcessBuilder.NullInputStream.INSTANCE :
-                            new ByteArrayInputStream(stragglers);
-                    }
-                } catch (IOException ignored) {}
-            }
-        }
-
-        @Override
-        public void close() throws IOException {
-            // BufferedInputStream#close() is not synchronized unlike most other methods.
-            // Synchronizing helps avoid race with processExited().
-            synchronized (closeLock) {
-                super.close();
-            }
-        }
-    }
-
-    /**
-     * A buffered output stream for a subprocess pipe file descriptor
-     * that allows the underlying file descriptor to be reclaimed when
-     * the process exits, via the processExited hook.
-     */
-    static class ProcessPipeOutputStream extends BufferedOutputStream {
-        ProcessPipeOutputStream(int fd) {
-            super(new FileOutputStream(newFileDescriptor(fd)));
-        }
-
-        /** Called by the process reaper thread when the process exits. */
-        synchronized void processExited() {
-            OutputStream out = this.out;
-            if (out != null) {
-                try {
-                    out.close();
-                } catch (IOException ignored) {
-                    // We know of no reason to get an IOException, but if
-                    // we do, there's nothing else to do but carry on.
-                }
-                this.out = ProcessBuilder.NullOutputStream.INSTANCE;
-            }
-        }
-    }
-}
--- a/src/solaris/classes/java/lang/UNIXProcess.java.solaris	Mon May 12 09:32:23 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,395 +0,0 @@
-/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.lang;
-
-import java.io.*;
-import java.util.concurrent.TimeUnit;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/* java.lang.Process subclass in the UNIX environment.
- *
- * @author Mario Wolczko and Ross Knippel.
- */
-
-final class UNIXProcess extends Process {
-    private static final sun.misc.JavaIOFileDescriptorAccess fdAccess
-        = sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess();
-
-    private final int pid;
-    private int exitcode;
-    private boolean hasExited;
-
-    private OutputStream stdin_stream;
-    private InputStream stdout_stream;
-    private DeferredCloseInputStream stdout_inner_stream;
-    private InputStream stderr_stream;
-
-    private static enum LaunchMechanism {
-        FORK(1),
-        POSIX_SPAWN(2);
-
-        private int value;
-        LaunchMechanism(int x) {value = x;}
-    };
-
-    /* On Solaris, the default is to spawn */
-    private static final LaunchMechanism launchMechanism;
-    private static byte[] helperpath;
-
-    private static byte[] toCString(String s) {
-        if (s == null)
-            return null;
-        byte[] bytes = s.getBytes();
-        byte[] result = new byte[bytes.length + 1];
-        System.arraycopy(bytes, 0,
-                         result, 0,
-                         bytes.length);
-        result[result.length-1] = (byte)0;
-        return result;
-    }
-
-    static {
-        launchMechanism = AccessController.doPrivileged(
-                new PrivilegedAction<LaunchMechanism>()
-        {
-            public LaunchMechanism run() {
-                String javahome = System.getProperty("java.home");
-                String osArch = System.getProperty("os.arch");
-                if (osArch.equals("x86")) {
-                    osArch = "i386";
-                } else if (osArch.equals("x86_64")) {
-                    osArch = "amd64";
-                }
-
-                helperpath = toCString(javahome + "/lib/" + osArch + "/jspawnhelper");
-                String s = System.getProperty(
-                    "jdk.lang.Process.launchMechanism", "posix_spawn");
-
-                try {
-                    return LaunchMechanism.valueOf(s.toUpperCase());
-                } catch (IllegalArgumentException e) {
-                    throw new Error(s + " is not a supported " +
-                        "process launch mechanism on this platform.");
-                }
-            }
-        });
-    }
-
-    /* this is for the reaping thread */
-    private native int waitForProcessExit(int pid);
-
-    /**
-     * Create a process. Depending on the mode flag, this is done by
-     * one of the following mechanisms.
-     * - fork(2) and exec(2)
-     * - posix_spawn(2)
-     *
-     * @param std_fds array of file descriptors.  Indexes 0, 1, and
-     *        2 correspond to standard input, standard output and
-     *        standard error, respectively.  On input, a value of -1
-     *        means to create a pipe to connect child and parent
-     *        processes.  On output, a value which is not -1 is the
-     *        parent pipe fd corresponding to the pipe which has
-     *        been created.  An element of this array is -1 on input
-     *        if and only if it is <em>not</em> -1 on output.
-     * @return the pid of the subprocess
-     */
-    private native int forkAndExec(int mode, byte[] helperpath,
-                                   byte[] prog,
-                                   byte[] argBlock, int argc,
-                                   byte[] envBlock, int envc,
-                                   byte[] dir,
-                                   int[] std_fds,
-                                   boolean redirectErrorStream)
-        throws IOException;
-
-    UNIXProcess(final byte[] prog,
-                final byte[] argBlock, int argc,
-                final byte[] envBlock, int envc,
-                final byte[] dir,
-                final int[] std_fds,
-                final boolean redirectErrorStream)
-    throws IOException {
-        pid = forkAndExec(launchMechanism.value,
-                          helperpath,
-                          prog,
-                          argBlock, argc,
-                          envBlock, envc,
-                          dir,
-                          std_fds,
-                          redirectErrorStream);
-
-        java.security.AccessController.doPrivileged(
-        new java.security.PrivilegedAction<Void>() { public Void run() {
-            if (std_fds[0] == -1)
-                stdin_stream = ProcessBuilder.NullOutputStream.INSTANCE;
-            else {
-                FileDescriptor stdin_fd = new FileDescriptor();
-                fdAccess.set(stdin_fd, std_fds[0]);
-                stdin_stream = new BufferedOutputStream(
-                    new FileOutputStream(stdin_fd));
-            }
-
-            if (std_fds[1] == -1)
-                stdout_stream = ProcessBuilder.NullInputStream.INSTANCE;
-            else {
-                FileDescriptor stdout_fd = new FileDescriptor();
-                fdAccess.set(stdout_fd, std_fds[1]);
-                stdout_inner_stream = new DeferredCloseInputStream(stdout_fd);
-                stdout_stream = new BufferedInputStream(stdout_inner_stream);
-            }
-
-            if (std_fds[2] == -1)
-                stderr_stream = ProcessBuilder.NullInputStream.INSTANCE;
-            else {
-                FileDescriptor stderr_fd = new FileDescriptor();
-                fdAccess.set(stderr_fd, std_fds[2]);
-                stderr_stream = new DeferredCloseInputStream(stderr_fd);
-            }
-
-            return null; }});
-
-        /*
-         * For each subprocess forked a corresponding reaper thread
-         * is started.  That thread is the only thread which waits
-         * for the subprocess to terminate and it doesn't hold any
-         * locks while doing so.  This design allows waitFor() and
-         * exitStatus() to be safely executed in parallel (and they
-         * need no native code).
-         */
-
-        java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction<Void>() { public Void run() {
-                Thread t = new Thread("process reaper") {
-                    public void run() {
-                        int res = waitForProcessExit(pid);
-                        synchronized (UNIXProcess.this) {
-                            hasExited = true;
-                            exitcode = res;
-                            UNIXProcess.this.notifyAll();
-                        }
-                    }
-                };
-                t.setDaemon(true);
-                t.start();
-                return null; }});
-    }
-
-    public OutputStream getOutputStream() {
-        return stdin_stream;
-    }
-
-    public InputStream getInputStream() {
-        return stdout_stream;
-    }
-
-    public InputStream getErrorStream() {
-        return stderr_stream;
-    }
-
-    public synchronized int waitFor() throws InterruptedException {
-        while (!hasExited) {
-            wait();
-        }
-        return exitcode;
-    }
-
-    @Override
-    public synchronized boolean waitFor(long timeout, TimeUnit unit)
-        throws InterruptedException
-    {
-        if (hasExited) return true;
-        if (timeout <= 0) return false;
-
-        long timeoutAsNanos = unit.toNanos(timeout);
-        long startTime = System.nanoTime();
-        long rem = timeoutAsNanos;
-
-        while (!hasExited && (rem > 0)) {
-            wait(Math.max(TimeUnit.NANOSECONDS.toMillis(rem), 1));
-            rem = timeoutAsNanos - (System.nanoTime() - startTime);
-        }
-        return hasExited;
-    }
-
-    public synchronized int exitValue() {
-        if (!hasExited) {
-            throw new IllegalThreadStateException("process hasn't exited");
-        }
-        return exitcode;
-    }
-
-    private static native void destroyProcess(int pid, boolean force);
-    private synchronized void destroy(boolean force) {
-        // There is a risk that pid will be recycled, causing us to
-        // kill the wrong process!  So we only terminate processes
-        // that appear to still be running.  Even with this check,
-        // there is an unavoidable race condition here, but the window
-        // is very small, and OSes try hard to not recycle pids too
-        // soon, so this is quite safe.
-        if (!hasExited)
-            destroyProcess(pid, force);
-        try {
-            stdin_stream.close();
-            if (stdout_inner_stream != null)
-                stdout_inner_stream.closeDeferred(stdout_stream);
-            if (stderr_stream instanceof DeferredCloseInputStream)
-                ((DeferredCloseInputStream) stderr_stream)
-                    .closeDeferred(stderr_stream);
-        } catch (IOException e) {
-            // ignore
-        }
-    }
-
-    public void destroy() {
-        destroy(false);
-    }
-
-    @Override
-    public Process destroyForcibly() {
-        destroy(true);
-        return this;
-    }
-
-    @Override
-    public synchronized boolean isAlive() {
-        return !hasExited;
-    }
-
-    // A FileInputStream that supports the deferment of the actual close
-    // operation until the last pending I/O operation on the stream has
-    // finished.  This is required on Solaris because we must close the stdin
-    // and stdout streams in the destroy method in order to reclaim the
-    // underlying file descriptors.  Doing so, however, causes any thread
-    // currently blocked in a read on one of those streams to receive an
-    // IOException("Bad file number"), which is incompatible with historical
-    // behavior.  By deferring the close we allow any pending reads to see -1
-    // (EOF) as they did before.
-    //
-    private static class DeferredCloseInputStream
-        extends FileInputStream
-    {
-
-        private DeferredCloseInputStream(FileDescriptor fd) {
-            super(fd);
-        }
-
-        private Object lock = new Object();     // For the following fields
-        private boolean closePending = false;
-        private int useCount = 0;
-        private InputStream streamToClose;
-
-        private void raise() {
-            synchronized (lock) {
-                useCount++;
-            }
-        }
-
-        private void lower() throws IOException {
-            synchronized (lock) {
-                useCount--;
-                if (useCount == 0 && closePending) {
-                    streamToClose.close();
-                }
-            }
-        }
-
-        // stc is the actual stream to be closed; it might be this object, or
-        // it might be an upstream object for which this object is downstream.
-        //
-        private void closeDeferred(InputStream stc) throws IOException {
-            synchronized (lock) {
-                if (useCount == 0) {
-                    stc.close();
-                } else {
-                    closePending = true;
-                    streamToClose = stc;
-                }
-            }
-        }
-
-        public void close() throws IOException {
-            synchronized (lock) {
-                useCount = 0;
-                closePending = false;
-            }
-            super.close();
-        }
-
-        public int read() throws IOException {
-            raise();
-            try {
-                return super.read();
-            } finally {
-                lower();
-            }
-        }
-
-        public int read(byte[] b) throws IOException {
-            raise();
-            try {
-                return super.read(b);
-            } finally {
-                lower();
-            }
-        }
-
-        public int read(byte[] b, int off, int len) throws IOException {
-            raise();
-            try {
-                return super.read(b, off, len);
-            } finally {
-                lower();
-            }
-        }
-
-        public long skip(long n) throws IOException {
-            raise();
-            try {
-                return super.skip(n);
-            } finally {
-                lower();
-            }
-        }
-
-        public int available() throws IOException {
-            raise();
-            try {
-                return super.available();
-            } finally {
-                lower();
-            }
-        }
-
-    }
-
-    private static native void init();
-
-    static {
-        init();
-    }
-}
--- a/src/solaris/classes/sun/tools/attach/BsdVirtualMachine.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/solaris/classes/sun/tools/attach/BsdVirtualMachine.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,14 +24,14 @@
  */
 package sun.tools.attach;
 
-import com.sun.tools.attach.VirtualMachine;
+import com.sun.tools.attach.AttachOperationFailedException;
 import com.sun.tools.attach.AgentLoadException;
 import com.sun.tools.attach.AttachNotSupportedException;
 import com.sun.tools.attach.spi.AttachProvider;
+
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.File;
-import java.util.Properties;
 
 /*
  * Bsd implementation of HotSpotVirtualMachine
@@ -191,6 +191,8 @@
         }
 
         if (completionStatus != 0) {
+            // read from the stream and use that as the error message
+            String message = readErrorMessage(sis);
             sis.close();
 
             // In the event of a protocol mismatch then the target VM
@@ -205,7 +207,11 @@
             if (cmd.equals("load")) {
                 throw new AgentLoadException("Failed to load agent library");
             } else {
-                throw new IOException("Command failed in target VM");
+                if (message == null) {
+                    throw new AttachOperationFailedException("Command failed in target VM");
+                } else {
+                    throw new AttachOperationFailedException(message);
+                }
             }
         }
 
@@ -237,8 +243,9 @@
             if ((off < 0) || (off > bs.length) || (len < 0) ||
                 ((off + len) > bs.length) || ((off + len) < 0)) {
                 throw new IndexOutOfBoundsException();
-            } else if (len == 0)
+            } else if (len == 0) {
                 return 0;
+            }
 
             return BsdVirtualMachine.read(s, bs, off, len);
         }
--- a/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,14 +24,14 @@
  */
 package sun.tools.attach;
 
-import com.sun.tools.attach.VirtualMachine;
+import com.sun.tools.attach.AttachOperationFailedException;
 import com.sun.tools.attach.AgentLoadException;
 import com.sun.tools.attach.AttachNotSupportedException;
 import com.sun.tools.attach.spi.AttachProvider;
+
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.File;
-import java.util.Properties;
 
 /*
  * Linux implementation of HotSpotVirtualMachine
@@ -207,6 +207,8 @@
         }
 
         if (completionStatus != 0) {
+            // read from the stream and use that as the error message
+            String message = readErrorMessage(sis);
             sis.close();
 
             // In the event of a protocol mismatch then the target VM
@@ -221,7 +223,11 @@
             if (cmd.equals("load")) {
                 throw new AgentLoadException("Failed to load agent library");
             } else {
-                throw new IOException("Command failed in target VM");
+                if (message == null) {
+                    throw new AttachOperationFailedException("Command failed in target VM");
+                } else {
+                    throw new AttachOperationFailedException(message);
+                }
             }
         }
 
--- a/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,15 +24,15 @@
  */
 package sun.tools.attach;
 
-import com.sun.tools.attach.VirtualMachine;
+import com.sun.tools.attach.AttachOperationFailedException;
 import com.sun.tools.attach.AgentLoadException;
 import com.sun.tools.attach.AttachNotSupportedException;
 import com.sun.tools.attach.spi.AttachProvider;
+
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.util.Properties;
 
 /*
  * Solaris implementation of HotSpotVirtualMachine.
@@ -147,11 +147,17 @@
         // If non-0 it means an error but we need to special-case the
         // "load" command to ensure that the right exception is thrown.
         if (completionStatus != 0) {
+            // read from the stream and use that as the error message
+            String message = readErrorMessage(sis);
             sis.close();
             if (cmd.equals("load")) {
                 throw new AgentLoadException("Failed to load agent library");
             } else {
-                throw new IOException("Command failed in target VM");
+                if (message == null) {
+                    throw new AttachOperationFailedException("Command failed in target VM");
+                } else {
+                    throw new AttachOperationFailedException(message);
+                }
             }
         }
 
--- a/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c	Mon May 12 09:32:23 2014 -0700
+++ b/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -200,14 +200,14 @@
         len = remaining;
     }
 
-    RESTARTABLE(read(fd, buf+off, len), n);
+    RESTARTABLE(read(fd, buf, len), n);
     if (n == -1) {
         JNU_ThrowIOExceptionWithLastError(env, "read");
     } else {
         if (n == 0) {
             n = -1;     // EOF
         } else {
-            (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf+off));
+            (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf));
         }
     }
     return n;
--- a/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c	Mon May 12 09:32:23 2014 -0700
+++ b/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c	Mon May 12 09:38:27 2014 -0700
@@ -418,14 +418,14 @@
         len = remaining;
     }
 
-    RESTARTABLE(read(fd, buf+off, len), n);
+    RESTARTABLE(read(fd, buf, len), n);
     if (n == -1) {
         JNU_ThrowIOExceptionWithLastError(env, "read");
     } else {
         if (n == 0) {
             n = -1;     // EOF
         } else {
-            (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf+off));
+            (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf));
         }
     }
     return n;
--- a/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c	Mon May 12 09:32:23 2014 -0700
+++ b/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -161,14 +161,14 @@
         len = remaining;
     }
 
-    RESTARTABLE(read(fd, buf+off, len), n);
+    RESTARTABLE(read(fd, buf, len), n);
     if (n == -1) {
         JNU_ThrowIOExceptionWithLastError(env, "read");
     } else {
         if (n == 0) {
             n = -1;     // EOF
         } else {
-            (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf+off));
+            (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf));
         }
     }
     return n;
--- a/src/windows/classes/sun/tools/attach/WindowsVirtualMachine.java	Mon May 12 09:32:23 2014 -0700
+++ b/src/windows/classes/sun/tools/attach/WindowsVirtualMachine.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,15 +24,15 @@
  */
 package sun.tools.attach;
 
-import com.sun.tools.attach.VirtualMachine;
+import com.sun.tools.attach.AttachOperationFailedException;
 import com.sun.tools.attach.AgentLoadException;
 import com.sun.tools.attach.AttachNotSupportedException;
 import com.sun.tools.attach.spi.AttachProvider;
+
 import sun.tools.attach.HotSpotVirtualMachine;
+
 import java.io.IOException;
-import java.io.File;
 import java.io.InputStream;
-import java.util.Properties;
 import java.util.Random;
 
 public class WindowsVirtualMachine extends HotSpotVirtualMachine {
@@ -105,11 +105,17 @@
             // read completion status
             int status = readInt(is);
             if (status != 0) {
+                // read from the stream and use that as the error message
+                String message = readErrorMessage(is);
                 // special case the load command so that the right exception is thrown
                 if (cmd.equals("load")) {
                     throw new AgentLoadException("Failed to load agent library");
                 } else {
-                    throw new IOException("Command failed in target VM");
+                    if (message == null) {
+                        throw new AttachOperationFailedException("Command failed in target VM");
+                    } else {
+                        throw new AttachOperationFailedException(message);
+                    }
                 }
             }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/windows/lib/security/java.policy	Mon May 12 09:38:27 2014 -0700
@@ -0,0 +1,3 @@
+grant codeBase "file:${java.home}/lib/ext/sunmscapi.jar" {
+        permission java.security.AllPermission;
+};
--- a/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c	Mon May 12 09:32:23 2014 -0700
+++ b/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c	Mon May 12 09:38:27 2014 -0700
@@ -343,7 +343,7 @@
         if (nread == 0) {
             return (jint)-1;        // EOF
         } else {
-            (*env)->SetByteArrayRegion(env, ba, off, (jint)nread, (jbyte *)(buf+off));
+            (*env)->SetByteArrayRegion(env, ba, off, (jint)nread, (jbyte *)(buf));
         }
     }
 
--- a/test/ProblemList.txt	Mon May 12 09:32:23 2014 -0700
+++ b/test/ProblemList.txt	Mon May 12 09:38:27 2014 -0700
@@ -249,6 +249,18 @@
 
 # jdk_jdi
 
+# 6983531
+com/sun/jdi/BadHandshakeTest.java                               linux-all, windows-all
+
+# 8004127
+com/sun/jdi/RedefineImplementor.sh                              generic-all
+
+# 8031555
+com/sun/jdi/JdbMethodExitTest.sh                                generic-all
+
+# 8041934
+com/sun/jdi/RepStep.java                                        generic-all
+
 ############################################################################
 
 # jdk_util
@@ -270,4 +282,10 @@
 # 8033104
 sun/jvmstat/monitor/MonitoredVm/CR6672135.java			generic-all
 
+# 8041989
+sun/tools/jstatd/TestJstatdDefaults.java                        generic-all
+
+# 8037285
+sun/tools/jstatd/TestJstatdServer.java                          generic-all
+
 ############################################################################
--- a/test/TEST.groups	Mon May 12 09:32:23 2014 -0700
+++ b/test/TEST.groups	Mon May 12 09:38:27 2014 -0700
@@ -1,4 +1,4 @@
-#  Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+#  Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
 #  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 #  This code is free software; you can redistribute it and/or modify it
@@ -97,7 +97,8 @@
 
 jdk_nio = \
     java/nio \
-    sun/nio
+    sun/nio \
+    jdk/nio
 
 jdk_net = \
     java/net \
@@ -155,6 +156,15 @@
 jdk_jdi = \
     com/sun/jdi
 
+# java launcher specific tests, Note: do not include this group into any groups
+# that potentially could be included into a jprt test rule, as the complementary
+# closed  group includes awt SplashScreen and these tests may not run 
+# satisfacotorily on all platforms and  profiles thus this group must always 
+# be a stand-alone group
+jdk_launcher = \
+    tools/launcher \
+    sun/tools
+    
 #
 # Tool (and tool API) tests are split into core and svc groups
 #
@@ -194,7 +204,6 @@
     com/sun/jndi \
     com/sun/corba \
     lib/testlibrary \
-    jdk/nio/zipfs \
     sample
 
 #
--- a/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java	Mon May 12 09:38:27 2014 -0700
@@ -26,6 +26,7 @@
  * @bug 8028994
  * @author Staffan Larsen
  * @library /lib/testlibrary
+ * @build jdk.testlibrary.*
  * @run main CheckOrigin
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/security/auth/module/AllPlatforms.java	Mon May 12 09:38:27 2014 -0700
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8039951
+ * @summary com.sun.security.auth.module missing classes on some platforms
+ * @run main/othervm AllPlatforms
+ */
+
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+public class AllPlatforms {
+    public static void main(String[] args) throws Exception {
+        login("cross-platform",
+                "UnixLoginModule", "optional",
+                "NTLoginModule", "optional",
+                "SolarisLoginModule", "optional");
+        try {
+            login("windows", "NTLoginModule", "required");
+            login("unix", "UnixLoginModule", "required");
+            login("solaris", "SolarisLoginModule", "required");
+        } catch (Exception e) {
+            e.printStackTrace(System.out);
+            if (e.toString().contains("UnsatisfiedLinkError")) {
+                throw new Exception("This is ugly");
+            }
+        }
+    }
+
+    static void login(String test, String... conf) throws Exception {
+        System.out.println("Testing " + test + "...");
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("hello {\n");
+        for (int i=0; i<conf.length; i+=2) {
+            sb.append("    com.sun.security.auth.module." + conf[i]
+                    + " " + conf[i+1] + ";\n");
+        }
+        sb.append("};\n");
+        Files.write(Paths.get(test), sb.toString().getBytes());
+
+        // Must be called. Configuration has an internal static field.
+        Configuration.setConfiguration(null);
+        System.setProperty("java.security.auth.login.config", test);
+
+        LoginContext lc = new LoginContext("hello");
+        lc.login();
+        System.out.println(lc.getSubject());
+    }
+}
--- a/test/com/sun/tools/attach/BasicTests.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/com/sun/tools/attach/BasicTests.java	Mon May 12 09:38:27 2014 -0700
@@ -38,7 +38,7 @@
  * @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757
  * @summary Basic unit tests for the VM attach mechanism.
  * @library /lib/testlibrary
- * @run build Agent BadAgent RedefineAgent Application Shutdown RedefineDummy
+ * @run build jdk.testlibrary.* Agent BadAgent RedefineAgent Application Shutdown RedefineDummy RunnerUtil
  * @run main BasicTests
  *
  * This test will perform a number of basic attach tests.
@@ -238,19 +238,17 @@
             // Test 6 - list method should list the target VM
             System.out.println(" - Test: VirtualMachine.list");
             List<VirtualMachineDescriptor> l = VirtualMachine.list();
-            if (!l.isEmpty()) {
-                boolean found = false;
-                for (VirtualMachineDescriptor vmd: l) {
-                    if (vmd.id().equals(pid)) {
-                        found = true;
-                        break;
-                    }
+            boolean found = false;
+            for (VirtualMachineDescriptor vmd: l) {
+                if (vmd.id().equals(pid)) {
+                    found = true;
+                    break;
                 }
-                if (found) {
-                    System.out.println(" - " + pid + " found.");
-                } else {
-                    throw new RuntimeException(pid + " not found in VM list");
-                }
+            }
+            if (found) {
+                System.out.println(" - " + pid + " found.");
+            } else {
+                throw new RuntimeException(pid + " not found in VM list");
             }
 
             // test 7 - basic hashCode/equals tests
--- a/test/com/sun/tools/attach/PermissionTest.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/com/sun/tools/attach/PermissionTest.java	Mon May 12 09:38:27 2014 -0700
@@ -34,7 +34,7 @@
  * @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757
  * @summary Basic unit tests for the VM attach mechanism.
  * @library /lib/testlibrary
- * @run build Application Shutdown
+ * @run build jdk.testlibrary.* Application Shutdown
  * @run main PermissionTest
  *
  * Unit test for Attach API -
--- a/test/com/sun/tools/attach/ProviderTest.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/com/sun/tools/attach/ProviderTest.java	Mon May 12 09:38:27 2014 -0700
@@ -33,7 +33,7 @@
  * @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757
  * @summary Basic unit tests for the VM attach mechanism.
  * @library /lib/testlibrary
- * @run build SimpleProvider
+ * @run build jdk.testlibrary.* SimpleProvider
  * @run main ProviderTest
  *
  * The test will attach and detach to/from the running Application.
--- a/test/com/sun/tools/attach/RunnerUtil.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/com/sun/tools/attach/RunnerUtil.java	Mon May 12 09:38:27 2014 -0700
@@ -24,12 +24,11 @@
 import java.io.IOException;
 import java.io.File;
 import java.nio.file.Files;
-import java.nio.file.Path;
 import java.util.Arrays;
 import java.util.regex.Pattern;
 import java.util.regex.Matcher;
+
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JDKToolLauncher;
 import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.Utils;
 import jdk.testlibrary.ProcessThread;
@@ -39,6 +38,7 @@
  * (Test runner = class that launch a test)
  */
 public class RunnerUtil {
+
     /**
      * The Application process must be run concurrently with our tests since
      * the tests will attach to the Application.
@@ -49,16 +49,31 @@
      *
      * The Application will write its pid and shutdownPort in the given outFile.
      */
-    public static ProcessThread startApplication(String outFile) throws Throwable {
+    public static ProcessThread startApplication(String outFile, String... additionalOpts) throws Throwable {
         String classpath = System.getProperty("test.class.path", ".");
-        String[] args = Utils.addTestJavaOpts(
-            "-Dattach.test=true", "-classpath", classpath, "Application", outFile);
+        String[] myArgs = concat(additionalOpts, new String [] { "-Dattach.test=true", "-classpath", classpath, "Application", outFile });
+        String[] args = Utils.addTestJavaOpts(myArgs);
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
         ProcessThread pt = new ProcessThread("runApplication", pb);
         pt.start();
         return pt;
     }
 
+    public static String[] concat(String[] a, String[] b) {
+        if (a == null) {
+            return b;
+        }
+        if (b == null) {
+            return a;
+        }
+        int aLen = a.length;
+        int bLen = b.length;
+        String[] c = new String[aLen + bLen];
+        System.arraycopy(a, 0, c, 0, aLen);
+        System.arraycopy(b, 0, c, aLen, bLen);
+        return c;
+     }
+
     /**
      * Will stop the running Application.
      * First tries to shutdown nicely by connecting to the shut down port.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/tools/attach/TempDirTest.java	Mon May 12 09:38:27 2014 -0700
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import com.sun.tools.attach.*;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Properties;
+import java.util.List;
+import java.io.File;
+
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.ProcessTools;
+import jdk.testlibrary.ProcessThread;
+
+/*
+ * @test
+ * @bug 8033104
+ * @summary Test to make sure attach and jvmstat works correctly when java.io.tmpdir is set
+ * @library /lib/testlibrary
+ * @run build Application Shutdown RunnerUtil
+ * @run main/timeout=10 TempDirTest
+ */
+
+public class TempDirTest {
+
+    public static void main(String args[]) throws Throwable {
+
+        Path clientTmpDir = Files.createTempDirectory("TempDirTest-client");
+        clientTmpDir.toFile().deleteOnExit();
+        Path targetTmpDir = Files.createTempDirectory("TempDirTest-target");
+        targetTmpDir.toFile().deleteOnExit();
+
+        // run the test with all possible combinations of setting java.io.tmpdir
+        runExperiment(null, null);
+        runExperiment(clientTmpDir, null);
+        runExperiment(clientTmpDir, targetTmpDir);
+        runExperiment(null, targetTmpDir);
+
+    }
+
+    private static int counter = 0;
+
+    /*
+     * The actual test is in the nested class TestMain.
+     * The responsibility of this class is to:
+     * 1. Start the Application class in a separate process.
+     * 2. Find the pid and shutdown port of the running Application.
+     * 3. Launches the tests in nested class TestMain that will attach to the Application.
+     * 4. Shut down the Application.
+     */
+    public static void runExperiment(Path clientTmpDir, Path targetTmpDir) throws Throwable {
+
+        System.out.print("### Running tests with overridden tmpdir for");
+        System.out.print(" client: " + (clientTmpDir == null ? "no" : "yes"));
+        System.out.print(" target: " + (targetTmpDir == null ? "no" : "yes"));
+        System.out.println(" ###");
+
+        final String pidFile = "TempDirTest.Application.pid-" + counter++;
+        ProcessThread processThread = null;
+        RunnerUtil.ProcessInfo info = null;
+        try {
+            String[] tmpDirArg = null;
+            if (targetTmpDir != null) {
+                tmpDirArg = new String[] {"-Djava.io.tmpdir=" + targetTmpDir};
+            }
+            processThread = RunnerUtil.startApplication(pidFile, tmpDirArg);
+            info = RunnerUtil.readProcessInfo(pidFile);
+            launchTests(info.pid, clientTmpDir);
+        } catch (Throwable t) {
+            System.out.println("TempDirTest got unexpected exception: " + t);
+            t.printStackTrace();
+            throw t;
+        } finally {
+            // Make sure the Application process is stopped.
+            RunnerUtil.stopApplication(info.shutdownPort, processThread);
+        }
+    }
+
+    /**
+     * Runs the actual tests in nested class TestMain.
+     * The reason for running the tests in a separate process
+     * is that we need to modify the class path and
+     * the -Djava.io.tmpdir property.
+     */
+    private static void launchTests(int pid, Path clientTmpDir) throws Throwable {
+        final String sep = File.separator;
+
+        // Need to add jdk/lib/tools.jar to classpath.
+        String classpath =
+            System.getProperty("test.class.path", "") + File.pathSeparator +
+            System.getProperty("test.jdk", ".") + sep + "lib" + sep + "tools.jar";
+
+        String[] tmpDirArg = null;
+        if (clientTmpDir != null) {
+            tmpDirArg = new String [] {"-Djava.io.tmpdir=" + clientTmpDir};
+        }
+
+        // Arguments : [-Djava.io.tmpdir=] -classpath cp TempDirTest$TestMain pid
+        String[] args = RunnerUtil.concat(
+                tmpDirArg,
+                new String[] {
+                    "-classpath",
+                    classpath,
+                    "TempDirTest$TestMain",
+                    Integer.toString(pid) });
+        OutputAnalyzer output = ProcessTools.executeTestJvm(args);
+        output.shouldHaveExitValue(0);
+    }
+
+    /**
+     * This is the actual test. It will attach to the running Application
+     * and perform a number of basic attach tests.
+     */
+    public static class TestMain {
+        public static void main(String args[]) throws Exception {
+            String pid = args[0];
+
+            // Test 1 - list method should list the target VM
+            System.out.println(" - Test: VirtualMachine.list");
+            List<VirtualMachineDescriptor> l = VirtualMachine.list();
+            boolean found = false;
+            for (VirtualMachineDescriptor vmd: l) {
+                if (vmd.id().equals(pid)) {
+                    found = true;
+                    break;
+                }
+            }
+            if (found) {
+                System.out.println(" - " + pid + " found.");
+            } else {
+                throw new RuntimeException(pid + " not found in VM list");
+            }
+
+            // Test 2 - try to attach and verify connection
+
+            System.out.println(" - Attaching to application ...");
+            VirtualMachine vm = VirtualMachine.attach(pid);
+
+            System.out.println(" - Test: system properties in target VM");
+            Properties props = vm.getSystemProperties();
+            String value = props.getProperty("attach.test");
+            if (value == null || !value.equals("true")) {
+                throw new RuntimeException("attach.test property not set");
+            }
+            System.out.println(" - attach.test property set as expected");
+        }
+    }
+}
--- a/test/com/sun/tools/attach/java.policy.allow	Mon May 12 09:32:23 2014 -0700
+++ b/test/com/sun/tools/attach/java.policy.allow	Mon May 12 09:38:27 2014 -0700
@@ -13,7 +13,6 @@
     permission java.lang.RuntimePermission "accessClassInPackage.sun.jvmstat.monitor";
     permission java.lang.RuntimePermission "loadLibrary.attach";
     permission java.util.PropertyPermission "sun.jvmstat.*", "read";
-    permission java.util.PropertyPermission "java.io.tmpdir", "read";
 
     /* to read configuration file in META-INF/services, and write/delete .attach_pid<pid> */
     permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
--- a/test/com/sun/tools/attach/java.policy.deny	Mon May 12 09:32:23 2014 -0700
+++ b/test/com/sun/tools/attach/java.policy.deny	Mon May 12 09:38:27 2014 -0700
@@ -11,7 +11,6 @@
     permission java.lang.RuntimePermission "accessClassInPackage.sun.tools.attach";
     permission java.lang.RuntimePermission "loadLibrary.attach";
     permission java.util.PropertyPermission "sun.jvmstat.*", "read";
-    permission java.util.PropertyPermission "java.io.tmpdir", "read";
 
     /* to read configuration file in META-INF/services, and write/delete .attach_pid<pid> */
     permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
--- a/test/java/io/BufferedInputStream/LargeCopyWithMark.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/java/io/BufferedInputStream/LargeCopyWithMark.java	Mon May 12 09:38:27 2014 -0700
@@ -26,6 +26,7 @@
  * @summary BufferedInputStream calculates negative array size with large
  *          streams and mark
  * @library /lib/testlibrary
+ * @build jdk.testlibrary.*
  * @run main/othervm LargeCopyWithMark
  */
 
--- a/test/java/lang/ProcessBuilder/SecurityManagerClinit.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/java/lang/ProcessBuilder/SecurityManagerClinit.java	Mon May 12 09:38:27 2014 -0700
@@ -54,9 +54,6 @@
             System.getProperty("java.home") +
             File.separator + "bin" + File.separator + "java";
 
-        // A funky contrived security setup, just for bug repro purposes.
-        java.security.Security.setProperty("package.access", "java.util");
-
         final Policy policy =
             new Policy
             (new FilePermission("<<ALL FILES>>", "execute"),
--- a/test/java/lang/instrument/PremainClass/NoPremainAgentTest.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/java/lang/instrument/PremainClass/NoPremainAgentTest.java	Mon May 12 09:38:27 2014 -0700
@@ -30,7 +30,7 @@
  * @bug 6289149
  * @summary test when the agent's class is missing the premain() function.
  * @library /lib/testlibrary
- * @run build DummyMain
+ * @run build jdk.testlibrary.* DummyMain
  * @run shell ../MakeJAR3.sh NoPremainAgent
  * @run main NoPremainAgentTest
  */
--- a/test/java/lang/instrument/PremainClass/PremainClassTest.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/java/lang/instrument/PremainClass/PremainClassTest.java	Mon May 12 09:38:27 2014 -0700
@@ -30,7 +30,7 @@
  * @bug 5055293
  * @summary Test non ascii characters in the Premain-Class attribute.
  * @library /lib/testlibrary
- * @run build DummyMain
+ * @run build jdk.testlibrary.* DummyMain
  * @run main PremainClassTest
  */
 public class PremainClassTest {
--- a/test/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java	Mon May 12 09:38:27 2014 -0700
@@ -30,7 +30,7 @@
  * @bug 6289149
  * @summary test when the agent's class has a zero arg premain() function.
  * @library /lib/testlibrary
- * @run build DummyMain
+ * @run build jdk.testlibrary.* DummyMain
  * @run shell ../MakeJAR3.sh ZeroArgPremainAgent
  * @run main ZeroArgPremainAgentTest
  */
--- a/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java	Mon May 12 09:38:27 2014 -0700
@@ -31,7 +31,7 @@
  * @author  Mandy Chung
  *
  * @library /lib/testlibrary/
- * @build CollectionUsageThreshold MemoryUtil RunUtil
+ * @build jdk.testlibrary.* CollectionUsageThreshold MemoryUtil RunUtil
  * @run main/timeout=300 CollectionUsageThreshold
  */
 
--- a/test/java/lang/management/MemoryMXBean/LowMemoryTest.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/java/lang/management/MemoryMXBean/LowMemoryTest.java	Mon May 12 09:38:27 2014 -0700
@@ -31,7 +31,7 @@
  * @author  Mandy Chung
  *
  * @library /lib/testlibrary/
- * @build LowMemoryTest MemoryUtil RunUtil
+ * @build jdk.testlibrary.* LowMemoryTest MemoryUtil RunUtil
  * @run main/timeout=600 LowMemoryTest
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/math/BigInteger/PrimeTest.java	Mon May 12 09:38:27 2014 -0700
@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026236
+ * @summary test primality verification methods in BigInteger
+ * @author bpb
+ */
+import java.math.BigInteger;
+import java.util.BitSet;
+import java.util.HashSet;
+import java.util.List;
+import java.util.NavigableSet;
+import java.util.Set;
+import java.util.SplittableRandom;
+import java.util.TreeSet;
+import static java.util.stream.Collectors.toCollection;
+import static java.util.stream.Collectors.toList;
+
+public class PrimeTest {
+
+    private static final int DEFAULT_UPPER_BOUND = 1299709; // 100000th prime
+    private static final int DEFAULT_CERTAINTY = 100;
+    private static final int NUM_NON_PRIMES = 10000;
+
+    /**
+     * Run the test.
+     *
+     * @param args The parameters.
+     * @throws Exception on failure
+     */
+    public static void main(String[] args) throws Exception {
+        // Prepare arguments
+        int upperBound = args.length > 0 ? Integer.valueOf(args[0]) : DEFAULT_UPPER_BOUND;
+        int certainty = args.length > 1 ? Integer.valueOf(args[1]) : DEFAULT_CERTAINTY;
+        boolean parallel = args.length > 2 ? Boolean.valueOf(args[2]) : true;
+
+        // Echo parameter settings
+        System.out.println("Upper bound = " + upperBound
+                + "\nCertainty = " + certainty
+                + "\nParallel = " + parallel);
+
+        // Get primes through specified bound (inclusive) and Integer.MAX_VALUE
+        NavigableSet<BigInteger> primes = getPrimes(upperBound);
+
+        // Check whether known primes are identified as such
+        boolean primeTest = checkPrime(primes, certainty, parallel);
+        System.out.println("Prime test result: " + (primeTest ? "SUCCESS" : "FAILURE"));
+        if (!primeTest) {
+            System.err.println("Prime test failed");
+        }
+
+        // Check whether known non-primes are not identified as primes
+        boolean nonPrimeTest = checkNonPrime(primes, certainty);
+        System.out.println("Non-prime test result: " + (nonPrimeTest ? "SUCCESS" : "FAILURE"));
+
+        boolean mersennePrimeTest = checkMersennePrimes(certainty);
+        System.out.println("Mersenne test result: " + (mersennePrimeTest ? "SUCCESS" : "FAILURE"));
+
+        if (!primeTest || !nonPrimeTest || !mersennePrimeTest) {
+            throw new Exception("PrimeTest FAILED!");
+        }
+
+        System.out.println("PrimeTest succeeded!");
+    }
+
+    /**
+     * Create a {@code BitSet} wherein a set bit indicates the corresponding
+     * index plus 2 is prime. That is, if bit N is set, then the integer N + 2
+     * is prime. The values 0 and 1 are intentionally excluded. See the
+     * <a
+     * href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes#Algorithm_description">
+     * Sieve of Eratosthenes</a> algorithm description for more information.
+     *
+     * @param upperBound The maximum prime to allow
+     * @return bits indicating which indexes represent primes
+     */
+    private static BitSet createPrimes(int upperBound) {
+        int nbits = upperBound - 1;
+        BitSet bs = new BitSet(nbits);
+        for (int p = 2; p * p < upperBound;) {
+            for (int i = p * p; i < nbits + 2; i += p) {
+                bs.set(i - 2, true);
+            }
+            do {
+                ++p;
+            } while (p > 1 && bs.get(p - 2));
+        }
+        bs.flip(0, nbits);
+        return bs;
+    }
+
+    /**
+     * Load the primes up to the specified bound (inclusive) into a
+     * {@code NavigableSet}, appending the prime {@code Integer.MAX_VALUE}.
+     *
+     * @param upperBound The maximum prime to allow
+     * @return a set of primes
+     */
+    private static NavigableSet<BigInteger> getPrimes(int upperBound) {
+        BitSet bs = createPrimes(upperBound);
+        NavigableSet<BigInteger> primes = bs.stream()
+                .mapToObj(p -> BigInteger.valueOf(p + 2))
+                .collect(toCollection(TreeSet::new));
+        primes.add(BigInteger.valueOf(Integer.MAX_VALUE));
+        System.out.println(String.format("Created %d primes", primes.size()));
+        return primes;
+    }
+
+    /**
+     * Verifies whether the fraction of probable primes detected is at least 1 -
+     * 1/2^certainty.
+     *
+     * @return true if and only if the test succeeds
+     */
+    private static boolean checkPrime(Set<BigInteger> primes,
+            int certainty,
+            boolean parallel) {
+        long probablePrimes = (parallel ? primes.parallelStream() : primes.stream())
+                .filter(bi -> bi.isProbablePrime(certainty))
+                .count();
+
+        // N = certainty / 2
+        // Success if p/t >= 1 - 1/4^N
+        // or (p/t)*4^N >= 4^N - 1
+        // or p*4^N >= t*(4^N - 1)
+        BigInteger p = BigInteger.valueOf(probablePrimes);
+        BigInteger t = BigInteger.valueOf(primes.size());
+        BigInteger fourToTheC = BigInteger.valueOf(4).pow(certainty / 2);
+        BigInteger fourToTheCMinusOne = fourToTheC.subtract(BigInteger.ONE);
+        BigInteger left = p.multiply(fourToTheC);
+        BigInteger right = t.multiply(fourToTheCMinusOne);
+
+        if (left.compareTo(right) < 0) {
+            System.err.println("Probable prime certainty test failed");
+        }
+
+        return left.compareTo(right) >= 0;
+    }
+
+    /**
+     * Verifies whether all {@code BigInteger}s in the tested range for which
+     * {@code isProbablePrime()} returns {@code false} are <i>not</i>
+     * prime numbers.
+     *
+     * @return true if and only if the test succeeds
+     */
+    private static boolean checkNonPrime(NavigableSet<BigInteger> primes,
+            int certainty) {
+        int maxPrime = DEFAULT_UPPER_BOUND;
+        try {
+            maxPrime = primes.last().intValueExact();
+        } catch (ArithmeticException e) {
+            // ignore it
+        }
+
+        // Create a list of non-prime BigIntegers.
+        List<BigInteger> nonPrimeBigInts = (new SplittableRandom())
+                .ints(NUM_NON_PRIMES, 2, maxPrime).mapToObj(BigInteger::valueOf)
+                .filter(b -> !b.isProbablePrime(certainty)).collect(toList());
+
+        // If there are any non-probable primes also in the primes list then fail.
+        boolean failed = nonPrimeBigInts.stream().anyMatch(primes::contains);
+
+        // In the event, print which purported non-primes were actually prime.
+        if (failed) {
+            for (BigInteger bigInt : nonPrimeBigInts) {
+                if (primes.contains(bigInt)) {
+                    System.err.println("Prime value thought to be non-prime: " + bigInt);
+                }
+            }
+        }
+
+        return !failed;
+    }
+
+    /**
+     * Verifies whether a specified subset of Mersenne primes are correctly
+     * identified as being prime. See
+     * <a href="https://en.wikipedia.org/wiki/Mersenne_prime">Mersenne prime</a>
+     * for more information.
+     *
+     * @return true if and only if the test succeeds
+     */
+    private static boolean checkMersennePrimes(int certainty) {
+        int[] MERSENNE_EXPONENTS = {
+            2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203,
+            2281, 3217, 4253, // uncomment remaining array elements to make this test run a long time
+            /* 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497,
+            86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269,
+            2976221, 3021377, 6972593, 13466917, 20996011, 24036583, 25964951,
+            30402457, 32582657, 37156667, 42643801, 43112609, 57885161 */
+        };
+        System.out.println("Checking first "+MERSENNE_EXPONENTS.length+" Mersenne primes");
+
+        boolean result = true;
+        for (int n : MERSENNE_EXPONENTS) {
+            BigInteger mp = BigInteger.ONE.shiftLeft(n).subtract(BigInteger.ONE);
+            if (!mp.isProbablePrime(certainty)) {
+                System.err.println("Mp with p = "+n+" not classified as prime");
+                result = false;
+            }
+        }
+
+        return result;
+    }
+}
--- a/test/java/net/URLPermission/nstest/lookup.sh	Mon May 12 09:32:23 2014 -0700
+++ b/test/java/net/URLPermission/nstest/lookup.sh	Mon May 12 09:38:27 2014 -0700
@@ -26,7 +26,7 @@
 # @library /lib/testlibrary
 # @compile -XDignore.symbol.file=true SimpleNameService.java
 #            LookupTest.java SimpleNameServiceDescriptor.java
-# @build jdk.testlibrary.Utils
+# @build jdk.testlibrary.*
 # @run shell/timeout=50 lookup.sh
 #
 
--- a/test/java/nio/file/WatchService/Basic.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/java/nio/file/WatchService/Basic.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4313887 6838333 7017446
+ * @bug 4313887 6838333 7017446 8011537 8042470
  * @summary Unit test for java.nio.file.WatchService
  * @library ..
  * @run main Basic
@@ -295,24 +295,31 @@
             // IllegalArgumentException
             System.out.println("IllegalArgumentException tests...");
             try {
-                dir.register(watcher, new WatchEvent.Kind<?>[]{ } );
+                dir.register(watcher /*empty event list*/);
                 throw new RuntimeException("IllegalArgumentException not thrown");
             } catch (IllegalArgumentException x) {
             }
             try {
                 // OVERFLOW is ignored so this is equivalent to the empty set
-                dir.register(watcher, new WatchEvent.Kind<?>[]{ OVERFLOW });
+                dir.register(watcher, OVERFLOW);
+                throw new RuntimeException("IllegalArgumentException not thrown");
+            } catch (IllegalArgumentException x) {
+            }
+            try {
+                // OVERFLOW is ignored even if specified multiple times
+                dir.register(watcher, OVERFLOW, OVERFLOW);
                 throw new RuntimeException("IllegalArgumentException not thrown");
             } catch (IllegalArgumentException x) {
             }
 
             // UnsupportedOperationException
             try {
-                dir.register(watcher, new WatchEvent.Kind<?>[]{
+                dir.register(watcher,
                              new WatchEvent.Kind<Object>() {
                                 @Override public String name() { return "custom"; }
                                 @Override public Class<Object> type() { return Object.class; }
-                             }});
+                             });
+                throw new RuntimeException("UnsupportedOperationException not thrown");
             } catch (UnsupportedOperationException x) {
             }
             try {
@@ -328,7 +335,7 @@
             // NullPointerException
             System.out.println("NullPointerException tests...");
             try {
-                dir.register(null, new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
+                dir.register(null, ENTRY_CREATE);
                 throw new RuntimeException("NullPointerException not thrown");
             } catch (NullPointerException x) {
             }
@@ -380,7 +387,7 @@
 
         try {
             dir.register(watcher, new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
-             throw new RuntimeException("ClosedWatchServiceException not thrown");
+            throw new RuntimeException("ClosedWatchServiceException not thrown");
         } catch (ClosedWatchServiceException  x) {
         }
 
@@ -468,6 +475,28 @@
         }
     }
 
+    /**
+     * Test that thread interruped status is preserved upon a call
+     * to register()
+     */
+    static void testThreadInterrupt(Path dir) throws IOException {
+        System.out.println("-- Thread interrupted status test --");
+
+        FileSystem fs = FileSystems.getDefault();
+        Thread curr = Thread.currentThread();
+        try (WatchService watcher = fs.newWatchService()) {
+            System.out.println("interrupting current thread");
+            curr.interrupt();
+            dir.register(watcher, ENTRY_CREATE);
+            if (!curr.isInterrupted())
+                throw new RuntimeException("thread should remain interrupted");
+            System.out.println("current thread is still interrupted");
+            System.out.println("OKAY");
+        } finally {
+            curr.interrupted();
+        }
+    }
+
     public static void main(String[] args) throws IOException {
         Path dir = TestUtil.createTemporaryDirectory();
         try {
@@ -478,6 +507,7 @@
             testWakeup(dir);
             testExceptions(dir);
             testTwoWatchers(dir);
+            testThreadInterrupt(dir);
 
         } finally {
             TestUtil.removeAll(dir);
--- a/test/java/util/BitSet/BSMethods.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/java/util/BitSet/BSMethods.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /* @test
  * @bug 4098239 4107540 4080736 4261102 4274710 4305272
- *      4979017 4979028 4979031 5030267 6222207
+ *      4979017 4979028 4979031 5030267 6222207 8040806
  * @summary Test the operation of the methods of BitSet class
  * @author Mike McCloskey, Martin Buchholz
  */
@@ -897,6 +897,16 @@
     private static void testToString() {
         check(new BitSet().toString().equals("{}"));
         check(makeSet(2,3,42,43,234).toString().equals("{2, 3, 42, 43, 234}"));
+        try {
+            check(makeSet(Integer.MAX_VALUE-1).toString().equals(
+                    "{" + (Integer.MAX_VALUE-1) + "}"));
+            check(makeSet(Integer.MAX_VALUE).toString().equals(
+                    "{" + Integer.MAX_VALUE + "}"));
+            check(makeSet(0, 1, Integer.MAX_VALUE-1, Integer.MAX_VALUE).toString().equals(
+                    "{0, 1, " + (Integer.MAX_VALUE-1) + ", " + Integer.MAX_VALUE + "}"));
+        } catch (IndexOutOfBoundsException exc) {
+            fail("toString() with indices near MAX_VALUE");
+        }
     }
 
     private static void testLogicalIdentities() {
--- a/test/java/util/Locale/Bug7069824.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/java/util/Locale/Bug7069824.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7069824
+ * @bug 7069824 8042360
  * @summary Verify implementation for Locale matching.
  * @run main Bug7069824
  */
@@ -91,6 +91,17 @@
         String range;
         double weight;
 
+        // Testcase for 8042360
+        range = "en-Latn-1234567890";
+        try {
+            lr = new LanguageRange(range);
+            error = true;
+            System.err.println("    IAE should be thrown for LanguageRange("
+                + range + ").");
+        }
+        catch (IllegalArgumentException ex) {
+        }
+
         range = null;
         try {
             lr = new LanguageRange(range);
--- a/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SortedOpTest.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SortedOpTest.java	Mon May 12 09:38:27 2014 -0700
@@ -26,6 +26,9 @@
 
 import java.util.*;
 import java.util.Spliterators;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.BiFunction;
+import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.function.Supplier;
 import java.util.stream.*;
@@ -122,24 +125,33 @@
 
     @Test(groups = { "serialization-hostile" })
     public void testSequentialShortCircuitTerminal() {
-        // The sorted op for sequential evaluation will buffer all elements when accepting
-        // then at the end sort those elements and push those elements downstream
+        // The sorted op for sequential evaluation will buffer all elements when
+        // accepting then at the end sort those elements and push those elements
+        // downstream
+        // A peek operation is added in-between the sorted() and terminal
+        // operation that counts the number of calls to its consumer and
+        // asserts that the number of calls is at most the required quantity
 
         List<Integer> l = Arrays.asList(5, 4, 3, 2, 1);
 
+        Function<Integer, Stream<Integer>> knownSize = i -> assertNCallsOnly(
+                l.stream().sorted(), Stream::peek, i);
+        Function<Integer, Stream<Integer>> unknownSize = i -> assertNCallsOnly
+                (unknownSizeStream(l).sorted(), Stream::peek, i);
+
         // Find
-        assertEquals(l.stream().sorted().findFirst(), Optional.of(1));
-        assertEquals(l.stream().sorted().findAny(), Optional.of(1));
-        assertEquals(unknownSizeStream(l).sorted().findFirst(), Optional.of(1));
-        assertEquals(unknownSizeStream(l).sorted().findAny(), Optional.of(1));
+        assertEquals(knownSize.apply(1).findFirst(), Optional.of(1));
+        assertEquals(knownSize.apply(1).findAny(), Optional.of(1));
+        assertEquals(unknownSize.apply(1).findFirst(), Optional.of(1));
+        assertEquals(unknownSize.apply(1).findAny(), Optional.of(1));
 
         // Match
-        assertEquals(l.stream().sorted().anyMatch(i -> i == 2), true);
-        assertEquals(l.stream().sorted().noneMatch(i -> i == 2), false);
-        assertEquals(l.stream().sorted().allMatch(i -> i == 2), false);
-        assertEquals(unknownSizeStream(l).sorted().anyMatch(i -> i == 2), true);
-        assertEquals(unknownSizeStream(l).sorted().noneMatch(i -> i == 2), false);
-        assertEquals(unknownSizeStream(l).sorted().allMatch(i -> i == 2), false);
+        assertEquals(knownSize.apply(2).anyMatch(i -> i == 2), true);
+        assertEquals(knownSize.apply(2).noneMatch(i -> i == 2), false);
+        assertEquals(knownSize.apply(2).allMatch(i -> i == 2), false);
+        assertEquals(unknownSize.apply(2).anyMatch(i -> i == 2), true);
+        assertEquals(unknownSize.apply(2).noneMatch(i -> i == 2), false);
+        assertEquals(unknownSize.apply(2).allMatch(i -> i == 2), false);
     }
 
     private <T> Stream<T> unknownSizeStream(List<T> l) {
@@ -199,19 +211,24 @@
     public void testIntSequentialShortCircuitTerminal() {
         int[] a = new int[]{5, 4, 3, 2, 1};
 
+        Function<Integer, IntStream> knownSize = i -> assertNCallsOnly(
+                Arrays.stream(a).sorted(), (s, c) -> s.peek(c::accept), i);
+        Function<Integer, IntStream> unknownSize = i -> assertNCallsOnly
+                (unknownSizeIntStream(a).sorted(), (s, c) -> s.peek(c::accept), i);
+
         // Find
-        assertEquals(Arrays.stream(a).sorted().findFirst(), OptionalInt.of(1));
-        assertEquals(Arrays.stream(a).sorted().findAny(), OptionalInt.of(1));
-        assertEquals(unknownSizeIntStream(a).sorted().findFirst(), OptionalInt.of(1));
-        assertEquals(unknownSizeIntStream(a).sorted().findAny(), OptionalInt.of(1));
+        assertEquals(knownSize.apply(1).findFirst(), OptionalInt.of(1));
+        assertEquals(knownSize.apply(1).findAny(), OptionalInt.of(1));
+        assertEquals(unknownSize.apply(1).findFirst(), OptionalInt.of(1));
+        assertEquals(unknownSize.apply(1).findAny(), OptionalInt.of(1));
 
         // Match
-        assertEquals(Arrays.stream(a).sorted().anyMatch(i -> i == 2), true);
-        assertEquals(Arrays.stream(a).sorted().noneMatch(i -> i == 2), false);
-        assertEquals(Arrays.stream(a).sorted().allMatch(i -> i == 2), false);
-        assertEquals(unknownSizeIntStream(a).sorted().anyMatch(i -> i == 2), true);
-        assertEquals(unknownSizeIntStream(a).sorted().noneMatch(i -> i == 2), false);
-        assertEquals(unknownSizeIntStream(a).sorted().allMatch(i -> i == 2), false);
+        assertEquals(knownSize.apply(2).anyMatch(i -> i == 2), true);
+        assertEquals(knownSize.apply(2).noneMatch(i -> i == 2), false);
+        assertEquals(knownSize.apply(2).allMatch(i -> i == 2), false);
+        assertEquals(unknownSize.apply(2).anyMatch(i -> i == 2), true);
+        assertEquals(unknownSize.apply(2).noneMatch(i -> i == 2), false);
+        assertEquals(unknownSize.apply(2).allMatch(i -> i == 2), false);
     }
 
     private IntStream unknownSizeIntStream(int[] a) {
@@ -242,19 +259,24 @@
     public void testLongSequentialShortCircuitTerminal() {
         long[] a = new long[]{5, 4, 3, 2, 1};
 
+        Function<Integer, LongStream> knownSize = i -> assertNCallsOnly(
+                Arrays.stream(a).sorted(), (s, c) -> s.peek(c::accept), i);
+        Function<Integer, LongStream> unknownSize = i -> assertNCallsOnly
+                (unknownSizeLongStream(a).sorted(), (s, c) -> s.peek(c::accept), i);
+
         // Find
-        assertEquals(Arrays.stream(a).sorted().findFirst(), OptionalLong.of(1));
-        assertEquals(Arrays.stream(a).sorted().findAny(), OptionalLong.of(1));
-        assertEquals(unknownSizeLongStream(a).sorted().findFirst(), OptionalLong.of(1));
-        assertEquals(unknownSizeLongStream(a).sorted().findAny(), OptionalLong.of(1));
+        assertEquals(knownSize.apply(1).findFirst(), OptionalLong.of(1));
+        assertEquals(knownSize.apply(1).findAny(), OptionalLong.of(1));
+        assertEquals(unknownSize.apply(1).findFirst(), OptionalLong.of(1));
+        assertEquals(unknownSize.apply(1).findAny(), OptionalLong.of(1));
 
         // Match
-        assertEquals(Arrays.stream(a).sorted().anyMatch(i -> i == 2), true);
-        assertEquals(Arrays.stream(a).sorted().noneMatch(i -> i == 2), false);
-        assertEquals(Arrays.stream(a).sorted().allMatch(i -> i == 2), false);
-        assertEquals(unknownSizeLongStream(a).sorted().anyMatch(i -> i == 2), true);
-        assertEquals(unknownSizeLongStream(a).sorted().noneMatch(i -> i == 2), false);
-        assertEquals(unknownSizeLongStream(a).sorted().allMatch(i -> i == 2), false);
+        assertEquals(knownSize.apply(2).anyMatch(i -> i == 2), true);
+        assertEquals(knownSize.apply(2).noneMatch(i -> i == 2), false);
+        assertEquals(knownSize.apply(2).allMatch(i -> i == 2), false);
+        assertEquals(unknownSize.apply(2).anyMatch(i -> i == 2), true);
+        assertEquals(unknownSize.apply(2).noneMatch(i -> i == 2), false);
+        assertEquals(unknownSize.apply(2).allMatch(i -> i == 2), false);
     }
 
     private LongStream unknownSizeLongStream(long[] a) {
@@ -285,19 +307,24 @@
     public void testDoubleSequentialShortCircuitTerminal() {
         double[] a = new double[]{5.0, 4.0, 3.0, 2.0, 1.0};
 
+        Function<Integer, DoubleStream> knownSize = i -> assertNCallsOnly(
+                Arrays.stream(a).sorted(), (s, c) -> s.peek(c::accept), i);
+        Function<Integer, DoubleStream> unknownSize = i -> assertNCallsOnly
+                (unknownSizeDoubleStream(a).sorted(), (s, c) -> s.peek(c::accept), i);
+
         // Find
-        assertEquals(Arrays.stream(a).sorted().findFirst(), OptionalDouble.of(1));
-        assertEquals(Arrays.stream(a).sorted().findAny(), OptionalDouble.of(1));
-        assertEquals(unknownSizeDoubleStream(a).sorted().findFirst(), OptionalDouble.of(1));
-        assertEquals(unknownSizeDoubleStream(a).sorted().findAny(), OptionalDouble.of(1));
+        assertEquals(knownSize.apply(1).findFirst(), OptionalDouble.of(1));
+        assertEquals(knownSize.apply(1).findAny(), OptionalDouble.of(1));
+        assertEquals(unknownSize.apply(1).findFirst(), OptionalDouble.of(1));
+        assertEquals(unknownSize.apply(1).findAny(), OptionalDouble.of(1));
 
         // Match
-        assertEquals(Arrays.stream(a).sorted().anyMatch(i -> i == 2.0), true);
-        assertEquals(Arrays.stream(a).sorted().noneMatch(i -> i == 2.0), false);
-        assertEquals(Arrays.stream(a).sorted().allMatch(i -> i == 2.0), false);
-        assertEquals(unknownSizeDoubleStream(a).sorted().anyMatch(i -> i == 2.0), true);
-        assertEquals(unknownSizeDoubleStream(a).sorted().noneMatch(i -> i == 2.0), false);
-        assertEquals(unknownSizeDoubleStream(a).sorted().allMatch(i -> i == 2.0), false);
+        assertEquals(knownSize.apply(2).anyMatch(i -> i == 2.0), true);
+        assertEquals(knownSize.apply(2).noneMatch(i -> i == 2.0), false);
+        assertEquals(knownSize.apply(2).allMatch(i -> i == 2.0), false);
+        assertEquals(unknownSize.apply(2).anyMatch(i -> i == 2.0), true);
+        assertEquals(unknownSize.apply(2).noneMatch(i -> i == 2.0), false);
+        assertEquals(unknownSize.apply(2).allMatch(i -> i == 2.0), false);
     }
 
     private DoubleStream unknownSizeDoubleStream(double[] a) {
@@ -321,4 +348,14 @@
         assertSorted(result);
         assertContentsUnordered(data, result);
     }
+
+    /**
+     * Interpose a consumer that asserts it is called at most N times.
+     */
+    <T, S extends BaseStream<T, S>, R> S assertNCallsOnly(S s, BiFunction<S, Consumer<T>, S> pf, int n) {
+        AtomicInteger boxedInt = new AtomicInteger();
+        return pf.apply(s, i -> {
+            assertFalse(boxedInt.incrementAndGet() > n, "Intermediate op called more than " + n + " time(s)");
+        });
+    }
 }
--- a/test/javax/management/monitor/StartStopTest.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/javax/management/monitor/StartStopTest.java	Mon May 12 09:38:27 2014 -0700
@@ -28,7 +28,7 @@
  *          monitors are started and stopped in a loop.
  * @author Luis-Miguel Alventosa
  * @library /lib/testlibrary
- * @run build jdk.testlibrary.Utils
+ * @build jdk.testlibrary.*
  * @run clean StartStopTest
  * @run build StartStopTest
  * @run main/othervm/timeout=300 StartStopTest 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/net/ssl/SSLEngine/IllegalRecordVersion.java	Mon May 12 09:38:27 2014 -0700
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// This test case relies on updated static security property, no way to re-use
+// security property in samevm/agentvm mode.
+
+/*
+ * @test
+ * @bug 8042449
+ * @summary Issue for negative byte major record version
+ *
+ * @run main/othervm IllegalRecordVersion
+ */
+
+import javax.net.ssl.*;
+import javax.net.ssl.SSLEngineResult.*;
+import java.io.*;
+import java.security.*;
+import java.nio.*;
+
+public class IllegalRecordVersion {
+
+    public static void main(String args[]) throws Exception {
+        SSLContext context = SSLContext.getDefault();
+
+        SSLEngine cliEngine = context.createSSLEngine();
+        cliEngine.setUseClientMode(true);
+        SSLEngine srvEngine = context.createSSLEngine();
+        srvEngine.setUseClientMode(false);
+
+        SSLSession session = cliEngine.getSession();
+        int netBufferMax = session.getPacketBufferSize();
+        int appBufferMax = session.getApplicationBufferSize();
+
+        ByteBuffer cliToSrv = ByteBuffer.allocateDirect(netBufferMax);
+        ByteBuffer srvIBuff = ByteBuffer.allocateDirect(appBufferMax + 50);
+        ByteBuffer cliOBuff = ByteBuffer.wrap("I'm client".getBytes());
+
+
+        System.out.println("client hello (record version(0xa9, 0xa2))");
+        SSLEngineResult cliRes = cliEngine.wrap(cliOBuff, cliToSrv);
+        System.out.println("Client wrap result: " + cliRes);
+        cliToSrv.flip();
+        if (cliToSrv.limit() > 5) {
+            cliToSrv.put(1, (byte)0xa9);
+            cliToSrv.put(2, (byte)0xa2);
+        }
+
+        try {
+            srvEngine.unwrap(cliToSrv, srvIBuff);
+            throw new Exception(
+                "Cannot catch the unsupported record version issue");
+        } catch (SSLException e) {
+            // get the expected exception
+        }
+    }
+}
--- a/test/jdk/nio/zipfs/Basic.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/jdk/nio/zipfs/Basic.java	Mon May 12 09:38:27 2014 -0700
@@ -31,8 +31,11 @@
 /**
  *
  * @test
- * @bug 8038500
+ * @bug 8038500 8040059
  * @summary Basic test for zip provider
+ *
+ * @run main Basic
+ * @run main/othervm/policy=test.policy Basic
  */
 
 public class Basic {
--- a/test/jdk/nio/zipfs/PathOps.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/jdk/nio/zipfs/PathOps.java	Mon May 12 09:38:27 2014 -0700
@@ -29,8 +29,11 @@
 /**
  *
  * @test
- * @bug 8038500
+ * @bug 8038500 8040059
  * @summary Tests path operations for zip provider.
+ *
+ * @run main PathOps
+ * @run main/othervm/policy=test.policy.readonly PathOps
  */
 
 public class PathOps {
--- a/test/jdk/nio/zipfs/ZFSTests.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/jdk/nio/zipfs/ZFSTests.java	Mon May 12 09:38:27 2014 -0700
@@ -22,8 +22,11 @@
  */
 
 /* @test
-   @bug 7156873
-   @summary ZipFileSystem regression tests
+ * @bug 7156873 8040059
+ * @summary ZipFileSystem regression tests
+ *
+ * @run main ZFSTests
+ * @run main/othervm/policy=test.policy ZFSTests
  */
 
 
--- a/test/jdk/nio/zipfs/ZipFSTester.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/jdk/nio/zipfs/ZipFSTester.java	Mon May 12 09:38:27 2014 -0700
@@ -40,8 +40,10 @@
  *
  * @test
  * @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840 7007596
- *      7157656 8002390 7012868 7012856 8015728 8038500
+ *      7157656 8002390 7012868 7012856 8015728 8038500 8040059
  * @summary Test Zip filesystem provider
+ * @run main ZipFSTester
+ * @run main/othervm/policy=test.policy ZipFSTester
  */
 
 public class ZipFSTester {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/nio/zipfs/test.policy	Mon May 12 09:38:27 2014 -0700
@@ -0,0 +1,16 @@
+grant codeBase "file:${java.home}/lib/ext/zipfs.jar" {
+    permission java.io.FilePermission "<<ALL FILES>>", "read,write";
+    permission java.lang.RuntimePermission "fileSystemProvider";
+    permission java.util.PropertyPermission "*", "read";
+};
+
+grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
+    permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
+};
+
+grant {
+    permission java.io.FilePermission "<<ALL FILES>>","read,write,delete";
+    permission java.util.PropertyPermission "test.jdk","read";
+    permission java.util.PropertyPermission "test.src","read";
+    permission java.util.PropertyPermission "user.dir","read";
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/nio/zipfs/test.policy.readonly	Mon May 12 09:38:27 2014 -0700
@@ -0,0 +1,12 @@
+grant codeBase "file:${java.home}/lib/ext/zipfs.jar" {
+    permission java.io.FilePermission "<<ALL FILES>>", "read,write";
+    permission java.lang.RuntimePermission "fileSystemProvider";
+    permission java.util.PropertyPermission "*", "read";
+};
+
+grant {
+    permission java.io.FilePermission "<<ALL FILES>>","read";
+    permission java.util.PropertyPermission "test.jdk","read";
+    permission java.util.PropertyPermission "test.src","read";
+    permission java.util.PropertyPermission "user.dir","read";
+};
--- a/test/lib/security/java.policy/Ext_AllPolicy.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/lib/security/java.policy/Ext_AllPolicy.java	Mon May 12 09:38:27 2014 -0700
@@ -30,12 +30,24 @@
 import java.security.*;
 
 public class Ext_AllPolicy {
-        public static void main (String[] args) {
-                FilePermission mine = new FilePermission("/tmp/bar", "read");
-                SecurityManager sm = System.getSecurityManager();
+    public static void main (String[] args) {
+        boolean allPerms = args.length == 1 && args[0].equals("AllPermission");
+        FilePermission mine = new FilePermission("/tmp/bar", "read");
+        SecurityManager sm = System.getSecurityManager();
 
-                if (sm != null) {
-                        sm.checkPermission(mine);
+        if (sm != null) {
+            try {
+                sm.checkPermission(mine);
+                if (!allPerms) {
+                    // Default has no privilege.
+                    throw new RuntimeException(mine + " expected to deny access");
                 }
+            } catch (AccessControlException e) {
+                if (allPerms) {
+                    // expected all permissions granted
+                    throw e;
+                }
+            }
         }
+    }
 }
--- a/test/lib/security/java.policy/Ext_AllPolicy.sh	Mon May 12 09:32:23 2014 -0700
+++ b/test/lib/security/java.policy/Ext_AllPolicy.sh	Mon May 12 09:38:27 2014 -0700
@@ -22,7 +22,7 @@
 #
 
 # @test
-# @bug 4215035
+# @bug 4215035 8040059
 # @summary standard extensions path is hard-coded in default system policy file
 #
 # @build Ext_AllPolicy
@@ -81,6 +81,9 @@
 
 rm Ext_AllPolicy.class
 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \
-        -Djava.security.manager -Djava.ext.dirs="${TESTCLASSES}" Ext_AllPolicy
+        -Djava.security.manager -Djava.ext.dirs="${TESTCLASSES}" Ext_AllPolicy || exit 10
 
+${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \
+        -Djava.security.policy=${TESTSRC}${FS}test.policy \
+        -Djava.security.manager -Djava.ext.dirs="${TESTCLASSES}" Ext_AllPolicy AllPermission
 exit $?
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/security/java.policy/test.policy	Mon May 12 09:38:27 2014 -0700
@@ -0,0 +1,3 @@
+grant codeBase "file:${{java.ext.dirs}}/*" {
+    permission java.security.AllPermission;
+};
--- a/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java	Mon May 12 09:38:27 2014 -0700
@@ -41,7 +41,7 @@
  * @test
  * @bug 6434402 8004926
  * @library /lib/testlibrary
- * @build jdk.testlibrary.ProcessTools
+ * @build jdk.testlibrary.*
  * @build TestManager TestApplication CustomLauncherTest
  * @run main/othervm CustomLauncherTest
  * @author Jaroslav Bachorik
--- a/test/sun/management/jmxremote/startstop/JMXStartStopTest.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/sun/management/jmxremote/startstop/JMXStartStopTest.java	Mon May 12 09:38:27 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -616,7 +616,7 @@
             final boolean[] checks = new boolean[3];
             jcmd(
                 line -> {
-                    if (line.equals("java.lang.RuntimeException: Invalid agent state")) {
+                    if (line.contains("java.lang.RuntimeException: Invalid agent state")) {
                         checks[0] = true;
                     }
                 },
@@ -627,7 +627,7 @@
 
             jcmd(
                 line -> {
-                    if (line.equals("java.lang.RuntimeException: Invalid agent state")) {
+                    if (line.contains("java.lang.RuntimeException: Invalid agent state")) {
                         checks[1] = true;
                     }
                 },
--- a/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java	Mon May 12 09:38:27 2014 -0700
@@ -28,6 +28,7 @@
  * @author  Robert Field
  * @library /lib/testlibrary
  * @compile -XDignore.symbol.file ManyNewInstanceAnonTest.java
+ * @build jdk.testlibrary.*
  * @run main ClassFileInstaller ManyNewInstanceAnonTest
  * @run main/othervm -Xbootclasspath/a:. -Xverify:all ManyNewInstanceAnonTest
  * @run main/othervm -Xbootclasspath/a:. -Xverify:all -Dsun.reflection.noInflation=true ManyNewInstanceAnonTest
--- a/test/sun/security/krb5/auto/ReplayCacheTestProc.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/sun/security/krb5/auto/ReplayCacheTestProc.java	Mon May 12 09:38:27 2014 -0700
@@ -39,6 +39,8 @@
 import java.nio.file.StandardOpenOption;
 import java.security.MessageDigest;
 import java.util.*;
+
+import com.sun.security.auth.module.UnixSystem;
 import sun.security.jgss.GSSUtil;
 import sun.security.krb5.internal.APReq;
 import sun.security.krb5.internal.rcache.AuthTime;
@@ -59,7 +61,7 @@
                 System.getProperty("user.dir");
 
 
-    private static int uid;
+    private static long uid;
 
     public static void main0(String[] args) throws Exception {
         System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF);
@@ -78,11 +80,10 @@
             }
 
             try {
-                Class<?> clazz = Class.forName(
-                        "com.sun.security.auth.module.UnixSystem");
-                uid = (int)(long)(Long)
-                        clazz.getMethod("getUid").invoke(clazz.newInstance());
-            } catch (Exception e) {
+                UnixSystem us = new com.sun.security.auth.module.UnixSystem();
+                uid = us.getUid();
+            } catch (Throwable e) {
+                // Cannot be only Exception, might be UnsatisfiedLinkError
                 uid = -1;
             }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/validator/ConstructorTest.java	Mon May 12 09:38:27 2014 -0700
@@ -0,0 +1,467 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6996377
+ * @summary shrink duplicate code in the constructor of PKIXValidator
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.security.KeyStore;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateFactory;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.security.cert.TrustAnchor;
+import java.security.cert.PKIXBuilderParameters;
+import java.security.cert.X509CertSelector;
+import javax.security.auth.x500.X500Principal;
+import java.util.Date;
+import java.util.List;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Enumeration;
+import java.util.Collection;
+import sun.security.validator.Validator;
+import sun.security.validator.PKIXValidator;
+
+public class ConstructorTest {
+
+    // COMMON-OPTS: All certs created with the following common options:
+    // -keystore <STORE> -storepass <PASS> -keypass <PASS> -keyalg rsa
+    // -keysize 2048 -validity 720 -sigalg sha256withrsa
+
+    // keytool <COMMON-OPTS> -alias root -ext bc:critical=ca:true
+    //         -ext ku:critical=keyCertSign,cRLSign
+    private static final String ROOT =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIC3jCCAcagAwIBAgIEInKZgjANBgkqhkiG9w0BAQsFADAPMQ0wCwYDVQQDEwRS\n" +
+        "b290MB4XDTE0MDUwODE4MjcwOFoXDTE2MDQyNzE4MjcwOFowDzENMAsGA1UEAxME\n" +
+        "Um9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIzgMkrCZD7PuoFb\n" +
+        "fmtAd2+Td6nA9sgBd8Z3NjQgP6nwyn79svaVV9XAVLTrLian72wV/1Kbq/6HUXQQ\n" +
+        "AqyUAvobDwXeIAmE4+D7qcZxiEJgVNr2Ddv1bbS8Y0/Ta72qzjFiEPMO3Y2GP52C\n" +
+        "ssKQpsdNttHfM9c73cKUspobc3p51k2lkynheshCSNOWxR/Rvsl/gcbEFg8vIEHV\n" +
+        "oJPwKSrABc4sWiiXQj0yLVW+DKVEFuWNqqitcikQLZFpgOYv8P1SjhJFkcA9s0oN\n" +
+        "sbvKO2VF141h161i0AFddTsGE85A3j42qEdwQ0cs9gyAoeU865TFvxCuhSqSgJ3a\n" +
+        "Mdgn7ssCAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw\n" +
+        "HQYDVR0OBBYEFFQY2UJynMSoS7Tf/+DvNPp/ZxXfMA0GCSqGSIb3DQEBCwUAA4IB\n" +
+        "AQAeXRQnEhxNl8lrcGY1U1LbIdrNMlGnc0JbgwiVYwRlE3+u4GvDae1VueXyY6nw\n" +
+        "8m63H3Q/Do9/72aw2Q0FSwvDg+k5ssj+gXQ3Gyx8xsVPJEG0TizOSwnWiZtWu65w\n" +
+        "14p5TB8P8wdPEs6sfE9oheiKhDRjBZHIfqMd4DaBiM9N9qHpSwTJc02BB2KnGwga\n" +
+        "yiYNJbce7GFKn/exryj972n/Nl4xy1WdZrRwTBbV21/GINw+xdXn1+FD95EGqGlr\n" +
+        "Sb4+G7U7Ydo+xFpVQnrqxZe98pI5W2bG7VSKvIzcPxfL5/tjwtNaqhiD7wIBNHVx\n" +
+        "ZeJevm41O9qFQEdXNyVGpB+u\n" +
+        "-----END CERTIFICATE-----\n";
+
+    // keytool <COMMON-OPTS> -alias int -ext bc:critical=ca:true
+    //         -ext ku:critical=keyCertSign,cRLSign
+    private static final String INTERMED =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIC/jCCAeagAwIBAgIEDkzdijANBgkqhkiG9w0BAQsFADAPMQ0wCwYDVQQDEwRS\n" +
+        "b290MB4XDTE0MDUwODE4MjcyNFoXDTE2MDQyNzE4MjcyNFowDjEMMAoGA1UEAxMD\n" +
+        "SW50MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwslILfgvXPxdRgu8\n" +
+        "4SnrZJsSzb/XvYwYGAKTSvsDaI1nXypBbwDGz87+YPpZSJcExcS8I8GBKqN6kXIh\n" +
+        "YvJ9yMGJX8wdwoMQpw2ZfJpzfw9Nqtlhv8/q5kPlaDghJ+nGNwy5lyYNOzDMVht0\n" +
+        "1XQG65C+l7m52lDJ478tGRZEFkx0aTh2QUBI59iNji6r2Buyeiijhg4YBrvIlYLK\n" +
+        "OAHxru4N/Y2Cq3ECUUvm7Lf8tM8yrINS8FLT+pmNcLj8AKkGW8cFFaiGPMyon0/m\n" +
+        "4iJB7ZaeG+BGm9TvBv93cphAsM2tY+S+P/dLfI01ltucibPkSglmquUSA0xW9ilv\n" +
+        "PEYWqQIDAQABo2MwYTAfBgNVHSMEGDAWgBRUGNlCcpzEqEu03//g7zT6f2cV3zAP\n" +
+        "BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU1jeG+pzz\n" +
+        "WnHa+0PfJNw9JTrZaoMwDQYJKoZIhvcNAQELBQADggEBABRshh0oJ8Dq87Tgcf3w\n" +
+        "ERVZ/uDWKj76UXWQ3uvKMhnNxKN/vs1rCfhovkptn39CXndOb8m6UkvmMjDtJsiO\n" +
+        "Oq/DiR6NngCy5yJ5hMuBsdQ2QVvdiqG4Sb+vOaQ2TNQNEHEWC7sB0ztImjxlqDtq\n" +
+        "yvof5pd8pHeZJNyDo5cHw1cpoUI9GLz6CK5i0wUlBvsYERIX5aRqxqdtKgBefHFN\n" +
+        "S2ChTRB16A5C1h+Lu79KnoeS33lZt1VeebIA7hvaHkqhGGpncutEYgT8QNFFpjM8\n" +
+        "yFCjZG+ZuUD/s5hd/xHnPdJzR+RWVKMjjVCTpnni3+NHXo2fh0G8YFhdHQ2F/YFI\n" +
+        "ig0=\n" +
+        "-----END CERTIFICATE-----\n";
+
+    // keytool <COMMON-OPTS> -alias user -ext ku:c=digitalSignature
+    //         -ext eku=clientAuth
+    private static final String USER =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIDAjCCAeqgAwIBAgIEKgsK2DANBgkqhkiG9w0BAQsFADAOMQwwCgYDVQQDEwNJ\n" +
+        "bnQwHhcNMTQwNTA4MTgyNzI3WhcNMTYwNDI3MTgyNzI3WjAPMQ0wCwYDVQQDEwRV\n" +
+        "c2VyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArBFLJZ1liQAEkEyJ\n" +
+        "9vAiViRXtDDV+lc62DR4DBj1/Vsw9djVOxmwDKM0+jj83F4Qn9vulr+xp2aZzx4Y\n" +
+        "GiJgbtoxPvZmwNv4MPCNX+fgl/+C0nFKOoSYfHb/tK0Jj6u8HOmQqkbSmGJd/yRL\n" +
+        "qavapRvhS94tFhiNK7wwLAK9AZ+r7cTEBtUSqfaS7mY7tUsERcZs6z3+rmsuxWw6\n" +
+        "/xnNTIVWjdUSbEnjZCdkfZ0cjFONotL6aKoa6YXzohzgA5c3SJZqscEaz4yPkMvl\n" +
+        "7bGy7cn6xjfbb5V3oNqo1dtF3Jm8zp0q8Zgvc47l+DAoGIHSpDhPGX+qSWOTwRla\n" +
+        "QT6NDwIDAQABo2cwZTAfBgNVHSMEGDAWgBTWN4b6nPNacdr7Q98k3D0lOtlqgzAT\n" +
+        "BgNVHSUEDDAKBggrBgEFBQcDAjAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0OBBYEFE/p\n" +
+        "UEn8+capIj2+V+7GoxUhdVnWMA0GCSqGSIb3DQEBCwUAA4IBAQBkEyFJ/1CCMoU3\n" +
+        "C1sYoq4Wt36z3e4Z2rMjfpFXcagqOQaq+hq+/eG8gDE50tOp30nZF7BxSv0RKnxa\n" +
+        "KSkrKcupwgPJOZZWVR6ycV3xWm4QleLuDJh3NdK0o8vvIwLQP47fXURzEXTpGodl\n" +
+        "+hGx7jcghsOKftBDCaleywam4jcZ5YPfp5Ayev0pK/Euf0kZgZAhRM33uJVVfEns\n" +
+        "UotoGK7SL6hZMCrreVlXygof19p531Ps5xMqu0y2u2xztjVQJ+gPU5zcYbjByUl+\n" +
+        "pY+wDPb8XU1EoLl7J5UyayXlk0c3KG/5f+CrVi2HtRfCcKLBf8/MH6OFIpX9O77p\n" +
+        "Qq3r+W/l\n" +
+        "-----END CERTIFICATE-----\n";
+
+    // keytool <COMMON-OPTS> -alias red-ta-key -ext bc:critical=ca:true
+    //         -ext ku:critical=keyCertSign,cRLSign
+    private static final String RED_ROOT =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIC5jCCAc6gAwIBAgIEWK8vRTANBgkqhkiG9w0BAQsFADATMREwDwYDVQQDEwhS\n" +
+        "ZWQgUm9vdDAeFw0xNDA1MDgxODI3MTNaFw0xNjA0MjcxODI3MTNaMBMxETAPBgNV\n" +
+        "BAMTCFJlZCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjpMy\n" +
+        "Qh5yq4R3DrwsWaBZoCR+gda4a1PjGpjlQW/Au6R3hwUDAunkQIz/sX1CnLLJ7cks\n" +
+        "4m6ba2wjYE3NbVP9D3HozLAv2ErB75/F3evRu5UvzkGLkamyHJBY0xEyFyOaD4MC\n" +
+        "hhlo8dDEY++YL8Od+m4i56fYXQlTT94u20I+6hZxeIpJxFSHyouZg06jb+URibi0\n" +
+        "e7I3JApWghgcDfgEXZWlCmB8IswYPdd+XWRFDNc4rSWueRP+SeQOFx9x1jM6+skP\n" +
+        "DGLpuaChO7cqsUxYnsEx9zhdxQ+v4V3vOye/GigpRaO7WvgPB4g5sYhFlwZ/tp+A\n" +
+        "KQebXExXCGOOQUoFEwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB\n" +
+        "/wQEAwIBBjAdBgNVHQ4EFgQUYL8o0Ku7Irg33xzCgA4q1PFz6IQwDQYJKoZIhvcN\n" +
+        "AQELBQADggEBAGSVpI7Qmb0oupBCs+tXlJ4/+TX6eBGcHydaT/2hlgEEdT7S7y6O\n" +
+        "iMC8C8wlEKTLZ6MJSxjeFTIO62OkTjCsGtk+BHTaE81QL5rxjGFkvtuQrwck8gHg\n" +
+        "fAb7daF9ZVLz6B8+cX047xZHx9ZGM/ID+GJg/3fk17WA2BhW1Xkzskby5AWpBDol\n" +
+        "i6+zEod0uZhpHiWwVSfHlEA+rnkhW632oVaVNNDkeUhsCxrU0k7nlQx8bG5bmUso\n" +
+        "1MaPP1kRKvcy0UGx6q3s8pcrKw0X1S66n7HV+WbQebg83U0MVE1r/J0Cfi0jMS/x\n" +
+        "ZUVXs7rjCGFhwfiT/kybKD8adrGHSmLhKs0=\n" +
+        "-----END CERTIFICATE-----\n";
+
+    // keytool <COMMON-OPTS> -alias orange-ta-key -ext bc:critical=ca:true
+    //         -ext ku:critical=keyCertSign,cRLSign
+    private static final String ORANGE_ROOT =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIC7DCCAdSgAwIBAgIEQPSszTANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDEwtP\n" +
+        "cmFuZ2UgUm9vdDAeFw0xNDA1MDgxODI3MTRaFw0xNjA0MjcxODI3MTRaMBYxFDAS\n" +
+        "BgNVBAMTC09yYW5nZSBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" +
+        "AQEAknfh3lKWVQxl2w/eRSza6+0+zeTtMkQFCEFpGJsisDK5XOU1HcJMP4QUteWM\n" +
+        "tg1SGO9bjpiKqJ7JVRnzOC3q6erBj2LmwpWW7p12tg6ENOQfsy6tRZLlQWMFGBkT\n" +
+        "Tatsg9HwKpr6itvk2wERh18AcIqSjtN94kGTljP1qf9gMd31G5d/HyG6EwMZukJm\n" +
+        "4/EFpzh3fVwr/EN1WzrYlsBOA+3Tru/k0p8wP6Bomrx1vAEUqRWSLWxsa7we76jL\n" +
+        "H/kMkyWENyjd/A2c5CwscoG+KSx9cifYnSqrUAmpY88KKuZG2Y1+9ablUEwXW4Gh\n" +
+        "RYLCGIgxp6NrtFG/eUcDBgtEwQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4G\n" +
+        "A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUPvRE9j3GPGcc3dNGrVrQoWDb9RMwDQYJ\n" +
+        "KoZIhvcNAQELBQADggEBADjPTuHXMbXc2Kn+i+dnBiQCWcjzaox4KWV4MNO7vkvi\n" +
+        "ADBk5/vVM+HTzwL+gZNwE96/agcOzwHZ8/Dz4aA3zzmAmQB4bt+pUa0iyGvX6+F5\n" +
+        "IH1kd4kBnSBMc76fRcEJnebhrXFgTlps5VELMVcEOn3Q4nt+gVfXmPStTkFjM1/4\n" +
+        "fQggsScLpE2TVkk3oS52NIzG/vyBIt3W0gX20hlQobA2vziJDx8xy/+qe5igyp5F\n" +
+        "WScwSQE8qeuoDJYJRxpxZ7kq8NiHxfGPw5Hjn518zBz2VKJOsJYmckAMFIdS//kM\n" +
+        "NUysH6gFksW/PHy75QkbtD4OFtb2zp01ERuf5OoJavs=\n" +
+        "-----END CERTIFICATE-----\n";
+
+    // keytool <COMMON-OPTS> -alias yellow-ta-key -ext bc:critical=ca:true
+    //         -ext ku:critical=keyCertSign,cRLSign
+    private static final String YELLOW_ROOT =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIC7DCCAdSgAwIBAgIEfLA7azANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDEwtZ\n" +
+        "ZWxsb3cgUm9vdDAeFw0xNDA1MDgxODI3MTZaFw0xNjA0MjcxODI3MTZaMBYxFDAS\n" +
+        "BgNVBAMTC1llbGxvdyBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" +
+        "AQEAgLMOpzIR8LyALox2AvItM42VjFDp1EyHU0faJZCpwVbQPJ2f+8Gr7XuTv1uZ\n" +
+        "Ixe6JjcyGNHZG0NuFmMFbK2Y7cg3PdQBjcm+x68iSWzyEUuhytSKSLUt6i+xAg+9\n" +
+        "h9UGXlBNarVjWq63tPt8HK/YHxt9Ber0iriF3SEUsgMOzRrLw1mw35SmgidRp19y\n" +
+        "yNXlgQfylEAVtYD9IYhxTm/j9NL3rTgqXiKjvNAVjAUrD2I2nK5WQqO2hmQr9x/9\n" +
+        "EqgIK03dw0ps7/XL+gpd+zwGZqDr9pbFnko4badiE4AJqPlm6u/Tdc0dSkLu/oXq\n" +
+        "Ex4iqtM0TP5+oeDXGZv6EprzKQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4G\n" +
+        "A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUp0/g/PqT9jDVGKSsBh997Kg9KBIwDQYJ\n" +
+        "KoZIhvcNAQELBQADggEBAG4vr5UkWUEA9qNU6wBNg5yySS6KhNVyBDMReyX6qsz6\n" +
+        "yUIeGU/UC8LwdB+Tl3S+FZyUlsx+gwh1n0ei7eOV58cCeWmZ3sUWvLTwsY9iBNyt\n" +
+        "HkItOCDO+JEjgo7OhEBlzYkD4MkwAjaYnT4tU41BSnlTR4+jK77f/b1oMVzDv2tL\n" +
+        "+JAiem04TEoGO97uZ94l6gKwwGO35uejGEUPhFPLtxo+yR2QQqX0S8smG88pCQ82\n" +
+        "6XscdvRTjSfkuI3LiqNORS0fGZ3ykxDCkDLZZ1mSg1h2/3xOUEbFQ0phhMrnr2Rl\n" +
+        "mWNGYCam2jns4qmMnbzPIwQduvRkz1O1lusbLNFpcdY=\n" +
+        "-----END CERTIFICATE-----\n";
+
+    // keytool <COMMON-OPTS> -alias green-ta-key -ext bc:critical=ca:true
+    //         -ext ku:critical=keyCertSign,cRLSign
+    private static final String GREEN_ROOT =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIC6jCCAdKgAwIBAgIENWwt8TANBgkqhkiG9w0BAQsFADAVMRMwEQYDVQQDEwpH\n" +
+        "cmVlbiBSb290MB4XDTE0MDUwODE4MjcxOFoXDTE2MDQyNzE4MjcxOFowFTETMBEG\n" +
+        "A1UEAxMKR3JlZW4gUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\n" +
+        "AKHvh3FRJghpNtLqIk5UDSGkcA3rtEygRsFa51ucwNQ1x4SXOVnsNHZZW66RuKOn\n" +
+        "6wjS8+xctNnMIy1XNXa2nlAswQVe75xX0jfGMB4w0MlaqLK9HrU479WrWmrBjz/P\n" +
+        "vvHY8x1CIfTMjOtLO9yxbYQrXsEz6JKxAz6/+ErbkvUjBynezZdJNXgURVz5HmFx\n" +
+        "e/SUbSALX+Kx+/+hXggaQdwlrpoDl/Nqm6S1iR5xtdZB1CEauIwFDSWOG1TjR1Hp\n" +
+        "8OSGb0AhwwM5FzIxevwgKke6WHFKf5p4lcpiQZqmhgqyFbARUfUjYX3WzQTmrJ/q\n" +
+        "87OMIJasvmkNEYkNbrSmI9kCAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV\n" +
+        "HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHG7s0KrfUsnl/3/UGYbCrdXTZtcMA0GCSqG\n" +
+        "SIb3DQEBCwUAA4IBAQBUe18kbDHeqsxM17ahr30hvjdxMkYLkLcGoSOlSI8sFBu6\n" +
+        "jG4JZvvFXw2ZqMQTLSALvsSZ9wkfS8tDCNEHRvCB6aqW4tjp9ddkfe+56WINzTv6\n" +
+        "Ibqwg2JGsOzWttpUA5OPLfODbMqOYzT101toF3sKteX0yyiF/SfMTXR5Jv0uo/dp\n" +
+        "sFeJtWFfhy/Q0jiEAz945BBoSHCIF7Fs4vcls7gNJxfap66W8lamjzFyMDsnlz+b\n" +
+        "sSLWZmvwM+R/RfL1Q3LPCcZWLiP9WSAO4hUoju1E9WeWHHjlPwJJ/iRECL9cnHRt\n" +
+        "Z7/kOlNLGxKvpEbY4xqH0zE07UWPCCBlemk/6jlO\n" +
+        "-----END CERTIFICATE-----\n";
+
+    // keytool <COMMON-OPTS> -alias blue-ta-key -ext bc:critical=ca:true
+    //         -ext ku:critical=keyCertSign,cRLSign
+    private static final String BLUE_ROOT =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIC6DCCAdCgAwIBAgIEX3XC9zANBgkqhkiG9w0BAQsFADAUMRIwEAYDVQQDEwlC\n" +
+        "bHVlIFJvb3QwHhcNMTQwNTA4MTgyNzIwWhcNMTYwNDI3MTgyNzIwWjAUMRIwEAYD\n" +
+        "VQQDEwlCbHVlIFJvb3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCY\n" +
+        "pc4r8mfgGGeiYlvHSrEIlp6djHS489P7eqoQRqmS5U/I0lLGNu7QZsY240a9a84S\n" +
+        "2t6VpZID5juK8AF2v4psShsqgfj+RjVev8FJE/D5j8B4QZ+HmbLJIl80f+YOPaLG\n" +
+        "HX1eNktLx3S2gkIKHVdn7q3o4DdXBO+YdaBA56lL4l+dWFtto65+5Sjy4yfyvWJz\n" +
+        "MylXjP/wiC0T3C0NcQX3AIu2tjY2u9lrVbem2rIi0kPFIoYvstKiqXMc/sRf2CfO\n" +
+        "it5k629HsbvdACVRZFxU3Lz25oP4HGz1kq1cpiIS+W3gQQmCKu9XqzpNRThG0SEL\n" +
+        "jaH9E4pZDnZiRCr+Mxm1AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P\n" +
+        "AQH/BAQDAgEGMB0GA1UdDgQWBBS5ebHO4iamr3n0+KtxJYAitg9QcTANBgkqhkiG\n" +
+        "9w0BAQsFAAOCAQEAGjh/UzERw+skEK4zM1zfL1RsZnUlFu7mTbOBGgccewHWC+MM\n" +
+        "AQbLo0m4NTEbRoW6fFcAESgE61ZZBLkmhcjXBunNJq6O1hMDpppYA806eG6GcZmK\n" +
+        "rLOZljxx4D1YC17vMEVsMF9XgIj5dLWceJjotZzNxe+miwXLEkxaGIMe/n2VtCoR\n" +
+        "BSrGrAeCsFZ7G2NRWUxUEVJrhLnVZJDt6fHd43BCVnV191PyF5TuB08nijyCoJoS\n" +
+        "/WJkYHxx3vUUfDE5E4UE+iY80BHnAPxiNKwO3XsWjeqbJ8PS+5AvShdG5QdFBhKe\n" +
+        "/tJTZLs0UEubKdaWd5ZgsXP3913bJm/mBo+eJA==\n" +
+        "-----END CERTIFICATE-----\n";
+
+    // keytool <COMMON-OPTS> -alias indigo-ta-key -ext bc:critical=ca:true
+    //         -ext ku:critical=keyCertSign,cRLSign
+    private static final String INDIGO_ROOT =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIC7DCCAdSgAwIBAgIESdUmczANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDEwtJ\n" +
+        "bmRpZ28gUm9vdDAeFw0xNDA1MDgxODI3MjFaFw0xNjA0MjcxODI3MjFaMBYxFDAS\n" +
+        "BgNVBAMTC0luZGlnbyBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" +
+        "AQEA2opDa3wDxQrX6GjffbDGtXyvKw0/vhZTeus4cxdZIYF3CWkGbeurDIhPUKRO\n" +
+        "Azact0SECJuMXVxkB5vQKBmHRByNh8ugFfzXWi7/rteXTNjLNKnzVr8plbMvzwM7\n" +
+        "zjIgm0mTRbwv6gZmUbgfmO9FCB8zlV4hYbYbFTJn7GlVPpqZkZNNMTyJkOPxMzXD\n" +
+        "yaToxyR0uY3cMv9pmks3GxU2XoGTFuqptbL9XFSpwrm5BRfWuJDP1t8moLHQZ5iu\n" +
+        "tkCz6MVYcrhTlV/UY0PSGcmUvAu83sNBfIGjme0RIiERy02gLJnSZ/M9r1ukCUJE\n" +
+        "Z6At+9TsNCYNPgW5vcjNLO63/wIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4G\n" +
+        "A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU8eJ+kMmanqF+IcAQTjxSMv+VR7kwDQYJ\n" +
+        "KoZIhvcNAQELBQADggEBAGRB4C5qYXXJJnEGzJZf8S974SaeLmEvHlmaQPOuCxME\n" +
+        "tCeBoWQqD9qTDVy39izzjA4uE/fCMVCkyr1QL+588dtMI8jJfbzx+TxnlDWlJcMM\n" +
+        "5J8EJPNEy7eR6qqpFncvjmbXzf16XfzL9qSXwHYCvpo25nEEH801y2njJE2gGzZT\n" +
+        "raYRFuwzsZLiSV5TyO5MbRXiZLebDXfE/wXukor87pjGpx1/kevjH/g66OpaIBzu\n" +
+        "IfLePEOekTKXHF1zL89uYHwpUVCzfhO5hNQlSsTCuBkBifSTYm4ixoATi/C2kqze\n" +
+        "WHUK179u1+7v6xRONLQxe1JDftdlHHVg7DSeTY59euo=\n" +
+        "-----END CERTIFICATE-----\n";
+
+    // keytool <COMMON-OPTS> -alias violet-ta-key -ext bc:critical=ca:true
+    //         -ext ku:critical=keyCertSign,cRLSign
+    private static final String VIOLET_ROOT =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIC7DCCAdSgAwIBAgIEXwgmLDANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDEwtW\n" +
+        "aW9sZXQgUm9vdDAeFw0xNDA1MDgxODI3MjNaFw0xNjA0MjcxODI3MjNaMBYxFDAS\n" +
+        "BgNVBAMTC1Zpb2xldCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" +
+        "AQEAvElr11MoHUNfnx6nBy4NSXFFzA68g57ohTt+sspEn3wzuPErugMypReHLhtH\n" +
+        "CTrs45T0KU8P4Gi5QHnsBs8yC3QCHNPugo2A4zP+ciTqp+1gRNxQ9wzKSzCoseJg\n" +
+        "RMQflGFzuEe7gWwYfrsDfD1sJCubfBtBUFCSYf1ZSZbdEMrc3RPtC35Ge+3XRxFZ\n" +
+        "KdzH8l7gQTtgAmRQmK+i4jwzSHV/Iu2yiRdhjqIZUezf3pYFfJlmfAY5ruQBKkc+\n" +
+        "KRgdmKanpLbmAo/+3q6snt8V09CoQ+6Cz+P9P0yOxiiwr/6jg9WtHA3ujvtf3dGj\n" +
+        "EeB8SmzXHFZErQIn+QbrJ3/izwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4G\n" +
+        "A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUlxlHI8JTrX86r4ezgDLICo6rApowDQYJ\n" +
+        "KoZIhvcNAQELBQADggEBALnfWZx6LC9vDMI8vBH/vbyk2ZQtiQFRt3kbwKtlrw65\n" +
+        "/bqeGXcQ1Lh9gDzp+uGYSfuDNvtJO6xmfny0W5j5WQVJxs+iWyoJfYxeG0kBZut+\n" +
+        "hbxJPlehBwhveuznZbeTN3RXeBi8MSxnBD/WC1e2rnfnrxoLfYZ1BSUP8LaIzC32\n" +
+        "vd6WCgnJRXputlGvnOoAT1WduWonhd7lCoqbtZksw7o0smuAn2mSnod8j948rzzt\n" +
+        "uDQVao/3tCyoX4NSom2hWooPltk5FTdF9cZKfbaU5TPV+U30RN7/UWY/dCvL1fMq\n" +
+        "1kvtJbkh+UMHvszHOxlgjk+3J76Wx0PFjNaIfbj2bmk=\n" +
+        "-----END CERTIFICATE-----\n";
+
+    public static final String[] rootArrayPEM = { RED_ROOT, ORANGE_ROOT,
+        YELLOW_ROOT, GREEN_ROOT, BLUE_ROOT, INDIGO_ROOT, VIOLET_ROOT, ROOT };
+
+    /**
+     * @param args {cacerts keystore, cert chain}
+     */
+    public static void main(String[] args) throws Exception {
+        Set<X509Certificate> trustedCertSet = new HashSet<>();
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+        for (String pemCert : rootArrayPEM) {
+            trustedCertSet.add(makeCertFromPEM(pemCert));
+        }
+
+        testCtorByCollection(trustedCertSet);
+
+        testCtorByPKIXBuilderParams(trustedCertSet);
+    }
+
+    public static X509Certificate makeCertFromPEM(String pemCert)
+            throws CertificateException {
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+        ByteArrayInputStream is = new ByteArrayInputStream(pemCert.getBytes());
+
+        return ((X509Certificate)cf.generateCertificate(is));
+    }
+
+    public static void showValidatedChain(Validator v, X509Certificate[] chain,
+            Set<X509Certificate> otherCerts) throws Exception {
+        for (X509Certificate cert : v.validate(chain, otherCerts)) {
+            System.out.println("\tSubj: " + cert.getSubjectX500Principal() +
+                    " Iss: " + cert.getIssuerX500Principal());
+        }
+    }
+
+    public static Set<TrustAnchor> makeTrustAnchorSet(
+            Set<X509Certificate> certSet) throws Exception {
+        Set<TrustAnchor> anchors = new HashSet<>();
+
+        for (Certificate cert : certSet) {
+            anchors.add(new TrustAnchor((X509Certificate)cert, null));
+        }
+
+        return anchors;
+    }
+
+    public static void testCtorByCollection(Set<X509Certificate> certSet)
+            throws Exception {
+        Validator valOK;
+        Validator valNoGood;
+        X509Certificate[] chain = new X509Certificate[1];
+        Set<X509Certificate> intermeds = new HashSet<>();
+
+        // Case 1: Make a PKIXValidator with valid arguments
+        // Expected result: Well-formed PKIXValidator
+        System.out.println("Constructor test 1: Valid inputs");
+        valOK = Validator.getInstance(Validator.TYPE_PKIX,
+                Validator.VAR_GENERIC, certSet);
+
+        // Convert our user cert from PEM format, then do the same for
+        // its intermediate signer and add that as a helper for path building
+        chain[0] = makeCertFromPEM(USER);
+        intermeds.add(makeCertFromPEM(INTERMED));
+        PKIXBuilderParameters pbParams = ((PKIXValidator)valOK).getParameters();
+        pbParams.setDate(new Date(1426399200000L)); // 03-15-2014 6:00:00 GMT
+
+        // See if we can build a trusted path to a root to make sure
+        // everything still works as expected.
+        showValidatedChain(valOK, chain, intermeds);
+
+        // Case 2: Make a PKIXValidator with null anchor list.
+        // Expected result: throw NullPointerException
+        System.out.println("Constructor test 2: null trustedCerts");
+        try {
+            valNoGood = Validator.getInstance(Validator.TYPE_PKIX,
+                    Validator.VAR_GENERIC, (Collection<X509Certificate>)null);
+            // Throw something non Runtime-related to indicate we shouldn't
+            // have succeeded on construction.
+            throw new IOException(
+                    "Constructor did not throw NullPointerException");
+        } catch (NullPointerException npe) {
+            System.out.println("\tCaught Exception (" + npe.toString() +
+                    ") [PASS])");
+        }
+
+        // Case 3: Try putting a null reference into a populated TA List
+        // Expected result: throw NullPointerException
+        System.out.println("Constructor test 3: null in trustedCerts list");
+        try {
+            certSet.add(null);
+            valNoGood = Validator.getInstance(Validator.TYPE_PKIX,
+                    Validator.VAR_GENERIC, certSet);
+            // Throw something non Runtime-related to indicate we shouldn't
+            // have succeeded on construction.
+            throw new IOException("Constructor did not throw RuntimeException");
+        } catch (NullPointerException npe) {
+            System.out.println("\tCaught Exception (" + npe.toString() +
+                    ") [PASS])");
+        } finally {
+            // Return the certSet list to its original state
+            certSet.remove(null);
+        }
+
+        // Case 4: Provide an empty List as the X509Certificate collection
+        // Expected result: throw RuntimeException
+        System.out.println("Constructor test 4: empty trustedCerts list");
+        try {
+            valNoGood = Validator.getInstance(Validator.TYPE_PKIX,
+                    Validator.VAR_GENERIC, new ArrayList<X509Certificate>());
+            // Throw something non Runtime-related to indicate we shouldn't
+            // have succeeded on construction.
+            throw new IOException("Constructor did not throw RuntimeException");
+        } catch (RuntimeException re) {
+            System.out.println("\tCaught RuntimeException (" + re.toString() +
+                    ") [PASS])");
+        }
+
+        // Case 5: Provide an invalid variant
+        // Expected result: successful construction.
+        // Note: subsequent calls to validate may throw CertificateException
+        // if the submitted chain has a length > 1.
+        System.out.println("Constructor test 5: Unsupported variant");
+        valNoGood = Validator.getInstance(Validator.TYPE_PKIX,
+                "BogusVariant", certSet);
+        System.out.println("\tSuccessful construction [PASS]");
+
+        // Case 6: Provide a null variant
+        // Expected result: throw NullPointerException
+        System.out.println("Constructor test 6: null variant");
+        try {
+            valNoGood = Validator.getInstance(Validator.TYPE_PKIX, null,
+                    certSet);
+            // Throw something non Runtime-related to indicate we shouldn't
+            // have succeeded on construction.
+            throw new IOException(
+                    "Constructor did not throw NullPointerException");
+        } catch (NullPointerException npe) {
+            System.out.println("\tCaught RuntimeException (" + npe.toString() +
+                    ") [PASS])");
+        }
+    }
+
+    public static void testCtorByPKIXBuilderParams(Set<X509Certificate> certSet)
+            throws Exception {
+        Set<TrustAnchor> taSet = makeTrustAnchorSet(certSet);
+        Validator valOK;
+        Validator valNoGood;
+        X509Certificate[] chain = new X509Certificate[1];
+        Set<X509Certificate> intermeds = new HashSet<>();
+
+        // Case 7: Make a PKIXValidator with valid arguments
+        // Expected result: Well-formed PKIXValidator object
+        System.out.println("Constructor test 7: Valid inputs");
+
+        // Set up the PKIXBuilderParameters
+        X509CertSelector sel = new X509CertSelector();
+        sel.setSubject("CN=User");
+        PKIXBuilderParameters pbParams = new PKIXBuilderParameters(taSet, sel);
+        pbParams.setRevocationEnabled(false);
+        pbParams.setDate(new Date(1426399200000L)); // 03-15-2014 6:00:00 GMT
+
+        valOK = Validator.getInstance(Validator.TYPE_PKIX,
+                Validator.VAR_GENERIC, pbParams);
+
+        // Convert our user cert from PEM format, then do the same for
+        // its intermediate signer and add that as a helper for path building
+        chain[0] = makeCertFromPEM(USER);
+        intermeds.add(makeCertFromPEM(INTERMED));
+
+        showValidatedChain(valOK, chain, intermeds);
+
+        // Case 8: Make a PKIXValidator but provide a null PKIXBuilderParameters
+        // Expected result: throw NullPointerException
+        System.out.println("Constructor test 8: null params");
+        try {
+            valNoGood = Validator.getInstance(Validator.TYPE_PKIX,
+                    Validator.VAR_GENERIC, (PKIXBuilderParameters)null);
+            // Throw something non Runtime-related to indicate we shouldn't
+            // have succeeded on construction.
+            throw new IOException(
+                    "Constructor did not throw NullPointerException");
+        } catch (NullPointerException npe) {
+            System.out.println("\tCaught RuntimeException (" + npe.toString() +
+                    ") [PASS])");
+        }
+    }
+}
--- a/test/sun/tools/jcmd/TestJcmdDefaults.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/sun/tools/jcmd/TestJcmdDefaults.java	Mon May 12 09:38:27 2014 -0700
@@ -39,6 +39,7 @@
  * @test
  * @bug 7104647
  * @library /lib/testlibrary
+ * @build jdk.testlibrary.*
  * @run main TestJcmdDefaults
  */
 public class TestJcmdDefaults {
--- a/test/sun/tools/jcmd/TestJcmdSanity.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/sun/tools/jcmd/TestJcmdSanity.java	Mon May 12 09:38:27 2014 -0700
@@ -40,6 +40,7 @@
  * @test
  * @bug 7104647 7154822
  * @library /lib/testlibrary
+ * @build jdk.testlibrary.*
  * @run main TestJcmdSanity
  */
 public class TestJcmdSanity {
--- a/test/sun/tools/jmap/BasicJMapTest.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/sun/tools/jmap/BasicJMapTest.java	Mon May 12 09:38:27 2014 -0700
@@ -34,6 +34,7 @@
  * @bug 6321286
  * @summary Unit test for jmap utility
  * @library /lib/testlibrary
+ * @build jdk.testlibrary.*
  * @run main BasicJMapTest
  */
 public class BasicJMapTest {
--- a/test/sun/tools/jstack/BasicJStackTest.java	Mon May 12 09:32:23 2014 -0700
+++ b/test/sun/tools/jstack/BasicJStackTest.java	Mon May 12 09:38:27 2014 -0700
@@ -32,6 +32,7 @@
  * @bug 6260070
  * @summary Unit test for jstack utility
  * @library /lib/testlibrary
+ * @build jdk.testlibrary.*
  * @run main BasicJStackTest
  */
 public class BasicJStackTest {