changeset 11840:3fc03181d7cd

Merge
author hseigel
date Sun, 29 Mar 2015 09:21:15 -0400
parents 483ecfd42109 6ec5c0ceb9de
children ce259f9be831
files make/Makefile test/java/util/Properties/Basic.java
diffstat 84 files changed, 1977 insertions(+), 531 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Mar 25 15:22:45 2015 +0000
+++ b/.hgtags	Sun Mar 29 09:21:15 2015 -0400
@@ -297,3 +297,4 @@
 607ea68032cd4a4cf2c7a7a41fcb39602d6a75e2 jdk9-b52
 6cb5f5c34009630749a40cefe116d143f0b2583e jdk9-b53
 568a62ab7d764d7c74ac1d87387dbe500662b551 jdk9-b54
+d49e247dade61f29f771f09b2105857492241156 jdk9-b55
--- a/make/Makefile	Wed Mar 25 15:22:45 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-#
-# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  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.
-#
-
-# Locate this Makefile
-ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))), )
-  makefile_path := $(CURDIR)/$(lastword $(MAKEFILE_LIST))
-else
-  makefile_path := $(lastword $(MAKEFILE_LIST))
-endif
-repo_dir := $(patsubst %/make/Makefile, %, $(makefile_path))
-
-# What is the name of this subsystem (langtools, corba, etc)?
-subsystem_name := $(notdir $(repo_dir))
-
-# Try to locate top-level makefile
-top_level_makefile := $(repo_dir)/../Makefile
-ifneq ($(wildcard $(top_level_makefile)), )
-  $(info Will run $(subsystem_name) target on top-level Makefile)
-  $(info WARNING: This is a non-recommended way of building!)
-  $(info ===================================================)
-else
-  $(info Cannot locate top-level Makefile. Is this repo not checked out as part of a complete forest?)
-  $(error Build from top-level Makefile instead)
-endif
-
-all:
-	@$(MAKE) -f $(top_level_makefile) $(subsystem_name)
--- a/make/launcher/Launcher-jdk.pack200.gmk	Wed Mar 25 15:22:45 2015 +0000
+++ b/make/launcher/Launcher-jdk.pack200.gmk	Sun Mar 29 09:21:15 2015 -0400
@@ -79,9 +79,6 @@
     CFLAGS_linux := -fPIC, \
     CFLAGS_solaris := -KPIC, \
     CFLAGS_macosx := -fPIC, \
-    DISABLED_WARNINGS_gcc := sign-compare unused-result format-nonliteral \
-        format-security parentheses, \
-    DISABLED_WARNINGS_microsoft := 4267 4018, \
     MAPFILE := $(UNPACK_MAPFILE),\
     LDFLAGS := $(UNPACKEXE_ZIPOBJS) \
         $(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \
--- a/make/lib/Lib-jdk.pack200.gmk	Wed Mar 25 15:22:45 2015 +0000
+++ b/make/lib/Lib-jdk.pack200.gmk	Sun Mar 29 09:21:15 2015 -0400
@@ -40,11 +40,6 @@
         -I$(JDK_TOPDIR)/src/jdk.pack200/share/native/common-unpack \
         $(LIBJAVA_HEADER_FLAGS), \
     CFLAGS_release := -DPRODUCT, \
-    DISABLED_WARNINGS_gcc := conversion-null sign-compare format-security \
-        format-nonliteral parentheses, \
-    DISABLED_WARNINGS_clang := bool-conversion format-security, \
-    DISABLED_WARNINGS_solstudio := truncwarn, \
-    DISABLED_WARNINGS_microsoft := 4267 4018, \
     MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libunpack/mapfile-vers, \
     LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
--- a/src/java.base/share/classes/com/sun/net/ssl/HttpsURLConnection.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/com/sun/net/ssl/HttpsURLConnection.java	Sun Mar 29 09:21:15 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,10 +32,10 @@
 import java.net.URL;
 import java.net.HttpURLConnection;
 import java.io.IOException;
+import java.security.cert.Certificate;
 import javax.net.SocketFactory;
 import javax.net.ssl.SSLSocketFactory;
-
-import javax.security.cert.X509Certificate;
+import javax.net.ssl.SSLPeerUnverifiedException;
 
 /**
  * HTTP URL connection with support for HTTPS-specific features. See
@@ -70,7 +70,8 @@
      * the server did not authenticate.
      * @return the server certificate chain
      */
-    public abstract X509Certificate [] getServerCertificateChain();
+    public abstract Certificate[] getServerCertificates()
+        throws SSLPeerUnverifiedException;
 
     /**
      * HostnameVerifier provides a callback mechanism so that
--- a/src/java.base/share/classes/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnectionOldImpl.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/com/sun/net/ssl/internal/www/protocol/https/HttpsURLConnectionOldImpl.java	Sun Mar 29 09:21:15 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -187,25 +187,6 @@
         return delegate.getServerCertificates();
     }
 
-    /**
-     * Returns the server's X.509 certificate chain, or null if
-     * the server did not authenticate.
-     *
-     * NOTE: This method is not necessary for the version of this class
-     * implementing javax.net.ssl.HttpsURLConnection, but provided for
-     * compatibility with the com.sun.net.ssl.HttpsURLConnection version.
-     */
-    public javax.security.cert.X509Certificate[] getServerCertificateChain() {
-        try {
-            return delegate.getServerCertificateChain();
-        } catch (SSLPeerUnverifiedException e) {
-            // this method does not throw an exception as declared in
-            // com.sun.net.ssl.HttpsURLConnection.
-            // Return null for compatibility.
-            return null;
-        }
-    }
-
     /*
      * Allowable input/output sequences:
      * [interpreted as POST/PUT]
--- a/src/java.base/share/classes/java/io/ObjectStreamException.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/java/io/ObjectStreamException.java	Sun Mar 29 09:21:15 2015 -0400
@@ -38,10 +38,10 @@
     /**
      * Create an ObjectStreamException with the specified argument.
      *
-     * @param classname the detailed message for the exception
+     * @param message the detailed message for the exception
      */
-    protected ObjectStreamException(String classname) {
-        super(classname);
+    protected ObjectStreamException(String message) {
+        super(message);
     }
 
     /**
--- a/src/java.base/share/classes/java/lang/ProcessBuilder.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/java/lang/ProcessBuilder.java	Sun Mar 29 09:21:15 2015 -0400
@@ -82,7 +82,7 @@
  * <li><a name="redirect-output">a destination for <i>standard output</i>
  * and <i>standard error</i></a>.  By default, the subprocess writes standard
  * output and standard error to pipes.  Java code can access these pipes
- * via the input streams returned by {@link Process#getInputStream()} and
+ * via the input streams returned by {@link Process#getOutputStream()} and
  * {@link Process#getErrorStream()}.  However, standard output and
  * standard error may be redirected to other destinations using
  * {@link #redirectOutput(Redirect) redirectOutput} and
@@ -988,14 +988,14 @@
      *         <li>the standard input to the subprocess was
      *         {@linkplain #redirectInput redirected from a file}
      *         and the security manager's
-     *         {@link SecurityManager#checkRead checkRead} method
+     *         {@link SecurityManager#checkRead(String) checkRead} method
      *         denies read access to the file, or
      *
      *         <li>the standard output or standard error of the
      *         subprocess was
      *         {@linkplain #redirectOutput redirected to a file}
      *         and the security manager's
-     *         {@link SecurityManager#checkWrite checkWrite} method
+     *         {@link SecurityManager#checkWrite(String) checkWrite} method
      *         denies write access to the file
      *
      *         </ul>
--- a/src/java.base/share/classes/java/net/ProtocolException.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/java/net/ProtocolException.java	Sun Mar 29 09:21:15 2015 -0400
@@ -42,10 +42,10 @@
      * Constructs a new {@code ProtocolException} with the
      * specified detail message.
      *
-     * @param   host   the detail message.
+     * @param   message   the detail message.
      */
-    public ProtocolException(String host) {
-        super(host);
+    public ProtocolException(String message) {
+        super(message);
     }
 
     /**
--- a/src/java.base/share/classes/java/net/UnknownHostException.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/java/net/UnknownHostException.java	Sun Mar 29 09:21:15 2015 -0400
@@ -41,10 +41,10 @@
      * Constructs a new {@code UnknownHostException} with the
      * specified detail message.
      *
-     * @param   host   the detail message.
+     * @param   message   the detail message.
      */
-    public UnknownHostException(String host) {
-        super(host);
+    public UnknownHostException(String message) {
+        super(message);
     }
 
     /**
--- a/src/java.base/share/classes/java/util/Date.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/java/util/Date.java	Sun Mar 29 09:21:15 2015 -0400
@@ -1317,6 +1317,7 @@
     private void writeObject(ObjectOutputStream s)
          throws IOException
     {
+        s.defaultWriteObject();
         s.writeLong(getTimeImpl());
     }
 
@@ -1326,6 +1327,7 @@
     private void readObject(ObjectInputStream s)
          throws IOException, ClassNotFoundException
     {
+        s.defaultReadObject();
         fastTime = s.readLong();
     }
 
--- a/src/java.base/share/classes/java/util/Optional.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/java/util/Optional.java	Sun Mar 29 09:21:15 2015 -0400
@@ -346,7 +346,7 @@
      * </ul>
      *
      * @param obj an object to be tested for equality
-     * @return {code true} if the other object is "equal to" this object
+     * @return {@code true} if the other object is "equal to" this object
      * otherwise {@code false}
      */
     @Override
--- a/src/java.base/share/classes/java/util/OptionalDouble.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/java/util/OptionalDouble.java	Sun Mar 29 09:21:15 2015 -0400
@@ -244,7 +244,7 @@
      * </ul>
      *
      * @param obj an object to be tested for equality
-     * @return {code true} if the other object is "equal to" this object
+     * @return {@code true} if the other object is "equal to" this object
      * otherwise {@code false}
      */
     @Override
--- a/src/java.base/share/classes/java/util/OptionalInt.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/java/util/OptionalInt.java	Sun Mar 29 09:21:15 2015 -0400
@@ -244,7 +244,7 @@
      * </ul>
      *
      * @param obj an object to be tested for equality
-     * @return {code true} if the other object is "equal to" this object
+     * @return {@code true} if the other object is "equal to" this object
      * otherwise {@code false}
      */
     @Override
--- a/src/java.base/share/classes/java/util/OptionalLong.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/java/util/OptionalLong.java	Sun Mar 29 09:21:15 2015 -0400
@@ -244,7 +244,7 @@
      * </ul>
      *
      * @param obj an object to be tested for equality
-     * @return {code true} if the other object is "equal to" this object
+     * @return {@code true} if the other object is "equal to" this object
      * otherwise {@code false}
      */
     @Override
--- a/src/java.base/share/classes/java/util/Properties.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/java/util/Properties.java	Sun Mar 29 09:21:15 2015 -0400
@@ -309,7 +309,7 @@
      *          input stream.
      * @throws  IllegalArgumentException if a malformed Unicode escape
      *          appears in the input.
-     * @throws NullPointerException if {@code reader} is null.
+     * @throws  NullPointerException if {@code reader} is null.
      * @since   1.6
      */
     public synchronized void load(Reader reader) throws IOException {
@@ -335,7 +335,7 @@
      *             input stream.
      * @throws     IllegalArgumentException if the input stream contains a
      *             malformed Unicode escape sequence.
-     * @throws NullPointerException if {@code inStream} is null.
+     * @throws     NullPointerException if {@code inStream} is null.
      * @since 1.2
      */
     public synchronized void load(InputStream inStream) throws IOException {
--- a/src/java.base/share/classes/java/util/stream/AbstractPipeline.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/java/util/stream/AbstractPipeline.java	Sun Mar 29 09:21:15 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -380,60 +380,6 @@
     }
 
     /**
-     * Prepare the pipeline for a parallel execution.  As the pipeline is built,
-     * the flags and depth indicators are set up for a sequential execution.
-     * If the execution is parallel, and there are any stateful operations, then
-     * some of these need to be adjusted, as well as adjusting for flags from
-     * the terminal operation (such as back-propagating UNORDERED).
-     * Need not be called for a sequential execution.
-     *
-     * @param terminalFlags Operation flags for the terminal operation
-     */
-    private void parallelPrepare(int terminalFlags) {
-        @SuppressWarnings("rawtypes")
-        AbstractPipeline backPropagationHead = sourceStage;
-        if (sourceStage.sourceAnyStateful) {
-            int depth = 1;
-            for (  @SuppressWarnings("rawtypes") AbstractPipeline u = sourceStage, p = sourceStage.nextStage;
-                 p != null;
-                 u = p, p = p.nextStage) {
-                int thisOpFlags = p.sourceOrOpFlags;
-                if (p.opIsStateful()) {
-                    // If the stateful operation is a short-circuit operation
-                    // then move the back propagation head forwards
-                    // NOTE: there are no size-injecting ops
-                    if (StreamOpFlag.SHORT_CIRCUIT.isKnown(thisOpFlags)) {
-                        backPropagationHead = p;
-                        // Clear the short circuit flag for next pipeline stage
-                        // This stage encapsulates short-circuiting, the next
-                        // stage may not have any short-circuit operations, and
-                        // if so spliterator.forEachRemaining should be used
-                        // for traversal
-                        thisOpFlags = thisOpFlags & ~StreamOpFlag.IS_SHORT_CIRCUIT;
-                    }
-
-                    depth = 0;
-                    // The following injects size, it is equivalent to:
-                    // StreamOpFlag.combineOpFlags(StreamOpFlag.IS_SIZED, p.combinedFlags);
-                    thisOpFlags = (thisOpFlags & ~StreamOpFlag.NOT_SIZED) | StreamOpFlag.IS_SIZED;
-                }
-                p.depth = depth++;
-                p.combinedFlags = StreamOpFlag.combineOpFlags(thisOpFlags, u.combinedFlags);
-            }
-        }
-
-        // Apply the upstream terminal flags
-        if (terminalFlags != 0) {
-            int upstreamTerminalFlags = terminalFlags & StreamOpFlag.UPSTREAM_TERMINAL_OP_MASK;
-            for ( @SuppressWarnings("rawtypes") AbstractPipeline p = backPropagationHead; p.nextStage != null; p = p.nextStage) {
-                p.combinedFlags = StreamOpFlag.combineOpFlags(upstreamTerminalFlags, p.combinedFlags);
-            }
-
-            combinedFlags = StreamOpFlag.combineOpFlags(terminalFlags, combinedFlags);
-        }
-    }
-
-    /**
      * Get the source spliterator for this pipeline stage.  For a sequential or
      * stateless parallel pipeline, this is the source spliterator.  For a
      * stateful parallel pipeline, this is a spliterator describing the results
@@ -456,24 +402,70 @@
             throw new IllegalStateException(MSG_CONSUMED);
         }
 
-        if (isParallel()) {
-            // @@@ Merge parallelPrepare with the loop below and use the
-            //     spliterator characteristics to determine if SIZED
-            //     should be injected
-            parallelPrepare(terminalFlags);
+        boolean hasTerminalFlags = terminalFlags != 0;
+        if (isParallel() && sourceStage.sourceAnyStateful) {
+            // Adjust pipeline stages if there are stateful ops,
+            // and find the last short circuiting op, if any, that
+            // defines the head stage for back-propagation of terminal flags
+            @SuppressWarnings("rawtypes")
+            AbstractPipeline backPropagationHead = sourceStage;
+            int depth = 1;
+            for (@SuppressWarnings("rawtypes") AbstractPipeline p = sourceStage.nextStage;
+                 p != null;
+                 p = p.nextStage) {
+                if (p.opIsStateful()) {
+                    if (StreamOpFlag.SHORT_CIRCUIT.isKnown(p.sourceOrOpFlags)) {
+                        // If the stateful operation is a short-circuit operation
+                        // then move the back propagation head forwards
+                        // NOTE: there are no size-injecting ops
+                        backPropagationHead = p;
+                    }
+
+                    depth = 0;
+                }
+                p.depth = depth++;
+            }
 
             // Adapt the source spliterator, evaluating each stateful op
             // in the pipeline up to and including this pipeline stage
-            for ( @SuppressWarnings("rawtypes") AbstractPipeline u = sourceStage, p = sourceStage.nextStage, e = this;
+            // Flags for each pipeline stage are adjusted accordingly
+            boolean backPropagate = false;
+            int upstreamTerminalFlags = terminalFlags & StreamOpFlag.UPSTREAM_TERMINAL_OP_MASK;
+            for (@SuppressWarnings("rawtypes") AbstractPipeline u = sourceStage, p = sourceStage.nextStage, e = this;
                  u != e;
                  u = p, p = p.nextStage) {
 
+                if (hasTerminalFlags &&
+                    (backPropagate || (backPropagate = (u == backPropagationHead)))) {
+                    // Back-propagate flags from the terminal operation
+                    u.combinedFlags = StreamOpFlag.combineOpFlags(upstreamTerminalFlags, u.combinedFlags);
+                }
+
+                int thisOpFlags = p.sourceOrOpFlags;
                 if (p.opIsStateful()) {
+                    if (StreamOpFlag.SHORT_CIRCUIT.isKnown(thisOpFlags)) {
+                        // Clear the short circuit flag for next pipeline stage
+                        // This stage encapsulates short-circuiting, the next
+                        // stage may not have any short-circuit operations, and
+                        // if so spliterator.forEachRemaining should be used
+                        // for traversal
+                        thisOpFlags = thisOpFlags & ~StreamOpFlag.IS_SHORT_CIRCUIT;
+                    }
+
                     spliterator = p.opEvaluateParallelLazy(u, spliterator);
+
+                    // Inject or clear SIZED on the source pipeline stage
+                    // based on the stage's spliterator
+                    thisOpFlags = spliterator.hasCharacteristics(Spliterator.SIZED)
+                            ? (thisOpFlags & ~StreamOpFlag.NOT_SIZED) | StreamOpFlag.IS_SIZED
+                            : (thisOpFlags & ~StreamOpFlag.IS_SIZED) | StreamOpFlag.NOT_SIZED;
                 }
+                p.combinedFlags = StreamOpFlag.combineOpFlags(thisOpFlags, u.combinedFlags);
             }
         }
-        else if (terminalFlags != 0)  {
+
+        if (hasTerminalFlags)  {
+            // Apply flags from the terminal operation to last pipeline stage
             combinedFlags = StreamOpFlag.combineOpFlags(terminalFlags, combinedFlags);
         }
 
--- a/src/java.base/share/classes/java/util/stream/ReduceOps.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/java/util/stream/ReduceOps.java	Sun Mar 29 09:21:15 2015 -0400
@@ -264,6 +264,11 @@
                     return spliterator.getExactSizeIfKnown();
                 return super.evaluateParallel(helper, spliterator);
             }
+
+            @Override
+            public int getOpFlags() {
+                return StreamOpFlag.NOT_ORDERED;
+            }
         };
     }
 
@@ -433,6 +438,11 @@
                     return spliterator.getExactSizeIfKnown();
                 return super.evaluateParallel(helper, spliterator);
             }
+
+            @Override
+            public int getOpFlags() {
+                return StreamOpFlag.NOT_ORDERED;
+            }
         };
     }
 
@@ -602,6 +612,11 @@
                     return spliterator.getExactSizeIfKnown();
                 return super.evaluateParallel(helper, spliterator);
             }
+
+            @Override
+            public int getOpFlags() {
+                return StreamOpFlag.NOT_ORDERED;
+            }
         };
     }
 
@@ -771,6 +786,11 @@
                     return spliterator.getExactSizeIfKnown();
                 return super.evaluateParallel(helper, spliterator);
             }
+
+            @Override
+            public int getOpFlags() {
+                return StreamOpFlag.NOT_ORDERED;
+            }
         };
     }
 
--- a/src/java.base/share/classes/sun/misc/Unsafe.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/sun/misc/Unsafe.java	Sun Mar 29 09:21:15 2015 -0400
@@ -631,6 +631,10 @@
     /**
      * Atomically updates Java variable to {@code x} if it is currently
      * holding {@code expected}.
+     *
+     * <p>This operation has memory semantics of a {@code volatile} read
+     * and write.  Corresponds to C11 atomic_compare_exchange_strong.
+     *
      * @return {@code true} if successful
      */
     public final native boolean compareAndSwapObject(Object o, long offset,
@@ -640,6 +644,10 @@
     /**
      * Atomically updates Java variable to {@code x} if it is currently
      * holding {@code expected}.
+     *
+     * <p>This operation has memory semantics of a {@code volatile} read
+     * and write.  Corresponds to C11 atomic_compare_exchange_strong.
+     *
      * @return {@code true} if successful
      */
     public final native boolean compareAndSwapInt(Object o, long offset,
@@ -649,6 +657,10 @@
     /**
      * Atomically updates Java variable to {@code x} if it is currently
      * holding {@code expected}.
+     *
+     * <p>This operation has memory semantics of a {@code volatile} read
+     * and write.  Corresponds to C11 atomic_compare_exchange_strong.
+     *
      * @return {@code true} if successful
      */
     public final native boolean compareAndSwapLong(Object o, long offset,
--- a/src/java.base/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java	Sun Mar 29 09:21:15 2015 -0400
@@ -262,27 +262,6 @@
     }
 
     /**
-     * Returns the server's X.509 certificate chain, or null if
-     * the server did not authenticate.
-     *
-     * @deprecated This method returns the deprecated
-     *  {@code javax.security.cert.X509Certificate} type.
-     *  Use {@code getServerCertificates()} instead.
-     */
-    @Deprecated
-    public javax.security.cert.X509Certificate[] getServerCertificateChain()
-            throws SSLPeerUnverifiedException {
-        if (cachedResponse != null) {
-            throw new UnsupportedOperationException("this method is not supported when using cache");
-        }
-        if (http == null) {
-            throw new IllegalStateException("connection not yet open");
-        } else {
-            return ((HttpsClient)http).getServerCertificateChain();
-        }
-    }
-
-    /**
      * Returns the server's principal, or throws SSLPeerUnverifiedException
      * if the server did not authenticate.
      */
--- a/src/java.base/share/classes/sun/net/www/protocol/https/HttpsClient.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/sun/net/www/protocol/https/HttpsClient.java	Sun Mar 29 09:21:15 2015 -0400
@@ -697,21 +697,6 @@
     }
 
     /**
-     * Returns the X.509 certificate chain with which the server
-     * authenticated itself, or null if the server did not authenticate.
-     *
-     * @deprecated This method returns the deprecated
-     *  {@code javax.security.cert.X509Certificate} type.
-     *  Use {@code getServerCertificates()} instead.
-     */
-    @Deprecated
-    javax.security.cert.X509Certificate [] getServerCertificateChain()
-            throws SSLPeerUnverifiedException
-    {
-        return session.getPeerCertificateChain();
-    }
-
-    /**
      * Returns the principal with which the server authenticated
      * itself, or throw a SSLPeerUnverifiedException if the
      * server did not authenticate.
--- a/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java	Sun Mar 29 09:21:15 2015 -0400
@@ -198,30 +198,6 @@
     }
 
     /**
-     * Returns the server's X.509 certificate chain, or null if
-     * the server did not authenticate.
-     *
-     * NOTE: This method is not necessary for the version of this class
-     * implementing javax.net.ssl.HttpsURLConnection, but provided for
-     * compatibility with the com.sun.net.ssl.HttpsURLConnection version.
-     *
-     * @deprecated This method returns the deprecated
-     *  {@code javax.security.cert.X509Certificate} type.
-     *  Use {@code getServerCertificates()} instead.
-     */
-    @Deprecated
-    public javax.security.cert.X509Certificate[] getServerCertificateChain() {
-        try {
-            return delegate.getServerCertificateChain();
-        } catch (SSLPeerUnverifiedException e) {
-            // this method does not throw an exception as declared in
-            // com.sun.net.ssl.HttpsURLConnection.
-            // Return null for compatibility.
-            return null;
-        }
-    }
-
-    /**
      * Returns the principal with which the server authenticated itself,
      * or throw a SSLPeerUnverifiedException if the server did not authenticate.
      */
--- a/src/java.base/share/classes/sun/security/pkcs10/PKCS10.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/sun/security/pkcs10/PKCS10.java	Sun Mar 29 09:21:15 2015 -0400
@@ -290,8 +290,9 @@
             throw new SignatureException("Cert request was not signed");
 
 
+        byte[] CRLF = new byte[] {'\r', '\n'};
         out.println("-----BEGIN NEW CERTIFICATE REQUEST-----");
-        out.println(Base64.getMimeEncoder().encodeToString(encoded));
+        out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(encoded));
         out.println("-----END NEW CERTIFICATE REQUEST-----");
     }
 
--- a/src/java.base/share/classes/sun/security/provider/X509Factory.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/sun/security/provider/X509Factory.java	Sun Mar 29 09:21:15 2015 -0400
@@ -28,6 +28,8 @@
 import java.io.*;
 import java.util.*;
 import java.security.cert.*;
+
+import sun.security.util.Pem;
 import sun.security.x509.X509CertImpl;
 import sun.security.x509.X509CRLImpl;
 import sun.security.pkcs.PKCS7;
@@ -633,7 +635,7 @@
 
             checkHeaderFooter(header.toString(), footer.toString());
 
-            return Base64.getMimeDecoder().decode(new String(data, 0, pos));
+            return Pem.decode(new String(data, 0, pos));
         }
     }
 
--- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Sun Mar 29 09:21:15 2015 -0400
@@ -80,6 +80,7 @@
 import sun.security.tools.KeyStoreUtil;
 import sun.security.tools.PathList;
 import sun.security.util.DerValue;
+import sun.security.util.Pem;
 import sun.security.x509.*;
 
 import static java.security.KeyStore.*;
@@ -100,6 +101,8 @@
  */
 public final class Main {
 
+    private static final byte[] CRLF = new byte[] {'\r', '\n'};
+
     private boolean debug = false;
     private Command command = null;
     private String sigAlgName = null;
@@ -1266,7 +1269,7 @@
                 sb.append(s);
             }
         }
-        byte[] rawReq = Base64.getMimeDecoder().decode(new String(sb));
+        byte[] rawReq = Pem.decode(new String(sb));
         PKCS10 req = new PKCS10(rawReq);
 
         info.set(X509CertInfo.KEY, new CertificateX509Key(req.getSubjectPublicKeyInfo()));
@@ -1343,7 +1346,7 @@
         crl.sign(privateKey, sigAlgName);
         if (rfc) {
             out.println("-----BEGIN X509 CRL-----");
-            out.println(Base64.getMimeEncoder().encodeToString(crl.getEncodedInternal()));
+            out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(crl.getEncodedInternal()));
             out.println("-----END X509 CRL-----");
         } else {
             out.write(crl.getEncodedInternal());
@@ -2304,7 +2307,7 @@
         if (rfc) {
             X509CRL xcrl = (X509CRL)crl;
             out.println("-----BEGIN X509 CRL-----");
-            out.println(Base64.getMimeEncoder().encodeToString(xcrl.getEncoded()));
+            out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(xcrl.getEncoded()));
             out.println("-----END X509 CRL-----");
         } else {
             out.println(crl.toString());
@@ -2331,7 +2334,7 @@
                 sb.append(s);
             }
         }
