Merge
authorlana
Fri, 16 Jan 2015 12:34:28 -0800
changeset 28432 0b4c78ff36f3
parent 28402 22cd37c4e391 (current diff)
parent 28431 a5c817e7ddb5 (diff)
child 28433 d05684cf69e9
Merge
jdk/test/java/util/logging/AnonLoggerWeakRefLeak.java
jdk/test/java/util/logging/AnonLoggerWeakRefLeak.sh
jdk/test/java/util/logging/LoggerWeakRefLeak.java
jdk/test/java/util/logging/LoggerWeakRefLeak.sh
jdk/test/sun/tools/common/CommonTests.sh
--- a/jdk/src/java.base/share/classes/java/io/BufferedWriter.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/io/BufferedWriter.java	Fri Jan 16 12:34:28 2015 -0800
@@ -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
@@ -73,12 +73,6 @@
     private static int defaultCharBufferSize = 8192;
 
     /**
-     * Line separator string.  This is the value of the line.separator
-     * property at the moment that the stream was created.
-     */
-    private String lineSeparator;
-
-    /**
      * Creates a buffered character-output stream that uses a default-sized
      * output buffer.
      *
@@ -105,9 +99,6 @@
         cb = new char[sz];
         nChars = sz;
         nextChar = 0;
-
-        lineSeparator = java.security.AccessController.doPrivileged(
-            new sun.security.action.GetPropertyAction("line.separator"));
     }
 
     /** Checks to make sure that the stream has not been closed */