-        PKCS10 req = new PKCS10(Base64.getMimeDecoder().decode(new String(sb)));
+        PKCS10 req = new PKCS10(Pem.decode(new String(sb)));
 
         PublicKey pkey = req.getSubjectPublicKeyInfo();
         out.printf(rb.getString("PKCS.10.Certificate.Request.Version.1.0.Subject.s.Public.Key.s.format.s.key."),
@@ -3115,7 +3118,7 @@
     {
         if (rfc) {
             out.println(X509Factory.BEGIN_CERT);
-            out.println(Base64.getMimeEncoder().encodeToString(cert.getEncoded()));
+            out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(cert.getEncoded()));
             out.println(X509Factory.END_CERT);
         } else {
             out.write(cert.getEncoded()); // binary
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/sun/security/util/Pem.java	Sun Mar 29 09:21:15 2015 -0400
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.util;
+
+import java.io.IOException;
+import java.util.Base64;
+
+/**
+ * The Length interface defines the length of an object
+ */
+public class Pem {
+
+    /**
+     * Decodes a PEM-encoded block.
+     *
+     * @param input the input string, according to RFC 1421, can only contain
+     *              characters in the base-64 alphabet and whitespaces.
+     * @return the decoded bytes
+     * @throws java.io.IOException if input is invalid
+     */
+    public static byte[] decode(String input) throws IOException {
+        byte[] src = input.replaceAll("\\s+", "").getBytes();
+        try {
+            return Base64.getDecoder().decode(src);
+        } catch (IllegalArgumentException e) {
+            throw new IOException(e);
+        }
+    }
+}
--- a/src/java.base/share/classes/sun/security/x509/X509CertImpl.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/classes/sun/security/x509/X509CertImpl.java	Sun Mar 29 09:21:15 2015 -0400
@@ -271,7 +271,7 @@
                         der = new DerValue(decstream.toByteArray());
                         break;
                     } else {
-                        decstream.write(Base64.getMimeDecoder().decode(line));
+                        decstream.write(Pem.decode(line));
                     }
                 }
             } catch (IOException ioe2) {
--- a/src/java.base/share/native/libjli/manifest_info.h	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/native/libjli/manifest_info.h	Sun Mar 29 09:21:15 2015 -0400
@@ -109,6 +109,8 @@
 /*
  * Macros for getting end of central directory header (END) fields
  */
+#define ENDNMD(b) SH(b, 4)          /* number of this disk */
+#define ENDDSK(b) SH(b, 6)          /* disk number of start */
 #define ENDSUB(b) SH(b, 8)          /* number of entries on this disk */
 #define ENDTOT(b) SH(b, 10)         /* total number of entries */
 #define ENDSIZ(b) LG(b, 12)         /* central directory size */
--- a/src/java.base/share/native/libjli/parse_manifest.c	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/share/native/libjli/parse_manifest.c	Sun Mar 29 09:21:15 2015 -0400
@@ -111,52 +111,127 @@
     return (NULL);
 }
 
-static jboolean zip64_present = JNI_FALSE;
+/*
+ * Implementation notes:
+ *
+ * This is a zip format reader for seekable files, that tolerates
+ * leading and trailing garbage, and tolerates having had internal
+ * offsets adjusted for leading garbage (as with Info-Zip's zip -A).
+ *
+ * We find the end header by scanning backwards from the end of the
+ * file for the end signature.  This may fail in the presence of
+ * trailing garbage or a ZIP file comment that contains binary data.
+ * Similarly, the ZIP64 end header may need to be located by scanning
+ * backwards from the end header.  It may be misidentified, but this
+ * is very unlikely to happen in practice without adversarial input.
+ *
+ * The zip file format is documented at:
+ * https://www.pkware.com/documents/casestudies/APPNOTE.TXT
+ *
+ * TODO: more informative error messages
+ */
+
+/** Reads count bytes from fd at position pos into given buffer. */
+static jboolean
+readAt(int fd, jlong pos, size_t count, void *buf) {
+    return (pos >= 0
+            && JLI_Lseek(fd, pos, SEEK_SET) == pos
+            && read(fd, buf, count) == (jlong) count);
+}
+
 
 /*
- * Checks to see if we have ZIP64 archive, and save
- * the check for later use
+ * Tells whether given header values (obtained from either ZIP64 or
+ * non-ZIP64 header) appear to be correct, by checking the first LOC
+ * and CEN headers.
  */