@@ -240,7 +231,7 @@
      * @exception  IOException  If an I/O error occurs
      */
     public void newLine() throws IOException {
-        write(lineSeparator);
+        write(System.lineSeparator());
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/io/PrintWriter.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/io/PrintWriter.java	Fri Jan 16 12:34:28 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2012, 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
@@ -69,12 +69,6 @@
     private PrintStream psOut = null;
 
     /**
-     * Line separator string.  This is the value of the line.separator
-     * property at the moment that the stream was created.
-     */
-    private final String lineSeparator;
-
-    /**
      * Returns a charset object for the given charset name.
      * @throws NullPointerException          is csn is null
      * @throws UnsupportedEncodingException  if the charset is not supported
@@ -113,8 +107,6 @@
         super(out);
         this.out = out;
         this.autoFlush = autoFlush;
-        lineSeparator = java.security.AccessController.doPrivileged(
-            new sun.security.action.GetPropertyAction("line.separator"));
     }
 
     /**
@@ -477,7 +469,7 @@
         try {
             synchronized (lock) {
                 ensureOpen();
-                out.write(lineSeparator);
+                out.write(System.lineSeparator());
                 if (autoFlush)
                     out.flush();
             }
--- a/jdk/src/java.base/share/classes/java/lang/String.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/String.java	Fri Jan 16 12:34:28 2015 -0800
@@ -135,7 +135,7 @@
      * unnecessary since Strings are immutable.
      */
     public String() {
-        this.value = new char[0];
+        this.value = "".value;
     }
 
     /**
@@ -175,7 +175,7 @@
      * not affect the newly created string.
      *
      * @param  value
-     *         Array that is the source of characters
+         *         Array that is the source of characters
      *
      * @param  offset
      *         The initial offset
@@ -191,8 +191,14 @@
         if (offset < 0) {
             throw new StringIndexOutOfBoundsException(offset);
         }
-        if (count < 0) {
-            throw new StringIndexOutOfBoundsException(count);
+        if (count <= 0) {
+            if (count < 0) {
+                throw new StringIndexOutOfBoundsException(count);
+            }
+            if (offset <= value.length) {
+                this.value = "".value;
+                return;
+            }
         }
         // Note: offset or count might be near -1>>>1.
         if (offset > value.length - count) {
@@ -233,8 +239,14 @@
         if (offset < 0) {
             throw new StringIndexOutOfBoundsException(offset);
         }
-        if (count < 0) {
-            throw new StringIndexOutOfBoundsException(count);
+        if (count <= 0) {
+            if (count < 0) {
+                throw new StringIndexOutOfBoundsException(count);
+            }
+            if (offset <= codePoints.length) {
+                this.value = "".value;
+                return;
+            }
         }
         // Note: offset or count might be near -1>>>1.
         if (offset > codePoints.length - count) {
@@ -246,11 +258,11 @@
         // Pass 1: Compute precise size of char[]
         int n = count;
         for (int i = offset; i < end; i++) {
-            int c = codePoints[i];
-            if (Character.isBmpCodePoint(c))
-                continue;
-            else if (Character.isValidCodePoint(c))
-                n++;
+        int c = codePoints[i];
+        if (Character.isBmpCodePoint(c))
+            continue;
+        else if (Character.isValidCodePoint(c))
+            n++;
             else throw new IllegalArgumentException(Integer.toString(c));
         }
 
@@ -783,7 +795,7 @@
      * subarray of {@code dst} starting at index {@code dstBegin}
      * and ending at index:
      * <blockquote><pre>
-     *     dstbegin + (srcEnd-srcBegin) - 1
+     *     dstBegin + (srcEnd-srcBegin) - 1
      * </pre></blockquote>
      *
      * @param      srcBegin   index of the first character in the string
@@ -828,7 +840,7 @@
      * dst} starting at index {@code dstBegin} and ending at index:
      *
      * <blockquote><pre>
-     *     dstbegin + (srcEnd-srcBegin) - 1
+     *     dstBegin + (srcEnd-srcBegin) - 1
      * </pre></blockquote>
      *
      * @deprecated  This method does not properly convert characters into
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Executable.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Executable.java	Fri Jan 16 12:34:28 2015 -0800
@@ -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
@@ -588,22 +588,29 @@
         return AnnotationParser.toArray(declaredAnnotations());
     }
 
-    private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
+    private transient volatile Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
 
-    private synchronized  Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
-        if (declaredAnnotations == null) {
-            Executable root = getRoot();
-            if (root != null) {
-                declaredAnnotations = root.declaredAnnotations();
-            } else {
-                declaredAnnotations = AnnotationParser.parseAnnotations(
-                    getAnnotationBytes(),
-                    sun.misc.SharedSecrets.getJavaLangAccess().
-                    getConstantPool(getDeclaringClass()),
-                    getDeclaringClass());
+    private Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
+        Map<Class<? extends Annotation>, Annotation> declAnnos;
+        if ((declAnnos = declaredAnnotations) == null) {
+            synchronized (this) {
+                if ((declAnnos = declaredAnnotations) == null) {
+                    Executable root = getRoot();
+                    if (root != null) {
+                        declAnnos = root.declaredAnnotations();
+                    } else {
+                        declAnnos = AnnotationParser.parseAnnotations(
+                                getAnnotationBytes(),
+                                sun.misc.SharedSecrets.getJavaLangAccess().
+                                        getConstantPool(getDeclaringClass()),
+                                getDeclaringClass()
+                        );
+                    }
+                    declaredAnnotations = declAnnos;
+                }
             }
         }
-        return declaredAnnotations;
+        return declAnnos;
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Field.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Field.java	Fri Jan 16 12:34:28 2015 -0800
@@ -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
@@ -1139,21 +1139,28 @@
         return AnnotationParser.toArray(declaredAnnotations());
     }
 
-    private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
+    private transient volatile Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
 
-    private synchronized  Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
-        if (declaredAnnotations == null) {
-            Field root = this.root;
-            if (root != null) {
-                declaredAnnotations = root.declaredAnnotations();
-            } else {
-                declaredAnnotations = AnnotationParser.parseAnnotations(
-                        annotations,
-                        sun.misc.SharedSecrets.getJavaLangAccess().getConstantPool(getDeclaringClass()),
-                        getDeclaringClass());
+    private Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
+        Map<Class<? extends Annotation>, Annotation> declAnnos;
+        if ((declAnnos = declaredAnnotations) == null) {
+            synchronized (this) {
+                if ((declAnnos = declaredAnnotations) == null) {
+                    Field root = this.root;
+                    if (root != null) {
+                        declAnnos = root.declaredAnnotations();
+                    } else {
+                        declAnnos = AnnotationParser.parseAnnotations(
+                                annotations,
+                                sun.misc.SharedSecrets.getJavaLangAccess()
+                                        .getConstantPool(getDeclaringClass()),
+                                getDeclaringClass());
+                    }
+                    declaredAnnotations = declAnnos;
+                }
             }
         }
-        return declaredAnnotations;
+        return declAnnos;
     }
 
     private native byte[] getTypeAnnotationBytes0();
--- a/jdk/src/java.base/share/classes/java/util/stream/Collectors.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/util/stream/Collectors.java	Fri Jan 16 12:34:28 2015 -0800
@@ -990,7 +990,7 @@
      * function.
      *
      * <p>There are no guarantees on the type, mutability, or serializability
-     * of the {@code Map} or {@code List} objects returned, or of the
+     * of the {@code ConcurrentMap} or {@code List} objects returned, or of the
      * thread-safety of the {@code List} objects returned.
      * @implSpec
      * This produces a result similar to:
@@ -1028,6 +1028,9 @@
      * produces a result of type {@code D}. The resulting collector produces a
      * {@code Map<K, D>}.
      *
+     * <p>There are no guarantees on the type, mutability, or serializability
+     * of the {@code ConcurrentMap} returned.
+     *
      * <p>For example, to compute the set of last names of people in each city,
      * where the city names are sorted:
      * <pre>{@code
@@ -1143,7 +1146,8 @@
      * {@code Map<Boolean, List<T>>}.
      *
      * There are no guarantees on the type, mutability,
-     * serializability, or thread-safety of the {@code Map} returned.
+     * serializability, or thread-safety of the {@code Map} or {@code List}
+     * returned.
      *
      * @param <T> the type of the input elements
      * @param predicate a predicate used for classifying input elements
@@ -1212,6 +1216,9 @@
      * may have duplicates, use {@link #toMap(Function, Function, BinaryOperator)}
      * instead.
      *
+     * <p>There are no guarantees on the type, mutability, serializability,
+     * or thread-safety of the {@code Map} returned.
+     *
      * @apiNote
      * It is common for either the key or the value to be the input elements.
      * In this case, the utility method
@@ -1271,6 +1278,9 @@
      * the value mapping function is applied to each equal element, and the
      * results are merged using the provided merging function.
      *
+     * <p>There are no guarantees on the type, mutability, serializability,
+     * or thread-safety of the {@code Map} returned.
+     *
      * @apiNote
      * There are multiple ways to deal with collisions between multiple elements
      * mapping to the same key.  The other forms of {@code toMap} simply use
@@ -1382,6 +1392,9 @@
      * may have duplicates, use
      * {@link #toConcurrentMap(Function, Function, BinaryOperator)} instead.
      *
+     * <p>There are no guarantees on the type, mutability, or serializability
+     * of the {@code ConcurrentMap} returned.
+     *
      * @apiNote
      * It is common for either the key or the value to be the input elements.
      * In this case, the utility method
@@ -1436,6 +1449,9 @@
      * the value mapping function is applied to each equal element, and the
      * results are merged using the provided merging function.
      *
+     * <p>There are no guarantees on the type, mutability, or serializability
+     * of the {@code ConcurrentMap} returned.
+     *
      * @apiNote
      * There are multiple ways to deal with collisions between multiple elements
      * mapping to the same key.  The other forms of {@code toConcurrentMap} simply use
--- a/jdk/src/java.base/share/classes/sun/security/x509/PolicyConstraintsExtension.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/x509/PolicyConstraintsExtension.java	Fri Jan 16 12:34:28 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -27,9 +27,7 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.security.cert.CertificateException;
 import java.util.Enumeration;
-import java.util.Vector;
 
 import sun.security.util.*;
 
@@ -111,7 +109,7 @@
      */
     public PolicyConstraintsExtension(int require, int inhibit)
     throws IOException {
-        this(Boolean.FALSE, require, inhibit);
+        this(Boolean.TRUE, require, inhibit);
     }
 
     /**
@@ -202,7 +200,7 @@
         DerOutputStream tmp = new DerOutputStream();
         if (extensionValue == null) {
           extensionId = PKIXExtensions.PolicyConstraints_Id;
-          critical = false;
+          critical = true;
           encodeThis();
         }
         super.encode(tmp);
--- a/jdk/src/java.base/share/classes/sun/security/x509/PolicyMappingsExtension.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/src/java.base/share/classes/sun/security/x509/PolicyMappingsExtension.java	Fri Jan 16 12:34:28 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -92,7 +92,7 @@
             throws IOException {
         this.maps = map;
         this.extensionId = PKIXExtensions.PolicyMappings_Id;
-        this.critical = false;
+        this.critical = true;
         encodeThis();
     }
 
@@ -100,8 +100,8 @@
      * Create a default PolicyMappingsExtension.
      */
     public PolicyMappingsExtension() {
-        extensionId = PKIXExtensions.KeyUsage_Id;
-        critical = false;
+        extensionId = PKIXExtensions.PolicyMappings_Id;
+        critical = true;
         maps = new ArrayList<CertificatePolicyMap>();
     }
 
@@ -153,7 +153,7 @@
         DerOutputStream tmp = new DerOutputStream();
         if (extensionValue == null) {
             extensionId = PKIXExtensions.PolicyMappings_Id;
-            critical = false;
+            critical = true;
             encodeThis();
         }
         super.encode(tmp);
--- a/jdk/src/java.base/unix/classes/java/io/FileDescriptor.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/src/java.base/unix/classes/java/io/FileDescriptor.java	Fri Jan 16 12:34:28 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -214,7 +214,7 @@
         if (!closed) {
             closed = true;
             IOException ioe = null;
-            try (Closeable c = releaser) {
+            try (releaser) {
                 if (otherParents != null) {
                     for (Closeable referent : otherParents) {
                         try {
--- a/jdk/src/java.base/windows/classes/java/io/FileDescriptor.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/src/java.base/windows/classes/java/io/FileDescriptor.java	Fri Jan 16 12:34:28 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -212,7 +212,7 @@
         if (!closed) {
             closed = true;
             IOException ioe = null;
-            try (Closeable c = releaser) {
+            try (releaser) {
                 if (otherParents != null) {
                     for (Closeable referent : otherParents) {
                         try {
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapCtx.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapCtx.java	Fri Jan 16 12:34:28 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -224,6 +224,7 @@
     String hostname = null;             // host name of server (no brackets
                                         //   for IPv6 literals)
     LdapClient clnt = null;             // connection handle
+    private boolean reconnect = false;  // indicates that re-connect requested
     Hashtable<String, java.lang.Object> envprops = null; // environment properties of context
     int handleReferrals = DEFAULT_REFERRAL_MODE; // how referral is handled
     boolean hasLdapsScheme = false;     // true if the context was created
@@ -2663,6 +2664,7 @@
         }
 
         sharable = false;  // can't share with existing contexts
+        reconnect = true;
         ensureOpen();      // open or reauthenticated
     }
 
@@ -2739,7 +2741,7 @@
         try {
             boolean initial = (clnt == null);
 
-            if (initial) {
+            if (initial || reconnect) {
                 ldapVersion = (ver != null) ? Integer.parseInt(ver) :
                     DEFAULT_LDAP_VERSION;
 
@@ -2767,6 +2769,7 @@
                     // Required for SASL client identity
                     envprops);
 
+                reconnect = false;
 
                 /**
                  * Pooled connections are preauthenticated;
--- a/jdk/src/java.naming/share/classes/sun/security/provider/certpath/ldap/LDAPCertStore.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/src/java.naming/share/classes/sun/security/provider/certpath/ldap/LDAPCertStore.java	Fri Jan 16 12:34:28 2015 -0800
@@ -37,12 +37,13 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.InitialDirContext;
 
 import java.security.*;
 import java.security.cert.Certificate;
 import java.security.cert.*;
+import javax.naming.CommunicationException;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
 import javax.security.auth.x500.X500Principal;
 
 import sun.misc.HexDumpEncoder;
@@ -160,7 +161,12 @@
     /**
      * The JNDI directory context.
      */
-    private DirContext ctx;
+    private LdapContext ctx;
+
+    /**
+     * Flag indicating that communication error occurred.
+     */
+    private boolean communicationError = false;
 
     /**
      * Flag indicating whether we should prefetch CRLs.
@@ -218,6 +224,11 @@
         certStoreCache = Cache.newSoftMemoryCache(185);
     static synchronized CertStore getInstance(LDAPCertStoreParameters params)
         throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
+        // if necessary, convert params to SunLDAPCertStoreParameters because
+        // LDAPCertStoreParameters does not override equals() and hashCode()
+        if (! (params instanceof SunLDAPCertStoreParameters)) {
+            params = new SunLDAPCertStoreParameters(params.getServerName(), params.getPort());
+        }
         CertStore lcs = certStoreCache.get(params);
         if (lcs == null) {
             lcs = CertStore.getInstance("LDAP", params);
@@ -256,7 +267,7 @@
         }
 
         try {
-            ctx = new InitialDirContext(env);
+            ctx = new InitialLdapContext(env, null);
             /*
              * By default, follow referrals unless application has
              * overridden property in an application resource file.
@@ -369,8 +380,17 @@
             valueMap = new HashMap<>(8);
             String[] attrIds = requestedAttributes.toArray(STRING0);
             Attributes attrs;
+
+            if (communicationError) {
+                ctx.reconnect(null);
+                communicationError = false;
+            }
+
             try {
                 attrs = ctx.getAttributes(name, attrIds);
+            } catch (CommunicationException ce) {
+                communicationError = true;
+                throw ce;
             } catch (NameNotFoundException e) {
                 // name does not exist on this LDAP server
                 // treat same as not attributes found
@@ -884,7 +904,12 @@
         SunLDAPCertStoreParameters() {
             super();
         }
+        @Override
         public boolean equals(Object obj) {
+            if (obj == null) {
+                return false;
+            }
+
             if (!(obj instanceof LDAPCertStoreParameters)) {
                 return false;
             }
@@ -892,6 +917,7 @@
             return (getPort() == params.getPort() &&
                     getServerName().equalsIgnoreCase(params.getServerName()));
         }
+        @Override
         public int hashCode() {
             if (hashCode == 0) {
                 int result = 17;
--- a/jdk/src/jdk.deploy.osx/macosx/classes/apple/security/KeychainStore.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/src/jdk.deploy.osx/macosx/classes/apple/security/KeychainStore.java	Fri Jan 16 12:34:28 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -911,6 +911,7 @@
         return true;
     }
 
+    @SuppressWarnings("deprecation")
     private byte[] fetchPrivateKeyFromBag(byte[] privateKeyInfo) throws IOException, NoSuchAlgorithmException, CertificateException
     {
         byte[] returnValue = null;
@@ -971,6 +972,7 @@
         return returnValue;
     }
 
+    @SuppressWarnings("deprecation")
     private byte[] extractKeyData(DerInputStream stream)
         throws IOException, NoSuchAlgorithmException, CertificateException
     {
--- a/jdk/test/ProblemList.txt	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/ProblemList.txt	Fri Jan 16 12:34:28 2015 -0800
@@ -142,9 +142,6 @@
 # 8058492
 java/lang/management/ThreadMXBean/FindDeadlocks.java                                      generic-all
 
-# 8058506
-java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java                              generic-all
-
 ############################################################################
 
 # jdk_jmx
--- a/jdk/test/TEST.groups	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/TEST.groups	Fri Jan 16 12:34:28 2015 -0800
@@ -421,8 +421,7 @@
   java/util/Collections/EmptyIterator.java \
   java/util/concurrent/locks/Lock/TimedAcquireLeak.java \
   java/util/jar/JarInputStream/ExtraFileInMetaInf.java \
-  java/util/logging/AnonLoggerWeakRefLeak.sh \
-  java/util/logging/LoggerWeakRefLeak.sh \
+  java/util/logging/TestLoggerWeakRefLeak.java \
   java/util/zip/3GBZipFiles.sh \
   jdk/lambda/FDTest.java \
   jdk/lambda/separate/Compiler.java \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/crypto/provider/Mac/EmptyByteBufferTest.java	Fri Jan 16 12:34:28 2015 -0800
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.nio.ByteBuffer;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+
+/**
+ * @test
+ * @bug 8048603
+ * @summary Checks if MAC algorithms work fine with empty buffer
+ * @author Alexander Fomin
+ * @build Utils
+ * @run main EmptyByteBufferTest
+ */
+public class EmptyByteBufferTest implements MacTest {
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) {
+        Utils.runTests(new EmptyByteBufferTest());
+    }
+
+    @Override
+    public void doTest(String alg) throws NoSuchAlgorithmException,
+            InvalidKeyException, NoSuchProviderException {
+        SecretKey key = Utils.getSecretKeySpec();
+
+        // instantiate Mac object and init it with a SecretKey
+        Mac mac = Mac.getInstance(alg, "SunJCE");
+        mac.init(key);
+
+        // prepare buffer
+        byte[] data = new byte[0];
+        ByteBuffer buf = ByteBuffer.wrap(data);
+
+        mac.update(buf);
+        mac.doFinal();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/crypto/provider/Mac/LargeByteBufferTest.java	Fri Jan 16 12:34:28 2015 -0800
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.nio.ByteBuffer;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+
+/**
+ * @test
+ * @bug 8048603
+ * @summary Checks if PBE algorithms work fine with large buffer
+ * @author Alexander Fomin
+ * @build Utils
+ * @run main LargeByteBufferTest
+ */
+public class LargeByteBufferTest implements MacTest {
+
+    private static final int BUFFER_SIZE = 65535;
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) {
+        Utils.runTests(new LargeByteBufferTest());
+    }
+
+    @Override
+    public void doTest(String alg) throws NoSuchAlgorithmException,
+            InvalidKeyException, NoSuchProviderException {
+        SecretKey key = Utils.getSecretKeySpec();
+
+        // instantiate Mac object and init it with a SecretKey
+        Mac mac = Mac.getInstance(alg, "SunJCE");
+        mac.init(key);
+
+        // prepare buffer
+        byte[] data = new byte[BUFFER_SIZE];
+        for (int i = 0; i < BUFFER_SIZE; i++) {
+            data[i] = (byte) (i % 256);
+        }
+
+        ByteBuffer buf = ByteBuffer.wrap(data);
+        int limitBefore = buf.limit();
+
+        mac.update(buf);
+        mac.doFinal();
+
+        int limitAfter = buf.limit();
+        int positonAfter = buf.position();
+
+        if (limitAfter != limitBefore) {
+            System.out.println("limit after = " + limitAfter);
+            System.out.println("limit before = " + limitBefore);
+            throw new RuntimeException("Test failed: "
+                    + "limit of buffer has been chenged.");
+        }
+
+        if (positonAfter != limitAfter) {
+            System.out.println("position after = " + positonAfter);
+            System.out.println("limit after = " + limitAfter);
+            throw new RuntimeException("Test failed: "
+                    + "position of buffer isn't equal to its limit");
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/crypto/provider/Mac/MacSameTest.java	Fri Jan 16 12:34:28 2015 -0800
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.SecureRandom;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+
+/**
+ * @test
+ * @bug 8048603
+ * @summary Check if doFinal and update operation result in same Mac
+ * @author Yu-Ching Valerie Peng, Bill Situ, Alexander Fomin
+ * @build Utils
+ * @run main MacSameTest
+ */
+public class MacSameTest implements MacTest {
+
+    private static final int MESSAGE_SIZE = 25;
+    private static final int OFFSET = 5;
+    private static final int KEY_SIZE = 70;
+
+    /**
+     * Initialize a message, instantiate a Mac object,
+     * initialize the object with a SecretKey,
+     * feed the message into the Mac object
+     * all at once and get the output MAC as result1.
+     * Reset the Mac object, chop the message into three pieces,
+     * feed into the Mac object sequentially, and get the output MAC as result2.
+     * Finally, compare result1 and result2 and see if they are the same.
+     *
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) {
+        Utils.runTests(new MacSameTest());
+    }
+
+    @Override
+    public void doTest(String algo) throws NoSuchAlgorithmException,
+            NoSuchProviderException, InvalidKeyException {
+        Mac mac;
+        try {
+            mac = Mac.getInstance(algo, "SunJCE");
+        } catch (NoSuchAlgorithmException nsae) {
+            // depending on Solaris configuration,
+            // it can support HMAC or not with Mac
+            System.out.println("Expected NoSuchAlgorithmException thrown: "
+                    + nsae);
+            return;
+        }
+
+        byte[] plain = new byte[MESSAGE_SIZE];
+        for (int i = 0; i < MESSAGE_SIZE; i++) {
+            plain[i] = (byte) (i % 256);
+        }
+
+        byte[] tail = new byte[plain.length - OFFSET];
+        System.arraycopy(plain, OFFSET, tail, 0, tail.length);
+
+        SecureRandom srdm = new SecureRandom();
+        byte[] keyVal = new byte[KEY_SIZE];
+        srdm.nextBytes(keyVal);
+        SecretKeySpec keySpec = new SecretKeySpec(keyVal, "HMAC");
+
+        mac.init(keySpec);
+        byte[] result1 = mac.doFinal(plain);
+
+        mac.reset();
+        mac.update(plain[0]);
+        mac.update(plain, 1, OFFSET - 1);
+        byte[] result2 = mac.doFinal(tail);
+
+        if (!java.util.Arrays.equals(result1, result2)) {
+            throw new RuntimeException("result1 and result2 are not the same");
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/crypto/provider/Mac/NullByteBufferTest.java	Fri Jan 16 12:34:28 2015 -0800
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.nio.ByteBuffer;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+
+/**
+ * @test
+ * @bug 8048603
+ * @summary Checks if PBE algorithms work fine with null buffer
+ * @author Alexander Fomin
+ * @build Utils
+ * @run main NullByteBufferTest
+ */
+public class NullByteBufferTest implements MacTest {
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) {
+        Utils.runTests(new NullByteBufferTest());
+    }
+
+    @Override
+    public void doTest(String alg) throws NoSuchAlgorithmException,
+            InvalidKeyException, NoSuchProviderException {
+        SecretKey key = Utils.getSecretKeySpec();
+
+        // instantiate Mac object and init it with a SecretKey
+        Mac mac = Mac.getInstance(alg, "SunJCE");
+        mac.init(key);
+
+        try {
+            ByteBuffer buf = null;
+            mac.update(buf);
+            mac.doFinal();
+            throw new RuntimeException(
+                    "Expected IllegalArgumentException not thrown");
+        } catch (IllegalArgumentException e) {
+            System.out.println("Expected IllegalArgumentException thrown: "
+                    + e);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/crypto/provider/Mac/Utils.java	Fri Jan 16 12:34:28 2015 -0800
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.security.SecureRandom;
+import javax.crypto.spec.SecretKeySpec;
+
+/**
+ * Helper class.
+ */
+class Utils {
+
+    static final int KEY_SIZE = 70;
+
+    static final String[] MAC_ALGOS = {"HmacMD5", "HmacSHA1", "HmacSHA224",
+        "HmacSHA256", "HmacSHA384", "HmacSHA512"};
+
+    /**
+     * Get SecretKeySpec.
+     */
+    static SecretKeySpec getSecretKeySpec() {
+        SecureRandom srdm = new SecureRandom();
+        byte[] keyVal = new byte[KEY_SIZE];
+        srdm.nextBytes(keyVal);
+        return new SecretKeySpec(keyVal, "HMAC");
+    }
+
+    static void runTests(MacTest... tests) {
+        boolean success = true;
+        for (MacTest test : tests) {
+            success &= runTest(test);
+        }
+
+        if (success) {
+            System.out.println("Test passed");
+        } else {
+            throw new RuntimeException("Test failed");
+        }
+    }
+
+    private static boolean runTest(MacTest test) {
+        boolean success = true;
+        for (String alg : MAC_ALGOS) {
+            try {
+                System.out.println("Test " + alg);
+                test.doTest(alg);
+            } catch (Exception e) {
+                System.out.println("Unexpected exception:");
+                e.printStackTrace();
+                success = false;
+            }
+        }
+
+        return success;
+    }
+}
+
+interface MacTest {
+    void doTest(String alg) throws Exception;
+}
\ No newline at end of file
--- a/jdk/test/java/lang/instrument/IsModifiableClassAgent.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/java/lang/instrument/IsModifiableClassAgent.java	Fri Jan 16 12:34:28 2015 -0800
@@ -23,6 +23,7 @@
 
 /**
  * @test
+ * @ignore JDK-8068162
  * @bug 6331574
  * @summary test isModifiableClass
  * @author Robert Field, Sun Microsystems
--- a/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java	Fri Jan 16 12:34:28 2015 -0800
@@ -30,11 +30,13 @@
  * @build TestMethods
  * @build LambdaFormTestCase
  * @build LFGarbageCollectedTest
- * @run main/othervm LFGarbageCollectedTest
+ * @run main/othervm -Xmx64m -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+HeapDumpOnOutOfMemoryError -DHEAP_DUMP=false LFGarbageCollectedTest
  */
 
 import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodType;
 import java.lang.ref.PhantomReference;
+import java.lang.ref.Reference;
 import java.lang.ref.ReferenceQueue;
 import java.lang.reflect.InvocationTargetException;
 import java.util.EnumSet;
@@ -44,6 +46,7 @@
  * Lambda forms garbage collection test class.
  */
 public final class LFGarbageCollectedTest extends LambdaFormTestCase {
+    private static boolean HEAP_DUMP = Boolean.getBoolean("HEAP_DUMP");
 
     /**
      * Constructor for a lambda forms garbage collection test case.
@@ -55,37 +58,86 @@
         super(testMethod);
     }
 
+    PhantomReference ph;
+    ReferenceQueue rq = new ReferenceQueue();
+    MethodType mtype;
+    Map<String, Object> data;
+
     @Override
     public void doTest() {
         try {
-            Map<String, Object> data = getTestMethod().getTestCaseData();
+            TestMethods testCase = getTestMethod();
+            data = testCase.getTestCaseData();
             MethodHandle adapter;
             try {
-                adapter = getTestMethod().getTestCaseMH(data, TestMethods.Kind.ONE);
+                adapter = testCase.getTestCaseMH(data, TestMethods.Kind.ONE);
             } catch (NoSuchMethodException ex) {
                 throw new Error("Unexpected exception: ", ex);
             }
-            Object lambdaForm = LambdaFormTestCase.INTERNAL_FORM.invoke(adapter);
+            mtype = adapter.type();
+            Object lambdaForm = INTERNAL_FORM.invoke(adapter);
             if (lambdaForm == null) {
                 throw new Error("Unexpected error: Lambda form of the method handle is null");
             }
-            ReferenceQueue rq = new ReferenceQueue();
-            PhantomReference ph = new PhantomReference(lambdaForm, rq);
+
+            String debugName = (String)DEBUG_NAME.get(lambdaForm);
+            if (debugName != null && debugName.startsWith("identity_")) {
+                // Ignore identity_* LambdaForms.
+                return;
+            }
+
+            ph = new PhantomReference(lambdaForm, rq);
             lambdaForm = null;
-            data = null;
             adapter = null;
-            for (int i = 0; i < 1000 && !ph.isEnqueued(); i++) {
-                System.gc();
-            }
-            if (!ph.isEnqueued()) {
-                throw new AssertionError("Error: Lambda form is not garbage collected");
-            }
+
+            collectLambdaForm();
         } catch (IllegalAccessException | IllegalArgumentException |
                 InvocationTargetException ex) {
             throw new Error("Unexpected exception: ", ex);
         }
     }
 
+
+    private void collectLambdaForm() throws IllegalAccessException {
+        // Usually, 2 System.GCs are necessary to enqueue a SoftReference.
+        System.gc();
+        System.gc();
+
+        Reference ref = null;
+        for (int i = 0; i < 10; i++) {
+            try {
+                ref = rq.remove(1000);
+            } catch (InterruptedException e) {
+                /* ignore */
+            }
+            if (ref != null) {
+                break;
+            }
+            System.gc(); // If the reference hasn't been queued yet, trigger one more GC.
+        }
+
+        if (ref == null) {
+            dumpTestData();
+            System.err.println("Method type: " + mtype);
+            System.err.println("LambdaForm:  " + REF_FIELD.get(ph));
+
+            if (HEAP_DUMP) {
+                // Trigger OOM to force heap dump for post-mortem analysis.
+                val = new long[1_000_000_000];
+            }
+            throw new AssertionError("Error: LambdaForm is not garbage collected");
+        };
+    }
+
+    private void dumpTestData() {
+        System.err.println("Test case: " + getTestMethod());
+        for (String s : data.keySet()) {
+            System.err.printf("\t%20s => %s\n", s, data.get(s));
+        }
+    }
+
+    private static long[] val;
+
     /**
      * Main routine for lambda forms garbage collection test.
      *
@@ -101,7 +153,9 @@
                 TestMethods.IDENTITY,
                 TestMethods.CONSTANT,
                 TestMethods.ARRAY_ELEMENT_GETTER,
-                TestMethods.ARRAY_ELEMENT_SETTER));
+                TestMethods.ARRAY_ELEMENT_SETTER,
+                TestMethods.EXACT_INVOKER,
+                TestMethods.INVOKER));
         LambdaFormTestCase.runTests(LFGarbageCollectedTest::new, testMethods);
     }
 }
--- a/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java	Fri Jan 16 12:34:28 2015 -0800
@@ -23,9 +23,11 @@
 
 import com.oracle.testlibrary.jsr292.Helper;
 import com.sun.management.HotSpotDiagnosticMXBean;
-
+import java.lang.invoke.MethodHandle;
 import java.lang.management.GarbageCollectorMXBean;
 import java.lang.management.ManagementFactory;
+import java.lang.ref.Reference;
+import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.Collection;
 import java.util.List;
@@ -42,8 +44,6 @@
  */
 public abstract class LambdaFormTestCase {
 
-    private final static String METHOD_HANDLE_CLASS_NAME = "java.lang.invoke.MethodHandle";
-    private final static String INTERNAL_FORM_METHOD_NAME = "internalForm";
     private static final double ITERATIONS_TO_CODE_CACHE_SIZE_RATIO
             = 45 / (128.0 * 1024 * 1024);
     private static final long TIMEOUT = Helper.IS_THOROUGH ? 0L : (long) (Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT) * 0.9);
@@ -53,6 +53,8 @@
      * used to get a lambda form from a method handle.
      */
     protected final static Method INTERNAL_FORM;
+    protected final static Field DEBUG_NAME;
+    protected final static Field REF_FIELD;
     private static final List<GarbageCollectorMXBean> gcInfo;
 
     private static long gcCount() {
@@ -61,9 +63,14 @@
 
     static {
         try {
-            Class mhClass = Class.forName(METHOD_HANDLE_CLASS_NAME);
-            INTERNAL_FORM = mhClass.getDeclaredMethod(INTERNAL_FORM_METHOD_NAME);
+            INTERNAL_FORM = MethodHandle.class.getDeclaredMethod("internalForm");
             INTERNAL_FORM.setAccessible(true);
+
+            DEBUG_NAME = Class.forName("java.lang.invoke.LambdaForm").getDeclaredField("debugName");
+            DEBUG_NAME.setAccessible(true);
+
+            REF_FIELD = Reference.class.getDeclaredField("referent");
+            REF_FIELD.setAccessible(true);
         } catch (Exception ex) {
             throw new Error("Unexpected exception: ", ex);
         }
@@ -138,6 +145,10 @@
                             testCase.getTestMethod().name);
                     testCase.doTest();
                     System.err.println("PASSED");
+                } catch (OutOfMemoryError e) {
+                    // Don't swallow OOME so a heap dump can be created.
+                    System.err.println("FAILED");
+                    throw e;
                 } catch (Throwable t) {
                     t.printStackTrace();
                     System.err.printf("FAILED. Caused by %s%n", t.getMessage());
--- a/jdk/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java	Fri Jan 16 12:34:28 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
  *
  * @library /lib/testlibrary/
  * @build jdk.testlibrary.* CollectionUsageThreshold MemoryUtil RunUtil
+ * @requires vm.opt.ExplicitGCInvokesConcurrent == "false" | vm.opt.ExplicitGCInvokesConcurrent == "null"
  * @run main/timeout=300 CollectionUsageThreshold
  */
 
--- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java	Fri Jan 16 12:34:28 2015 -0800
@@ -32,6 +32,7 @@
  *
  * @library /lib/testlibrary/
  * @build jdk.testlibrary.* LowMemoryTest MemoryUtil RunUtil
+ * @requires vm.opt.ExplicitGCInvokesConcurrent == "false" | vm.opt.ExplicitGCInvokesConcurrent == "null"
  * @run main/timeout=600 LowMemoryTest
  */
 
--- a/jdk/test/java/net/DatagramSocket/InheritHandle.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/java/net/DatagramSocket/InheritHandle.java	Fri Jan 16 12:34:28 2015 -0800
@@ -22,27 +22,51 @@
  */
 
 /* @test
- * @bug 4945514
+ * @bug 4945514 8042581
  * @summary DatagramSocket should make handle not inherited
  */
 
-import java.net.*;
+import java.net.BindException;
+import java.net.DatagramSocket;
+import java.net.InetSocketAddress;
 
 public class InheritHandle {
+    private static final long SLEEPTIME_MS = 1000L;
+
     public static void main(String[] args) throws Exception {
-        DatagramSocket sock = new DatagramSocket (0);
-        sock.setReuseAddress(true);
-        int port = sock.getLocalPort();
+        int port;
+        try (DatagramSocket sock = new DatagramSocket(0);) {
+            sock.setReuseAddress(true);
+            port = sock.getLocalPort();
+
+            /**
+             * spawn a child to check whether handle passed to it or not; it
+             * shouldn't
+             */
+            Runtime.getRuntime().exec("sleep 10");
+        }
 
-        /**
-         * spawn a child to check whether handle passed to it or not;
-         * it shouldn't
-         */
-        Runtime.getRuntime().exec ("sleep 10");
+        try (DatagramSocket sock = new DatagramSocket(null);) {
+            sock.setReuseAddress(true);
+            int retries = 0;
+            boolean isWindows = System.getProperty("os.name").startsWith("Windows");
+            InetSocketAddress addr = new InetSocketAddress(port);
+            while (true) {
+                try {
+                    sock.bind(addr);
+                    break;
+                } catch (BindException e) {
+                    if (isWindows && retries++ < 5) {
+                        Thread.sleep(SLEEPTIME_MS);
+                        System.out.println("BindException \"" + e.getMessage() + "\", retrying...");
+                        continue;
+                    } else {
+                        throw e;
+                    }
+                }
+            }
 
-        sock.close();
-        sock = new DatagramSocket (null);
-        sock.setReuseAddress(true);
-        sock.bind(new InetSocketAddress(port));
+        }
     }
 }
+
--- a/jdk/test/java/util/logging/AnonLoggerWeakRefLeak.java	Thu Jan 15 13:09:48 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2010, 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.util.logging.*;
-
-public class AnonLoggerWeakRefLeak extends SimpleApplication {
-    // The test driver script will allow this program to run until we
-    // reach DEFAULT_LOOP_TIME or a decrease in instance counts is
-    // observed. For this particular WeakReference leak, the count
-    // was always observed to be increasing so if we get a decreasing
-    // count, then the leak is fixed in the bits being tested.
-    // Two minutes has been enough time to observe a decrease in
-    // fixed bits on overloaded systems, but the test will likely
-    // finish more quickly.
-    public static int DEFAULT_LOOP_TIME = 120;  // time is in seconds
-
-    // execute the AnonLoggerWeakRefLeak app work
-    public void doMyAppWork(String[] args) throws Exception {
-        int loop_time = 0;
-        int max_loop_time = DEFAULT_LOOP_TIME;
-
-        // args[0] is the port-file
-        if (args.length < 2) {
-            System.out.println("INFO: using default time of "
-                + max_loop_time + " seconds.");
-        } else {
-            try {
-                max_loop_time = Integer.parseInt(args[1]);
-            } catch (NumberFormatException nfe) {
-                throw new RuntimeException("Error: '" + args[1]
-                    + "': is not a valid seconds value.");
-            }
-        }
-
-        long count = 0;
-        long now = 0;
-        long startTime = System.currentTimeMillis();
-
-        while (now < (startTime + (max_loop_time * 1000))) {
-            if ((count % 1000) == 0) {
-                // Print initial call count to let caller know that
-                // we're up and running and then periodically
-                System.out.println("INFO: call count = " + count);
-            }
-
-            for (int i = 0; i < 100; i++) {
-                // this Logger call is leaking a WeakReference in Logger.kids
-                java.util.logging.Logger.getAnonymousLogger();
-                count++;
-            }
-
-            try {
-                // delay for 1/10 of a second to avoid CPU saturation
-                Thread.sleep(100);
-            } catch (InterruptedException ie) {
-                // ignore any exceptions
-            }
-
-            now = System.currentTimeMillis();
-        }
-
-        System.out.println("INFO: final loop count = " + count);
-    }
-
-    public static void main(String[] args) throws Exception {
-        AnonLoggerWeakRefLeak myApp = new AnonLoggerWeakRefLeak();
-
-        SimpleApplication.setMyApp(myApp);
-
-        SimpleApplication.main(args);
-    }
-}
--- a/jdk/test/java/util/logging/AnonLoggerWeakRefLeak.sh	Thu Jan 15 13:09:48 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,254 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2010, 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 6942989
-# @summary Check for WeakReference leak in anonymous Logger objects
-# @author Daniel D. Daugherty
-#
-# @library ../../../sun/tools/common
-# @build SimpleApplication ShutdownSimpleApplication
-# @build AnonLoggerWeakRefLeak
-# @run shell/timeout=240 AnonLoggerWeakRefLeak.sh
-
-# The timeout is: 2 minutes for infrastructure and 2 minutes for the test
-#
-
-. ${TESTSRC}/../../../sun/tools/common/CommonSetup.sh
-. ${TESTSRC}/../../../sun/tools/common/ApplicationSetup.sh
-
-
-TEST_NAME="AnonLoggerWeakRefLeak"
-TARGET_CLASS="java\.lang\.ref\.WeakReference"
-
-
-# MAIN begins here
-#
-
-seconds=
-if [ "$#" -gt 0 ]; then
-    seconds="$1"
-fi
-
-# see if this version of jmap supports the '-histo:live' option
-jmap_option="-histo:live"
-set +e
-"${JMAP}" 2>&1 | grep ':live' > /dev/null 2>&1
-status="$?"
-set -e
-if [ "$status" != 0 ]; then
-    # usage message doesn't show ':live' option
-
-    if $isWindows; then
-        # If SA isn't present, then jmap gives a different usage message
-        # that doesn't show the ':live' option. However, that's a bug that
-        # is covered by 6971851 so we try using the option just to be sure.
-        # For some reason, this problem has only been seen on OpenJDK6 on
-        # Windows. Not sure why.
-        set +e
-        # Note: Don't copy this code to try probing process 0 on Linux; it
-        # will kill the process group in strange ways.
-        "${JMAP}" "$jmap_option" 0 2>&1 | grep 'Usage' > /dev/null 2>&1
-        status="$?"
-        set -e
-        if [ "$status" = 0 ]; then
-            # Usage message generated so flag the problem.
-            status=1
-        else
-            # No usage message so clear the flag.
-            status=0
-        fi
-    fi
-
-    if [ "$status" != 0 ]; then
-        echo "WARNING: 'jmap $jmap_option' is not supported on this platform"
-        echo "WARNING: so this test cannot work reliably. Aborting!"
-        exit 0
-    fi
-fi
-
-# Start application and use TEST_NAME.port for coordination
-startApplication "$TEST_NAME" "$TEST_NAME.port" $seconds
-
-finished_early=false
-
-decreasing_cnt=0
-increasing_cnt=0
-loop_cnt=0
-prev_instance_cnt=0
-
-MAX_JMAP_TRY_CNT=10
-jmap_retry_cnt=0
-loop_cnt_on_retry=0
-
-while true; do
-    # see if the target process has finished its run and bail if it has
-    set +e
-    grep "^INFO: final loop count = " "$appOutput" > /dev/null 2>&1
-    status="$?"
-    set -e
-    if [ "$status" = 0 ]; then
-        break
-    fi
-
-    # Output format for 'jmap -histo' in JDK1.5.0:
-    #
-    #     <#bytes> <#instances> <class_name>
-    #
-    # Output format for 'jmap -histo:live':
-    #
-    #     <num>: <#instances> <#bytes> <class_name>
-    #
-    set +e
-    "${JMAP}" "$jmap_option" "$appJavaPid" > "$TEST_NAME.jmap" 2>&1
-    status="$?"
-    set -e
-
-    if [ "$status" != 0 ]; then
-        echo "INFO: jmap exited with exit code = $status"
-
-        # There are intermittent jmap failures; see 6498448.
-        #
-        # So far the following have been observed in a jmap call
-        # that was not in a race with target process termination:
-        #
-        # (Solaris specific, 2nd sample)
-        # <pid>: Unable to open door: target process not responding or HotSpot VM not loaded
-        # The -F option can be used when the target process is not responding
-        #
-        # (on Solaris so far)
-        # java.io.IOException
-        #
-        # (on Solaris so far, 1st sample)
-        # <pid>: Permission denied
-        #
-        sed 's/^/INFO: /' "$TEST_NAME.jmap"
-
-        if [ "$loop_cnt" = "$loop_cnt_on_retry" ]; then
-            # loop count hasn't changed
-            jmap_retry_cnt=`expr $jmap_retry_cnt + 1`
-        else
-            # loop count has changed so remember it
-            jmap_retry_cnt=1
-            loop_cnt_on_retry="$loop_cnt"
-        fi
-
-        # This is '-ge' because we have the original attempt plus
-        # MAX_JMAP_TRY_CNT - 1 retries.
-        if [ "$jmap_retry_cnt" -ge "$MAX_JMAP_TRY_CNT" ]; then
-            echo "INFO: jmap failed $MAX_JMAP_TRY_CNT times in a row" \
-                "without making any progress."
-            echo "FAIL: jmap is unable to take any samples." >&2
-            killApplication
-            exit 2
-        fi
-
-        # short delay and try again
-        # Note: sleep 1 didn't help with "<pid>: Permission denied"
-        sleep 2
-        echo "INFO: retrying jmap (retry=$jmap_retry_cnt, loop=$loop_cnt)."
-        continue
-    fi
-
-    set +e
-    instance_cnt=`grep "${PATTERN_WS}${TARGET_CLASS}${PATTERN_EOL}" \
-        "$TEST_NAME.jmap" \
-        | sed '
-            # strip leading whitespace; does nothing in JDK1.5.0
-            s/^'"${PATTERN_WS}${PATTERN_WS}"'*//
-            # strip <#bytes> in JDK1.5.0; does nothing otherwise
-            s/^[1-9][0-9]*'"${PATTERN_WS}${PATTERN_WS}"'*//
-            # strip <num>: field; does nothing in JDK1.5.0
-            s/^[1-9][0-9]*:'"${PATTERN_WS}${PATTERN_WS}"'*//
-            # strip <class_name> field
-            s/'"${PATTERN_WS}"'.*//
-            '`
-    set -e
-    if [ -z "$instance_cnt" ]; then
-        echo "INFO: instance count is unexpectedly empty"
-        if [ "$loop_cnt" = 0 ]; then
-            echo "INFO: on the first iteration so no sample was found."
-            echo "INFO: There is likely a problem with the sed filter."
-            echo "INFO: start of jmap output:"
-            cat "$TEST_NAME.jmap"
-            echo "INFO: end of jmap output."
-            echo "FAIL: cannot find the instance count value." >&2
-            killApplication
-            exit 2
-        fi
-    else
-        echo "INFO: instance_cnt = $instance_cnt"
-
-        if [ "$instance_cnt" -gt "$prev_instance_cnt" ]; then
-            increasing_cnt=`expr $increasing_cnt + 1`
-        else
-            # actually decreasing or the same
-            decreasing_cnt=`expr $decreasing_cnt + 1`
-
-            # For this particular WeakReference leak, the count was
-            # always observed to be increasing so if we get a decreasing
-            # or the same count, then the leak is fixed in the bits
-            # being tested.
-            echo "INFO: finishing early due to non-increasing instance count."
-            finished_early=true
-            killApplication
-            break
-        fi
-        prev_instance_cnt="$instance_cnt"
-    fi
-
-    # delay between samples
-    sleep 5
-
-    loop_cnt=`expr $loop_cnt + 1`
-done
-
-if [ $finished_early = false ]; then
-    stopApplication "$TEST_NAME.port"
-    waitForApplication
-fi
-
-echo "INFO: $TEST_NAME has finished running."
-echo "INFO: increasing_cnt = $increasing_cnt"
-echo "INFO: decreasing_cnt = $decreasing_cnt"
-if [ "$jmap_retry_cnt" -gt 0 ]; then
-    echo "INFO: jmap_retry_cnt = $jmap_retry_cnt (in $loop_cnt iterations)"
-fi
-
-if [ "$loop_cnt" = 0 ]; then
-    echo "FAIL: jmap is unable to take any samples." >&2
-    exit 2
-fi
-
-echo "INFO: The instance count of" `eval echo $TARGET_CLASS` "objects"
-if [ "$decreasing_cnt" = 0 ]; then
-    echo "INFO: is always increasing."
-    echo "FAIL: This indicates that there is a memory leak." >&2
-    exit 2
-fi
-
-echo "INFO: is not always increasing."
-echo "PASS: This indicates that there is not a memory leak."
-exit 0
--- a/jdk/test/java/util/logging/LoggerWeakRefLeak.java	Thu Jan 15 13:09:48 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2010, 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.util.logging.*;
-
-public class LoggerWeakRefLeak extends SimpleApplication {
-    // The test driver script will allow this program to run until we
-    // reach DEFAULT_LOOP_TIME or a decrease in instance counts is
-    // observed. For these particular WeakReference leaks, the count
-    // was always observed to be increasing so if we get a decreasing
-    // count, then the leaks are fixed in the bits being tested.
-    // Two minutes has been enough time to observe a decrease in
-    // fixed bits on overloaded systems, but the test will likely
-    // finish more quickly.
-    public static int DEFAULT_LOOP_TIME = 120;  // time is in seconds
-
-    // execute the LoggerWeakRefLeak app work
-    public void doMyAppWork(String[] args) throws Exception {
-        int loop_time = 0;
-        int max_loop_time = DEFAULT_LOOP_TIME;
-
-        // args[0] is the port-file
-        if (args.length < 2) {
-            System.out.println("INFO: using default time of "
-                + max_loop_time + " seconds.");
-        } else {
-            try {
-                max_loop_time = Integer.parseInt(args[1]);
-            } catch (NumberFormatException nfe) {
-                throw new RuntimeException("Error: '" + args[1]
-                    + "': is not a valid seconds value.");
-            }
-        }
-
-        long count = 0;
-        int  loggerCount = 0;
-        long now = 0;
-        long startTime = System.currentTimeMillis();
-
-        while (now < (startTime + (max_loop_time * 1000))) {
-            if ((count % 1000) == 0) {
-                // Print initial call count to let caller know that
-                // we're up and running and then periodically
-                System.out.println("INFO: call count = " + count);
-            }
-
-            for (int i = 0; i < 100; i++) {
-                // This Logger call is leaking two different WeakReferences:
-                // - one in LogManager.LogNode
-                // - one in Logger.kids
-                java.util.logging.Logger.getLogger("logger-" + loggerCount);
-                count++;
-                if (++loggerCount >= 25000) {
-                    // Limit the Logger namespace used by the test so
-                    // the weak refs in LogManager.loggers that are
-                    // being properly managed don't skew the counts
-                    // by too much.
-                    loggerCount = 0;
-                }
-            }
-
-            try {
-                // delay for 1/10 of a second to avoid CPU saturation
-                Thread.sleep(100);
-            } catch (InterruptedException ie) {
-                // ignore any exceptions
-            }
-
-            now = System.currentTimeMillis();
-        }
-
-        System.out.println("INFO: final loop count = " + count);
-    }
-
-    public static void main(String[] args) throws Exception {
-        AnonLoggerWeakRefLeak myApp = new AnonLoggerWeakRefLeak();
-
-        SimpleApplication.setMyApp(myApp);
-
-        SimpleApplication.main(args);
-    }
-}
--- a/jdk/test/java/util/logging/LoggerWeakRefLeak.sh	Thu Jan 15 13:09:48 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,254 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2010, 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 6942989
-# @summary Check for WeakReference leak in Logger objects
-# @author Daniel D. Daugherty
-#
-# @library ../../../sun/tools/common
-# @build SimpleApplication ShutdownSimpleApplication
-# @build LoggerWeakRefLeak
-# @run shell/timeout=240 LoggerWeakRefLeak.sh
-
-# The timeout is: 2 minutes for infrastructure and 2 minutes for the test
-#
-
-. ${TESTSRC}/../../../sun/tools/common/CommonSetup.sh
-. ${TESTSRC}/../../../sun/tools/common/ApplicationSetup.sh
-
-
-TEST_NAME="LoggerWeakRefLeak"
-TARGET_CLASS="java\.lang\.ref\.WeakReference"
-
-
-# MAIN begins here
-#
-
-seconds=
-if [ "$#" -gt 0 ]; then
-    seconds="$1"
-fi
-
-# see if this version of jmap supports the '-histo:live' option
-jmap_option="-histo:live"
-set +e
-"${JMAP}" 2>&1 | grep ':live' > /dev/null 2>&1
-status="$?"
-set -e
-if [ "$status" != 0 ]; then
-    # usage message doesn't show ':live' option
-
-    if $isWindows; then
-        # If SA isn't present, then jmap gives a different usage message
-        # that doesn't show the ':live' option. However, that's a bug that
-        # is covered by 6971851 so we try using the option just to be sure.
-        # For some reason, this problem has only been seen on OpenJDK6 on
-        # Windows. Not sure why.
-        set +e
-        # Note: Don't copy this code to try probing process 0 on Linux; it
-        # will kill the process group in strange ways.
-        "${JMAP}" "$jmap_option" 0 2>&1 | grep 'Usage' > /dev/null 2>&1
-        status="$?"
-        set -e
-        if [ "$status" = 0 ]; then
-            # Usage message generated so flag the problem.
-            status=1
-        else
-            # No usage message so clear the flag.
-            status=0
-        fi
-    fi
-
-    if [ "$status" != 0 ]; then
-        echo "WARNING: 'jmap $jmap_option' is not supported on this platform"
-        echo "WARNING: so this test cannot work reliably. Aborting!"
-        exit 0
-    fi
-fi
-
-# Start application and use TEST_NAME.port for coordination
-startApplication "$TEST_NAME" "$TEST_NAME.port" $seconds
-
-finished_early=false
-
-decreasing_cnt=0
-increasing_cnt=0
-loop_cnt=0
-prev_instance_cnt=0
-
-MAX_JMAP_TRY_CNT=10
-jmap_retry_cnt=0
-loop_cnt_on_retry=0
-
-while true; do
-    # see if the target process has finished its run and bail if it has
-    set +e
-    grep "^INFO: final loop count = " "$appOutput" > /dev/null 2>&1
-    status="$?"
-    set -e
-    if [ "$status" = 0 ]; then
-        break
-    fi
-
-    # Output format for 'jmap -histo' in JDK1.5.0:
-    #
-    #     <#bytes> <#instances> <class_name>
-    #
-    # Output format for 'jmap -histo:live':
-    #
-    #     <num>: <#instances> <#bytes> <class_name>
-    #
-    set +e
-    "${JMAP}" "$jmap_option" "$appJavaPid" > "$TEST_NAME.jmap" 2>&1
-    status="$?"
-    set -e
-
-    if [ "$status" != 0 ]; then
-        echo "INFO: jmap exited with exit code = $status"
-
-        # There are intermittent jmap failures; see 6498448.
-        #
-        # So far the following have been observed in a jmap call
-        # that was not in a race with target process termination:
-        #
-        # (Solaris specific, 2nd sample)
-        # <pid>: Unable to open door: target process not responding or HotSpot VM not loaded
-        # The -F option can be used when the target process is not responding
-        #
-        # (on Solaris so far)
-        # java.io.IOException
-        #
-        # (on Solaris so far, 1st sample)
-        # <pid>: Permission denied
-        #
-        sed 's/^/INFO: /' "$TEST_NAME.jmap"
-
-        if [ "$loop_cnt" = "$loop_cnt_on_retry" ]; then
-            # loop count hasn't changed
-            jmap_retry_cnt=`expr $jmap_retry_cnt + 1`
-        else
-            # loop count has changed so remember it
-            jmap_retry_cnt=1
-            loop_cnt_on_retry="$loop_cnt"
-        fi
-
-        # This is '-ge' because we have the original attempt plus
-        # MAX_JMAP_TRY_CNT - 1 retries.
-        if [ "$jmap_retry_cnt" -ge "$MAX_JMAP_TRY_CNT" ]; then
-            echo "INFO: jmap failed $MAX_JMAP_TRY_CNT times in a row" \
-                "without making any progress."
-            echo "FAIL: jmap is unable to take any samples." >&2
-            killApplication
-            exit 2
-        fi
-
-        # short delay and try again
-        # Note: sleep 1 didn't help with "<pid>: Permission denied"
-        sleep 2
-        echo "INFO: retrying jmap (retry=$jmap_retry_cnt, loop=$loop_cnt)."
-        continue
-    fi
-
-    set +e
-    instance_cnt=`grep "${PATTERN_WS}${TARGET_CLASS}${PATTERN_EOL}" \
-        "$TEST_NAME.jmap" \
-        | sed '
-            # strip leading whitespace; does nothing in JDK1.5.0
-            s/^'"${PATTERN_WS}${PATTERN_WS}"'*//
-            # strip <#bytes> in JDK1.5.0; does nothing otherwise
-            s/^[1-9][0-9]*'"${PATTERN_WS}${PATTERN_WS}"'*//
-            # strip <num>: field; does nothing in JDK1.5.0
-            s/^[1-9][0-9]*:'"${PATTERN_WS}${PATTERN_WS}"'*//
-            # strip <class_name> field
-            s/'"${PATTERN_WS}"'.*//
-            '`
-    set -e
-    if [ -z "$instance_cnt" ]; then
-        echo "INFO: instance count is unexpectedly empty"
-        if [ "$loop_cnt" = 0 ]; then
-            echo "INFO: on the first iteration so no sample was found."
-            echo "INFO: There is likely a problem with the sed filter."
-            echo "INFO: start of jmap output:"
-            cat "$TEST_NAME.jmap"
-            echo "INFO: end of jmap output."
-            echo "FAIL: cannot find the instance count value." >&2
-            killApplication
-            exit 2
-        fi
-    else
-        echo "INFO: instance_cnt = $instance_cnt"
-
-        if [ "$instance_cnt" -gt "$prev_instance_cnt" ]; then
-            increasing_cnt=`expr $increasing_cnt + 1`
-        else
-            # actually decreasing or the same
-            decreasing_cnt=`expr $decreasing_cnt + 1`
-
-            # For these particular WeakReference leaks, the count was
-            # always observed to be increasing so if we get a decreasing
-            # or the same count, then the leaks are fixed in the bits
-            # being tested.
-            echo "INFO: finishing early due to non-increasing instance count."
-            finished_early=true
-            killApplication
-            break
-        fi
-        prev_instance_cnt="$instance_cnt"
-    fi
-
-    # delay between samples
-    sleep 5
-
-    loop_cnt=`expr $loop_cnt + 1`
-done
-
-if [ $finished_early = false ]; then
-    stopApplication "$TEST_NAME.port"
-    waitForApplication
-fi
-
-echo "INFO: $TEST_NAME has finished running."
-echo "INFO: increasing_cnt = $increasing_cnt"
-echo "INFO: decreasing_cnt = $decreasing_cnt"
-if [ "$jmap_retry_cnt" -gt 0 ]; then
-    echo "INFO: jmap_retry_cnt = $jmap_retry_cnt (in $loop_cnt iterations)"
-fi
-
-if [ "$loop_cnt" = 0 ]; then
-    echo "FAIL: jmap is unable to take any samples." >&2
-    exit 2
-fi
-
-echo "INFO: The instance count of" `eval echo $TARGET_CLASS` "objects"
-if [ "$decreasing_cnt" = 0 ]; then
-    echo "INFO: is always increasing."
-    echo "FAIL: This indicates that there is a memory leak." >&2
-    exit 2
-fi
-
-echo "INFO: is not always increasing."
-echo "PASS: This indicates that there is not a memory leak."
-exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/logging/TestLoggerWeakRefLeak.java	Fri Jan 16 12:34:28 2015 -0800
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import static jdk.testlibrary.Asserts.assertGreaterThan;
+import jdk.testlibrary.ProcessTools;
+
+import com.sun.tools.attach.AttachNotSupportedException;
+import com.sun.tools.attach.VirtualMachine;
+
+import sun.tools.attach.HotSpotVirtualMachine;
+
+/*
+ * @test
+ * @bug 6942989
+ * @summary Check for WeakReference leak in Logger and anonymous Logger objects
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.*
+ * @run main/othervm TestLoggerWeakRefLeak Logger
+ * @run main/othervm TestLoggerWeakRefLeak AnonymousLogger
+ */
+public class TestLoggerWeakRefLeak {
+
+    private static final String TARGET_CLASS = "java.lang.ref.WeakReference";
+    private static final int INSTANCE_COUNT = 100;
+    private static int loggerCount = 0;
+
+    public static void main(String[] args) throws Exception {
+        if (args[0].equals("AnonymousLogger")) {
+            System.out.println("Test for WeakReference leak in AnonymousLogger object");
+            testIfLeaking(TestLoggerWeakRefLeak::callAnonymousLogger);
+        } else {
+            System.out.println("Test for WeakReference leak in Logger object");
+            testIfLeaking(TestLoggerWeakRefLeak::callLogger);
+        }
+    }
+
+    /**
+     * For these particular WeakReference leaks, the count was always observed
+     * to be increasing so if decreasing or the same count is observed,
+     * then there is no leak.
+     */
+    private static void testIfLeaking(Runnable callLogger) throws Exception {
+        long count = 0;
+        int instanceCount = 0;
+        int previousInstanceCount = 0;
+        int increasingCount = 0;
+        int decreasingCount = 0;
+
+        while (true) {
+            callLogger.run();
+            count += INSTANCE_COUNT;
+
+            if ((count % 1000) == 0) {
+                System.out.println("call count = " + count);
+
+                instanceCount = getInstanceCountFromHeapHisto();
+                if (instanceCount > previousInstanceCount) {
+                    increasingCount++;
+                } else {
+                    decreasingCount++;
+                    System.out.println("increasing count: " + increasingCount);
+                    System.out.println("decreasing or the same count: " + decreasingCount);
+                    System.out.println("Test passed: decreasing or the same instance count is observed");
+                    break;
+                }
+                previousInstanceCount = instanceCount;
+            }
+
+            delayExecution();
+        }
+    }
+
+    /**
+     * This Logger call is leaking two different WeakReferences:
+     * - one in LogManager.LogNode
+     * - one in Logger.kids
+     */
+    private static void callLogger() {
+        for (int i = 0; i < INSTANCE_COUNT; i++) {
+            java.util.logging.Logger.getLogger("logger-" + loggerCount);
+            if (++loggerCount >= 25000) {
+                // Limit the Logger namespace used by the test so the weak refs
+                // in LogManager.loggers that are being properly managed
+                // don't skew the counts by too much.
+                loggerCount = 0;
+            }
+        }
+    }
+
+    /**
+     * This Logger call is leaking a WeakReference in Logger.kids
+     */
+    private static void callAnonymousLogger() {
+        for (int i = 0; i < INSTANCE_COUNT; i++) {
+            java.util.logging.Logger.getAnonymousLogger();
+        }
+    }
+
+    /**
+     * 'vm.heapHisto("-live")' will request a full GC
+     */
+    private static int getInstanceCountFromHeapHisto() throws AttachNotSupportedException, Exception {
+        int instanceCount = 0;
+
+        HotSpotVirtualMachine vm = (HotSpotVirtualMachine) VirtualMachine
+                .attach(Integer.toString(ProcessTools.getProcessId()));
+        try {
+            try (InputStream heapHistoStream = vm.heapHisto("-live");
+                    BufferedReader in = new BufferedReader(new InputStreamReader(heapHistoStream))) {
+                String inputLine;
+                while ((inputLine = in.readLine()) != null) {
+                    if (inputLine.contains(TARGET_CLASS)) {
+                        instanceCount = Integer.parseInt(inputLine
+                                .split("[ ]+")[2]);
+                        System.out.println("instance count: " + instanceCount);
+                        break;
+                    }
+                }
+            }
+        } finally {
+            vm.detach();
+        }
+
+        assertGreaterThan(instanceCount, 0, "No instances of " + TARGET_CLASS + " are found");
+
+        return instanceCount;
+    }
+
+    /**
+     * Delay for 1/10 of a second to avoid CPU saturation
+     */
+    private static void delayExecution() {
+        try {
+            Thread.sleep(100);
+        } catch (InterruptedException ie) {
+            // Ignore any exceptions
+        }
+    }
+
+}
--- a/jdk/test/javax/management/monitor/CounterMonitorDeadlockTest.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/javax/management/monitor/CounterMonitorDeadlockTest.java	Fri Jan 16 12:34:28 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -37,7 +37,6 @@
 
 import java.lang.management.ManagementFactory;
 import java.util.concurrent.atomic.AtomicInteger;
-import javax.management.Attribute;
 import javax.management.JMX;
 import javax.management.MBeanServer;
 import javax.management.Notification;
@@ -95,18 +94,16 @@
             monitorProxy.setInitThreshold(100);
             monitorProxy.setGranularityPeriod(10L); // 10 ms
             monitorProxy.setNotify(true);
+
+            final int initGetCount = observedProxy.getGetCount();
             monitorProxy.start();
 
-            final int initGetCount = observedProxy.getGetCount();
-            int getCount;
             System.out.println("Checking GetCount, possible deadlock if timeout.");
             do { // 8038322. Until timeout of testing harness
                 Thread.sleep(200);
-            } while ((getCount=observedProxy.getGetCount()) == initGetCount);
+            } while ((observedProxy.getGetCount()) == initGetCount);
             System.out.println("Done!");
 
-            if (getCount <= initGetCount)
-                throw new Exception("Test failed: presumable deadlock");
             // This won't show up as a deadlock in CTRL-\ or in
             // ThreadMXBean.findDeadlockedThreads(), because they don't
             // see that thread A is waiting for thread B (B.join()), and
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/FilterClassLoader.java	Fri Jan 16 12:34:28 2015 -0800
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.testlibrary;
+
+import java.util.function.Predicate;
+/**
+ * A classloader, which using target classloader in case provided condition
+ * for class name is met, and using parent otherwise
+ */
+public class FilterClassLoader extends ClassLoader {
+
+    private final ClassLoader target;
+    private final Predicate<String> condition;
+
+    public FilterClassLoader(ClassLoader target, ClassLoader parent,
+            Predicate<String> condition) {
+        super(parent);
+        this.condition = condition;
+        this.target = target;
+    }
+
+    @Override
+    public Class<?> loadClass(String name) throws ClassNotFoundException {
+        if (condition.test(name)) {
+            return target.loadClass(name);
+        }
+        return super.loadClass(name);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/ParentLastURLClassLoader.java	Fri Jan 16 12:34:28 2015 -0800
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.testlibrary;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * An url classloader, which trying to load class from provided URL[] first,
+ * and using parent classloader in case it failed
+ */
+public class ParentLastURLClassLoader extends URLClassLoader {
+
+    public ParentLastURLClassLoader(URL urls[], ClassLoader parent) {
+        super(urls, parent);
+    }
+
+    @Override
+    public Class<?> loadClass(String name) throws ClassNotFoundException {
+        try {
+            Class c = findClass(name);
+            if (c != null) {
+                return c;
+            }
+        } catch (ClassNotFoundException e) {
+            // ignore
+        }
+        return super.loadClass(name);
+    }
+}
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java	Fri Jan 16 12:34:28 2015 -0800
@@ -28,6 +28,15 @@
     private static final String dataModel   = System.getProperty("sun.arch.data.model");
     private static final String vmVersion   = System.getProperty("java.vm.version");
     private static final String osArch      = System.getProperty("os.arch");
+    private static final String vmName      = System.getProperty("java.vm.name");
+
+    public static boolean isClient() {
+        return vmName.endsWith(" Client VM");
+    }
+
+    public static boolean isServer() {
+        return vmName.endsWith(" Server VM");
+    }
 
     public static boolean is32bit() {
         return dataModel.equals("32");
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java	Fri Jan 16 12:34:28 2015 -0800
@@ -39,6 +39,7 @@
 import java.util.regex.Pattern;
 import java.util.regex.Matcher;
 import java.util.concurrent.TimeUnit;
+import java.util.function.BooleanSupplier;
 
 /**
  * Common library for various test helper functions.
@@ -271,25 +272,6 @@
     }
 
     /**
-     * Returns file content as a list of strings
-     *
-     * @param file File to operate on
-     * @return List of strings
-     * @throws IOException
-     */
-    public static List<String> fileAsList(File file) throws IOException {
-        assertTrue(file.exists() && file.isFile(),
-                file.getAbsolutePath() + " does not exist or not a file");
-        List<String> output = new ArrayList<>();
-        try (BufferedReader reader = new BufferedReader(new FileReader(file.getAbsolutePath()))) {
-            while (reader.ready()) {
-                output.add(reader.readLine().replace(NEW_LINE, ""));
-            }
-        }
-        return output;
-    }
-
-    /**
      * Adjusts the provided timeout value for the TIMEOUT_FACTOR
      * @param tOut the timeout value to be adjusted
      * @return The timeout value adjusted for the value of "test.timeout.factor"
@@ -298,4 +280,50 @@
     public static long adjustTimeout(long tOut) {
         return Math.round(tOut * Utils.TIMEOUT_FACTOR);
     }
+
+    /**
+     * Wait for condition to be true
+     *
+     * @param condition, a condition to wait for
+     */
+    public static final void waitForCondition(BooleanSupplier condition) {
+        waitForCondition(condition, -1L, 100L);
+    }
+
+    /**
+     * Wait until timeout for condition to be true
+     *
+     * @param condition, a condition to wait for
+     * @param timeout a time in milliseconds to wait for condition to be true
+     * specifying -1 will wait forever
+     * @return condition value, to determine if wait was successfull
+     */
+    public static final boolean waitForCondition(BooleanSupplier condition,
+            long timeout) {
+        return waitForCondition(condition, timeout, 100L);
+    }
+
+    /**
+     * Wait until timeout for condition to be true for specified time
+     *
+     * @param condition, a condition to wait for
+     * @param timeout a time in milliseconds to wait for condition to be true,
+     * specifying -1 will wait forever
+     * @param sleepTime a time to sleep value in milliseconds
+     * @return condition value, to determine if wait was successfull
+     */
+    public static final boolean waitForCondition(BooleanSupplier condition,
+            long timeout, long sleepTime) {
+        long startTime = System.currentTimeMillis();
+        while (!(condition.getAsBoolean() || (timeout != -1L
+                && ((System.currentTimeMillis() - startTime) > timeout)))) {
+            try {
+                Thread.sleep(sleepTime);
+            } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
+                throw new Error(e);
+            }
+        }
+        return condition.getAsBoolean();
+    }
 }
--- a/jdk/test/sun/awt/datatransfer/DataFlavorComparatorTest.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/sun/awt/datatransfer/DataFlavorComparatorTest.java	Fri Jan 16 12:34:28 2015 -0800
@@ -29,13 +29,14 @@
 */
 
 import sun.awt.datatransfer.DataTransferer;
-
+import java.util.Comparator;
+import sun.datatransfer.DataFlavorUtil;
 import java.awt.datatransfer.DataFlavor;
 
 public class DataFlavorComparatorTest {
 
     public static void main(String[] args) {
-        DataTransferer.DataFlavorComparator comparator = new DataTransferer.DataFlavorComparator();
+        Comparator<DataFlavor> comparator = DataFlavorUtil.getDataFlavorComparator();
         DataFlavor flavor1 = DataFlavor.imageFlavor;
         DataFlavor flavor2 = DataFlavor.selectionHtmlFlavor;
         if (comparator.compare(flavor1, flavor2) == 0) {
--- a/jdk/test/sun/reflect/CallerSensitive/CallerSensitiveFinder.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/sun/reflect/CallerSensitive/CallerSensitiveFinder.java	Fri Jan 16 12:34:28 2015 -0800
@@ -26,20 +26,22 @@
 import static com.sun.tools.classfile.ConstantPool.*;
 import java.io.File;
 import java.io.IOException;
-import java.nio.file.FileVisitResult;
+import java.io.UncheckedIOException;
+import java.net.URI;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
-import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.FutureTask;
+import java.util.stream.Stream;
 
 /*
  * @test
@@ -52,8 +54,10 @@
 public class CallerSensitiveFinder {
     private static int numThreads = 3;
     private static boolean verbose = false;
+    private final ExecutorService pool;
+
     public static void main(String[] args) throws Exception {
-        List<Path> classes = new ArrayList<>();
+        Stream<Path> classes = null;
         String testclasses = System.getProperty("test.classes", ".");
         int i = 0;
         while (i < args.length) {
@@ -65,25 +69,30 @@
                 if (!p.toFile().exists()) {
                     throw new IllegalArgumentException(arg + " does not exist");
                 }
-                classes.add(p);
+                classes = Stream.of(p);
             }
         }
-        if (classes.isEmpty()) {
-            classes.addAll(PlatformClassPath.getJREClasses());
+
+        if (classes == null) {
+            classes = getPlatformClasses();
         }
-        CallerSensitiveFinder csfinder = new CallerSensitiveFinder();
 
+        CallerSensitiveFinder csfinder = new CallerSensitiveFinder();
         List<String> errors = csfinder.run(classes);
+
         if (!errors.isEmpty()) {
             throw new RuntimeException(errors.size() +
                     " caller-sensitive methods are missing @CallerSensitive annotation");
         }
     }
 
-    private final List<String> csMethodsMissingAnnotation = new ArrayList<>();
+    private final List<String> csMethodsMissingAnnotation =
+            Collections.synchronizedList(new ArrayList<>());
     private final ReferenceFinder finder;
     public CallerSensitiveFinder() {
         this.finder = new ReferenceFinder(getFilter(), getVisitor());
+        pool = Executors.newFixedThreadPool(numThreads);
+
     }
 
     private ReferenceFinder.Filter getFilter() {
@@ -123,11 +132,17 @@
         };
     }
 
-    public List<String> run(List<Path> classes) throws IOException, InterruptedException,
+    public List<String> run(Stream<Path> classes)throws IOException, InterruptedException,
             ExecutionException, ConstantPoolException
     {
-        ExecutorService pool = Executors.newFixedThreadPool(numThreads);
-        for (Path path : classes) {
+        classes.forEach(this::processPath);
+        waitForCompletion();
+        pool.shutdown();
+        return csMethodsMissingAnnotation;
+    }
+
+    void processPath(Path path) {
+        try {
             ClassFileReader reader = ClassFileReader.newInstance(path);
             for (ClassFile cf : reader.getClassFiles()) {
                 String classFileName = cf.getName();
@@ -137,10 +152,11 @@
                 //      - visit and find method references matching the given method name
                 pool.submit(getTask(cf));
             }
+        } catch (IOException x) {
+            throw new UncheckedIOException(x);
+        } catch (ConstantPoolException x) {
+            throw new RuntimeException(x);
         }
-        waitForCompletion();
-        pool.shutdown();
-        return csMethodsMissingAnnotation;
     }
 
     private static final String CALLER_SENSITIVE_ANNOTATION = "Lsun/reflect/CallerSensitive;";
@@ -178,61 +194,34 @@
         for (FutureTask<Void> t : tasks) {
             t.get();
         }
+        if (tasks.isEmpty()) {
+            throw new RuntimeException("No classes found, or specified.");
+        }
         System.out.println("Parsed " + tasks.size() + " classfiles");
     }
 
-    static class PlatformClassPath {
-        static List<Path> getJREClasses() throws IOException {
-            List<Path> result = new ArrayList<Path>();
-            Path home = Paths.get(System.getProperty("java.home"));
-
-            if (home.endsWith("jre")) {
-                // jar files in <javahome>/jre/lib
-                // skip <javahome>/lib
-                result.addAll(addJarFiles(home.resolve("lib")));
-            } else if (home.resolve("lib").toFile().exists()) {
-                // either a JRE or a jdk build image
-                File classes = home.resolve("classes").toFile();
-                if (classes.exists() && classes.isDirectory()) {
-                    // jdk build outputdir
-                    result.add(classes.toPath());
-                }
-                // add other JAR files
-                result.addAll(addJarFiles(home.resolve("lib")));
-            } else {
-                throw new RuntimeException("\"" + home + "\" not a JDK home");
-            }
-            return result;
-        }
+    static Stream<Path> getPlatformClasses() throws IOException {
+        Path home = Paths.get(System.getProperty("java.home"));
 
-        static List<Path> addJarFiles(final Path root) throws IOException {
-            final List<Path> result = new ArrayList<Path>();
-            final Path ext = root.resolve("ext");
-            Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
-                @Override
-                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
-                        throws IOException {
-                    if (dir.equals(root) || dir.equals(ext)) {
-                        return FileVisitResult.CONTINUE;
-                    } else {
-                        // skip other cobundled JAR files
-                        return FileVisitResult.SKIP_SUBTREE;
-                    }
-                }
+        // Either an exploded build or an image.
+        File classes = home.resolve("modules").toFile();
+        if (classes.isDirectory()) {
+            return Stream.of(classes.toPath());
+        } else {
+            return jrtPaths();
+        }
+    }
 
-                @Override
-                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
-                        throws IOException {
-                    File f = file.toFile();
-                    String fn = f.getName();
-                    // parse alt-rt.jar as well
-                    if (fn.endsWith(".jar") && !fn.equals("jfxrt.jar")) {
-                        result.add(file);
-                    }
-                    return FileVisitResult.CONTINUE;
-                }
-            });
-            return result;
+    static Stream<Path> jrtPaths() {
+        FileSystem jrt = FileSystems.getFileSystem(URI.create("jrt:/"));
+        Path root = jrt.getPath("/");
+
+        try {
+            return Files.walk(root)
+                    .filter(p -> p.getNameCount() > 1)
+                    .filter(p -> p.toString().endsWith(".class"));
+        } catch (IOException x) {
+            throw new UncheckedIOException(x);
         }
     }
 }
--- a/jdk/test/sun/reflect/CallerSensitive/MissingCallerSensitive.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/sun/reflect/CallerSensitive/MissingCallerSensitive.java	Fri Jan 16 12:34:28 2015 -0800
@@ -34,11 +34,13 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.*;
+import java.util.stream.Stream;
+
 public class MissingCallerSensitive {
     public static void main(String[] args) throws Exception {
         String testclasses = System.getProperty("test.classes", ".");
-        List<Path> classes = new ArrayList<>();
-        classes.add(Paths.get(testclasses, "MissingCallerSensitive.class"));
+
+        Stream<Path> classes = Stream.of(Paths.get(testclasses, "MissingCallerSensitive.class"));
 
         CallerSensitiveFinder csfinder = new CallerSensitiveFinder();
         List<String> errors = csfinder.run(classes);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs11/Mac/MacKAT.java	Fri Jan 16 12:34:28 2015 -0800
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.UnsupportedEncodingException;
+import java.security.Provider;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Random;
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+
+/**
+ * @test
+ * @bug 4846410 6313661 4963723
+ * @summary Basic known-answer-test for Hmac algorithms
+ * @author Andreas Sterbenz
+ * @library ..
+ * @run main MacKAT
+ */
+public class MacKAT extends PKCS11Test {
+
+    private final static byte[] ALONG, BLONG, BKEY, BKEY_20, DDDATA_50,
+            AAKEY_20, CDDATA_50, AAKEY_131;
+
+    static {
+        ALONG = new byte[1024 * 128];
+        Arrays.fill(ALONG, (byte)'a');
+        BLONG = new byte[1024 * 128];
+        Random random = new Random(12345678);
+        random.nextBytes(BLONG);
+        BKEY = new byte[128];
+        random.nextBytes(BKEY);
+        BKEY_20 = new byte[20];
+        Arrays.fill(BKEY_20, (byte) 0x0b);
+        DDDATA_50 = new byte[50];
+        Arrays.fill(DDDATA_50, (byte) 0xdd);
+        AAKEY_20 = new byte[20];
+        Arrays.fill(AAKEY_20, (byte) 0xaa);
+        CDDATA_50 = new byte[50];
+        Arrays.fill(CDDATA_50, (byte) 0xcd);
+        AAKEY_131 = new byte[131];
+        Arrays.fill(AAKEY_131, (byte) 0xaa);
+    }
+
+    private final static Test[] tests = {
+        newMacTest("SslMacMD5",
+                ALONG,
+                "f4:ad:01:71:51:f6:89:56:72:a3:32:bf:d9:2a:f2:a5",
+                "1b:34:61:29:05:0d:73:db:25:d0:dd:64:06:29:f6:8a"),
+        newMacTest("SslMacMD5",
+                BLONG,
+                "34:1c:ad:a0:95:57:32:f8:8e:80:8f:ee:b2:d8:23:e5",
+                "76:00:4a:72:98:9b:65:ec:2e:f1:43:c4:65:4a:13:71"),
+        newMacTest("SslMacSHA1",
+                ALONG,
+                "11:c1:71:2e:61:be:4b:cf:bc:6d:e2:4c:58:ae:27:30:0b:24:a4:87",
+                "23:ae:dd:61:87:6c:7a:45:47:2f:2c:8f:ea:64:99:3e:27:5f:97:a5"),
+        newMacTest("SslMacSHA1",
+                BLONG,
+                "84:af:57:0a:af:ef:16:93:90:50:da:88:f8:ad:1a:c5:66:6c:94:d0",
+                "9b:bb:e2:aa:9b:28:1c:95:0e:ea:30:21:98:a5:7e:31:9e:bf:5f:51"),
+        newMacTest("HmacMD5",
+                ALONG,
+                "76:00:4a:72:98:9b:65:ec:2e:f1:43:c4:65:4a:13:71",
+                "1b:34:61:29:05:0d:73:db:25:d0:dd:64:06:29:f6:8a"),
+        newMacTest("HmacMD5",
+                BLONG,
+                "6c:22:79:bb:34:9e:da:f4:f5:cf:df:0c:62:3d:59:e0",
+                "76:00:4a:72:98:9b:65:ec:2e:f1:43:c4:65:4a:13:71"),
+        newMacTest("HmacMD5",
+                BLONG,
+                "e6:ad:00:c9:49:6b:98:fe:53:a2:b9:2d:7d:41:a2:03",
+                BKEY),
+        newMacTest("HmacSHA1",
+                ALONG,
+                "9e:b3:6e:35:fa:fb:17:2e:2b:f3:b0:4a:9d:38:83:c4:5f:6d:d9:00",
+                "1b:34:61:29:05:0d:73:db:25:d0:dd:64:06:29:f6:8a"),
+        newMacTest("HmacSHA1",
+                BLONG,
+                "80:2d:5b:ea:08:df:a4:1f:e5:3e:1c:fa:fc:ad:dd:31:da:15:60:2c",
+                "76:00:4a:72:98:9b:65:ec:2e:f1:43:c4:65:4a:13:71"),
+        newMacTest("HmacSHA1",
+                BLONG,
+                "a2:fa:2a:85:18:0e:94:b2:a5:e2:17:8b:2a:29:7a:95:cd:e8:aa:82",
+                BKEY),
+        newMacTest("HmacSHA256",
+                ALONG,
+                "3f:6d:08:df:0c:90:b0:e9:ed:13:4a:2e:c3:48:1d:3d:3e:61:2e:f1:"
+                        + "30:c2:63:c4:58:57:03:c2:cb:87:15:07",
+                "1b:34:61:29:05:0d:73:db:25:d0:dd:64:06:29:f6:8a"),
+        newMacTest("HmacSHA256",
+                BLONG,
+                "e2:4e:a3:b9:0b:b8:99:e4:71:cf:ca:9f:f8:4e:f0:34:8b:19:9f:33:"
+                        + "4b:1a:b7:13:f7:c8:57:92:e3:03:74:78",
+                BKEY),
+        newMacTest("HmacSHA384",
+                ALONG,
+                "d0:f0:d4:54:1c:0a:6d:81:ed:15:20:d7:0c:96:06:61:a0:ff:c9:ff:"
+                        + "91:e9:a0:cd:e2:45:64:9d:93:4c:a9:fa:89:ae:c0:90:e6:"
+                        + "0b:a1:a0:56:80:57:3b:ed:4b:b0:71",
+                "1b:34:61:29:05:0d:73:db:25:d0:dd:64:06:29:f6:8a"),
+        newMacTest("HmacSHA384",
+                BLONG,
+                "75:c4:ca:c7:f7:58:9d:d3:23:b1:1b:5c:93:2d:ec:7a:03:dc:8c:eb:"
+                        + "8d:fe:79:46:4f:30:e7:99:62:de:44:e2:38:95:0e:79:91:"
+                        + "78:2f:a4:05:0a:f0:17:10:38:a1:8e",
+                BKEY),
+        newMacTest("HmacSHA512",
+                ALONG,
+                "41:ea:4c:e5:31:3f:7c:18:0e:5e:95:a9:25:0a:10:58:e6:40:53:88:"
+                        + "82:4f:5a:da:6f:29:de:04:7b:8e:d7:ed:7c:4d:b8:2a:48:"
+                        + "2d:17:2a:2d:59:bb:81:9c:bf:33:40:04:77:44:fb:45:25:"
+                        + "1f:fd:b9:29:f4:a6:69:a3:43:6f",
+                "1b:34:61:29:05:0d:73:db:25:d0:dd:64:06:29:f6:8a"),
+        newMacTest("HmacSHA512",
+                BLONG,
+                "fb:cf:4b:c6:d5:49:5a:5b:0b:d9:2a:32:f5:fa:68:d2:68:a4:0f:ae:"
+                        + "53:fc:49:12:e6:1d:53:cf:b2:cb:c5:c5:f2:2d:86:bd:14:"
+                        + "61:30:c3:a6:6f:44:1f:77:9b:aa:a1:22:48:a9:dd:d0:45:"
+                        + "86:d1:a1:82:53:13:c4:03:06:a3",
+                BKEY),
+
+        // Test vectors From RFC 4231
+        newMacTest("HmacSHA224",
+                bytes("Hi There"),
+                "89:6f:b1:12:8a:bb:df:19:68:32:10:7c:d4:9d:f3:3f:47:b4:b1:16:"
+                        + "99:12:ba:4f:53:68:4b:22",
+                BKEY_20),
+        newMacTest("HmacSHA224",
+                bytes("what do ya want for nothing?"),
+                "a3:0e:01:09:8b:c6:db:bf:45:69:0f:3a:7e:9e:6d:0f:8b:be:a2:a3:"
+                        + "9e:61:48:00:8f:d0:5e:44",
+                bytes("Jefe")),
+        newMacTest("HmacSHA224",
+                DDDATA_50,
+                "7f:b3:cb:35:88:c6:c1:f6:ff:a9:69:4d:7d:6a:d2:64:93:65:b0:c1:"
+                        + "f6:5d:69:d1:ec:83:33:ea",
+                AAKEY_20),
+        newMacTest("HmacSHA224",
+                CDDATA_50,
+                "6c:11:50:68:74:01:3c:ac:6a:2a:bc:1b:b3:82:62:7c:ec:6a:90:d8:"
+                        + "6e:fc:01:2d:e7:af:ec:5a",
+                "01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f:10:11:12:13:14:"
+                        + "15:16:17:18:19"),
+        newMacTest("HmacSHA224",
+                bytes("Test Using Larger Than Block-Size Key - Hash Key First"),
+                "95:e9:a0:db:96:20:95:ad:ae:be:9b:2d:6f:0d:bc:e2:d4:99:f1:12:"
+                        + "f2:d2:b7:27:3f:a6:87:0e",
+                AAKEY_131),
+        newMacTest("HmacSHA224",
+                bytes("This is a test using a larger than block-size key and "
+                        + "a larger than block-size data. The key needs to be "
+                        + "hashed before being used by the HMAC algorithm."),
+                "3a:85:41:66:ac:5d:9f:02:3f:54:d5:17:d0:b3:9d:bd:94:67:70:db:"
+                        + "9c:2b:95:c9:f6:f5:65:d1",
+                AAKEY_131),
+    };
+
+    public static void main(String[] args) throws Exception {
+        main(new MacKAT());
+    }
+
+    @Override
+    public void main(Provider p) throws Exception {
+        long start = System.currentTimeMillis();
+
+        List<String> algorithms = getSupportedAlgorithms("Mac", "", p);
+        for (Test test : tests) {
+            if(!algorithms.contains(test.getAlg())) {
+                continue;
+            }
+            test.run(p);
+        }
+
+        System.out.println("All tests passed");
+        long stop = System.currentTimeMillis();
+        System.out.println("Done (" + (stop - start) + " ms).");
+    }
+
+    private static byte[] bytes(String s) {
+        try {
+            return s.getBytes("UTF8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private static Test newMacTest(String alg, byte[] input, String macvalue,
+            String key) {
+        return new MacTest(alg, input, parse(macvalue), parse(key));
+    }
+
+    private static Test newMacTest(String alg, byte[] input, String macvalue,
+            byte[] key) {
+        return new MacTest(alg, input, parse(macvalue), key);
+    }
+
+    interface Test {
+        void run(Provider p) throws Exception;
+        String getAlg();
+    }
+
+    static class MacTest implements Test {
+        private final String alg;
+        private final byte[] input;
+        private final byte[] macvalue;
+        private final byte[] key;
+
+        MacTest(String alg, byte[] input, byte[] macvalue, byte[] key) {
+            this.alg = alg;
+            this.input = input;
+            this.macvalue = macvalue;
+            this.key = key;
+        }
+
+        @Override
+        public String getAlg() {
+            return alg;
+        }
+
+        @Override
+        public void run(Provider p) throws Exception {
+            Mac mac = Mac.getInstance(alg, p);
+            SecretKey keySpec = new SecretKeySpec(key, alg);
+            mac.init(keySpec);
+            mac.update(input);
+            byte[] macv = mac.doFinal();
+            if (Arrays.equals(macvalue, macv) == false) {
+                System.out.println("Mac test for " + alg + " failed:");
+                if (input.length < 256) {
+                    System.out.println("input:       "
+                            + PKCS11Test.toString(input));
+                }
+                System.out.println("key:        " + PKCS11Test.toString(key));
+                System.out.println("macvalue:   "
+                        + PKCS11Test.toString(macvalue));
+                System.out.println("calculated: " + PKCS11Test.toString(macv));
+                throw new Exception("Mac test for " + alg + " failed");
+            }
+            System.out.println("passed: " + alg);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs11/Mac/MacSameTest.java	Fri Jan 16 12:34:28 2015 -0800
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.util.List;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+
+/**
+ * @test
+ * @bug 8048603
+ * @summary Check if doFinal and update operation result in same Mac
+ * @author Yu-Ching Valerie Peng, Bill Situ, Alexander Fomin
+ * @library ..
+ * @run main MacSameTest
+ */
+public class MacSameTest extends PKCS11Test {
+
+    private static final int MESSAGE_SIZE = 25;
+    private static final int OFFSET = 5;
+    private static final int KEY_SIZE = 70;
+
+    /**
+     * Initialize a message, instantiate a Mac object,
+     * initialize the object with a SecretKey,
+     * feed the message into the Mac object
+     * all at once and get the output MAC as result1.
+     * Reset the Mac object, chop the message into three pieces,
+     * feed into the Mac object sequentially, and get the output MAC as result2.
+     * Finally, compare result1 and result2 and see if they are the same.
+     *
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) throws Exception {
+        main(new MacSameTest());
+    }
+
+    @Override
+    public void main(Provider p) {
+        List<String> algorithms = getSupportedAlgorithms("Mac", "Hmac", p);
+        boolean success = true;
+        for (String alg : algorithms) {
+            try {
+                doTest(alg, p);
+            } catch (Exception e) {
+                System.out.println("Unexpected exception: " + e);
+                e.printStackTrace();
+                success = false;
+            }
+        }
+
+        if (!success) {
+            throw new RuntimeException("Test failed");
+        }
+    }
+
+    private void doTest(String algo, Provider provider)
+            throws NoSuchAlgorithmException, NoSuchProviderException,
+            InvalidKeyException {
+        System.out.println("Test " + algo);
+        Mac mac;
+        try {
+            mac = Mac.getInstance(algo, provider);
+        } catch (NoSuchAlgorithmException nsae) {
+            if ("SunPKCS11-Solaris".equals(provider.getName())) {
+                // depending on Solaris configuration,
+                // it can support HMAC or not with Mac
+                System.out.println("Expected NoSuchAlgorithmException thrown: "
+                        + nsae);
+                return;
+            }
+            throw nsae;
+        }
+
+        byte[] plain = new byte[MESSAGE_SIZE];
+        for (int i = 0; i < MESSAGE_SIZE; i++) {
+            plain[i] = (byte) (i % 256);
+        }
+
+        byte[] tail = new byte[plain.length - OFFSET];
+        System.arraycopy(plain, OFFSET, tail, 0, tail.length);
+
+        SecureRandom srdm = new SecureRandom();
+        byte[] keyVal = new byte[KEY_SIZE];
+        srdm.nextBytes(keyVal);
+        SecretKeySpec keySpec = new SecretKeySpec(keyVal, "HMAC");
+
+        mac.init(keySpec);
+        byte[] result1 = mac.doFinal(plain);
+
+        mac.reset();
+        mac.update(plain[0]);
+        mac.update(plain, 1, OFFSET - 1);
+        byte[] result2 = mac.doFinal(tail);
+
+        if (!java.util.Arrays.equals(result1, result2)) {
+            throw new RuntimeException("result1 and result2 are not the same");
+        }
+    }
+
+}
--- a/jdk/test/sun/security/pkcs11/PKCS11Test.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/sun/security/pkcs11/PKCS11Test.java	Fri Jan 16 12:34:28 2015 -0800
@@ -582,4 +582,21 @@
         return r;
     }
 
+    /**
+     * Returns supported algorithms of specified type.
+     */
+    static List<String> getSupportedAlgorithms(String type, String alg,
+            Provider p) {
+        // prepare a list of supported algorithms
+        List<String> algorithms = new ArrayList<>();
+        Set<Provider.Service> services = p.getServices();
+        for (Provider.Service service : services) {
+            if (service.getType().equals(type)
+                    && service.getAlgorithm().startsWith(alg)) {
+                algorithms.add(service.getAlgorithm());
+            }
+        }
+        return algorithms;
+    }
+
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/x509/Extensions/DefaultCriticality.java	Fri Jan 16 12:34:28 2015 -0800
@@ -0,0 +1,50 @@
+/*
+ * 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
+ * @summary Change default criticality of policy mappings and policy constraints
+            certificate extensions
+ * @bug 8059916
+ */
+
+import sun.security.x509.PolicyConstraintsExtension;
+import sun.security.x509.PolicyMappingsExtension;
+
+public class DefaultCriticality {
+    public static void main(String [] args) throws Exception {
+        PolicyConstraintsExtension pce = new PolicyConstraintsExtension(-1,-1);
+        if (!pce.isCritical()) {
+            throw new Exception("PolicyConstraintsExtension should be " +
+                                "critical by default");
+        }
+
+        PolicyMappingsExtension pme = new PolicyMappingsExtension();
+        if (!pme.isCritical()) {
+            throw new Exception("PolicyMappingsExtension should be " +
+                                "critical by default");
+        }
+
+        System.out.println("Test passed.");
+    }
+}
--- a/jdk/test/sun/tools/common/CommonTests.sh	Thu Jan 15 13:09:48 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,314 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2010, 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 6964018
-# @summary Unit test for common tools infrastructure.
-#
-# @build SimpleApplication SleeperApplication ShutdownSimpleApplication
-# @run shell CommonTests.sh
-
-. ${TESTSRC}/CommonSetup.sh
-. ${TESTSRC}/ApplicationSetup.sh
-
-# hope for the best:
-status=0
-
-
-# Test program path constants from CommonSetup.sh:
-#
-for name in JAVA JHAT JINFO JMAP JPS JSTACK; do
-    eval value=$`echo $name`
-
-    echo "INFO: $name=$value"
-    if [ -x "$value" ]; then
-        echo "INFO: '$value' is executable."
-    else
-        echo "ERROR: '$value' is not executable." >&2
-        status=1
-    fi
-done
-
-
-# Display flag values from CommonSetup.sh:
-#
-for name in isCygwin isMKS isLinux isSolaris isUnknownOS isWindows; do
-    eval value=$`echo $name`
-    echo "INFO: flag $name=$value"
-done
-
-
-# Test OS constant from CommonSetup.sh:
-#
-if [ -z "$OS" ]; then
-    echo "ERROR: OS constant cannot be empty." >&2
-    status=1
-fi
-
-
-# Display the PATTERN_EOL value:
-#
-echo "INFO: PATTERN_EOL="`echo "$PATTERN_EOL" | od -c`
-
-
-# Test PATTERN_EOL with 'grep' for a regular line.
-#
-TESTOUT="${TESTCLASSES}/testout.grep_reg_line_eol"
-set +e
-echo 'regular line' | grep "line${PATTERN_EOL}" > "$TESTOUT"
-set -e
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: PATTERN_EOL works for regular line with grep."
-else
-    echo "ERROR: PATTERN_EOL does not work for regular line with grep." >&2
-    status=1
-fi
-
-
-if $isWindows; then
-    # Test PATTERN_EOL with 'grep' for a CR line.
-    #
-    TESTOUT="${TESTCLASSES}/testout.grep_cr_line_eol"
-    set +e
-    echo 'CR line
' | grep "line${PATTERN_EOL}" > "$TESTOUT"
-    set -e
-    if [ -s "$TESTOUT" ]; then
-        echo "INFO: PATTERN_EOL works for CR line with grep."
-    else
-        echo "ERROR: PATTERN_EOL does not work for CR line with grep." >&2
-        status=1
-    fi
-fi
-
-
-# Test PATTERN_EOL with 'sed' for a regular line.
-#
-TESTOUT="${TESTCLASSES}/testout.sed_reg_line_eol"
-echo 'regular line' | sed -n "/line${PATTERN_EOL}/p" > "$TESTOUT"
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: PATTERN_EOL works for regular line with sed."
-else
-    echo "ERROR: PATTERN_EOL does not work for regular line with sed." >&2
-    status=1
-fi
-
-
-if $isWindows; then
-    # Test PATTERN_EOL with 'sed' for a CR line.
-    #
-    TESTOUT="${TESTCLASSES}/testout.sed_cr_line_eol"
-    echo 'CR line
' | sed -n "/line${PATTERN_EOL}/p" > "$TESTOUT"
-    if [ -s "$TESTOUT" ]; then
-        echo "INFO: PATTERN_EOL works for CR line with sed."
-    else
-        echo "ERROR: PATTERN_EOL does not work for CR line with sed." >&2
-        status=1
-    fi
-fi
-
-
-# Display the PATTERN_WS value:
-#
-echo "INFO: PATTERN_WS="`echo "$PATTERN_WS" | od -c`
-
-
-# Test PATTERN_WS with 'grep' for a blank.
-#
-TESTOUT="${TESTCLASSES}/testout.grep_blank"
-set +e
-echo 'blank: ' | grep "$PATTERN_WS" > "$TESTOUT"
-set -e
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: PATTERN_WS works for blanks with grep."
-else
-    echo "ERROR: PATTERN_WS does not work for blanks with grep." >&2
-    status=1
-fi
-
-
-# Test PATTERN_WS with 'grep' for a tab.
-#
-TESTOUT="${TESTCLASSES}/testout.grep_tab"
-set +e
-echo 'tab:	' | grep "$PATTERN_WS" > "$TESTOUT"
-set -e
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: PATTERN_WS works for tabs with grep."
-else
-    echo "ERROR: PATTERN_WS does not work for tabs with grep." >&2
-    status=1
-fi
-
-
-# Test PATTERN_WS with 'sed' for a blank.
-#
-TESTOUT="${TESTCLASSES}/testout.sed_blank"
-echo 'blank: ' | sed -n "/$PATTERN_WS/p" > "$TESTOUT"
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: PATTERN_WS works for blanks with sed."
-else
-    echo "ERROR: PATTERN_WS does not work for blanks with sed." >&2
-    status=1
-fi
-
-
-# Test PATTERN_WS with 'sed' for a tab.
-#
-TESTOUT="${TESTCLASSES}/testout.sed_tab"
-echo 'tab:	' | sed -n "/$PATTERN_WS/p" > "$TESTOUT"
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: PATTERN_WS works for tabs with sed."
-else
-    echo "ERROR: PATTERN_WS does not work for tabs with sed." >&2
-    status=1
-fi
-
-
-# Test startApplication and use PORTFILE for coordination
-# The app sleeps for 30 seconds.
-#
-PORTFILE="${TESTCLASSES}"/shutdown.port
-startApplication SleeperApplication "${PORTFILE}" 30
-
-
-# Test appJavaPid in "ps" cmd output.
-#
-TESTOUT="${TESTCLASSES}/testout.ps_app"
-set +e
-if $isCygwin; then
-    # On Cygwin, appJavaPid is the Windows pid for the Java process
-    # and appOtherPid is the Cygwin pid for the Java process.
-    ps -p "$appOtherPid" \
-        | grep "${PATTERN_WS}${appJavaPid}${PATTERN_WS}" > "$TESTOUT"
-else
-    # output only pid and comm columns to avoid mismatches
-    ps -eo pid,comm \
-        | grep "^${PATTERN_WS}*${appJavaPid}${PATTERN_WS}" > "$TESTOUT"
-fi
-set -e
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: begin appJavaPid=$appJavaPid in 'ps' cmd output:"
-    cat "$TESTOUT"
-    echo "INFO: end appJavaPid=$appJavaPid in 'ps' cmd output."
-else
-    echo "ERROR: 'ps' cmd should show appJavaPid=$appJavaPid." >&2
-    status=1
-fi
-
-if [ -n "$appOtherPid" ]; then
-    # Test appOtherPid in "ps" cmd output, if we have one.
-    #
-    TESTOUT="${TESTCLASSES}/testout.ps_other"
-    set +e
-    if $isCygwin; then
-        ps -p "$appOtherPid" \
-            | grep "${PATTERN_WS}${appOtherPid}${PATTERN_WS}" > "$TESTOUT"
-    else
-        # output only pid and comm columns to avoid mismatches
-        ps -eo pid,comm \
-            | grep "^${PATTERN_WS}*${appOtherPid}${PATTERN_WS}" > "$TESTOUT"
-    fi
-    set -e
-    if [ -s "$TESTOUT" ]; then
-        echo "INFO: begin appOtherPid=$appOtherPid in 'ps' cmd output:"
-        cat "$TESTOUT"
-        echo "INFO: end appOtherPid=$appOtherPid in 'ps' cmd output."
-    else
-        echo "ERROR: 'ps' cmd should show appOtherPid=$appOtherPid." >&2
-        status=1
-    fi
-fi
-
-
-# Test stopApplication and PORTFILE for coordination
-#
-stopApplication "${PORTFILE}"
-
-
-# Test application still running after stopApplication.
-#
-# stopApplication just lets the app know that it can stop, but the
-# app might still be doing work. This test just demonstrates that
-# fact and doesn't fail if the app is already done.
-#
-TESTOUT="${TESTCLASSES}/testout.after_stop"
-set +e
-if $isCygwin; then
-    # On Cygwin, appJavaPid is the Windows pid for the Java process
-    # and appOtherPid is the Cygwin pid for the Java process.
-    ps -p "$appOtherPid" \
-        | grep "${PATTERN_WS}${appJavaPid}${PATTERN_WS}" > "$TESTOUT"
-else
-    # output only pid and comm columns to avoid mismatches
-    ps -eo pid,comm \
-        | grep "^${PATTERN_WS}*${appJavaPid}${PATTERN_WS}" > "$TESTOUT"
-fi
-set -e
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: it is okay for appJavaPid=$appJavaPid to still be running" \
-        "after stopApplication() is called."
-    echo "INFO: begin 'after_stop' output:"
-    cat "$TESTOUT"
-    echo "INFO: end 'after_stop' output."
-fi
-
-
-# Test waitForApplication
-#
-# The app might already be gone so this function shouldn't generate
-# a fatal error in either call.
-#
-waitForApplication
-
-if [ $isWindows = false ]; then
-    # Windows can recycle pids quickly so we can't use this test there
-    TESTOUT="${TESTCLASSES}/testout.after_kill"
-    set +e
-    # output only pid and comm columns to avoid mismatches
-    ps -eo pid,comm \
-        | grep "^${PATTERN_WS}*${appJavaPid}${PATTERN_WS}" > "$TESTOUT"
-    set -e
-    if [ -s "$TESTOUT" ]; then
-        echo "ERROR: 'ps' cmd should not show appJavaPid." >&2
-        echo "ERROR: begin 'after_kill' output:" >&2
-        cat "$TESTOUT" >&2
-        echo "ERROR: end 'after_kill' output." >&2
-        status=1
-    else
-        echo "INFO: 'ps' cmd does not show appJavaPid after" \
-            "waitForApplication() is called."
-    fi
-fi
-
-
-# Test killApplication
-#
-# The app is already be gone so this function shouldn't generate
-# a fatal error.
-#
-killApplication
-
-exit $status
--- a/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java	Fri Jan 16 12:34:28 2015 -0800
@@ -25,6 +25,9 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.List;
 
 import jdk.testlibrary.JcmdBase;
@@ -95,11 +98,11 @@
     }
 
     private static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException {
-        File file = new File(TEST_SRC, "usage.out");
-        List<String> fileOutput = Utils.fileAsList(file);
+        Path path = Paths.get(TEST_SRC, "usage.out");
+        List<String> fileOutput = Files.readAllLines(path);
         List<String> outputAsLines = output.asLines();
         assertTrue(outputAsLines.containsAll(fileOutput),
-                "The ouput should contain all content of " + file.getAbsolutePath());
+                "The ouput should contain all content of " + path.toAbsolutePath());
     }
 
 }
--- a/jdk/test/sun/tools/jcmd/TestJcmdSanity.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/sun/tools/jcmd/TestJcmdSanity.java	Fri Jan 16 12:34:28 2015 -0800
@@ -25,6 +25,9 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.List;
 
 import jdk.testlibrary.JcmdBase;
@@ -160,11 +163,11 @@
     }
 
     private static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException {
-        File file = new File(TEST_SRC, "help_help.out");
-        List<String> fileOutput = Utils.fileAsList(file);
+        Path path = Paths.get(TEST_SRC, "help_help.out");
+        List<String> fileOutput = Files.readAllLines(path);
         List<String> outputAsLines = output.asLines();
         assertTrue(outputAsLines.containsAll(fileOutput),
-                "The ouput should contain all content of " + file.getAbsolutePath());
+                "The ouput should contain all content of " + path.toAbsolutePath());
     }
 
 }
--- a/jdk/test/sun/tools/jps/JpsHelper.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/sun/tools/jps/JpsHelper.java	Fri Jan 16 12:34:28 2015 -0800
@@ -28,6 +28,9 @@
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -189,11 +192,11 @@
      */
     public static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException {
         String testSrc = System.getProperty("test.src", "?");
-        File file = new File(testSrc, "usage.out");
-        List<String> fileOutput = Utils.fileAsList(file);
+        Path path = Paths.get(testSrc, "usage.out");
+        List<String> fileOutput = Files.readAllLines(path);
         List<String> outputAsLines = output.asLines();
         assertTrue(outputAsLines.containsAll(fileOutput),
-                "The ouput should contain all content of " + file.getAbsolutePath());
+                "The ouput should contain all content of " + path.toAbsolutePath());
     }
 
     private static File getManifest(String className) throws IOException {
--- a/jdk/test/tools/launcher/Arrrghs.java	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/tools/launcher/Arrrghs.java	Fri Jan 16 12:34:28 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -30,12 +30,10 @@
  * @run main/othervm Arrrghs
  */
 
-import java.io.BufferedReader;
+
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -48,9 +46,6 @@
     private Arrrghs(){}
     /**
      * This class provides various tests for arguments processing.
-     * A group of tests to ensure that arguments are passed correctly to
-     * a child java process upon a re-exec, this typically happens when
-     * a version other than the one being executed is requested by the user.
      *
      * History: these set of tests  were part of Arrrghs.sh. The MKS shell
      * implementations were notoriously buggy. Implementing these tests purely
@@ -58,12 +53,6 @@
      *
      */
 
-    // The version string to force a re-exec
-    final static String VersionStr = "-version:1.1+";
-
-    // The Cookie or the pattern we match in the debug output.
-    final static String Cookie = "ReExec Args: ";
-
     /*
      * SIGH, On Windows all strings are quoted, we need to unwrap it
      */
@@ -78,122 +67,6 @@
         return in;
     }
 
-    /*
-     * This method detects the cookie in the output stream of the process.
-     */
-    private boolean detectCookie(InputStream istream,
-            String expectedArguments) throws IOException {
-        BufferedReader rd = new BufferedReader(new InputStreamReader(istream));
-        boolean retval = false;
-
-        String in = rd.readLine();
-        while (in != null) {
-            if (debug) System.out.println(in);
-            if (in.startsWith(Cookie)) {
-                String detectedArgument = removeExtraQuotes(in.substring(Cookie.length()));
-                if (expectedArguments.equals(detectedArgument)) {
-                    retval = true;
-                } else {
-                    System.out.println("Error: Expected Arguments\t:'" +
-                            expectedArguments + "'");
-                    System.out.println(" Detected Arguments\t:'" +
-                            detectedArgument + "'");
-                }
-                // Return the value asap if not in debug mode.
-                if (!debug) {
-                    rd.close();
-                    istream.close();
-                    return retval;
-                }
-            }
-            in = rd.readLine();
-        }
-        return retval;
-    }
-
-    private boolean doReExecTest0(ProcessBuilder pb, String expectedArguments) {
-        boolean retval = false;
-        try {
-            pb.redirectErrorStream(true);
-            Process p = pb.start();
-            retval = detectCookie(p.getInputStream(), expectedArguments);
-            p.waitFor();
-            p.destroy();
-        } catch (Exception ex) {
-            ex.printStackTrace();
-            throw new RuntimeException(ex.getMessage());
-        }
-        return retval;
-    }
-
-    /**
-     * This method returns true  if the expected and detected arguments are the same.
-     * Quoting could cause dissimilar testArguments and expected arguments.
-     */
-    int doReExecTest(String testArguments, String expectedPattern) {
-        ProcessBuilder pb = new ProcessBuilder(javaCmd,
-                VersionStr, testArguments);
-
-        Map<String, String> env = pb.environment();
-        env.put(JLDEBUG_KEY, "true");
-        return doReExecTest0(pb, testArguments) ? 0 : 1;
-    }
-
-    /**
-     * A convenience method for identical test pattern and expected arguments
-     */
-    int doReExecTest(String testPattern) {
-        return doReExecTest(testPattern, testPattern);
-    }
-
-    @Test
-    void testQuoteParsingThroughReExec() {
-        /*
-         * Tests for 6214916
-         * These tests require that a JVM (any JVM) be installed in the system registry.
-         * If none is installed, skip this test.
-         */
-        TestResult tr = doExec(javaCmd, VersionStr, "-version");
-        if (!tr.isOK()) {
-            System.err.println("Warning:Argument Passing Tests were skipped, " +
-                    "no java found in system registry.");
-            return;
-        }
-
-        // Basic test
-        testExitValue += doReExecTest("-a -b -c -d");
-
-        // Basic test with many spaces
-        testExitValue += doReExecTest("-a    -b      -c       -d");
-
-        // Quoted whitespace does matter ?
-        testExitValue += doReExecTest("-a \"\"-b      -c\"\" -d");
-
-
-        // Escaped quotes outside of quotes as literals
-        testExitValue += doReExecTest("-a \\\"-b -c\\\" -d");
-
-        // Check for escaped quotes inside of quotes as literal
-        testExitValue += doReExecTest("-a \"-b \\\"stuff\\\"\" -c -d");
-
-        // A quote preceeded by an odd number of slashes is a literal quote
-        testExitValue += doReExecTest("-a -b\\\\\\\" -c -d");
-
-        // A quote preceeded by an even number of slashes is a literal quote
-        // see 6214916.
-        testExitValue += doReExecTest("-a -b\\\\\\\\\" -c -d");
-
-        // Make sure that whitespace doesn't interfere with the removal of the
-        // appropriate tokens. (space-tab-space preceeds -jre-restict-search).
-        testExitValue += doReExecTest("-a -b  \t -jre-restrict-search -c -d", "-a -b -c -d");
-
-        // Make sure that the mJRE tokens being stripped, aren't stripped if
-        // they happen to appear as arguments to the main class.
-        testExitValue += doReExecTest("foo -version:1.1+");
-
-        System.out.println("Completed arguments quoting tests with "
-                + testExitValue + " errors");
-    }
     // the pattern we hope to see in the output
     static final Pattern ArgPattern = Pattern.compile("\\s*argv\\[[0-9]*\\].*=.*");
 
--- a/jdk/test/tools/launcher/MultipleJRE.sh	Thu Jan 15 13:09:48 2015 -0800
+++ b/jdk/test/tools/launcher/MultipleJRE.sh	Fri Jan 16 12:34:28 2015 -0800
@@ -90,36 +90,6 @@
 }
 
 #
-# Shell routine to ensure help page does not include mjre options
-#
-TestHelp() {
-    mess="`$JAVA -help 2>&1`"
-    # make sure it worked
-    if [ $? -ne 0 ]; then
-        echo "java -help failed ????"
-        exit 1
-    fi
-
-    echo $mess | grep '\-version:<value>' > /dev/null 2>&1
-    if [ $? -eq 0 ]; then
-       echo "help message contains obsolete option version:<value>"
-       exit 1
-    fi
-
-    echo $mess | grep '\-jre-restrict-search' > /dev/null 2>&1
-    if [ $? -eq 0 ]; then
-       echo "help message contains obsolete option jre-restrict-search"
-       exit 1
-    fi
-
-    echo $mess | grep '\-no-jre-restrict-search' > /dev/null 2>&1
-    if [ $? -eq 0 ]; then
-       echo "help message contains obsolete option no-jre-restrict-search"
-       exit 1
-    fi
-}
-
-#
 # Just as the name says.  We sprinkle these in the appropriate location
 # in the test file system and they just say who they are pretending to be.
 #
@@ -461,33 +431,4 @@
 	LaunchVM "" "${RELEASE}"
 fi
 
-#
-# Now test specification of mJRE
-#
-#   In some cases this should result in failure of the command,
-#   in some cases, a warning messages, with the command succeeding.
-#
-
-	# Commandline use of "-version:" should fail
-	#   with a message containing "no longer supported"
-	LaunchVM "-version:1.10+" "Error: Specifying an alternate JDK/JRE"
-	LaunchVM "-version:prettymuchanything" "Error: Specifying an alternate JDK/JRE"
-
-	# Commandline use of "-jre-restrict-search" should now fail
-	LaunchVM "-jre-restrict-search" "\-jre\-no\-restrict\-search are also no longer valid"
-	# Commandline use of "-jre-no-restrict-search" should now fail
-	LaunchVM "-jre-no-restrict-search" "\-jre\-no\-restrict\-search are also no longer valid"
-
-
-	# mJRE directives to use a specific version should be flagged
-	#   with a warning, but the jar should be executed with the
-	#   current jre
-	CreateFullJar "junk request" ""
-	LaunchVM "" "${RELEASE}"
-        # Going to silently ignore JRE-Version setting in jar file manifest
-	#LaunchVM "" "warning: The jarfile JRE-Version"
-
-	# Verify help does not contain obsolete options
-	TestHelp
-
 exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/MultipleJRERemoved.java	Fri Jan 16 12:34:28 2015 -0800
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2014, 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 8067437
+ * @summary Verify Multiple JRE version support has been removed.
+ * @build TestHelper
+ * @run main MultipleJRERemoved
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.*;
+import java.util.jar.Attributes;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import java.util.zip.ZipEntry;
+
+public class MultipleJRERemoved extends TestHelper {
+
+    public static final String VERSION_JAR = "version.jar";
+    public static final String PRINT_VERSION_CLASS = "PrintVersion";
+    private final File javaFile = new File(PRINT_VERSION_CLASS + ".java");
+    private final File clsFile = new File(PRINT_VERSION_CLASS + ".class");
+
+    private MultipleJRERemoved() {
+    }
+
+    /**
+     * @param args the command line arguments
+     * @throws java.io.FileNotFoundException
+     */
+    public static void main(String[] args) throws Exception {
+        MultipleJRERemoved a = new MultipleJRERemoved();
+        a.run(args);
+    }
+
+    /**
+     * Check all combinations of flags: "-version:", "-jre-restrict-search", "-jre-no-restrict-search". Test expects to see errors.
+     */
+    @Test
+    public void allFlagCombinations() throws IOException {
+        final Pattern newLine = Pattern.compile("\n");
+        createJar(Collections.emptyMap());
+
+        for (Flag flag1 : Flag.values()) {
+            for (Flag flag2 : Flag.values()) {
+                for (Flag flag3 : Flag.values()) {
+                    List<Flag> flags = Stream.of(flag1, flag2, flag3)
+                            .filter(f -> !Flag.EMPTY.equals(f))
+                            .collect(Collectors.toList());
+
+                    if (flags.size() == 0) continue;
+
+                    List<String> flagValues = flags.stream()
+                            .map(Flag::value)
+                            .collect(Collectors.toList());
+
+                    List<String> errorMessages = flags.stream()
+                            .map(Flag::errorMessage)
+                            .flatMap(newLine::splitAsStream)
+                            .collect(Collectors.toList());
+
+                    List<String> jarCmd = new ArrayList<>();
+                    jarCmd.add(javaCmd);
+                    jarCmd.addAll(flagValues);
+                    jarCmd.add("-jar");
+                    jarCmd.add("version.jar");
+
+                    check(jarCmd, errorMessages);
+
+                    List<String> cmd = new ArrayList<>();
+                    cmd.add(javaCmd);
+                    cmd.addAll(flagValues);
+                    cmd.add(PRINT_VERSION_CLASS);
+
+                    check(cmd, errorMessages);
+                }
+            }
+        }
+    }
+
+    private void check(List<String> cmd, List<String> errorMessages) {
+        TestResult tr = doExec(cmd.toArray(new String[cmd.size()]));
+        tr.checkNegative();
+        tr.isNotZeroOutput();
+        errorMessages.forEach(tr::contains);
+
+        if (!tr.testStatus) {
+            System.out.println(tr);
+            throw new RuntimeException("test case: failed\n" + cmd);
+        }
+    }
+
+    /**
+     * Verifies that java -help output doesn't contain information about "mJRE" flags.
+     */
+    @Test
+    public void javaHelp() {
+        TestResult tr = doExec(javaCmd, "-help");
+        tr.checkPositive();
+        tr.isNotZeroOutput();
+        tr.notContains("-version:<value>");
+        tr.notContains("-jre-restrict-search");
+        tr.notContains("-jre-no-restrict-search");
+        tr.notContains("-no-jre-restrict-search");  //it's not a typo in flag name.
+        if (!tr.testStatus) {
+            System.out.println(tr);
+            throw new RuntimeException("Failed. java -help output contains obsolete flags.\n");
+        }
+    }
+
+    /**
+     * Verifies that java -jar version.jar output ignores "mJRE" manifest directives.
+     */
+    @Test
+    public void manifestDirectives() throws IOException {
+        Map<String, String> manifest = new TreeMap<>();
+        manifest.put("JRE-Version", "1.8");
+        manifest.put("JRE-Restrict-Search", "1.8");
+        createJar(manifest);
+
+        TestResult tr = doExec(javaCmd, "-jar", VERSION_JAR);
+        tr.checkPositive();
+        tr.contains(System.getProperty("java.version"));
+        if (!tr.testStatus) {
+            System.out.println(tr);
+            throw new RuntimeException("Failed.\n");
+        }
+    }
+
+    private void emitFile() throws IOException {
+        List<String> scr = new ArrayList<>();
+        scr.add("public class PrintVersion {");
+        scr.add("    public static void main(String... args) {");
+        scr.add("       System.out.println(System.getProperty(\"java.version\"));");
+        scr.add("    }");
+        scr.add("}");
+        createFile(javaFile, scr);
+        compile(javaFile.getName());
+    }
+
+    private void createJar(Map<String, String> manifestAttributes) throws IOException {
+        emitFile();
+
+        Manifest manifest = new Manifest();
+        final Attributes mainAttributes = manifest.getMainAttributes();
+        mainAttributes.putValue("Manifest-Version", "1.0");
+        mainAttributes.putValue("Main-Class", PRINT_VERSION_CLASS);
+        manifestAttributes.forEach(mainAttributes::putValue);
+
+        try (JarOutputStream jar = new JarOutputStream(new FileOutputStream(VERSION_JAR), manifest)) {
+            jar.putNextEntry(new ZipEntry(PRINT_VERSION_CLASS + ".class"));
+            jar.write(Files.readAllBytes(clsFile.toPath()));
+            jar.closeEntry();
+        } finally {
+            javaFile.delete();
+        }
+    }
+
+    private enum Flag {
+        EMPTY("", ""),
+        VERSION("-version:1.9", "Error: Specifying an alternate JDK/JRE version is no longer supported.\n" +
+                "The use of the flag '-version:' is no longer valid.\n" +
+                "Please download and execute the appropriate version."),
+        JRE_RESTRICT_SEARCH("-jre-restrict-search", "Error: Specifying an alternate JDK/JRE is no longer supported.\n" +
+                "The related flags -jre-restrict-search | -jre-no-restrict-search are also no longer valid."),
+        JRE_NO_RESTRICT_SEARCH("-jre-no-restrict-search", "Error: Specifying an alternate JDK/JRE is no longer supported.\n" +
+                "The related flags -jre-restrict-search | -jre-no-restrict-search are also no longer valid.");
+        private final String flag;
+        private final String errorMessage;
+
+        Flag(String flag, String errorMessage) {
+            this.flag = flag;
+            this.errorMessage = errorMessage;
+        }
+
+        String value() {
+            return flag;
+        }
+
+        String errorMessage() {
+            return errorMessage;
+        }
+    }
+}