-static int
-haveZIP64(Byte *p) {
-    jlong cenlen, cenoff, centot;
-    cenlen = ENDSIZ(p);
-    cenoff = ENDOFF(p);
-    centot = ENDTOT(p);
-    zip64_present = (cenlen == ZIP64_MAGICVAL ||
-                     cenoff == ZIP64_MAGICVAL ||
-                     centot == ZIP64_MAGICCOUNT);
-    return zip64_present;
-}
-
-static jlong
-find_end64(int fd, Byte *ep, jlong pos)
-{
-    jlong end64pos;
-    jlong bytes;
-    if ((end64pos = JLI_Lseek(fd, pos - ZIP64_LOCHDR, SEEK_SET)) < (jlong)0)
-        return -1;
-    if ((bytes = read(fd, ep, ZIP64_LOCHDR)) < 0)
-        return -1;
-    if (ZIP64_LOCSIG_AT(ep))
-       return end64pos;
-    return -1;
+static jboolean
+is_valid_end_header(int fd, jlong endpos,
+                    jlong censiz, jlong cenoff, jlong entries) {
+    Byte cenhdr[CENHDR];
+    Byte lochdr[LOCHDR];
+    // Expected offset of the first central directory header
+    jlong censtart = endpos - censiz;
+    // Expected position within the file that offsets are relative to
+    jlong base_offset = endpos - (censiz + cenoff);
+    return censtart >= 0 && cenoff >= 0 &&
+        (censiz == 0 ||
+         // Validate first CEN and LOC header signatures.
+         // Central directory must come directly before the end header.
+         (readAt(fd, censtart, CENHDR, cenhdr)
+          && CENSIG_AT(cenhdr)
+          && readAt(fd, base_offset + CENOFF(cenhdr), LOCHDR, lochdr)
+          && LOCSIG_AT(lochdr)
+          && CENNAM(cenhdr) == LOCNAM(lochdr)));
 }
 
 /*
- * A very little used routine to handle the case that zip file has
- * a comment at the end. Believe it or not, the only way to find the
- * END record is to walk backwards, byte by bloody byte looking for
- * the END record signature.
+ * Tells whether p appears to be pointing at a valid ZIP64 end header.
+ * Values censiz, cenoff, and entries are the corresponding values
+ * from the non-ZIP64 end header.  We perform extra checks to avoid
+ * misidentifying data from the last entry as a ZIP64 end header.
+ */
+static jboolean
+is_zip64_endhdr(int fd, const Byte *p, jlong end64pos,
+                jlong censiz, jlong cenoff, jlong entries) {
+    if (ZIP64_ENDSIG_AT(p)) {
+        jlong censiz64 = ZIP64_ENDSIZ(p);
+        jlong cenoff64 = ZIP64_ENDOFF(p);
+        jlong entries64 = ZIP64_ENDTOT(p);
+        return (censiz64 == censiz || censiz == ZIP64_MAGICVAL)
+            && (cenoff64 == cenoff || cenoff == ZIP64_MAGICVAL)
+            && (entries64 == entries || entries == ZIP64_MAGICCOUNT)
+            && is_valid_end_header(fd, end64pos, censiz64, cenoff64, entries64);
+    }
+    return JNI_FALSE;
+}
+
+/*
+ * Given a non-ZIP64 end header located at endhdr and endpos, look for
+ * an adjacent ZIP64 end header, finding the base offset and censtart
+ * from the ZIP64 header if available, else from the non-ZIP64 header.
+ * @return 0 if successful, -1 in case of failure
+ */
+static int
+find_positions64(int fd, const Byte * const endhdr, const jlong endpos,
+                 jlong* base_offset, jlong* censtart)
+{
+    jlong censiz = ENDSIZ(endhdr);
+    jlong cenoff = ENDOFF(endhdr);
+    jlong entries = ENDTOT(endhdr);
+    jlong end64pos;
+    Byte buf[ZIP64_ENDHDR + ZIP64_LOCHDR];
+    if (censiz + cenoff != endpos
+        && (end64pos = endpos - sizeof(buf)) >= (jlong)0
+        && readAt(fd, end64pos, sizeof(buf), buf)
+        && ZIP64_LOCSIG_AT(buf + ZIP64_ENDHDR)
+        && (jlong) ZIP64_LOCDSK(buf + ZIP64_ENDHDR) == ENDDSK(endhdr)
+        && (is_zip64_endhdr(fd, buf, end64pos, censiz, cenoff, entries)
+            || // A variable sized "zip64 extensible data sector" ?
+            ((end64pos = ZIP64_LOCOFF(buf + ZIP64_ENDHDR)) >= (jlong)0
+             && readAt(fd, end64pos, ZIP64_ENDHDR, buf)
+             && is_zip64_endhdr(fd, buf, end64pos, censiz, cenoff, entries)))
+        ) {
+        *censtart = end64pos - ZIP64_ENDSIZ(buf);
+        *base_offset = *censtart - ZIP64_ENDOFF(buf);
+    } else {
+        if (!is_valid_end_header(fd, endpos, censiz, cenoff, entries))
+            return -1;
+        *censtart = endpos - censiz;
+        *base_offset = *censtart - cenoff;
+    }
+    return 0;
+}
+
+/*
+ * Finds the base offset and censtart of the zip file.
  *
- *      fd:     File descriptor of the jar file.
- *      eb:     Pointer to a buffer to receive a copy of the END header.
- *
- * Returns the offset of the END record in the file on success,
- * -1 on failure.
+ * @param fd file descriptor of the jar file
+ * @param eb scratch buffer
+ * @return 0 if successful, -1 in case of failure
  */
-static jlong
-find_end(int fd, Byte *eb)
+static int
+find_positions(int fd, Byte *eb, jlong* base_offset, jlong* censtart)
 {
     jlong   len;
     jlong   pos;
@@ -177,7 +252,7 @@
     if ((bytes = read(fd, eb, ENDHDR)) < 0)
         return (-1);
     if (ENDSIG_AT(eb)) {
-        return haveZIP64(eb) ? find_end64(fd, eb, pos) : pos;
+        return find_positions64(fd, eb, pos, base_offset, censtart);
     }
 
     /*
@@ -208,7 +283,7 @@
             (void) memcpy(eb, cp, ENDHDR);
             free(buffer);
             pos = flen - (endpos - cp);
-            return haveZIP64(eb) ? find_end64(fd, eb, pos) : pos;
+            return find_positions64(fd, eb, pos, base_offset, censtart);
         }
     free(buffer);
     return (-1);
@@ -218,82 +293,6 @@
 #define MINREAD 1024
 
 /*
- * Computes and positions at the start of the CEN header, ie. the central
- * directory, this will also return the offset if there is a zip file comment
- * at the end of the archive, for most cases this would be 0.
- */
-static jlong
-compute_cen(int fd, Byte *bp)
-{
-    int bytes;
-    Byte *p;
-    jlong base_offset;
-    jlong offset;
-    char buffer[MINREAD];
-    p = (Byte*) buffer;
-    /*
-     * Read the END Header, which is the starting point for ZIP files.
-     * (Clearly designed to make writing a zip file easier than reading
-     * one. Now isn't that precious...)
-     */
-    if ((base_offset = find_end(fd, bp)) == -1) {
-        return (-1);
-    }
-    p = bp;
-    /*
-     * There is a historical, but undocumented, ability to allow for
-     * additional "stuff" to be prepended to the zip/jar file. It seems
-     * that this has been used to prepend an actual java launcher
-     * executable to the jar on Windows.  Although this is just another
-     * form of statically linking a small piece of the JVM to the
-     * application, we choose to continue to support it.  Note that no
-     * guarantees have been made (or should be made) to the customer that
-     * this will continue to work.
-     *
-     * Therefore, calculate the base offset of the zip file (within the
-     * expanded file) by assuming that the central directory is followed
-     * immediately by the end record.
-     */
-    if (zip64_present) {
-        if ((offset = ZIP64_LOCOFF(p)) < (jlong)0) {
-            return -1;
-        }
-        if (JLI_Lseek(fd, offset, SEEK_SET) < (jlong) 0) {
-            return (-1);
-        }
-        if ((bytes = read(fd, buffer, MINREAD)) < 0) {
-            return (-1);
-        }
-        if (!ZIP64_ENDSIG_AT(buffer)) {
-            return -1;
-        }
-        if ((offset = ZIP64_ENDOFF(buffer)) < (jlong)0) {
-            return -1;
-        }
-        if (JLI_Lseek(fd, offset, SEEK_SET) < (jlong)0) {
-            return (-1);
-        }
-        p = (Byte*) buffer;
-        base_offset = base_offset - ZIP64_ENDSIZ(p) - ZIP64_ENDOFF(p) - ZIP64_ENDHDR;
-    } else {
-        base_offset = base_offset - ENDSIZ(p) - ENDOFF(p);
-        /*
-         * The END Header indicates the start of the Central Directory
-         * Headers. Remember that the desired Central Directory Header (CEN)
-         * will almost always be the second one and the first one is a small
-         * directory entry ("META-INF/"). Keep the code optimized for
-         * that case.
-         *
-         * Seek to the beginning of the Central Directory.
-         */
-        if (JLI_Lseek(fd, base_offset + ENDOFF(p), SEEK_SET) < (jlong) 0) {
-            return (-1);
-        }
-    }
-    return base_offset;
-}
-
-/*
  * Locate the manifest file with the zip/jar file.
  *
  *      fd:     File descriptor of the jar file.
@@ -327,7 +326,23 @@
     int     res;
     int     entry_size;
     int     read_size;
+
+    /*
+     * The (imaginary) position within the file relative to which
+     * offsets within the zip file refer.  This is usually the
+     * location of the first local header (the start of the zip data)
+     * (which in turn is usually 0), but if the zip file has content
+     * prepended, then it will be either 0 or the length of the
+     * prepended content, depending on whether or not internal offsets
+     * have been adjusted (via e.g. zip -A).  May be negative if
+     * content is prepended, zip -A is run, then the prefix is
+     * detached!
+     */
     jlong   base_offset;
+
+    /** The position within the file of the start of the central directory. */
+    jlong   censtart;
+
     Byte    *p;
     Byte    *bp;
     Byte    *buffer;
@@ -338,9 +353,11 @@
     }
 
     bp = buffer;
-    base_offset = compute_cen(fd, bp);
-    if (base_offset == -1) {
-        free(buffer);
+
+    if (find_positions(fd, bp, &base_offset, &censtart) == -1) {
+        return -1;
+    }
+    if (JLI_Lseek(fd, censtart, SEEK_SET) < (jlong) 0) {
         return -1;
     }
 
--- a/src/java.base/unix/classes/java/lang/ProcessImpl.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/unix/classes/java/lang/ProcessImpl.java	Sun Mar 29 09:21:15 2015 -0400
@@ -496,12 +496,11 @@
     public synchronized boolean waitFor(long timeout, TimeUnit unit)
             throws InterruptedException
     {
+        long remainingNanos = unit.toNanos(timeout);    // throw NPE before other conditions
         if (hasExited) return true;
         if (timeout <= 0) return false;
 
-        long remainingNanos = unit.toNanos(timeout);
         long deadline = System.nanoTime() + remainingNanos;
-
         do {
             // Round up to next millisecond
             wait(TimeUnit.NANOSECONDS.toMillis(remainingNanos + 999_999L));
--- a/src/java.base/windows/classes/java/lang/ProcessImpl.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/java.base/windows/classes/java/lang/ProcessImpl.java	Sun Mar 29 09:21:15 2015 -0400
@@ -458,12 +458,11 @@
     public boolean waitFor(long timeout, TimeUnit unit)
         throws InterruptedException
     {
+        long remainingNanos = unit.toNanos(timeout);    // throw NPE before other conditions
         if (getExitCodeProcess(handle) != STILL_ACTIVE) return true;
         if (timeout <= 0) return false;
 
-        long remainingNanos  = unit.toNanos(timeout);
         long deadline = System.nanoTime() + remainingNanos ;
-
         do {
             // Round up to next millisecond
             long msTimeout = TimeUnit.NANOSECONDS.toMillis(remainingNanos + 999_999L);
--- a/src/jdk.localedata/share/classes/sun/text/resources/de/FormatData_de.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/jdk.localedata/share/classes/sun/text/resources/de/FormatData_de.java	Sun Mar 29 09:21:15 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -142,7 +142,7 @@
                 new String[] {
                     "Jan", // abb january
                     "Feb", // abb february
-                    "Mrz", // abb march
+                    "M\u00e4r", // abb march
                     "Apr", // abb april
                     "Mai", // abb may
                     "Jun", // abb june
--- a/src/jdk.pack200/share/native/common-unpack/bytes.h	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/jdk.pack200/share/native/common-unpack/bytes.h	Sun Mar 29 09:21:15 2015 -0400
@@ -63,7 +63,7 @@
     bytes res;
     res.ptr = ptr + beg;
     res.len = end - beg;
-    assert(res.len == 0 || inBounds(res.ptr) && inBounds(res.limit()-1));
+    assert(res.len == 0 || (inBounds(res.ptr) && inBounds(res.limit()-1)));
     return res;
   }
   // building C strings inside byte buffers:
--- a/src/jdk.pack200/share/native/common-unpack/unpack.cpp	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/jdk.pack200/share/native/common-unpack/unpack.cpp	Sun Mar 29 09:21:15 2015 -0400
@@ -225,9 +225,9 @@
   }
 
 #ifdef PRODUCT
-  char* string() { return 0; }
+  const char* string() { return NULL; }
 #else
-  char* string();  // see far below
+  const char* string();  // see far below
 #endif
 };
 
@@ -718,13 +718,13 @@
   // Now we can size the whole archive.
   // Read everything else into a mega-buffer.
   rp = hdr.rp;
-  int header_size_0 = (int)(rp - input.base()); // used-up header (4byte + 3int)
-  int header_size_1 = (int)(rplimit - rp);      // buffered unused initial fragment
-  int header_size   = header_size_0+header_size_1;
+  size_t header_size_0 = (rp - input.base()); // used-up header (4byte + 3int)
+  size_t header_size_1 = (rplimit - rp);      // buffered unused initial fragment
+  size_t header_size   = header_size_0 + header_size_1;
   unsized_bytes_read = header_size_0;
   CHECK;
   if (foreign_buf) {
-    if (archive_size > (size_t)header_size_1) {
+    if (archive_size > header_size_1) {
       abort("EOF reading fixed input buffer");
       return;
     }
@@ -738,7 +738,7 @@
       return;
     }
     input.set(U_NEW(byte, add_size(header_size_0, archive_size, C_SLOP)),
-              (size_t) header_size_0 + archive_size);
+              header_size_0 + archive_size);
     CHECK;
     assert(input.limit()[0] == 0);
     // Move all the bytes we read initially into the real buffer.
@@ -961,13 +961,13 @@
   nentries = next_entry;
 
   // place a limit on future CP growth:
-  int generous = 0;
+  size_t generous = 0;
   generous = add_size(generous, u->ic_count); // implicit name
   generous = add_size(generous, u->ic_count); // outer
   generous = add_size(generous, u->ic_count); // outer.utf8
   generous = add_size(generous, 40); // WKUs, misc
   generous = add_size(generous, u->class_count); // implicit SourceFile strings
-  maxentries = add_size(nentries, generous);
+  maxentries = (uint)add_size(nentries, generous);
 
   // Note that this CP does not include "empty" entries
   // for longs and doubles.  Those are introduced when
@@ -985,8 +985,9 @@
   }
 
   // Initialize *all* our entries once
-  for (int i = 0 ; i < maxentries ; i++)
+  for (uint i = 0 ; i < maxentries ; i++) {
     entries[i].outputIndex = REQUESTED_NONE;
+  }
 
   initGroupIndexes();
   // Initialize hashTab to a generous power-of-two size.
@@ -3680,21 +3681,22 @@
 
 unpacker* debug_u;
 
-static bytes& getbuf(int len) {  // for debugging only!
+static bytes& getbuf(size_t len) {  // for debugging only!
   static int bn = 0;
   static bytes bufs[8];
   bytes& buf = bufs[bn++ & 7];
-  while ((int)buf.len < len+10)
+  while (buf.len < len + 10) {
     buf.realloc(buf.len ? buf.len * 2 : 1000);
+  }
   buf.ptr[0] = 0;  // for the sake of strcat
   return buf;
 }
 
-char* entry::string() {
+const char* entry::string() {
   bytes buf;
   switch (tag) {
   case CONSTANT_None:
-    return (char*)"<empty>";
+    return "<empty>";
   case CONSTANT_Signature:
     if (value.b.ptr == null)
       return ref(0)->string();
@@ -3714,26 +3716,28 @@
     break;
   default:
     if (nrefs == 0) {
-      buf = getbuf(20);
-      sprintf((char*)buf.ptr, TAG_NAME[tag]);
+      return TAG_NAME[tag];
     } else if (nrefs == 1) {
       return refs[0]->string();
     } else {
-      char* s1 = refs[0]->string();
-      char* s2 = refs[1]->string();
-      buf = getbuf((int)strlen(s1) + 1 + (int)strlen(s2) + 4 + 1);
+      const char* s1 = refs[0]->string();
+      const char* s2 = refs[1]->string();
+      buf = getbuf(strlen(s1) + 1 + strlen(s2) + 4 + 1);
       buf.strcat(s1).strcat(" ").strcat(s2);
       if (nrefs > 2)  buf.strcat(" ...");
     }
   }
-  return (char*)buf.ptr;
+  return (const char*)buf.ptr;
 }
 
 void print_cp_entry(int i) {
   entry& e = debug_u->cp.entries[i];
-  char buf[30];
-  sprintf(buf, ((uint)e.tag < CONSTANT_Limit)? TAG_NAME[e.tag]: "%d", e.tag);
-  printf(" %d\t%s %s\n", i, buf, e.string());
+
+  if ((uint)e.tag < CONSTANT_Limit) {
+    printf(" %d\t%s %s\n", i, TAG_NAME[e.tag], e.string());
+  } else {
+    printf(" %d\t%d %s\n", i, e.tag, e.string());
+  }
 }
 
 void print_cp_entries(int beg, int end) {
--- a/src/jdk.pack200/share/native/common-unpack/unpack.h	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/jdk.pack200/share/native/common-unpack/unpack.h	Sun Mar 29 09:21:15 2015 -0400
@@ -210,7 +210,7 @@
   byte*     rp;          // read pointer (< rplimit <= input.limit())
   byte*     rplimit;     // how much of the input block has been read?
   julong    bytes_read;
-  int       unsized_bytes_read;
+  size_t    unsized_bytes_read;
 
   // callback to read at least one byte, up to available input
   typedef jlong (*read_input_fn_t)(unpacker* self, void* buf, jlong minlen, jlong maxlen);
--- a/src/jdk.pack200/share/native/common-unpack/utils.cpp	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/jdk.pack200/share/native/common-unpack/utils.cpp	Sun Mar 29 09:21:15 2015 -0400
@@ -81,7 +81,7 @@
 int assert_failed(const char* p) {
   char message[1<<12];
   sprintf(message, "@assert failed: %s\n", p);
-  fprintf(stdout, 1+message);
+  fprintf(stdout, "%s", 1+message);
   breakpoint();
   unpack_abort(message);
   return 0;
--- a/src/jdk.pack200/share/native/common-unpack/zip.cpp	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/jdk.pack200/share/native/common-unpack/zip.cpp	Sun Mar 29 09:21:15 2015 -0400
@@ -84,7 +84,7 @@
 }
 
 // Write data to the ZIP output stream.
-void jar::write_data(void* buff, int len) {
+void jar::write_data(void* buff, size_t len) {
   while (len > 0) {
     int rc = (int)fwrite(buff, 1, len, jarfp);
     if (rc <= 0) {
@@ -323,12 +323,12 @@
     // Total number of disks (int)
     header64[36] = (ushort)SWAP_BYTES(1);
     header64[37] = 0;
-    write_data(header64, (int)sizeof(header64));
+    write_data(header64, sizeof(header64));
   }
 
   // Write the End of Central Directory structure.
   PRINTCR((2, "end-of-directory at %d\n", output_file_offset));
-  write_data(header, (int)sizeof(header));
+  write_data(header, sizeof(header));
 
   PRINTCR((2, "writing zip comment\n"));
   // Write the comment.
@@ -590,7 +590,7 @@
   zstream = NEW(z_stream, 1);
   u->gzin = this;
   u->read_input_fn = read_input_via_gzip;
-  u->gzcrc = crc32(0L, Z_NULL, 0);
+  u->gzcrc = crc32(0, Z_NULL, 0);
 }
 
 void gunzip::start(int magic) {
--- a/src/jdk.pack200/share/native/common-unpack/zip.h	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/jdk.pack200/share/native/common-unpack/zip.h	Sun Mar 29 09:21:15 2015 -0400
@@ -68,8 +68,8 @@
   }
 
   // Private Methods
-  void write_data(void* ptr, int len);
-  void write_data(bytes& b) { write_data(b.ptr, (int)b.len); }
+  void write_data(void* ptr, size_t len);
+  void write_data(bytes& b) { write_data(b.ptr, b.len); }
   void add_to_jar_directory(const char* fname, bool store, int modtime,
                             int len, int clen, uLong crc);
   void write_jar_header(const char* fname, bool store, int modtime,
--- a/src/jdk.pack200/share/native/libunpack/jni.cpp	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/jdk.pack200/share/native/libunpack/jni.cpp	Sun Mar 29 09:21:15 2015 -0400
@@ -292,7 +292,7 @@
 
   if (uPtr->aborting()) {
     THROW_IOE(uPtr->get_abort_message());
-    return false;
+    return null;
   }
 
   // We have fetched all the files.
@@ -310,7 +310,7 @@
 JNIEXPORT jlong JNICALL
 Java_com_sun_java_util_jar_pack_NativeUnpack_finish(JNIEnv *env, jobject pObj) {
   unpacker* uPtr = get_unpacker(env, pObj, false);
-  CHECK_EXCEPTION_RETURN_VALUE(uPtr, NULL);
+  CHECK_EXCEPTION_RETURN_VALUE(uPtr, 0);
   size_t consumed = uPtr->input_consumed();
   free_unpacker(env, pObj, uPtr);
   return consumed;
@@ -320,6 +320,7 @@
 Java_com_sun_java_util_jar_pack_NativeUnpack_setOption(JNIEnv *env, jobject pObj,
                                        jstring pProp, jstring pValue) {
   unpacker*   uPtr  = get_unpacker(env, pObj);
+  CHECK_EXCEPTION_RETURN_VALUE(uPtr, false);
   const char* prop  = env->GetStringUTFChars(pProp, JNI_FALSE);
   CHECK_EXCEPTION_RETURN_VALUE(prop, false);
   const char* value = env->GetStringUTFChars(pValue, JNI_FALSE);
--- a/src/jdk.pack200/share/native/unpack200/main.cpp	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/jdk.pack200/share/native/unpack200/main.cpp	Sun Mar 29 09:21:15 2015 -0400
@@ -149,31 +149,28 @@
   return progname;
 }
 
-static const char* usage_lines[] = {
-  "Usage:  %s [-opt... | --option=value]... x.pack[.gz] y.jar\n",
-    "\n",
-    "Unpacking Options\n",
-    "  -H{h}, --deflate-hint={h}     override transmitted deflate hint: true, false, or keep (default)\n",
-    "  -r, --remove-pack-file        remove input file after unpacking\n",
-    "  -v, --verbose                 increase program verbosity\n",
-    "  -q, --quiet                   set verbosity to lowest level\n",
-    "  -l{F}, --log-file={F}         output to the given log file, or '-' for standard output (default)\n",
-    "  -?, -h, --help                print this message\n",
-    "  -V, --version                 print program version\n",
-    "  -J{X}                         Java VM argument (ignored)\n",
-    null
-};
+#define USAGE_HEADER "Usage:  %s [-opt... | --option=value]... x.pack[.gz] y.jar\n"
+#define USAGE_OPTIONS \
+    "\n" \
+    "Unpacking Options\n" \
+    "  -H{h}, --deflate-hint={h}     override transmitted deflate hint: true, false, or keep (default)\n" \
+    "  -r, --remove-pack-file        remove input file after unpacking\n" \
+    "  -v, --verbose                 increase program verbosity\n" \
+    "  -q, --quiet                   set verbosity to lowest level\n" \
+    "  -l{F}, --log-file={F}         output to the given log file, or '-' for standard output (default)\n" \
+    "  -?, -h, --help                print this message\n" \
+    "  -V, --version                 print program version\n" \
+    "  -J{X}                         Java VM argument (ignored)\n"
 
 static void usage(unpacker* u, const char* progname, bool full = false) {
   // WinMain does not set argv[0] to the progrname
   progname = (progname != null) ? nbasename(progname) : "unpack200";
-  for (int i = 0; usage_lines[i] != null; i++) {
-    fprintf(u->errstrm, usage_lines[i], progname);
-    if (!full) {
-      fprintf(u->errstrm,
-              "(For more information, run %s --help .)\n", progname);
-      break;
-    }
+
+  fprintf(u->errstrm, USAGE_HEADER, progname);
+  if (full) {
+    fprintf(u->errstrm, USAGE_OPTIONS);
+  } else {
+    fprintf(u->errstrm, "(For more information, run %s --help .)\n", progname);
   }
 }
 
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipConstants.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipConstants.java	Sun Mar 29 09:21:15 2015 -0400
@@ -184,10 +184,19 @@
         return (LG(b, n)) | (LG(b, n + 4) << 32);
     }
 
-    static final long GETSIG(byte[] b) {
-        return LG(b, 0);
+    static long getSig(byte[] b, int n) { return LG(b, n); }
+
+    private static boolean pkSigAt(byte[] b, int n, int b1, int b2) {
+        return b[n] == 'P' & b[n + 1] == 'K' & b[n + 2] == b1 & b[n + 3] == b2;
     }
 
+    static boolean cenSigAt(byte[] b, int n) { return pkSigAt(b, n, 1, 2); }
+    static boolean locSigAt(byte[] b, int n) { return pkSigAt(b, n, 3, 4); }
+    static boolean endSigAt(byte[] b, int n) { return pkSigAt(b, n, 5, 6); }
+    static boolean extSigAt(byte[] b, int n) { return pkSigAt(b, n, 7, 8); }
+    static boolean end64SigAt(byte[] b, int n) { return pkSigAt(b, n, 6, 6); }
+    static boolean locator64SigAt(byte[] b, int n) { return pkSigAt(b, n, 6, 7); }
+
     // local file (LOC) header fields
     static final long LOCSIG(byte[] b) { return LG(b, 0); } // signature
     static final int  LOCVER(byte[] b) { return SH(b, 4); } // version needed to extract
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java	Sun Mar 29 09:21:15 2015 -0400
@@ -1060,7 +1060,7 @@
         int pos = 0;
         int limit = cen.length - ENDHDR;
         while (pos < limit) {
-            if (CENSIG(cen, pos) != CENSIG)
+            if (!cenSigAt(cen, pos))
                 zerror("invalid CEN header (bad signature)");
             int method = CENHOW(cen, pos);
             int nlen   = CENNAM(cen, pos);
@@ -1894,7 +1894,7 @@
             throws IOException
         {
             byte[] cen = zipfs.cen;
-            if (CENSIG(cen, pos) != CENSIG)
+            if (!cenSigAt(cen, pos))
                 zerror("invalid CEN header (bad signature)");
             versionMade = CENVEM(cen, pos);
             version     = CENVER(cen, pos);
@@ -2057,9 +2057,9 @@
             assert (buf.length >= LOCHDR);
             if (zipfs.readFullyAt(buf, 0, LOCHDR , pos) != LOCHDR)
                 throw new ZipException("loc: reading failed");
-            if (LOCSIG(buf) != LOCSIG)
+            if (!locSigAt(buf, 0))
                 throw new ZipException("loc: wrong sig ->"
-                                       + Long.toString(LOCSIG(buf), 16));
+                                       + Long.toString(getSig(buf, 0), 16));
             //startPos = pos;
             version  = LOCVER(buf);
             flag     = LOCFLG(buf);
@@ -2289,9 +2289,9 @@
                     if (zipfs.readFullyAt(buf, 0, buf.length , locoff)
                         != buf.length)
                         throw new ZipException("loc: reading failed");
-                    if (LOCSIG(buf) != LOCSIG)
+                    if (!locSigAt(buf, 0))
                         throw new ZipException("loc: wrong sig ->"
-                                           + Long.toString(LOCSIG(buf), 16));
+                                           + Long.toString(getSig(buf, 0), 16));
 
                     int locElen = LOCEXT(buf);
                     if (locElen < 9)    // EXTT is at lease 9 bytes
--- a/test/TEST.ROOT	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/TEST.ROOT	Sun Mar 29 09:21:15 2015 -0400
@@ -2,7 +2,7 @@
 # It also contains test-suite configuration information.
 
 # The list of keywords supported in the entire test suite
-keys=2d dnd i18n
+keys=2d dnd i18n intermittent
 
 # Tests that must run in othervm mode
 othervm.dirs=java/awt java/beans javax/accessibility javax/imageio javax/sound javax/print javax/management com/sun/awt sun/awt sun/java2d sun/pisces javax/xml/jaxp/testng/validation
--- a/test/TEST.groups	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/TEST.groups	Sun Mar 29 09:21:15 2015 -0400
@@ -38,7 +38,9 @@
     :jdk_time \
     :jdk_security \
     :jdk_text \
-    :core_tools
+    :core_tools \
+    :jdk_other \
+    :jdk_svc
 
 ###############################################################################
 #
--- a/test/com/sun/jndi/ldap/LdapTimeoutTest.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/com/sun/jndi/ldap/LdapTimeoutTest.java	Sun Mar 29 09:21:15 2015 -0400
@@ -26,6 +26,7 @@
  * @run main/othervm LdapTimeoutTest
  * @bug 7094377 8000487 6176036 7056489
  * @summary Timeout tests for ldap
+ * @key intermittent
  */
 
 import java.net.Socket;
--- a/test/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java	Sun Mar 29 09:21:15 2015 -0400
@@ -43,11 +43,16 @@
 
     void test(String[] args) throws IOException {
         SocketAddress address = null;
+        String os = System.getProperty("os.name").toLowerCase();
 
         if (!Util.isSCTPSupported()) {
             out.println("SCTP protocol is not supported");
             out.println("Test cannot be run");
             return;
+        } else if (os.startsWith("sunos")) {
+            out.println("Test not supported on Solaris");
+            out.println("Test cannot be run");
+            return;
         }
 
         System.out.println("remote address: " + remoteAddress);
--- a/test/java/lang/ProcessBuilder/Basic.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/lang/ProcessBuilder/Basic.java	Sun Mar 29 09:21:15 2015 -0400
@@ -27,6 +27,7 @@
  *      5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313
  *      6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958
  *      4947220 7018606 7034570 4244896 5049299 8003488 8054494 8058464
+ *      8067796
  * @summary Basic tests for Process and Environment Variable code
  * @run main/othervm/timeout=300 Basic
  * @run main/othervm/timeout=300 -Djdk.lang.Process.launchMechanism=fork Basic
@@ -2387,6 +2388,56 @@
         } catch (Throwable t) { unexpected(t); }
 
         //----------------------------------------------------------------
+        // Check that Process.waitFor(timeout, null) throws NPE.
+        //----------------------------------------------------------------
+        try {
+            List<String> childArgs = new ArrayList<String>(javaChildArgs);
+            childArgs.add("sleep");
+            final Process p = new ProcessBuilder(childArgs).start();
+            THROWS(NullPointerException.class,
+                    () ->  p.waitFor(10L, null));
+            THROWS(NullPointerException.class,
+                    () ->  p.waitFor(0L, null));
+            THROWS(NullPointerException.class,
+                    () -> p.waitFor(-1L, null));
+            // Terminate process and recheck after it exits
+            p.destroy();
+            p.waitFor();
+            THROWS(NullPointerException.class,
+                    () -> p.waitFor(10L, null));
+            THROWS(NullPointerException.class,
+                    () -> p.waitFor(0L, null));
+            THROWS(NullPointerException.class,
+                    () -> p.waitFor(-1L, null));
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
+        // Check that default implementation of Process.waitFor(timeout, null) throws NPE.
+        //----------------------------------------------------------------
+        try {
+            List<String> childArgs = new ArrayList<String>(javaChildArgs);
+            childArgs.add("sleep");
+            final Process proc = new ProcessBuilder(childArgs).start();
+            final DelegatingProcess p = new DelegatingProcess(proc);
+
+            THROWS(NullPointerException.class,
+                    () ->  p.waitFor(10L, null));
+            THROWS(NullPointerException.class,
+                    () ->  p.waitFor(0L, null));
+            THROWS(NullPointerException.class,
+                    () ->  p.waitFor(-1L, null));
+            // Terminate process and recheck after it exits
+            p.destroy();
+            p.waitFor();
+            THROWS(NullPointerException.class,
+                    () -> p.waitFor(10L, null));
+            THROWS(NullPointerException.class,
+                    () -> p.waitFor(0L, null));
+            THROWS(NullPointerException.class,
+                    () -> p.waitFor(-1L, null));
+        } catch (Throwable t) { unexpected(t); }
+
+        //----------------------------------------------------------------
         // Check the default implementation for
         // Process.waitFor(long, TimeUnit)
         //----------------------------------------------------------------
--- a/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java	Sun Mar 29 09:21:15 2015 -0400
@@ -41,6 +41,7 @@
  * @library /lib/testlibrary/jsr292 /lib/testlibrary/
  * @compile CatchExceptionTest.java
  * @run main/othervm -esa test.java.lang.invoke.MethodHandles.CatchExceptionTest
+ * @key intermittent
  */
 public class CatchExceptionTest {
     private static final List<Class<?>> ARGS_CLASSES;
--- a/test/java/lang/ref/OOMEInReferenceHandler.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/lang/ref/OOMEInReferenceHandler.java	Sun Mar 29 09:21:15 2015 -0400
@@ -27,6 +27,7 @@
  * @summary Verify that the reference handler does not die after an OOME allocating the InterruptedException object
  * @run main/othervm -XX:-UseGCOverheadLimit -Xmx24M -XX:-UseTLAB OOMEInReferenceHandler
  * @author peter.levart@gmail.com
+ * @key intermittent
  */
 
 import java.lang.ref.*;
--- a/test/java/net/Inet6Address/serialize/Inet6AddressSerializationTest.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/net/Inet6Address/serialize/Inet6AddressSerializationTest.java	Sun Mar 29 09:21:15 2015 -0400
@@ -42,6 +42,7 @@
  * @test
  * @bug 8007373
  * @summary jdk7 backward compatibility serialization problem
+ * @key intermittent
  */
 
 public class Inet6AddressSerializationTest {
--- a/test/java/net/SocketPermission/SocketPermissionTest.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/net/SocketPermission/SocketPermissionTest.java	Sun Mar 29 09:21:15 2015 -0400
@@ -27,6 +27,7 @@
  * @summary SocketPermission tests for legacy socket types
  * @library ../../../lib/testlibrary
  * @run testng/othervm/policy=policy SocketPermissionTest
+ * @key intermittent
  */
 import java.io.IOException;
 import java.net.DatagramPacket;
--- a/test/java/nio/Buffer/genBasic.sh	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/nio/Buffer/genBasic.sh	Sun Mar 29 09:21:15 2015 -0400
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 #
-# Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 # questions.
 #
 
-javac -d . ../../../../make/tools/src/build/tools/spp/Spp.java
+javac -d . ../../../../make/src/classes/build/tools/spp/Spp.java
 
 gen() {
     java build.tools.spp.Spp -K$1 -Dtype=$1 -DType=$2 -DFulltype=$3 <Basic-X.java.template >Basic$2.java
--- a/test/java/nio/Buffer/genCopyDirectMemory.sh	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/nio/Buffer/genCopyDirectMemory.sh	Sun Mar 29 09:21:15 2015 -0400
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 #
-# Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 # questions.
 #
 
-javac -d . ../../../../make/tools/src/build/tools/spp/Spp.java > Spp.java
+javac -d . ../../../../make/src/classes/build/tools/spp/Spp.java > Spp.java
 
 gen() {
     java  build.tools.spp.Spp -K$1 -Dtype=$1 -DType=$2 -DFulltype=$3<CopyDirect-X-Memory.java.template >CopyDirect$2Memory.java
--- a/test/java/nio/channels/ServerSocketChannel/AdaptServerSocket.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/nio/channels/ServerSocketChannel/AdaptServerSocket.java	Sun Mar 29 09:21:15 2015 -0400
@@ -23,6 +23,7 @@
 
 /* @test
  * @summary Unit test for server-socket-channel adaptors
+ * @key intermittent
  */
 
 import java.io.*;
--- a/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh	Sun Mar 29 09:21:15 2015 -0400
@@ -24,12 +24,12 @@
 #
 
 # @test
-# @bug 4673940
-# @bug 4930794
+# @bug 4673940 4930794
 # @summary Unit tests for inetd feature
 #
 # @build StateTest StateTestService EchoTest EchoService CloseTest Launcher Util
 # @run shell run_tests.sh
+# @key intermittent
 
 os=`uname -s`
 
--- a/test/java/nio/file/FileStore/Basic.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/nio/file/FileStore/Basic.java	Sun Mar 29 09:21:15 2015 -0400
@@ -25,6 +25,7 @@
  * @bug 4313887 6873621 6979526 7006126 7020517
  * @summary Unit test for java.nio.file.FileStore
  * @library ..
+ * @key intermittent
  */
 
 import java.nio.file.*;
--- a/test/java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java	Sun Mar 29 09:21:15 2015 -0400
@@ -39,6 +39,7 @@
  * @build TestLibrary RMID ActivateMe CheckActivateRef_Stub
  * @run main/othervm/policy=security.policy/timeout=240 -Djava.rmi.server.ignoreStubClasses=true CheckActivateRef
  * @run main/othervm/policy=security.policy/timeout=240 -Djava.rmi.server.ignoreStubClasses=false CheckActivateRef
+ * @key intermittent
  */
 
 import java.io.*;
--- a/test/java/rmi/registry/interfaceHash/InterfaceHash.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/rmi/registry/interfaceHash/InterfaceHash.java	Sun Mar 29 09:21:15 2015 -0400
@@ -38,6 +38,7 @@
  * @library ../../testlibrary
  * @build TestLibrary ReferenceRegistryStub
  * @run main/othervm InterfaceHash
+ * @key intermittent
  */
 
 import java.lang.reflect.Constructor;
--- a/test/java/rmi/server/UnicastRemoteObject/exportObject/GcDuringExport.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/rmi/server/UnicastRemoteObject/exportObject/GcDuringExport.java	Sun Mar 29 09:21:15 2015 -0400
@@ -31,6 +31,7 @@
  * @summary GC'ing objects whilst being exported to RMI should not cause exceptions
  * @author Neil Richards <neil.richards@ngmr.net>, <neil_richards@uk.ibm.com>
  * @run main/othervm GcDuringExport
+ * @key intermittent
  */
 
 import java.rmi.Remote;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/security/KeyStore/PKCS12/WriteP12Test.java	Sun Mar 29 09:21:15 2015 -0400
@@ -0,0 +1,371 @@
+/*
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import static java.lang.System.out;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.Key;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Enumeration;
+
+/*
+ * @test
+ * @bug 8048618
+ * @summary Write different types p12 key store to Check the write related
+ *  APIs.
+ * @run main WriteP12Test
+ */
+
+public class WriteP12Test {
+
+    private static final String IN_KEYSTORE_TYPE = "jks";
+    private static final String IN_KEYSTORE_PRV = "SUN";
+
+    private static final String IN_KEYSTORE_ENDUSER = "keystoreEU.jks.data";
+    private static final String IN_KEYSTORE_CA = "keystoreCA.jks.data";
+    private static final String OUT_KEYSTORE = "outKeyStore.p12";
+
+    private static final String IN_STORE_PASS = "storepass";
+    private static final String IN_KEY_PASS = "keypass";
+
+    private static final String CERT_PATH = System.getProperty("test.src", ".")
+            + File.separator + "certs" + File.separator + "writeP12"
+            + File.separator;
+
+    private static final String CA_CERT_STR = "-----BEGIN CERTIFICATE-----\n"
+            + "MIIDFzCCAf8CBD8+0nAwDQYJKoZIhvcNAQEFBQAwUDELMAkGA1UEBhMCV\n"
+            + "VMxETAPBgNVBAoTCEphdmFTb2Z0MRUwEwYDVQQLEwxTZWN1cml0eSBTUU\n"
+            + "UxFzAVBgNVBAMTDlBLQ1MxMiBUZXN0IENBMB4XDTAzMDgxNzAwNTUxMlo\n"
+            + "XDTEzMDgxNDAwNTUxMlowUDELMAkGA1UEBhMCVVMxETAPBgNVBAoTCEph\n"
+            + "dmFTb2Z0MRUwEwYDVQQLEwxTZWN1cml0eSBTUUUxFzAVBgNVBAMTDlBLQ\n"
+            + "1MxMiBUZXN0IENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQ\n"
+            + "EAk7Sh+K/yGsmJacZnjfkZfuWxGNJCPW0q69exwoRP+eBHMQwG00yi9aL\n"
+            + "SsZAqNpJSCDvpgySOAUmBd+f8WFhHqJfRVREVfv3mradDKZCjhqtsUI7I\n"
+            + "wRTYYy9clFkeeK4dHaxbuFMPpUu7yQfwSTXgvOA/UJ4kJuGtaYAdTJI4e\n"
+            + "f1mUASo6+dea0UZA/FHCuV7O6z3hr5VHlyhJL2/o/8M5tGBTBISODJSnn\n"
+            + "GNBvtQLNHnWYvs470UAE2BtuCGYh1V/3HAH1tRirS3MBBcb1XnIkiiXR3\n"
+            + "tjaBSB+XhoCfuG8KtInXXFaAnvKfY9mYFw6VJt9JYQpY2VDC7281/Pbz0\n"
+            + "dQIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQBzXZ8zHWrnC8/E+N/n2Czhx\n"
+            + "i18YQc2LPWBDLYTTxoFEazWmYLv1k/JT7Nta1qu1quvxXJ4uV1XHbd9NF\n"
+            + "AJWKwtFQEpfv4o6I7qWUPoxnfA+jyqKXxv27z25tzt+Y4xOEhqvO03G0Q\n"
+            + "imhkiNt9MF7L69y2U0/U73+uFNGzdAEDiI9EibvICiOnr1TeQ5GekK3Yb\n"
+            + "k5qe3lviMZPkkSXepTJI8m0AiXCji+eXj97jVLeH+RxeBchBY+uELrqUr\n"
+            + "sVOVWh7IBCqC/V7FqUTkmD1IFlzkkinatpl42s1MbhJId2yQkzaeBRc\n"
+            + "suE63bDEtuRWp9ynMO3QA4Yu85uBRWGzQ1Di\n"
+            + "-----END CERTIFICATE-----";
+    private static final String LEAD_CERT = "-----BEGIN CERTIFICATE-----\n"
+            + "MIICwDCCAaigAwIBAgIEPz7S1jANBgkqhkiG9w0BAQQFADBQMQswCQYDV\n"
+            + "QQGEwJVUzERMA8GA1UEChMISmF2YVNvZnQxFTATBgNVBAsTDFNlY3VyaX\n"
+            + "R5IFNRRTEXMBUGA1UEAxMOUEtDUzEyIFRlc3QgQ0EwHhcNMDAwODA5MDc\n"
+            + "wMDAwWhcNMTAwODA3MDcwMDAwWjBSMQswCQYDVQQGEwJVUzERMA8GA1UE\n"
+            + "ChMISmF2YVNvZnQxFTATBgNVBAsTDFNlY3VyaXR5IFNRRTEZMBcGA1UEA\n"
+            + "xMQUEtDUzEyIFRlc3QgTGVhZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgY\n"
+            + "kCgYEAzq9X2USz/WjDhT+jUyZWqB5h4A33tS11YqH5qYvqjTXjcUI6gOp\n"
+            + "moXMafDG9RHRlIccvp51xLp7Ap3WMrv411lWBttqtZi5c1/DEC1cEM/Sl\n"
+            + "PCk1r2zFbkJu7QKieXeMcrjZEo6LcBHMwQjIpI+up9cr3VjuyqG/olQkU\n"
+            + "mXVuS0CAwEAAaMkMCIwDwYDVR0PAQH/BAUDAweAADAPBgNVHRMBAf8EBT\n"
+            + "ADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBhbuim98TWmtv9vSldRE7RvQ8\n"
+            + "FlS0TyZVO7kcSNtfCUE4R76J1ElN74Koc5pQnUtduLeQJs2ao/mEcCZsE\n"
+            + "zVcwI3mSZrSzPhc8s7w5gOQA4TUwVLSSjKgBCaZ7R3+qJ3QeqPJ5O6sFz\n"
+            + "pvBYkgSa4MWptK41jbmT8cwZQJXFCi8WxFFJ+p97F1Ppm3LgmYmtiUP4M\n"
+            + "ZQwOBvpTZWXU0WrqFXpzWQx0mg4SX19fZm4nLcJAerCEUphf8ILagtpQM\n"
+            + "EErT3/jg6mfCdT3Rj055QXPfF4OiRFevPF5a1fZgrCePCukRQZcd7s8K5\n"
+            + "OBIaryuM0MdFtlzxi6XWeUNpVFFHURcy\n"
+            + "-----END CERTIFICATE-----";
+    private static final String END_CERT = "-----BEGIN CERTIFICATE-----\n"
+            + "MIICNjCCAZ+gAwIBAgIEPz7WtzANBgkqhkiG9w0BAQQFADBSMQswCQYDV\n"
+            + "QQGEwJVUzERMA8GA1UEChMISmF2YVNvZnQxFTATBgNVBAsTDFNlY3VyaX\n"
+            + "R5IFNRRTEZMBcGA1UEAxMQUEtDUzEyIFRlc3QgTGVhZDAeFw0wMDA4MDk\n"
+            + "wNzAwMDBaFw0xMDA4MDcwNzAwMDBaMFgxCzAJBgNVBAYTAlVTMREwDwYD\n"
+            + "VQQKEwhKYXZhU29mdDEVMBMGA1UECxMMU2VjdXJpdHkgU1FFMR8wHQYDV\n"
+            + "QQDExZQS0NTMTIgVGVzdCBFbmQgVXNlciAxMIGfMA0GCSqGSIb3DQEBAQ\n"
+            + "UAA4GNADCBiQKBgQDIKomSYomDzH/V63eDQEG7od0DLcnnVZ81pbWhDss\n"
+            + "8gHV2m8pADdRqdihBmnSQEaMW4D3uZ4sFE1LtkQls6hjd7SdOsG5Y24L8\n"
+            + "15jot9a2JcB73H8H0VKirrObL5BZdt7BtASPDnYtW4Spt++YjDoJFxyF0\n"
+            + "HchkavzXaVTlexakwIDAQABoxMwETAPBgNVHQ8BAf8EBQMDB4AAMA0GCS\n"
+            + "qGSIb3DQEBBAUAA4GBAIFA3JXEmb9AXn3RD7t+Mn6DoyVDIy5jsn6xOKT\n"
+            + "JV25I0obpDUzgw4QaAMmM0ZvusOmZ2wZNS8MtyTUgdANyakbzn5SdxbTy\n"
+            + "TLEqQsFbX8UVC38fx5ZM6ExA5YSAvgmXudZpOVC0ATccoZS3JFU8CxSfW\n"
+            + "+Q3IC2MLh+QTg3hUJ5b\n-----END CERTIFICATE-----";
+
+    private final Certificate testerCert;
+    private final Certificate testLeadCert;
+    private final Certificate caCert;
+
+    WriteP12Test() throws CertificateException {
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+        caCert = cf.generateCertificate(new ByteArrayInputStream(CA_CERT_STR
+                .getBytes()));
+        testLeadCert = cf.generateCertificate(new ByteArrayInputStream(
+                LEAD_CERT.getBytes()));
+        testerCert = cf.generateCertificate(new ByteArrayInputStream(END_CERT
+                .getBytes()));
+    }
+
+    public static void main(String[] args) throws CertificateException,
+            UnrecoverableKeyException, KeyStoreException,
+            NoSuchProviderException, NoSuchAlgorithmException, IOException {
+        WriteP12Test jstest = new WriteP12Test();
+        out.println("test WriteP12CertChain");
+        /*
+         * WriteP12CertChain: This test creates a p12 keystore contains one
+         * entry with private key and a certificate chains contains three
+         * certificates in the order of user->lead->ca. This case expects to
+         * pass.
+         */
+        jstest.test(new Certificate[] { jstest.testerCert, jstest.testLeadCert,
+                jstest.caCert }, IN_KEYSTORE_ENDUSER, "pkcs12testenduser1",
+                "pass", "pass");
+
+        /*
+         * WriteP12CertChainBad: same as WriteP12CertChain but chains order is
+         * user-ca-lead, the order is wrong so expects to fail.
+         */
+        out.println("test WriteP12CertChainBad");
+        try {
+            jstest.test(new Certificate[] { jstest.testerCert, jstest.caCert,
+                    jstest.testLeadCert }, IN_KEYSTORE_ENDUSER,
+                    "pkcs12testenduser1", "pass", "pass");
+            throw new RuntimeException(
+                    " Certificate chain is not valid, test should not pass."
+                            + " Test failed.");
+        } catch (KeyStoreException e) {
+            e.printStackTrace();
+            out.println(" Certificate chain is not valid,exception is"
+                    + " expected. Test passed.");
+        }
+        /*
+         * WriteP12PrivateKey:This test creates a p12 contains a self-signed
+         * cert and private key,expects no exception
+         */
+        out.println("test WriteP12PrivateKey");
+        jstest.test(null, IN_KEYSTORE_ENDUSER, "pkcs12testenduser1", "pass",
+                "pass");
+
+        /*
+         * WriteP12TwoEntry: This test creates a p12 keystore with different
+         * storepass and keypass, and contains two entries.
+         */
+        out.println("test WriteP12TwoEntry");
+        jstest.testTwoEntry(IN_KEYSTORE_ENDUSER, IN_KEYSTORE_CA,
+                "pkcs12testenduser1", "pass", "pass");
+        /*
+         * WriteP12TwoPass: This test creates a p12 keystore with different
+         * storepass and keypass, and contains one entry with private key and a
+         * certificate
+         */
+        out.println("test WriteP12TwoPass");
+        jstest.test(null, IN_KEYSTORE_CA, "pkcs12testCA", "storepass",
+                "keypass");
+    }
+
+    private void test(Certificate certs[], String inKeyStorePath,
+            String userAlias, String outStorePass, String outKeyPass)
+            throws KeyStoreException, NoSuchProviderException, IOException,
+            CertificateException, UnrecoverableKeyException,
+            NoSuchAlgorithmException {
+        // init output key store
+        KeyStore outputKeyStore = KeyStore.getInstance("pkcs12", "SunJSSE");
+        outputKeyStore.load(null, null);
+        try (FileOutputStream fout = new FileOutputStream(OUT_KEYSTORE)) {
+            // KeyStore have encoded by Base64.getMimeEncoder().encode(),need
+            // decode first.
+            byte[] input = Files.readAllBytes(Paths.get(CERT_PATH,
+                    inKeyStorePath));
+            ByteArrayInputStream arrayIn = new ByteArrayInputStream(Base64
+                    .getMimeDecoder().decode(input));
+            // input key store
+            KeyStore inputKeyStore = KeyStore.getInstance(IN_KEYSTORE_TYPE,
+                    IN_KEYSTORE_PRV);
+            inputKeyStore.load(arrayIn, IN_STORE_PASS.toCharArray());
+            // add key/certificate to output key store
+            Key key = inputKeyStore
+                    .getKey(userAlias, IN_KEY_PASS.toCharArray());
+            out.println("Input Key Algorithm " + key.getAlgorithm());
+            out.println("====Input Certs=====");
+            if (certs == null) {
+                certs = new Certificate[] { inputKeyStore
+                        .getCertificate(userAlias) };
+            }
+            for (Certificate cert : certs) {
+                out.println(((X509Certificate) cert).getSubjectDN());
+            }
+            outputKeyStore.setKeyEntry(userAlias, key,
+                    outKeyPass.toCharArray(), certs);
+            Certificate retCerts[] = outputKeyStore
+                    .getCertificateChain(userAlias);
+            out.println("====Output Certs=====");
+            for (Certificate retCert : retCerts) {
+                out.println(((X509Certificate) retCert).getSubjectDN());
+            }
+            out.println("====Output Key Algorithm=====");
+            Key outKey = outputKeyStore.getKey(userAlias,
+                    outKeyPass.toCharArray());
+            out.println(outKey.getAlgorithm());
+
+            if (!key.equals(outKey)) {
+                throw new RuntimeException("key don't match");
+            }
+            if (!Arrays.equals(certs, retCerts)) {
+                throw new RuntimeException("certs don't match");
+            }
+            // save output
+            outputKeyStore.store(fout, outStorePass.toCharArray());
+            // test output
+            testKeyStore(outputKeyStore, outKeyPass.toCharArray());
+        }
+    }
+
+    private void testTwoEntry(String inKeyStoreOnePath,
+            String inKeyStoreTwoPath, String userAlias, String outStorePass,
+            String outKeyPass) throws KeyStoreException,
+            NoSuchProviderException, NoSuchAlgorithmException,
+            CertificateException, IOException, UnrecoverableKeyException {
+        // initial KeyStore
+        KeyStore outputKeyStore = KeyStore.getInstance("pkcs12", "SunJSSE");
+        try (FileOutputStream fout = new FileOutputStream(OUT_KEYSTORE);) {
+            outputKeyStore.load(null, null);
+            KeyStore inputKeyStoreOne, inputKeyStoreTwo;
+            inputKeyStoreOne = KeyStore.getInstance(IN_KEYSTORE_TYPE,
+                    IN_KEYSTORE_PRV);
+            // KeyStore have encoded by Base64.getMimeEncoder().encode(),need
+            // decode first.
+            byte[] inputBytes = Files.readAllBytes(Paths.get(CERT_PATH,
+                    inKeyStoreOnePath));
+            ByteArrayInputStream arrayIn = new ByteArrayInputStream(Base64
+                    .getMimeDecoder().decode(inputBytes));
+            // input key store
+            inputKeyStoreOne.load(arrayIn, IN_STORE_PASS.toCharArray());
+
+            inputBytes = Files.readAllBytes(Paths.get(CERT_PATH,
+                    inKeyStoreTwoPath));
+            arrayIn = new ByteArrayInputStream(Base64.getMimeDecoder().decode(
+                    inputBytes));
+            inputKeyStoreTwo = KeyStore.getInstance(IN_KEYSTORE_TYPE,
+                    IN_KEYSTORE_PRV);
+            inputKeyStoreTwo.load(arrayIn, IN_STORE_PASS.toCharArray());
+
+            // add key/certificate to output key store
+            out.println("====First Entry=====");
+            Key inputKey = inputKeyStoreOne.getKey(userAlias,
+                    IN_KEY_PASS.toCharArray());
+            Certificate cert = inputKeyStoreOne.getCertificate(userAlias);
+            Certificate certs[] = new Certificate[1];
+            certs[0] = cert;
+
+            out.println("====Input1 Key=====");
+            out.println(inputKey.getAlgorithm());
+            out.println("====Input1 Certs=====");
+            out.println("Certificate :");
+            out.println(((X509Certificate) cert).getSubjectDN());
+            outputKeyStore.setKeyEntry("USER", inputKey,
+                    outKeyPass.toCharArray(), certs);
+            out.println("====Second Entry=====");
+            String caAlias = "pkcs12testca";
+            inputKey = inputKeyStoreTwo.getKey(caAlias,
+                    IN_KEY_PASS.toCharArray());
+            cert = inputKeyStoreTwo.getCertificate(caAlias);
+            certs[0] = cert;
+            out.println("====Input2 Key=====");
+            out.println(inputKey.getAlgorithm());
+            out.println("====Input2 Certs=====");
+            out.println("Certificate :");
+            out.println(((X509Certificate) cert).getSubjectDN());
+            outputKeyStore.setKeyEntry("CA", inputKey,
+                    outKeyPass.toCharArray(), certs);
+            // save output
+            outputKeyStore.store(fout, outStorePass.toCharArray());
+            // test output
+            testKeyStore(outputKeyStore, outKeyPass.toCharArray());
+        }
+    }
+
+    private void testKeyStore(KeyStore inputKeyStore, char[] keypass)
+            throws KeyStoreException, UnrecoverableKeyException,
+            NoSuchAlgorithmException {
+        out.println("========== Key Store ==========");
+        out.println("getProvider : " + inputKeyStore.getProvider());
+        out.println("getType : " + inputKeyStore.getType());
+        out.println("getDefaultType : " + KeyStore.getDefaultType());
+
+        int idx = 0;
+        Enumeration<String> e = inputKeyStore.aliases();
+        String alias;
+        while (e.hasMoreElements()) {
+            alias = e.nextElement();
+            if (!inputKeyStore.containsAlias(alias)) {
+                throw new RuntimeException("Alias not found");
+            }
+            out.println("Alias " + idx + " : " + alias);
+            out.println("getCreationDate : "
+                    + inputKeyStore.getCreationDate(alias));
+            X509Certificate cert = (X509Certificate) inputKeyStore
+                    .getCertificate(alias);
+            out.println("getCertificate : " + cert.getSubjectDN());
+            String retAlias = inputKeyStore.getCertificateAlias(cert);
+            if (!retAlias.equals(alias)) {
+                throw new RuntimeException("Alias mismatch, actually "
+                        + retAlias + ", expected " + alias);
+            }
+            out.println("getCertificateAlias : " + retAlias);
+            Certificate[] certs = inputKeyStore.getCertificateChain(alias);
+            int i = 0;
+            for (Certificate certification : certs) {
+                out.println("getCertificateChain " + i
+                        + ((X509Certificate) certification).getSubjectDN());
+                i++;
+            }
+            if (inputKeyStore.isCertificateEntry(alias)) {
+                throw new RuntimeException(
+                        "inputKeystore should not be certEntry because this"
+                                + " keystore only contain key pair entries.");
+            }
+            if (!inputKeyStore.isKeyEntry(alias)) {
+                throw new RuntimeException("Entry type unknown.");
+            }
+            idx++;
+        }
+        int size = inputKeyStore.size();
+        if (idx != size) {
+            throw new RuntimeException("Size not match, actually " + idx
+                    + ", expected " + size);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/security/KeyStore/PKCS12/certs/writeP12/keystoreCA.jks.data	Sun Mar 29 09:21:15 2015 -0400
@@ -0,0 +1,38 @@
+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
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/security/KeyStore/PKCS12/certs/writeP12/keystoreEU.jks.data	Sun Mar 29 09:21:15 2015 -0400
@@ -0,0 +1,79 @@
+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
+VL+NWQOgtME=
\ No newline at end of file
--- a/test/java/util/Arrays/TimSortStackSize2.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/util/Arrays/TimSortStackSize2.java	Sun Mar 29 09:21:15 2015 -0400
@@ -24,22 +24,63 @@
 /*
  * @test
  * @bug 8072909
- * @run main/othervm -Xms385m TimSortStackSize2 67108864
+ * @library /lib/testlibrary /../../test/lib
+ * @build jdk.testlibrary.*
+ * @build TimSortStackSize2
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ *     -XX:+WhiteBoxAPI TimSortStackSize2
  * @summary Test TimSort stack size on big arrays
- * big tests not for regular execution on all platforms:
- * run main/othervm -Xmx8g TimSortStackSize2 1073741824
- * run main/othervm -Xmx16g TimSortStackSize2 2147483644
  */
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Comparator;
 import java.util.List;
 import java.util.function.Consumer;
 
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.ProcessTools;
+import jdk.testlibrary.Utils;
+import sun.hotspot.WhiteBox;
+
 public class TimSortStackSize2 {
 
     public static void main(String[] args) {
-        int lengthOfTest = Integer.parseInt(args[0]);
+        if ( args == null || args.length == 0 ){
+            startMeWithArgs();
+        } else {
+            doTestOfTwoTimSorts(Integer.parseInt(args[0]));
+        }
+    }
+
+    private static void startMeWithArgs(){
+        /*
+         * big tests not for regular execution on all platforms:
+         * run main/othervm -Xmx8g TimSortStackSize2 1073741824
+         * run main/othervm -Xmx16g TimSortStackSize2 2147483644
+         */
+        try {
+            Boolean compressedOops = WhiteBox.getWhiteBox()
+                .getBooleanVMFlag("UseCompressedOops");
+            final String xmsValue = "-Xms" +
+                ((compressedOops == null || compressedOops) ? "385" : "770")
+                + "m";
+            System.out.println( "compressedOops: " + compressedOops
+                + "; Test will be started with \"" + xmsValue + "\"");
+            ProcessBuilder processBuilder = ProcessTools
+                .createJavaProcessBuilder(Utils.addTestJavaOpts(xmsValue,
+                    "TimSortStackSize2", "67108864"
+                )
+            );
+            OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
+            System.out.println(output.getOutput());
+            output.shouldHaveExitValue(0);
+        } catch( Exception e ){
+            e.printStackTrace();
+            throw new RuntimeException(e);
+        }
+    }
+
+    private static void doTestOfTwoTimSorts(final int lengthOfTest){
         boolean passed = doTest("TimSort", lengthOfTest,
             (Integer [] a) -> Arrays.sort(a));
         passed = doTest("ComparableTimSort", lengthOfTest, (Integer [] a) ->
--- a/test/java/util/Properties/Basic.java	Wed Mar 25 15:22:45 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.Properties;
-
-/*
- * @test
- * @bug 8073214
- * @summary Basic tests of Properties methods.
- */
-public class Basic
-{
-    public static void main(String[] args) throws Exception
-    {
-        int failures = 0;
-
-        Properties props = new Properties();
-
-        try {
-            props.store((OutputStream)null, "comments");
-            failures++;
-        } catch (NullPointerException e) {
-            // do nothing
-        }
-
-        try {
-            props.store((Writer)null, "comments");
-            failures++;
-        } catch (NullPointerException e) {
-            // do nothing
-        }
-
-        try {
-            props.load((InputStream)null);
-            failures++;
-        } catch (NullPointerException e) {
-            // do nothing
-        }
-
-        try {
-            props.load((Reader)null);
-            failures++;
-        } catch (NullPointerException e) {
-            // do nothing
-        }
-
-        if (failures != 0) {
-            throw new RuntimeException("Basic failed with "
-                + failures + " errors!");
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/Properties/LoadAndStoreNPE.java	Sun Mar 29 09:21:15 2015 -0400
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.Properties;
+
+/*
+ * @test
+ * @bug 8073214 8075362
+ * @summary Tests to verify that load() and store() throw NPEs as advertised.
+ */
+public class LoadAndStoreNPE
+{
+    public static void main(String[] args) throws Exception
+    {
+        int failures = 0;
+
+        Properties props = new Properties();
+
+        try {
+            props.store((OutputStream)null, "comments");
+            failures++;
+        } catch (NullPointerException e) {
+            // do nothing
+        }
+
+        try {
+            props.store((Writer)null, "comments");
+            failures++;
+        } catch (NullPointerException e) {
+            // do nothing
+        }
+
+        try {
+            props.load((InputStream)null);
+            failures++;
+        } catch (NullPointerException e) {
+            // do nothing
+        }
+
+        try {
+            props.load((Reader)null);
+            failures++;
+        } catch (NullPointerException e) {
+            // do nothing
+        }
+
+        if (failures != 0) {
+            throw new RuntimeException("LoadAndStoreNPE failed with "
+                + failures + " errors!");
+        }
+    }
+}
--- a/test/java/util/stream/boottest/java/util/stream/UnorderedTest.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/util/stream/boottest/java/util/stream/UnorderedTest.java	Sun Mar 29 09:21:15 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -251,7 +251,7 @@
 
         final int lastLimitIndex = l;
         return s -> {
-            if (lastLimitIndex == -1)
+            if (lastLimitIndex == -1 && fs.size() > 0)
                 s = fi.apply(s);
             for (int i = 0; i < fs.size(); i++) {
                 s = fs.get(i).apply(s);
--- a/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountTest.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountTest.java	Sun Mar 29 09:21:15 2015 -0400
@@ -24,11 +24,12 @@
 /**
  * @test
  * @summary Tests counting of streams
- * @bug 8031187 8067969
+ * @bug 8031187 8067969 8075307
  */
 
 package org.openjdk.tests.java.util.stream;
 
+import java.util.HashSet;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.DoubleStream;
 import java.util.stream.DoubleStreamTestDataProvider;
@@ -59,6 +60,19 @@
                 terminal(s -> s.filter(e -> true), Stream::count).
                 expectedResult(expectedCount).
                 exercise();
+
+        // Test with stateful distinct op that is a barrier or lazy
+        // depending if source is not already distinct and encounter order is
+        // preserved or not
+        expectedCount = data.into(new HashSet<>()).size();
+        withData(data).
+                terminal(Stream::distinct, Stream::count).
+                expectedResult(expectedCount).
+                exercise();
+        withData(data).
+                terminal(s -> s.unordered().distinct(), Stream::count).
+                expectedResult(expectedCount).
+                exercise();
     }
 
     @Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class)
@@ -74,6 +88,16 @@
                 terminal(s -> s.filter(e -> true), IntStream::count).
                 expectedResult(expectedCount).
                 exercise();
+
+        expectedCount = data.into(new HashSet<>()).size();
+        withData(data).
+                terminal(IntStream::distinct, IntStream::count).
+                expectedResult(expectedCount).
+                exercise();
+        withData(data).
+                terminal(s -> s.unordered().distinct(), IntStream::count).
+                expectedResult(expectedCount).
+                exercise();
     }
 
     @Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class)
@@ -89,6 +113,16 @@
                 terminal(s -> s.filter(e -> true), LongStream::count).
                 expectedResult(expectedCount).
                 exercise();
+
+        expectedCount = data.into(new HashSet<>()).size();
+        withData(data).
+                terminal(LongStream::distinct, LongStream::count).
+                expectedResult(expectedCount).
+                exercise();
+        withData(data).
+                terminal(s -> s.unordered().distinct(), LongStream::count).
+                expectedResult(expectedCount).
+                exercise();
     }
 
     @Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class)
@@ -104,6 +138,16 @@
                 terminal(s -> s.filter(e -> true), DoubleStream::count).
                 expectedResult(expectedCount).
                 exercise();
+
+        expectedCount = data.into(new HashSet<>()).size();
+        withData(data).
+                terminal(DoubleStream::distinct, DoubleStream::count).
+                expectedResult(expectedCount).
+                exercise();
+        withData(data).
+                terminal(s -> s.unordered().distinct(), DoubleStream::count).
+                expectedResult(expectedCount).
+                exercise();
     }
 
     public void testNoEvaluationForSizedStream() {
@@ -111,24 +155,36 @@
             AtomicInteger ai = new AtomicInteger();
             Stream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).count();
             assertEquals(ai.get(), 0);
+
+            Stream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).parallel().count();
+            assertEquals(ai.get(), 0);
         }
 
         {
             AtomicInteger ai = new AtomicInteger();
             IntStream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).count();
             assertEquals(ai.get(), 0);
+
+            IntStream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).parallel().count();
+            assertEquals(ai.get(), 0);
         }
 
         {
             AtomicInteger ai = new AtomicInteger();
             LongStream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).count();
             assertEquals(ai.get(), 0);
+
+            LongStream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).parallel().count();
+            assertEquals(ai.get(), 0);
         }
 
         {
             AtomicInteger ai = new AtomicInteger();
             DoubleStream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).count();
             assertEquals(ai.get(), 0);
+
+            DoubleStream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).parallel().count();
+            assertEquals(ai.get(), 0);
         }
     }
 }
--- a/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DistinctOpTest.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DistinctOpTest.java	Sun Mar 29 09:21:15 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -128,7 +128,7 @@
     @Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class)
     public void testDistinctDistinct(String name, TestData.OfRef<Integer> data) {
         Collection<Integer> result = withData(data)
-                .stream(s -> s.distinct().distinct(), new CollectorOps.TestParallelSizedOp<>())
+                .stream(s -> s.distinct().distinct())
                 .exercise();
         assertUnique(result);
     }
--- a/test/java/util/zip/EntryCount64k.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/java/util/zip/EntryCount64k.java	Sun Mar 29 09:21:15 2015 -0400
@@ -24,31 +24,64 @@
 /**
  * @test
  * @summary Test java.util.zip behavior with ~64k entries
+ * @library /lib/testlibrary
  * @run main/othervm EntryCount64k
  * @run main/othervm -Djdk.util.zip.inhibitZip64=true EntryCount64k
  * @run main/othervm -Djdk.util.zip.inhibitZip64=false EntryCount64k
  */
 
 import java.io.*;
+import java.nio.file.Paths;
 import java.util.*;
 import java.util.zip.*;
 
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.ProcessTools;
+
 public class EntryCount64k {
+    public static class Main {
+        public static void main(String[] args) {
+            System.out.println("Main");
+        }
+    }
 
-    public static void main(String[] args) throws Exception {
-        for (int i = (1 << 16) - 2; i < (1 << 16) + 2; i++)
+    static final String mainClass = "EntryCount64k$Main";
+
+    public static void main(String[] args) throws Throwable {
+        for (int i = (1 << 16) - 3; i < (1 << 16) + 2; i++)
             test(i);
     }
 
-    static void test(int entryCount) throws Exception {
+    static void test(int entryCount) throws Throwable {
         File zipFile = new File("EntryCount64k-tmp.zip");
         zipFile.delete();
 
-        try (ZipOutputStream zos =
-             new ZipOutputStream(
-                new BufferedOutputStream(
-                    new FileOutputStream(zipFile)))) {
-            for (int i = 0; i < entryCount; i++) {
+        try (FileOutputStream fos = new FileOutputStream(zipFile);
+             BufferedOutputStream bos = new BufferedOutputStream(fos);
+             ZipOutputStream zos = new ZipOutputStream(bos)) {
+
+            // Add 2 special entries, manifest and main class,
+            // to allow the zip file to be used with "java -jar"
+            ZipEntry man = new ZipEntry("META-INF/MANIFEST.MF");
+            zos.putNextEntry(man);
+            zos.write("Manifest-Version: 1.0\n".getBytes("US-ASCII"));
+            zos.write(("Main-Class: " + mainClass + "\n").getBytes("US-ASCII"));
+            zos.closeEntry();
+
+            String mainName = mainClass + ".class";
+            ZipEntry mainEntry = new ZipEntry(mainName);
+            String testClasses = System.getProperty("test.classes");
+            File mainFile = new File(testClasses, mainName);
+            zos.putNextEntry(mainEntry);
+            try (FileInputStream fis = new FileInputStream(mainFile)) {
+                byte[] buf = new byte[4096];
+                int n;
+                while ((n = fis.read(buf)) > 0)
+                    zos.write(buf, 0, n);
+            }
+            zos.closeEntry();
+
+            for (int i = 2; i < entryCount; i++) {
                 ZipEntry e = new ZipEntry(Integer.toString(i));
                 zos.putNextEntry(e);
                 zos.closeEntry();
@@ -86,16 +119,19 @@
         return false;
     }
 
-    static void checkCanRead(File zipFile, int entryCount) throws Exception {
+    static void checkCanRead(File zipFile, int entryCount) throws Throwable {
         // Check ZipInputStream API
         try (ZipInputStream zis =
              new ZipInputStream(
                  new BufferedInputStream(
                      new FileInputStream(zipFile)))) {
-            for (int i = 0; i < entryCount; i++) {
+            // skip over first two entries
+            for (int i = 0; i < 2; i++)
+                zis.getNextEntry();
+            for (int i = 2; i < entryCount; i++) {
                 ZipEntry e = zis.getNextEntry();
                 if (Integer.parseInt(e.getName()) != i)
-                    throw new AssertionError();
+                    throw new AssertionError(e.getName());
             }
             if (zis.getNextEntry() != null)
                 throw new AssertionError();
@@ -104,7 +140,10 @@
         // Check ZipFile API
         try (ZipFile zf = new ZipFile(zipFile)) {
             Enumeration<? extends ZipEntry> en = zf.entries();
-            for (int i = 0; i < entryCount; i++) {
+            // skip over first two entries
+            for (int i = 0; i < 2; i++)
+                en.nextElement();
+            for (int i = 2; i < entryCount; i++) {
                 ZipEntry e = en.nextElement();
                 if (Integer.parseInt(e.getName()) != i)
                     throw new AssertionError();
@@ -115,5 +154,15 @@
                 || (zf.getEntry(Integer.toString(entryCount)) != null))
                 throw new AssertionError();
         }
+
+        // Check java -jar
+        String javaHome = System.getProperty("java.home");
+        String java = Paths.get(javaHome, "bin", "java").toString();
+        String[] cmd = { java, "-jar", zipFile.getName() };
+        ProcessBuilder pb = new ProcessBuilder(cmd);
+        OutputAnalyzer a = ProcessTools.executeProcess(pb);
+        a.shouldHaveExitValue(0);
+        a.stdoutShouldMatch("\\AMain\n\\Z");
+        a.stderrShouldMatch("\\A\\Z");
     }
 }
--- a/test/javax/net/ssl/FixingJavadocs/ComURLNulls.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/javax/net/ssl/FixingJavadocs/ComURLNulls.java	Sun Mar 29 09:21:15 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -80,7 +80,7 @@
             }
 
             try {
-                urlc.getServerCertificateChain();
+                urlc.getServerCertificates();
             } catch (IllegalStateException e) {
                 System.out.print("Caught proper exception: ");
                 System.out.println(e.getMessage());
--- a/test/javax/net/ssl/TLS/TestJSSE.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/javax/net/ssl/TLS/TestJSSE.java	Sun Mar 29 09:21:15 2015 -0400
@@ -70,6 +70,7 @@
  *        -DCLIENT_PROTOCOL=DEFAULT -Djdk.tls.client.protocols=TLSv1.2
  *        -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
  *        TestJSSE javax.net.ssl.SSLHandshakeException
+ * @key intermittent
  *
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/security/auth/Subject/doAs/NestedActions.java	Sun Mar 29 09:21:15 2015 -0400
@@ -0,0 +1,541 @@
+/*
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.security.AccessControlContext;
+import java.security.AccessControlException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import javax.security.auth.Subject;
+import javax.security.auth.x500.X500Principal;
+import jdk.testlibrary.ProcessTools;
+
+/**
+ * @test
+ * @bug 8048147
+ * @summary Check if proper AccessControlException is thrown
+ *          in case of nested Subject.doAs() invocations
+ *          when one of protection domains doesn't have permissions
+ *
+ * @library /lib/testlibrary
+ *
+ * @run main NestedActions jar NestedActionsACE.jar
+ *              NestedActionsACE.class Utils.class
+ * @run main NestedActions jar NestedActionsPAE.jar
+ *              NestedActionsPAE.class Utils.class
+ * @run main NestedActions jar NestedActionsOnePrincipal.jar
+ *              NestedActionsOnePrincipal.class Utils.class
+ * @run main NestedActions jar NestedActionsTwoPrincipals.jar
+ *              NestedActionsTwoPrincipals.class Utils.class
+ * @run main NestedActions jar WriteToFileAction.jar
+ *              WriteToFileAction.class
+ * @run main NestedActions jar WriteToFileNegativeAction.jar
+ *              WriteToFileNegativeAction.class
+ * @run main NestedActions jar WriteToFileExceptionAction.jar
+ *              WriteToFileExceptionAction.class
+ * @run main NestedActions jar ReadFromFileAction.jar
+ *              ReadFromFileAction.class
+ * @run main NestedActions jar ReadFromFileNegativeAction.jar
+ *              ReadFromFileNegativeAction.class
+ * @run main NestedActions jar ReadFromFileExceptionAction.jar
+ *              ReadFromFileExceptionAction.class
+ * @run main NestedActions jar ReadPropertyAction.jar
+ *              ReadPropertyAction.class
+ * @run main NestedActions jar ReadPropertyNegativeAction.jar
+ *              ReadPropertyNegativeAction.class
+ * @run main NestedActions jar ReadPropertyExceptionAction.jar
+ *              ReadPropertyExceptionAction.class ReadPropertyException.class
+ *
+ * @run main NestedActions NestedActionsACE policy.expect.ace
+ *              NestedActionsACE.jar WriteToFileNegativeAction.jar
+ *              ReadFromFileNegativeAction.jar ReadPropertyNegativeAction.jar
+ * @run main NestedActions NestedActionsPAE policy.expect.pae
+ *              NestedActionsPAE.jar WriteToFileExceptionAction.jar
+ *              ReadFromFileExceptionAction.jar ReadPropertyExceptionAction.jar
+ * @run main NestedActions NestedActionsOnePrincipal policy.one.principal
+ *              NestedActionsOnePrincipal.jar WriteToFileAction.jar
+ *              ReadFromFileAction.jar ReadPropertyAction.jar
+ * @run main NestedActions NestedActionsTwoPrincipals policy.two.principals
+ *              NestedActionsTwoPrincipals.jar WriteToFileAction.jar
+ *              ReadFromFileAction.jar ReadPropertyAction.jar
+ */
+public class NestedActions {
+
+    static final String file = "NestedActions.tmp";
+    static final String PS = System.getProperty("path.separator");
+    static final String FS = System.getProperty("file.separator");
+    static final String TEST_CLASSES = System.getProperty("test.classes");
+    static final String TEST_SOURCES = System.getProperty("test.src");
+    static final String JAVA_OPTS = System.getProperty("test.java.opts");
+    static final String JAVA = System.getProperty("java.home")
+            + FS + "bin" + FS + "java";
+
+    public static void main(String[] args) throws IOException {
+        if (args.length > 0) {
+            if ("jar".equals(args[0]) && args.length > 2) {
+                createJar(args[1],
+                    Arrays.copyOfRange(args, 2, args.length));
+            } else {
+                runJava(args);
+            }
+        } else {
+            throw new RuntimeException("Wrong parameters");
+        }
+    }
+
+    static void createJar(String dest, String... files) throws IOException {
+        System.out.println("Create " + dest + " with the following content:");
+        try (JarOutputStream jos = new JarOutputStream(
+                new FileOutputStream(dest), new Manifest())) {
+            for (String file : files) {
+                System.out.println("  " + file);
+                jos.putNextEntry(new JarEntry(file));
+                try (FileInputStream fis = new FileInputStream(
+                        TEST_CLASSES + FS + file)) {
+                    fis.transferTo(jos);
+                }
+            }
+        }
+    }
+
+    static void runJava(String[] args) {
+        if (args == null || args.length < 3) {
+            throw new IllegalArgumentException("wrong parameters");
+        }
+
+        List<String> cmds = new ArrayList<>();
+        cmds.add(JAVA);
+        StringBuilder sb = new StringBuilder();
+        cmds.add("-classpath");
+        for (int i=2; i<args.length; i++) {
+            sb.append(args[i]).append(PS);
+        }
+        cmds.add(sb.toString());
+        if (JAVA_OPTS != null && !JAVA_OPTS.isEmpty()) {
+            cmds.add(JAVA_OPTS);
+        }
+        cmds.add("-Djava.security.manager");
+        cmds.add("-Djava.security.policy=" + TEST_SOURCES + FS + args[1]);
+        cmds.add(args[0]);
+        try {
+            ProcessTools.executeCommand(cmds.toArray(new String[cmds.size()]))
+                    .shouldHaveExitValue(0);
+        } catch (Throwable e) {
+            throw new RuntimeException(e);
+        }
+    }
+}
+
+/**
+ * Test for nested Subject.doAs() invocation:
+ *
+ * WriteToFileAction (CN=Duke principal) ->
+ *      ReadFromFileAction (CN=Duke principal) ->
+ *          ReadPropertyAction (CN=Duke principal)
+ *
+ * The test expects AccessControllException.
+ */
+class NestedActionsACE {
+
+    public static void main(String args[]) {
+        Subject subject = new Subject();
+        subject.getPrincipals().add(new X500Principal("CN=Duke"));
+        WriteToFileNegativeAction writeToFile
+                = new WriteToFileNegativeAction(NestedActions.file);
+        Subject.doAs(subject, writeToFile);
+    }
+}
+
+/**
+ * Test for nested Subject.doAs() invocation:
+ *
+ * WriteToFileAction (CN=Duke principal) ->
+ *      ReadFromFileAction (CN=Duke principal) ->
+ *          ReadPropertyAction (CN=Duke principal)
+ *
+ * The test expects PrivilegedActionException
+ * that caused by AccessControlEception.
+ */
+class NestedActionsPAE {
+
+    public static void main(String args[]) {
+        Subject subject = new Subject();
+        subject.getPrincipals().add(new X500Principal("CN=Duke"));
+        try {
+            WriteToFileExceptionAction writeToFile =
+                    new WriteToFileExceptionAction(NestedActions.file);
+            Subject.doAs(subject, writeToFile);
+            throw new RuntimeException(
+                    "Test failed: no PrivilegedActionException thrown");
+        } catch (PrivilegedActionException pae) {
+            System.out.println(
+                    "PrivilegedActionException thrown as expected: "
+                    + pae);
+
+            // check if AccessControlException caused PrivilegedActionException
+            Throwable exception = pae.getException();
+            do {
+                if (!(exception instanceof PrivilegedActionException)) {
+                    break;
+                }
+                exception = ((PrivilegedActionException) exception).
+                        getException();
+            } while (true);
+
+            if (!(exception instanceof ReadPropertyException)) {
+                throw new RuntimeException(
+                        "Test failed: PrivilegedActionException "
+                        + "was not caused by ReadPropertyException");
+            }
+
+            exception = exception.getCause();
+            if (!(exception instanceof AccessControlException)) {
+                throw new RuntimeException(
+                        "Test failed: PrivilegedActionException "
+                        + "was not caused by ReadPropertyException");
+            }
+
+            System.out.println(
+                    "Test passed: PrivilegedActionException "
+                    + "was caused by AccessControlException");
+        }
+    }
+}
+
+/**
+ * Test for nested Subject.doAs() invocation:
+ *
+ * WriteToFileAction (CN=Duke principal) ->
+ *      ReadFromFileAction (CN=Duke principal) ->
+ *          ReadPropertyAction (CN=Duke principal)
+ */
+class NestedActionsOnePrincipal {
+
+    public static void main(String args[]) {
+        Subject subject = new Subject();
+        subject.getPrincipals().add(new X500Principal("CN=Duke"));
+        WriteToFileAction writeToFile =
+                new WriteToFileAction(NestedActions.file);
+        Subject.doAs(subject, writeToFile);
+    }
+}
+
+/**
+ * Test for nested Subject.doAs() invocation:
+ *
+ * WriteToFileAction (CN=Duke principal) ->
+ *      ReadFromFileAction (CN=Duke principal) ->
+ *          ReadPropertyAction (CN=Java principal)
+ */
+class NestedActionsTwoPrincipals {
+
+    public static void main(String args[]) {
+        Subject subject = new Subject();
+        subject.getPrincipals().add(new X500Principal("CN=Duke"));
+        Subject anotherSubject = new Subject();
+        anotherSubject.getPrincipals().add(new X500Principal("CN=Java"));
+        ReadFromFileAction readFromFile
+                = new ReadFromFileAction(NestedActions.file, anotherSubject);
+        WriteToFileAction writeToFile
+                = new WriteToFileAction(NestedActions.file, readFromFile);
+        Subject.doAs(subject, writeToFile);
+    }
+}
+
+/**
+ * Helper class.
+ */
+class Utils {
+
+    static void readFile(String filename) {
+        System.out.println("ReadFromFileAction: try to read " + filename);
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        System.out.println("principals = " + subject.getPrincipals());
+        try (FileInputStream fis = new FileInputStream(filename)) {
+            // do nothing
+        } catch (IOException e) {
+            throw new RuntimeException("Unexpected IOException", e);
+        }
+    }
+
+    static void writeFile(String filename) {
+        System.out.println("WriteToFileAction: try to write to " + filename);
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        System.out.println("principals = " + subject.getPrincipals());
+        try (BufferedOutputStream bos = new BufferedOutputStream(
+                new FileOutputStream(filename))) {
+            bos.write(0);
+            bos.flush();
+        } catch (IOException e) {
+            throw new RuntimeException("Unexpected IOException", e);
+        }
+    }
+
+}
+
+class WriteToFileAction implements PrivilegedAction {
+
+    private final String filename;
+    private final PrivilegedAction nextAction;
+
+    WriteToFileAction(String filename, PrivilegedAction nextAction) {
+        this.filename = filename;
+        this.nextAction = nextAction;
+    }
+
+    WriteToFileAction(String filename) {
+        this(filename, new ReadFromFileAction(filename));
+    }
+
+    @Override
+    public Object run() {
+        Utils.writeFile(filename);
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        return Subject.doAs(subject, nextAction);
+    }
+
+}
+
+class ReadFromFileAction implements PrivilegedAction {
+
+    private final String filename;
+    private final Subject anotherSubject;
+
+    ReadFromFileAction(String filename) {
+        this(filename, null);
+    }
+
+    ReadFromFileAction(String filename, Subject anotherSubject) {
+        this.filename = filename;
+        this.anotherSubject = anotherSubject;
+    }
+
+    @Override
+    public Object run() {
+        Utils.readFile(filename);
+
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        ReadPropertyAction readProperty = new ReadPropertyAction();
+        if (anotherSubject != null) {
+            return Subject.doAs(anotherSubject, readProperty);
+        } else {
+            return Subject.doAs(subject, readProperty);
+        }
+    }
+
+}
+
+class ReadPropertyAction implements PrivilegedAction {
+
+    @Override
+    public java.lang.Object run() {
+        System.out.println("ReadPropertyAction: "
+                + "try to read 'java.class.path' property");
+
+        AccessControlContext acc = AccessController.getContext();
+        Subject s = Subject.getSubject(acc);
+        System.out.println("principals = " + s.getPrincipals());
+        System.out.println("java.class.path = "
+                + System.getProperty("java.class.path"));
+
+        return null;
+    }
+
+}
+
+class WriteToFileNegativeAction implements PrivilegedAction {
+
+    private final String filename;
+
+    public WriteToFileNegativeAction(String filename) {
+        this.filename = filename;
+    }
+
+    @Override
+    public Object run() {
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        System.out.println("principals = " + subject.getPrincipals());
+
+        try {
+            Utils.writeFile(filename);
+            new File(filename).delete();
+            throw new RuntimeException(
+                    "Test failed: no AccessControlException thrown");
+        } catch (AccessControlException ace) {
+            System.out.println(
+                    "AccessControlException thrown as expected: "
+                    + ace.getMessage());
+        }
+
+        ReadFromFileNegativeAction readFromFile
+                = new ReadFromFileNegativeAction(filename);
+        return Subject.doAs(subject, readFromFile);
+    }
+
+}
+
+class ReadFromFileNegativeAction implements PrivilegedAction {
+
+    private final String filename;
+
+    public ReadFromFileNegativeAction(String filename) {
+        this.filename = filename;
+    }
+
+    @Override
+    public Object run() {
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        System.out.println("principals = " + subject.getPrincipals());
+
+        try {
+            Utils.readFile(filename);
+            throw new RuntimeException(
+                    "Test failed: no AccessControlException thrown");
+        } catch (AccessControlException ace) {
+            System.out.println(
+                    "AccessControlException thrown as expected: "
+                    + ace.getMessage());
+        }
+
+        ReadPropertyNegativeAction readProperty =
+                new ReadPropertyNegativeAction();
+        return Subject.doAs(subject, readProperty);
+    }
+
+}
+
+class ReadPropertyNegativeAction implements PrivilegedAction {
+
+    @Override
+    public java.lang.Object run() {
+        System.out.println("Try to read 'java.class.path' property");
+
+        AccessControlContext acc = AccessController.getContext();
+        Subject s = Subject.getSubject(acc);
+        System.out.println("principals = " + s.getPrincipals());
+
+        try {
+            System.out.println("java.class.path = "
+                    + System.getProperty("java.class.path"));
+            throw new RuntimeException(
+                    "Test failed: no AccessControlException thrown");
+        } catch (AccessControlException ace) {
+            System.out.println(
+                    "AccessControlException thrown as expected: "
+                    + ace.getMessage());
+        }
+
+        return null;
+    }
+
+}
+
+class WriteToFileExceptionAction implements PrivilegedExceptionAction {
+
+    private final String filename;
+
+    WriteToFileExceptionAction(String filename) {
+        this.filename = filename;
+    }
+
+    @Override
+    public Object run() throws Exception {
+        Utils.writeFile(filename);
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        ReadFromFileExceptionAction readFromFile =
+                new ReadFromFileExceptionAction(filename);
+        return Subject.doAs(subject, readFromFile);
+    }
+
+}
+
+class ReadFromFileExceptionAction implements PrivilegedExceptionAction {
+
+    private final String filename;
+
+    ReadFromFileExceptionAction(String filename) {
+        this.filename = filename;
+    }
+
+    @Override
+    public Object run() throws Exception {
+        Utils.readFile(filename);
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        ReadPropertyExceptionAction readProperty =
+                new ReadPropertyExceptionAction();
+        return Subject.doAs(subject, readProperty);
+    }
+
+}
+
+class ReadPropertyExceptionAction implements PrivilegedExceptionAction {
+
+    @Override
+    public java.lang.Object run() throws Exception {
+        System.out.println("Try to read 'java.class.path' property");
+
+        AccessControlContext acc = AccessController.getContext();
+        Subject s = Subject.getSubject(acc);
+        System.out.println("principals = " + s.getPrincipals());
+
+        try {
+            System.out.println("java.class.path = "
+                    + System.getProperty("java.class.path"));
+            throw new RuntimeException(
+                    "Test failed: no AccessControlException thrown");
+        } catch (AccessControlException ace) {
+            System.out.println(
+                    "AccessControlException thrown as expected: "
+                    + ace.getMessage());
+            throw new ReadPropertyException(ace);
+        }
+    }
+
+}
+
+class ReadPropertyException extends Exception {
+
+    ReadPropertyException(Throwable cause) {
+        super(cause);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/security/auth/Subject/doAs/policy.expect.ace	Sun Mar 29 09:21:15 2015 -0400
@@ -0,0 +1,27 @@
+// this code has limited permissions that should cause ACE
+grant codeBase "file:NestedActionsACE.jar" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "modifyPrincipals";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "path.separator", "read";
+    permission java.util.PropertyPermission "file.separator", "read";
+    permission java.util.PropertyPermission "test.classes", "read";
+    permission java.util.PropertyPermission "test.src", "read";
+    permission java.util.PropertyPermission "test.java.opts", "read";
+    permission java.util.PropertyPermission "java.home", "read";
+};
+
+grant codeBase "file:WriteToFileNegativeAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission java.security.AllPermission;
+};
+
+grant codeBase "file:ReadFromFileNegativeAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission java.security.AllPermission;
+};
+
+grant codeBase "file:ReadPropertyNegativeAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission java.security.AllPermission;
+};
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/security/auth/Subject/doAs/policy.expect.pae	Sun Mar 29 09:21:15 2015 -0400
@@ -0,0 +1,19 @@
+grant codeBase "file:NestedActionsPAE.jar" {
+    permission java.security.AllPermission;
+};
+
+grant codeBase "file:WriteToFileExceptionAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission java.security.AllPermission;
+};
+
+grant codeBase "file:ReadFromFileExceptionAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission java.security.AllPermission;
+};
+
+// this code has limited permissions that should cause ACE
+grant codeBase "file:ReadPropertyExceptionAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission javax.security.auth.AuthPermission "getSubject";
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/security/auth/Subject/doAs/policy.one.principal	Sun Mar 29 09:21:15 2015 -0400
@@ -0,0 +1,36 @@
+grant codeBase "file:NestedActionsOnePrincipal.jar" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "modifyPrincipals";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "path.separator", "read";
+    permission java.util.PropertyPermission "file.separator", "read";
+    permission java.util.PropertyPermission "test.classes", "read";
+    permission java.util.PropertyPermission "test.src", "read";
+    permission java.util.PropertyPermission "test.java.opts", "read";
+    permission java.util.PropertyPermission "java.home", "read";
+    permission java.util.PropertyPermission "java.class.path", "read";
+    permission java.io.FilePermission "NestedActions.tmp", "read,write";
+};
+
+grant codeBase "file:WriteToFileAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "java.class.path", "read";
+    permission java.io.FilePermission "NestedActions.tmp", "read,write";
+};
+
+grant codeBase "file:ReadFromFileAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "java.class.path", "read";
+    permission java.io.FilePermission "NestedActions.tmp", "read";
+};
+
+grant codeBase "file:ReadPropertyAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "java.class.path", "read";
+};
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/security/auth/Subject/doAs/policy.two.principals	Sun Mar 29 09:21:15 2015 -0400
@@ -0,0 +1,37 @@
+grant codeBase "file:NestedActionsTwoPrincipals.jar" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "modifyPrincipals";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "path.separator", "read";
+    permission java.util.PropertyPermission "file.separator", "read";
+    permission java.util.PropertyPermission "test.classes", "read";
+    permission java.util.PropertyPermission "test.src", "read";
+    permission java.util.PropertyPermission "test.java.opts", "read";
+    permission java.util.PropertyPermission "java.home", "read";
+    permission java.util.PropertyPermission "java.class.path", "read";
+    permission java.io.FilePermission "NestedActions.tmp", "read,write,delete";
+};
+
+grant codeBase "file:WriteToFileAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission javax.security.auth.AuthPermission "modifyPrincipals";
+    permission java.util.PropertyPermission "java.class.path", "read";
+    permission java.io.FilePermission "NestedActions.tmp", "read,write";
+};
+
+grant codeBase "file:ReadFromFileAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke"{
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "java.class.path", "read";
+    permission java.io.FilePermission "NestedActions.tmp", "read";
+};
+
+grant codeBase "file:ReadPropertyAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Java" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "java.class.path", "read";
+};
\ No newline at end of file
--- a/test/sun/net/www/protocol/https/NewImpl/ComHTTPSConnection.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/sun/net/www/protocol/https/NewImpl/ComHTTPSConnection.java	Sun Mar 29 09:21:15 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,8 +34,8 @@
 
 import java.io.*;
 import java.net.*;
+import java.security.cert.Certificate;
 import javax.net.ssl.*;
-import javax.security.cert.*;
 import com.sun.net.ssl.HostnameVerifier;
 import com.sun.net.ssl.HttpsURLConnection;
 
@@ -240,8 +240,8 @@
 
                 System.out.println("Cipher Suite: " +
                     ((HttpsURLConnection)urlc).getCipherSuite());
-                X509Certificate[] certs =
-                    ((HttpsURLConnection)urlc).getServerCertificateChain();
+                Certificate[] certs =
+                    ((HttpsURLConnection)urlc).getServerCertificates();
                 for (int i = 0; i < certs.length; i++) {
                     System.out.println(certs[0]);
                 }
--- a/test/sun/security/mscapi/ShortRSAKey1024.sh	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/sun/security/mscapi/ShortRSAKey1024.sh	Sun Mar 29 09:21:15 2015 -0400
@@ -30,6 +30,7 @@
 # @run shell ShortRSAKey1024.sh 1024
 # @run shell ShortRSAKey1024.sh 768
 # @run shell ShortRSAKey1024.sh 512
+# @key intermittent
 
 # set a few environment variables so that the shell-script can run stand-alone
 # in the source directory
--- a/test/sun/security/mscapi/SignUsingNONEwithRSA.sh	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/sun/security/mscapi/SignUsingNONEwithRSA.sh	Sun Mar 29 09:21:15 2015 -0400
@@ -28,6 +28,7 @@
 # @bug 6578658
 # @run shell SignUsingNONEwithRSA.sh
 # @summary Sign using the NONEwithRSA signature algorithm from SunMSCAPI
+# @key intermittent
 
 # set a few environment variables so that the shell-script can run stand-alone
 # in the source directory
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/provider/X509Factory/BadPem.java	Sun Mar 29 09:21:15 2015 -0400
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8074935
+ * @summary jdk8 keytool doesn't validate pem files for RFC 1421 correctness, as jdk7 did
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.security.KeyStore;
+import java.security.cert.CertificateException;
+import java.util.Arrays;
+import java.util.Base64;
+
+import sun.security.provider.X509Factory;
+import java.security.cert.CertificateFactory;
+import java.io.ByteArrayInputStream;
+
+public class BadPem {
+
+    public static void main(String[] args) throws Exception {
+        String ks = System.getProperty("test.src", ".")
+                + "/../../../../javax/net/ssl/etc/keystore";
+        String pass = "passphrase";
+        String alias = "dummy";
+
+        KeyStore keyStore = KeyStore.getInstance("JKS");
+        keyStore.load(new FileInputStream(ks), pass.toCharArray());
+        byte[] cert = keyStore.getCertificate(alias).getEncoded();
+
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        PrintStream pout = new PrintStream(bout);
+        byte[] CRLF = new byte[] {'\r', '\n'};
+        pout.println(X509Factory.BEGIN_CERT);
+        for (int i=0; i<cert.length; i += 48) {
+            int blockLen = (cert.length > i + 48) ? 48 : (cert.length - i);
+            pout.println("!" + Base64.getEncoder()
+                    .encodeToString(Arrays.copyOfRange(cert, i, i + blockLen)));
+        }
+        pout.println(X509Factory.END_CERT);
+
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+        try {
+            cf.generateCertificate(new ByteArrayInputStream(bout.toByteArray()));
+            throw new Exception("Should fail");
+        } catch (CertificateException e) {
+            // Good
+        }
+    }
+}
+
--- a/test/sun/security/tools/keytool/KeyToolTest.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/sun/security/tools/keytool/KeyToolTest.java	Sun Mar 29 09:21:15 2015 -0400
@@ -56,6 +56,8 @@
  * NSS PKCS11 config file are changed, DSA not supported now.
  */
 
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.security.KeyStore;
 import sun.security.x509.*;
 import java.io.*;
@@ -1222,6 +1224,24 @@
         remove("mykey.cert");
     }
 
+    // 8074935: jdk8 keytool doesn't validate pem files for RFC 1421 correctness
+    static void checkPem(String file) throws Exception {
+        boolean maybeLast = false;
+        for (String s: Files.readAllLines(Paths.get(file))) {
+            if (s.isEmpty()) continue;
+            if (s.startsWith("---")) continue;
+            if (maybeLast) {
+                throw new Exception("Last line already seen");
+            }
+            if (s.length() > 64) {
+                throw new Exception(s);
+            }
+            if (s.length() < 64) {
+                maybeLast = true;
+            }
+        }
+    }
+
     void v3extTest(String keyAlg) throws Exception {
         KeyStore ks;
         remove("x.jks");
@@ -1588,12 +1608,14 @@
                 "-rfc -file test.req");
         // printcertreq
         testOK("", "-printcertreq -file test.req");
+        checkPem("test.req");
         // issue: deny KU, change criticality of 1.2.3 and 1.2.4,
         // change content of BC, add 2.3.4
         testOK("", simple+"-gencert -alias ca -infile test.req -ext " +
                 "honored=all,-KU,1.2.3:critical,1.2.4:non-critical " +
                 "-ext BC=2 -ext 2.3.4=01020304 " +
                 "-debug -rfc -outfile test.cert");
+        checkPem("test.cert");
         testOK("", simple+"-importcert -file test.cert -alias a");
         ks = loadStore("x.jks", "changeit", "JKS");
         X509CertImpl a = (X509CertImpl)ks.getCertificate("a");
--- a/test/sun/text/resources/LocaleData	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/sun/text/resources/LocaleData	Sun Mar 29 09:21:15 2015 -0400
@@ -8279,3 +8279,6 @@
 FormatData/fi/DatePatterns/1=d. MMMM yyyy
 FormatData/fi/DatePatterns/2=d.M.yyyy
 FormatData/fi/DatePatterns/3=d.M.yyyy
+
+# bug #8075173
+FormatData/de/standalone.MonthAbbreviations/2=M\u00e4r
--- a/test/sun/text/resources/LocaleDataTest.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/sun/text/resources/LocaleDataTest.java	Sun Mar 29 09:21:15 2015 -0400
@@ -36,7 +36,7 @@
  *      6919624 6998391 7019267 7020960 7025837 7020583 7036905 7066203 7101495
  *      7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509
  *      7114053 7074882 7040556 8013836 8021121 6192407 6931564 8027695 8017142
- *      8037343 8055222 8042126 8074791
+ *      8037343 8055222 8042126 8074791 8075173
  * @summary Verify locale data
  *
  */
--- a/test/sun/tools/jmap/heapconfig/LingeredApp.java	Wed Mar 25 15:22:45 2015 +0000
+++ b/test/sun/tools/jmap/heapconfig/LingeredApp.java	Sun Mar 29 09:21:15 2015 -0400
@@ -417,7 +417,9 @@
                 setLastModified(theLockFileName, epoch());
                 Thread.sleep(spinDelay);
             }
-
+        } catch (NoSuchFileException ex) {
+            // Lock deleted while we are setting last modified time.
+            // Ignore error and lets the app exits
         } catch (Exception ex) {
             System.err.println("LingeredApp ERROR: " + ex);
             // Leave exit_code = 1 to Java launcher